Committer  : entrope
CVSROOT    : /cvsroot/undernet-ircu
Module     : ircu2.10
Branch tags: u2_10_12_branch
Commit time: 2007-08-15 02:50:04 UTC

Modified files:
  Tag: u2_10_12_branch
     ircd/channel.c ChangeLog

Log message:

Properly handle removing and adding a key in the same command.

---------------------- diff included ----------------------
Index: ircu2.10/ChangeLog
diff -u ircu2.10/ChangeLog:1.710.2.202 ircu2.10/ChangeLog:1.710.2.203
--- ircu2.10/ChangeLog:1.710.2.202      Mon Aug 13 20:56:46 2007
+++ ircu2.10/ChangeLog  Tue Aug 14 19:49:54 2007
@@ -1,3 +1,11 @@
+2007-08-14  Michael Poole <[EMAIL PROTECTED]>
+
+       * 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 <[EMAIL PROTECTED]>
 
        * ircd/s_user.c (whipser): CNOTICEs should not trigger away
Index: ircu2.10/ircd/channel.c
diff -u ircu2.10/ircd/channel.c:1.155.2.17 ircu2.10/ircd/channel.c:1.155.2.18
--- ircu2.10/ircd/channel.c:1.155.2.17  Mon Jan 22 18:23:34 2007
+++ ircu2.10/ircd/channel.c     Tue Aug 14 19:49:54 2007
@@ -19,7 +19,7 @@
  */
 /** @file
  * @brief Channel management and maintenance
- * @version $Id: channel.c,v 1.155.2.17 2007/01/23 02:23:34 entrope Exp $
+ * @version $Id: channel.c,v 1.155.2.18 2007/08/15 02:49:54 entrope Exp $
  */
 #include "config.h"
 
@@ -2203,12 +2203,15 @@
 
 /* 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 @@
     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 @@
     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 @@
     }
   }
 
-  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 @@
     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);
   }
----------------------- End of diff -----------------------
_______________________________________________
Patches mailing list
[email protected]
http://undernet.sbg.org/mailman/listinfo/patches

Reply via email to