+2005-09-22 Michael Poole <mdpoole@troilus.org>
+
+ * ircd/channel.c (mode_parse_key): Only accept the new key when
+ the current one is empty or "greater" than the new one.
+ (mode_parse_upass): Likewise, for upass.
+ (mode_parse_apass): Likewise, for apass.
+
2005-09-22 Michael Poole <mdpoole@troilus.org>
* ircd/gline.c (gline_checkmask): Add missing digit in mask length
modebuf_mode_string(state->mbuf, state->dir | flag_p[0], t_str, 0);
if (state->flags & MODE_PARSE_SET) {
- if (state->dir == MODE_ADD) /* set the new key */
- ircd_strncpy(state->chptr->mode.key, t_str, KEYLEN);
- else /* remove the old key */
+ 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)
+ ircd_strncpy(state->chptr->mode.key, t_str, KEYLEN);
}
}
modebuf_mode_string(state->mbuf, state->dir | flag_p[0], t_str, 0);
if (state->flags & MODE_PARSE_SET) {
- if (state->dir == MODE_ADD) /* set the new upass */
- ircd_strncpy(state->chptr->mode.upass, t_str, KEYLEN);
- else /* remove the old upass */
+ 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)
+ ircd_strncpy(state->chptr->mode.upass, t_str, KEYLEN);
}
}
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)
+ ircd_strncpy(state->chptr->mode.apass, t_str, KEYLEN);
/* Make it VERY clear to the user that this is a one-time password */
- ircd_strncpy(state->chptr->mode.apass, t_str, KEYLEN);
if (MyUser(state->sptr)) {
send_reply(state->sptr, RPL_APASSWARN_SET, state->chptr->mode.apass);
send_reply(state->sptr, RPL_APASSWARN_SECRET, state->chptr->chname,