Fix bug #1298149 and a similar desynch for channel keys.
authorMichael Poole <mdpoole@troilus.org>
Fri, 23 Sep 2005 01:15:51 +0000 (01:15 +0000)
committerMichael Poole <mdpoole@troilus.org>
Fri, 23 Sep 2005 01:15:51 +0000 (01:15 +0000)
git-svn-id: file:///home/klmitch/undernet-ircu/undernet-ircu-svn/ircu2/trunk@1494 c9e4aea6-c8fd-4c43-8297-357d70d61c8c

ChangeLog
ircd/channel.c

index a06a9df82e68e8e422469518b71b7da57e3000f0..549e60b184cb7eda9bf6f1fd5268fe9bab208dd6 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+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
index d4b383524c1ec630e39df6f5d534fc75b48c239f..01ec91a2c51d3e8e50c51f98e47601db4217e628 100644 (file)
@@ -2326,10 +2326,11 @@ mode_parse_key(struct ParseState *state, int *flag_p)
     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);
   }
 }
 
@@ -2430,10 +2431,11 @@ mode_parse_upass(struct ParseState *state, int *flag_p)
     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);
   }
 }
 
@@ -2538,8 +2540,14 @@ 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)
+        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,