From e22c93b27e9f501b7869b310dff7df384e06f7e6 Mon Sep 17 00:00:00 2001 From: pk910 Date: Sun, 8 Nov 2015 01:41:54 +0100 Subject: [PATCH] added support for user privileges through connection class --- include/client.h | 4 +++- include/s_conf.h | 2 +- ircd/client.c | 16 ++++++++++++++++ 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/include/client.h b/include/client.h index f93a3ee..4fb584c 100644 --- a/include/client.h +++ b/include/client.h @@ -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 */ diff --git a/include/s_conf.h b/include/s_conf.h index 301e9ab..ea4f1c2 100644 --- a/include/s_conf.h +++ b/include/s_conf.h @@ -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; }; diff --git a/ircd/client.c b/ircd/client.c index e3961b4..b4d3afe 100644 --- a/ircd/client.c +++ b/ircd/client.c @@ -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; +} + -- 2.20.1