added support for user privileges through connection class
authorpk910 <philipp@zoelle1.de>
Sun, 8 Nov 2015 00:41:54 +0000 (01:41 +0100)
committerpk910 <philipp@zoelle1.de>
Sun, 8 Nov 2015 00:41:54 +0000 (01:41 +0100)
include/client.h
include/s_conf.h
ircd/client.c

index f93a3ee425e3032a6de1a7df24f1410a4241168b..4fb584c3cb827defe72c2c6d464baf1943e5514a 100644 (file)
@@ -715,7 +715,7 @@ struct Client {
 #define SNO_NOISY (SNO_SERVKILL|SNO_UNAUTH)
 
 /** Test whether a privilege has been granted to a client. */
-#define HasPriv(cli, priv)  FlagHas(cli_privs(cli), priv)
+#define HasPriv(cli, priv)  FlagHas(client_get_privs(cli), priv)
 /** Grant a privilege to a client. */
 #define SetPriv(cli, priv)  FlagSet(cli_privs(cli), priv)
 /** Revoke a privilege from a client. */
@@ -738,5 +738,7 @@ extern void client_add_sendq(struct Connection* con,
 extern void client_set_privs(struct Client *client, struct ConfItem *oper);
 extern int client_report_privs(struct Client* to, struct Client* client);
 
+extern int client_get_privs(struct Client* client);
+
 #endif /* INCLUDED_client_h */
 
index 301e9ab2f3b30e4f9f49efa4303505421c2afe9b..ea4f1c21706066755795585fd2702ac166c2f844 100644 (file)
@@ -67,7 +67,7 @@ struct ConfItem
   int dns_pending;    /**< A dns request is pending. */
   int flags;          /**< Additional modifiers for item. */
   int addrbits;       /**< Number of bits valid in ConfItem::address. */
-  struct Privs privs; /**< Privileges for opers. */
+  struct Privs privs; /**< Privileges for all users in this class. */
   /** Used to detect if a privilege has been set by this ConfItem. */
   struct Privs privs_dirty;
 };
index e3961b43ffac28d51545d7267d57f072532e8727..b4d3afe8b3da73f304f7517c5e28dfe4a53286da 100644 (file)
@@ -264,3 +264,19 @@ client_report_privs(struct Client *to, struct Client *client)
 
   return 0;
 }
+
+int client_get_privs(struct Client* client) {
+  int privs = cli_privs(client);
+
+  // add privs from class
+  struct SLink *list;
+
+  for (list = cli_confs(cptr); list != NULL; list = list->next) {
+    struct ConfItem *aconf;
+    aconf = list->value.aconf;
+    if (aconf->status & CONF_CLIENT)
+      privs |= aconf->privs;
+  }
+  return privs;
+}
+