aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar jesopo2021-10-10 15:10:09 +0000
committerGravatar jesopo2021-10-10 15:10:09 +0000
commit5ebb0d93d0ae6e6caa0281c766814531c4f0c2f5 (patch)
tree8ee8efad9660674c2d250176ce1f83f71ed81b33
parentreturn *ChannelMode from cflag_add (diff)
downloadsolanum-jess/chmode-priv.tar.gz
solanum-jess/chmode-priv.tar.bz2
solanum-jess/chmode-priv.zip
remove chm_staff & chm_hidden, replace with chmode->priv & CHM_HIDDEN jess/chmode-priv
-rw-r--r--extensions/chm_adminonly.c4
-rw-r--r--extensions/chm_operonly.c4
-rw-r--r--extensions/chm_operpeace.c7
-rw-r--r--include/channel.h2
-rw-r--r--include/chmode.h2
-rw-r--r--ircd/channel.c2
-rw-r--r--ircd/chmode.c108
7 files changed, 35 insertions, 94 deletions
diff --git a/extensions/chm_adminonly.c b/extensions/chm_adminonly.c
index 9ab064c5..5b65190c 100644
--- a/extensions/chm_adminonly.c
+++ b/extensions/chm_adminonly.c
@@ -25,9 +25,11 @@ static struct ChannelMode *mymode;
static int
_modinit(void)
{
- mymode = cflag_add('A', chm_staff);
+ mymode = cflag_add('A', chm_simple);
if (mymode == NULL)
return -1;
+ else
+ mymode->priv = "oper:cmodes";
return 0;
}
diff --git a/extensions/chm_operonly.c b/extensions/chm_operonly.c
index 219112ca..8df1b5d3 100644
--- a/extensions/chm_operonly.c
+++ b/extensions/chm_operonly.c
@@ -25,9 +25,11 @@ static struct ChannelMode *mymode;
static int
_modinit(void)
{
- mymode = cflag_add('O', chm_staff);
+ mymode = cflag_add('O', chm_simple);
if (mymode == NULL)
return -1;
+ else
+ mymode->priv = "oper:cmodes";
return 0;
}
diff --git a/extensions/chm_operpeace.c b/extensions/chm_operpeace.c
index 01519a7a..6a7c564d 100644
--- a/extensions/chm_operpeace.c
+++ b/extensions/chm_operpeace.c
@@ -33,9 +33,14 @@ static struct ChannelMode *mymode;
static int
_modinit(void)
{
- mymode = cflag_add('M', chm_hidden);
+ mymode = cflag_add('M', chm_simple);
if (mymode == NULL)
return -1;
+ else
+ {
+ mymode->priv = "oper:cmodes";
+ mymode->flags |= CHM_HIDDEN;
+ }
return 0;
}
diff --git a/include/channel.h b/include/channel.h
index 19ca532f..feae232c 100644
--- a/include/channel.h
+++ b/include/channel.h
@@ -131,6 +131,7 @@ enum chm_flags
CHM_OPS_QUERY = 1 << 1,
CHM_ARG_SET = 1 << 2,
CHM_ARG_DEL = 1 << 3,
+ CHM_HIDDEN = 1 << 4,
CHM_ARGS = CHM_ARG_SET | CHM_ARG_DEL,
CHM_QUERYABLE = CHM_ARGS | CHM_CAN_QUERY,
};
@@ -140,6 +141,7 @@ struct ChannelMode
ChannelModeFunc *set_func;
long mode_type;
enum chm_flags flags;
+ const char *priv;
};
typedef int (*ExtbanFunc)(const char *data, struct Client *client_p,
diff --git a/include/chmode.h b/include/chmode.h
index 92dcece4..4a66eb21 100644
--- a/include/chmode.h
+++ b/include/chmode.h
@@ -37,8 +37,6 @@ extern int chmode_flags[256];
extern ChannelModeFunc chm_orphaned;
extern ChannelModeFunc chm_simple;
extern ChannelModeFunc chm_ban;
-extern ChannelModeFunc chm_hidden;
-extern ChannelModeFunc chm_staff;
extern ChannelModeFunc chm_forward;
extern ChannelModeFunc chm_throttle;
extern ChannelModeFunc chm_key;
diff --git a/ircd/channel.c b/ircd/channel.c
index 9c67aaab..2c8f899c 100644
--- a/ircd/channel.c
+++ b/ircd/channel.c
@@ -1141,7 +1141,7 @@ channel_modes(struct Channel *chptr, struct Client *client_p)
for (i = 0; i < 256; i++)
{
- if(chmode_table[i].set_func == chm_hidden && (!HasPrivilege(client_p, "auspex:cmodes") || !IsClient(client_p)))
+ if(chmode_table[i].flags & CHM_HIDDEN && (!HasPrivilege(client_p, "auspex:cmodes") || !IsClient(client_p)))
continue;
if(chptr->mode.mode & chmode_flags[i])
*mbuf++ = i;
diff --git a/ircd/chmode.c b/ircd/chmode.c
index feb84c1c..7bef9752 100644
--- a/ircd/chmode.c
+++ b/ircd/chmode.c
@@ -637,92 +637,6 @@ chm_orphaned(struct Client *source_p, struct Channel *chptr,
}
void
-chm_hidden(struct Client *source_p, struct Channel *chptr,
- int alevel, const char *arg, int *errors, int dir, char c, long mode_type)
-{
- if(MyClient(source_p) && !IsOperGeneral(source_p))
- {
- if(!(*errors & SM_ERR_NOPRIVS))
- sendto_one_numeric(source_p, ERR_NOPRIVILEGES, form_str(ERR_NOPRIVILEGES));
- *errors |= SM_ERR_NOPRIVS;
- return;
- }
- if(MyClient(source_p) && !IsOperAdmin(source_p))
- {
- if(!(*errors & SM_ERR_NOPRIVS))
- sendto_one(source_p, form_str(ERR_NOPRIVS), me.name,
- source_p->name, "admin");
- *errors |= SM_ERR_NOPRIVS;
- return;
- }
-
- /* setting + */
- if((dir == MODE_ADD) && !(chptr->mode.mode & mode_type))
- {
- chptr->mode.mode |= mode_type;
-
- mode_changes[mode_count].letter = c;
- mode_changes[mode_count].dir = MODE_ADD;
- mode_changes[mode_count].id = NULL;
- mode_changes[mode_count].mems = ONLY_OPERS;
- mode_changes[mode_count++].arg = NULL;
- }
- else if((dir == MODE_DEL) && (chptr->mode.mode & mode_type))
- {
- chptr->mode.mode &= ~mode_type;
-
- mode_changes[mode_count].letter = c;
- mode_changes[mode_count].dir = MODE_DEL;
- mode_changes[mode_count].mems = ONLY_OPERS;
- mode_changes[mode_count].id = NULL;
- mode_changes[mode_count++].arg = NULL;
- }
-}
-
-void
-chm_staff(struct Client *source_p, struct Channel *chptr,
- int alevel, const char *arg, int *errors, int dir, char c, long mode_type)
-{
- if(MyClient(source_p) && !IsOper(source_p))
- {
- if(!(*errors & SM_ERR_NOPRIVS))
- sendto_one_numeric(source_p, ERR_NOPRIVILEGES, form_str(ERR_NOPRIVILEGES));
- *errors |= SM_ERR_NOPRIVS;
- return;
- }
- if(MyClient(source_p) && !HasPrivilege(source_p, "oper:cmodes"))
- {
- if(!(*errors & SM_ERR_NOPRIVS))
- sendto_one(source_p, form_str(ERR_NOPRIVS), me.name,
- source_p->name, "cmodes");
- *errors |= SM_ERR_NOPRIVS;
- return;
- }
-
- /* setting + */
- if((dir == MODE_ADD) && !(chptr->mode.mode & mode_type))
- {
- chptr->mode.mode |= mode_type;
-
- mode_changes[mode_count].letter = c;
- mode_changes[mode_count].dir = MODE_ADD;
- mode_changes[mode_count].id = NULL;
- mode_changes[mode_count].mems = ALL_MEMBERS;
- mode_changes[mode_count++].arg = NULL;
- }
- else if((dir == MODE_DEL) && (chptr->mode.mode & mode_type))
- {
- chptr->mode.mode &= ~mode_type;
-
- mode_changes[mode_count].letter = c;
- mode_changes[mode_count].dir = MODE_DEL;
- mode_changes[mode_count].mems = ALL_MEMBERS;
- mode_changes[mode_count].id = NULL;
- mode_changes[mode_count++].arg = NULL;
- }
-}
-
-void
chm_ban(struct Client *source_p, struct Channel *chptr,
int alevel, const char *arg, int *errors, int dir, char c, long mode_type)
{
@@ -1287,8 +1201,8 @@ struct ChannelMode chmode_table[256] =
{
['F'] = {chm_simple, MODE_FREETARGET, 0 },
['I'] = {chm_ban, CHFL_INVEX, CHM_QUERYABLE | CHM_OPS_QUERY },
- ['L'] = {chm_staff, MODE_EXLIMIT, 0 },
- ['P'] = {chm_staff, MODE_PERMANENT, 0 },
+ ['L'] = {chm_simple, MODE_EXLIMIT, 0, "oper:cmodes" },
+ ['P'] = {chm_simple, MODE_PERMANENT, 0, "oper:cmodes" },
['Q'] = {chm_simple, MODE_DISFORWARD, 0 },
['b'] = {chm_ban, CHFL_BAN, CHM_QUERYABLE },
['e'] = {chm_ban, CHFL_EXCEPTION, CHM_QUERYABLE | CHM_OPS_QUERY },
@@ -1403,6 +1317,24 @@ set_channel_mode(struct Client *client_p, struct Client *source_p,
use_arg = false;
}
+ if (cm->priv)
+ {
+ if (!IsOper(source_p))
+ {
+ if(!(errors & SM_ERR_NOPRIVS))
+ sendto_one_numeric(source_p, ERR_NOPRIVILEGES, form_str(ERR_NOPRIVILEGES));
+ errors |= SM_ERR_NOPRIVS;
+ return;
+ }
+ else if (!HasPrivilege(source_p, cm->priv))
+ {
+ if (!(errors & SM_ERR_NOPRIVS))
+ sendto_one(source_p, form_str(ERR_NOPRIVS), me.name, source_p->name, cm->priv);
+ errors |= SM_ERR_NOPRIVS;
+ return;
+ }
+ }
+
if (effective_dir == MODE_QUERY && !(cm->flags & CHM_CAN_QUERY))
{
/* XXX this currently replicates traditional behaviour and just