summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorgeniusdex geniusdex@31f1291d-b8d6-0310-a050-a5561fc1590b <geniusdex geniusdex@31f1291d-b8d6-0310-a050-a5561fc1590b@5417fbe8-f217-4b02-8779-1006273d7864>2007-09-08 08:34:45 +0000
committergeniusdex geniusdex@31f1291d-b8d6-0310-a050-a5561fc1590b <geniusdex geniusdex@31f1291d-b8d6-0310-a050-a5561fc1590b@5417fbe8-f217-4b02-8779-1006273d7864>2007-09-08 08:34:45 +0000
commit5f5ac9f0d77d8d94cf1fc4e74f486e43df9c7e1d (patch)
tree429461f701b1c2fe389cc775cf5dec2d867849b0 /src
parent76f61c3e339a9b83fa324694d7e8065c1fb25a13 (diff)
BUILD : 1.7.19 (1303) BUGS : 703 NOTES : Fixed user being able to change channel modes on empty channels without permission (eg SECUREOPS)
git-svn-id: svn://svn.anope.org/anope/trunk@1303 31f1291d-b8d6-0310-a050-a5561fc1590b git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@1021 5417fbe8-f217-4b02-8779-1006273d7864
Diffstat (limited to 'src')
-rw-r--r--src/channels.c33
1 files changed, 30 insertions, 3 deletions
diff --git a/src/channels.c b/src/channels.c
index 372f657f0..e93ea8401 100644
--- a/src/channels.c
+++ b/src/channels.c
@@ -165,7 +165,7 @@ void chan_set_modes(const char *source, Channel * chan, int ac, char **av,
CUMode *cum;
unsigned char botmode = 0;
BotInfo *bi;
- User *user;
+ User *u, *user;
int i, real_ac = ac;
char **real_av = av;
@@ -173,6 +173,27 @@ void chan_set_modes(const char *source, Channel * chan, int ac, char **av,
alog("debug: Changing modes for %s to %s", chan->name,
merge_args(ac, av));
+ u = finduser(source);
+ if (u && (chan_get_user_status(chan, u) & CUS_DEOPPED)) {
+ char *s;
+
+ if (debug)
+ alog("debug: Removing instead of setting due to DEOPPED flag");
+
+ /* Swap adding and removing of the modes */
+ for (s = av[0]; *s; s++) {
+ if (*s == '+')
+ *s = '-';
+ else if (*s == '-')
+ *s = '+';
+ }
+
+ /* Set the resulting mode buffer */
+ anope_cmd_mode(whosends(chan->ci), chan->name, merge_args(ac, av));
+
+ return;
+ }
+
ac--;
while ((mode = *modes++)) {
@@ -231,10 +252,14 @@ void chan_set_modes(const char *source, Channel * chan, int ac, char **av,
alog("debug: Setting %c%c on %s for %s", (add ? '+' : '-'),
mode, chan->name, user->nick);
- if (add)
+ if (add) {
chan_set_user_status(chan, user, cum->status);
- else
+ /* If this does +o, remove any DEOPPED flag */
+ if (cum->status & CUS_OP)
+ chan_remove_user_status(chan, user, CUS_DEOPPED);
+ } else {
chan_remove_user_status(chan, user, cum->status);
+ }
} else if ((cbm = &cbmodes[(int) mode])->flag != 0) {
if (check >= 0) {
@@ -1405,6 +1430,7 @@ void chan_set_correct_modes(User * user, Channel * c, int give_modes)
strcat(modebuf, "o");
strcat(userbuf, " ");
strcat(userbuf, user->nick);
+ rem_modes |= CUS_DEOPPED;
} else {
add_modes &= ~CUS_OP;
}
@@ -1443,6 +1469,7 @@ void chan_set_correct_modes(User * user, Channel * c, int give_modes)
strcat(modebuf, "o");
strcat(userbuf, " ");
strcat(userbuf, user->nick);
+ add_modes |= CUS_DEOPPED;
}
if (rem_modes & CUS_HALFOP) {
strcat(modebuf, "h");