From: Michael Poole Date: Sun, 19 Mar 2006 04:03:55 +0000 (+0000) Subject: Fix bug #1444405 by allowing other servers to overwrite keys and Upass. X-Git-Url: http://git.pk910.de/?p=ircu2.10.12-pk.git;a=commitdiff_plain;h=a01b4da7e557a5947f7685e3c35e4cf4be3b08ab Fix bug #1444405 by allowing other servers to overwrite keys and Upass. git-svn-id: file:///home/klmitch/undernet-ircu/undernet-ircu-svn/ircu2/branches/u2_10_12_branch@1630 c9e4aea6-c8fd-4c43-8297-357d70d61c8c --- diff --git a/ChangeLog b/ChangeLog index fbcc650..d2ea5f8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2006-06-18 Michael Poole + + * ircd/channel.c (mode_parse_key): Outside of burst, allow + overwriting of keys by a service when a key is already set. + (mode_parse_upass): Likewise. Instead, ignore new Upass during + burst if it is lexicographically greater than the current one. + (mode_parse_apas): Likewise for Apass, but only allow overwiting + an existing Apass in a BURST. + 2006-06-18 Michael Poole * ircd/channel.c (modebuf_flush_int): Fix typo about changing diff --git a/ircd/channel.c b/ircd/channel.c index e79dba7..b97b89a 100644 --- a/ircd/channel.c +++ b/ircd/channel.c @@ -2390,8 +2390,7 @@ mode_parse_key(struct ParseState *state, int *flag_p) if (state->flags & MODE_PARSE_SET) { if (state->dir == MODE_DEL) /* remove the old key */ *state->chptr->mode.key = '\0'; - else if (!state->chptr->mode.key[0] - || ircd_strcmp(t_str, state->chptr->mode.key) < 0) + else ircd_strncpy(state->chptr->mode.key, t_str, KEYLEN); } } @@ -2485,6 +2484,13 @@ mode_parse_upass(struct ParseState *state, int *flag_p) !ircd_strcmp(state->chptr->mode.upass, t_str)) return; /* no upass change */ + /* Skip if this is a burst, we have a Upass already and the new Upass is + * after the old one alphabetically */ + if ((state->flags & MODE_PARSE_BURST) && + *(state->chptr->mode.upass) && + ircd_strcmp(state->chptr->mode.upass, t_str) <= 0) + return; + if (state->flags & MODE_PARSE_BOUNCE) { if (*state->chptr->mode.upass) /* reset old upass */ modebuf_mode_string(state->mbuf, MODE_DEL | flag_p[0], @@ -2497,8 +2503,7 @@ mode_parse_upass(struct ParseState *state, int *flag_p) if (state->flags & MODE_PARSE_SET) { if (state->dir == MODE_DEL) /* remove the old upass */ *state->chptr->mode.upass = '\0'; - else if (state->chptr->mode.upass[0] == '\0' - || ircd_strcmp(t_str, state->chptr->mode.upass) < 0) + else ircd_strncpy(state->chptr->mode.upass, t_str, KEYLEN); } } @@ -2596,6 +2601,13 @@ mode_parse_apass(struct ParseState *state, int *flag_p) !ircd_strcmp(state->chptr->mode.apass, t_str)) return; /* no apass change */ + /* Skip if this is a burst, we have an Apass already and the new Apass is + * after the old one alphabetically */ + if ((state->flags & MODE_PARSE_BURST) && + *(state->chptr->mode.apass) && + ircd_strcmp(state->chptr->mode.apass, t_str) <= 0) + return; + if (state->flags & MODE_PARSE_BOUNCE) { if (*state->chptr->mode.apass) /* reset old apass */ modebuf_mode_string(state->mbuf, MODE_DEL | flag_p[0], @@ -2607,12 +2619,10 @@ mode_parse_apass(struct ParseState *state, int *flag_p) if (state->flags & MODE_PARSE_SET) { if (state->dir == MODE_ADD) { /* set the new apass */ - /* Only accept the new apass if there is no current apass - * (e.g. when a user sets it) or the new one is "less" than the - * old (for resolving conflicts during burst). - */ - if (state->chptr->mode.apass[0] == '\0' - || ircd_strcmp(t_str, state->chptr->mode.apass) < 0) + /* Only accept the new apass if there is no current apass or + * this is a BURST. */ + if (state->chptr->mode.apass[0] == '\0' || + (state->flags & MODE_PARSE_BURST)) ircd_strncpy(state->chptr->mode.apass, t_str, KEYLEN); /* Make it VERY clear to the user that this is a one-time password */ if (MyUser(state->sptr)) {