From db2faab2b1529ef0c5e8338e2bbbe01a10232307 Mon Sep 17 00:00:00 2001 From: Michael Poole Date: Wed, 15 Aug 2007 02:49:54 +0000 Subject: [PATCH] Properly handle removing and adding a key in the same command. git-svn-id: file:///home/klmitch/undernet-ircu/undernet-ircu-svn/ircu2/branches/u2_10_12_branch@1832 c9e4aea6-c8fd-4c43-8297-357d70d61c8c --- ChangeLog | 8 +++++++ ircd/channel.c | 63 ++++++++++++++++++++++++++++++++++++++------------ 2 files changed, 56 insertions(+), 15 deletions(-) diff --git a/ChangeLog b/ChangeLog index c357292..6d4a60a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2007-08-14 Michael Poole + + * ircd/channel.c (DONE_*): Split key changes into _ADD and _DEL. + (mode_parse_key): Check both, to properly handle -k+k changes. + (mode_parse_upass): Likewise, for -U+U. + (mode_parse_apass): Liekwise, for -A+A (in case that ever happens). + (mode_parse): Update which "done" flag is checked during a wipeout. + 2007-08-13 Michael Poole * ircd/s_user.c (whipser): CNOTICEs should not trigger away diff --git a/ircd/channel.c b/ircd/channel.c index 355b99d..4ba3669 100644 --- a/ircd/channel.c +++ b/ircd/channel.c @@ -2203,12 +2203,15 @@ mode_invite_clear(struct Channel *chan) /* What we've done for mode_parse so far... */ #define DONE_LIMIT 0x01 /**< We've set the limit */ -#define DONE_KEY 0x02 /**< We've set the key */ +#define DONE_KEY_ADD 0x02 /**< We've set the key */ #define DONE_BANLIST 0x04 /**< We've sent the ban list */ #define DONE_NOTOPER 0x08 /**< We've sent a "Not oper" error */ #define DONE_BANCLEAN 0x10 /**< We've cleaned bans... */ -#define DONE_UPASS 0x20 /**< We've set user pass */ -#define DONE_APASS 0x40 /**< We've set admin pass */ +#define DONE_UPASS_ADD 0x20 /**< We've set user pass */ +#define DONE_APASS_ADD 0x40 /**< We've set admin pass */ +#define DONE_KEY_DEL 0x80 /**< We've removed the key */ +#define DONE_UPASS_DEL 0x100 /**< We've removed the user pass */ +#define DONE_APASS_DEL 0x200 /**< We've removed the admin pass */ struct ParseState { struct ModeBuf *mbuf; @@ -2361,9 +2364,19 @@ mode_parse_key(struct ParseState *state, int *flag_p) return; } - if (state->done & DONE_KEY) /* allow key to be set only once */ - return; - state->done |= DONE_KEY; + /* allow removing and then adding key, but not adding and then removing */ + if (state->dir == MODE_ADD) + { + if (state->done & DONE_KEY_ADD) + return; + state->done |= DONE_KEY_ADD; + } + else + { + if (state->done & (DONE_KEY_ADD | DONE_KEY_DEL)) + return; + state->done |= DONE_KEY_DEL; + } /* clean up the key string */ clean_key(t_str); @@ -2463,9 +2476,19 @@ mode_parse_upass(struct ParseState *state, int *flag_p) return; } - if (state->done & DONE_UPASS) /* allow upass to be set only once */ - return; - state->done |= DONE_UPASS; + /* allow removing and then adding upass, but not adding and then removing */ + if (state->dir == MODE_ADD) + { + if (state->done & DONE_UPASS_ADD) + return; + state->done |= DONE_UPASS_ADD; + } + else + { + if (state->done & (DONE_UPASS_ADD | DONE_UPASS_DEL)) + return; + state->done |= DONE_UPASS_DEL; + } /* clean up the upass string */ clean_key(t_str); @@ -2600,9 +2623,19 @@ mode_parse_apass(struct ParseState *state, int *flag_p) } } - if (state->done & DONE_APASS) /* allow apass to be set only once */ - return; - state->done |= DONE_APASS; + /* allow removing and then adding apass, but not adding and then removing */ + if (state->dir == MODE_ADD) + { + if (state->done & DONE_APASS_ADD) + return; + state->done |= DONE_APASS_ADD; + } + else + { + if (state->done & (DONE_APASS_ADD | DONE_APASS_DEL)) + return; + state->done |= DONE_APASS_DEL; + } /* clean up the apass string */ clean_key(t_str); @@ -3376,13 +3409,13 @@ mode_parse(struct ModeBuf *mbuf, struct Client *cptr, struct Client *sptr, if (state.chptr->mode.limit && !(state.done & DONE_LIMIT)) modebuf_mode_uint(state.mbuf, MODE_DEL | MODE_LIMIT, state.chptr->mode.limit); - if (*state.chptr->mode.key && !(state.done & DONE_KEY)) + if (*state.chptr->mode.key && !(state.done & DONE_KEY_DEL)) modebuf_mode_string(state.mbuf, MODE_DEL | MODE_KEY, state.chptr->mode.key, 0); - if (*state.chptr->mode.upass && !(state.done & DONE_UPASS)) + if (*state.chptr->mode.upass && !(state.done & DONE_UPASS_DEL)) modebuf_mode_string(state.mbuf, MODE_DEL | MODE_UPASS, state.chptr->mode.upass, 0); - if (*state.chptr->mode.apass && !(state.done & DONE_APASS)) + if (*state.chptr->mode.apass && !(state.done & DONE_APASS_DEL)) modebuf_mode_string(state.mbuf, MODE_DEL | MODE_APASS, state.chptr->mode.apass, 0); } -- 2.20.1