Make keys and passwords behave more uniformly.
authorMichael Poole <mdpoole@troilus.org>
Mon, 29 Aug 2005 21:39:26 +0000 (21:39 +0000)
committerMichael Poole <mdpoole@troilus.org>
Mon, 29 Aug 2005 21:39:26 +0000 (21:39 +0000)
git-svn-id: file:///home/klmitch/undernet-ircu/undernet-ircu-svn/ircu2/trunk@1470 c9e4aea6-c8fd-4c43-8297-357d70d61c8c

ChangeLog
include/numeric.h
ircd/channel.c
ircd/s_err.c

index 07ae22b092626f5044be9c188baba21c569bc117..bf51a871b7f97a773afdd469d6acd3dd26bb5cee 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2005-08-29  Michael Poole <mdpoole@troilus.org>
+
+       * include/numeric.h (ERR_NOMANAGER_LONG): Undefine.
+       (ERR_NOMANAGER_SHORT): Rename to ERR_NOMANAGER.
+
+       * ircd/s_err.c (replyTable): Change to reflect that.
+
+       * ircd/channel.c (clean_key): New function.
+       (mode_parse_key): Use it, and check that keys do not start with :.
+       (mode_parse_upass): Likewise, and adjust for ERR_NOMANAGER.
+       (mode_parse_apass): Likewise.
+
 2005-08-27  Michael Poole <mdpoole@troilus.org>
 
        * ircd/channel.c (add_user_to_channel): Use SetOpLevel() instead
index 0ce4bdc112ca8898067605b3e77fb7817168300d..26fbfb9256caf7ab46c45d7b18bb5f52b0a5b561 100644 (file)
@@ -461,8 +461,8 @@ extern const struct Numeric* get_error_numeric(int err);
 #define ERR_CHANSECURED      562       /* Undernet extension */
 #define ERR_UPASSSET         563       /* Undernet extension */
 #define ERR_UPASSNOTSET      564       /* Undernet extension */
-#define ERR_NOMANAGER_LONG   565       /* Undernet extension */
-#define ERR_NOMANAGER_SHORT  566       /* Undernet extension */
+/*      ERR_NOMANAGER_LONG   565       no longer used */
+#define ERR_NOMANAGER        566       /* Undernet extension */
 #define ERR_UPASS_SAME_APASS 567        /* Undernet extension */
 #define ERR_LASTERROR        568
 
index b2007f84d4e8c4c58674b482244d5c9f228b430d..4cf0ae8443c3badd9caf16cb7685471d9143c65d 100644 (file)
@@ -2337,14 +2337,24 @@ mode_parse_limit(struct ParseState *state, int *flag_p)
   }
 }
 
+/** Helper function to clean key-like parameters. */
+static void
+clean_key(char *s)
+{
+  int t_len = KEYLEN;
+
+  while (*s > ' ' && *s != ':' && *s != ',' && t_len--)
+    s++;
+  *s = '\0';
+}
+
 /*
  * Helper function to convert keys
  */
 static void
 mode_parse_key(struct ParseState *state, int *flag_p)
 {
-  char *t_str, *s;
-  int t_len;
+  char *t_str;
 
   if (MyUser(state->sptr) && state->max_args <= 0) /* drop if too many args */
     return;
@@ -2370,15 +2380,9 @@ mode_parse_key(struct ParseState *state, int *flag_p)
     return;
   state->done |= DONE_KEY;
 
-  t_len = KEYLEN;
-
   /* clean up the key string */
-  s = t_str;
-  while (*s > ' ' && *s != ':' && *s != ',' && t_len--)
-    s++;
-  *s = '\0';
-
-  if (!*t_str) { /* warn if empty */
+  clean_key(t_str);
+  if (!*t_str || *t_str == ':') { /* warn if empty */
     if (MyUser(state->sptr))
       need_more_params(state->sptr, state->dir == MODE_ADD ? "MODE +k" :
                       "MODE -k");
@@ -2431,8 +2435,7 @@ mode_parse_key(struct ParseState *state, int *flag_p)
 static void
 mode_parse_upass(struct ParseState *state, int *flag_p)
 {
-  char *t_str, *s;
-  int t_len;
+  char *t_str;
 
   if (MyUser(state->sptr) && state->max_args <= 0) /* drop if too many args */
     return;
@@ -2467,10 +2470,8 @@ mode_parse_upass(struct ParseState *state, int *flag_p)
     if (*state->chptr->mode.apass) {
       send_reply(state->sptr, ERR_NOTMANAGER, state->chptr->chname,
                  state->chptr->chname);
-    } else if (TStime() - state->chptr->creationtime >= 171000) {
-      send_reply(state->sptr, ERR_NOMANAGER_LONG, state->chptr->chname);
     } else {
-      send_reply(state->sptr, ERR_NOMANAGER_SHORT, state->chptr->chname);
+      send_reply(state->sptr, ERR_NOMANAGER, state->chptr->chname);
     }
     return;
   }
@@ -2479,15 +2480,9 @@ mode_parse_upass(struct ParseState *state, int *flag_p)
     return;
   state->done |= DONE_UPASS;
 
-  t_len = PASSLEN + 1;
-
   /* clean up the upass string */
-  s = t_str;
-  while (*++s > ' ' && *s != ':' && --t_len)
-    ;
-  *s = '\0';
-
-  if (!*t_str) { /* warn if empty */
+  clean_key(t_str);
+  if (!*t_str || *t_str == ':') { /* warn if empty */
     if (MyUser(state->sptr))
       need_more_params(state->sptr, state->dir == MODE_ADD ? "MODE +U" :
                       "MODE -U");
@@ -2545,8 +2540,7 @@ static void
 mode_parse_apass(struct ParseState *state, int *flag_p)
 {
   struct Membership *memb;
-  char *t_str, *s;
-  int t_len;
+  char *t_str;
 
   if (MyUser(state->sptr) && state->max_args <= 0) /* drop if too many args */
     return;
@@ -2577,7 +2571,9 @@ mode_parse_apass(struct ParseState *state, int *flag_p)
   }
 
   /* Don't allow to change the Apass if the channel is older than 48 hours. */
-  if (TStime() - state->chptr->creationtime >= 172800 && !IsAnOper(state->sptr)) {
+  if (MyUser(state->sptr)
+      && TStime() - state->chptr->creationtime >= 172800
+      && !IsAnOper(state->sptr)) {
     send_reply(state->sptr, ERR_CHANSECURED, state->chptr->chname);
     return;
   }
@@ -2587,10 +2583,8 @@ mode_parse_apass(struct ParseState *state, int *flag_p)
     if (*state->chptr->mode.apass) {
       send_reply(state->sptr, ERR_NOTMANAGER, state->chptr->chname,
                  state->chptr->chname);
-    } else if (TStime() - state->chptr->creationtime >= 171000) {
-      send_reply(state->sptr, ERR_NOMANAGER_LONG, state->chptr->chname);
     } else {
-      send_reply(state->sptr, ERR_NOMANAGER_SHORT, state->chptr->chname);
+      send_reply(state->sptr, ERR_NOMANAGER, state->chptr->chname);
     }
     return;
   }
@@ -2599,15 +2593,9 @@ mode_parse_apass(struct ParseState *state, int *flag_p)
     return;
   state->done |= DONE_APASS;
 
-  t_len = PASSLEN + 1;
-
   /* clean up the apass string */
-  s = t_str;
-  while (*++s > ' ' && *s != ':' && --t_len)
-    ;
-  *s = '\0';
-
-  if (!*t_str) { /* warn if empty */
+  clean_key(t_str);
+  if (!*t_str || *t_str == ':') { /* warn if empty */
     if (MyUser(state->sptr))
       need_more_params(state->sptr, state->dir == MODE_ADD ? "MODE +A" :
                       "MODE -A");
index 8ce4b1dd2923f94ad91752e5ed2ee0b9e0a6369f..ed2e509762431405f22d2573e660a5f1429f2626 100644 (file)
@@ -1162,9 +1162,9 @@ static Numeric replyTable[] = {
 /* 564 */
   { ERR_UPASSNOTSET, "%s :Cannot set user pass (+U) until Admin pass (+A) is set.  First use /MODE %s +A <adminpass>", "564" },
 /* 565 */
-  { ERR_NOMANAGER_LONG, "%s :Re-create the channel.  The channel must be *empty* for 48 continuous hours before it can be recreated.", "565" },
+  { 0 },
 /* 566 */
-  { ERR_NOMANAGER_SHORT, "%s :Re-create the channel.  The channel must be *empty* for a minute or two before it can be recreated.", "566" },
+  { ERR_NOMANAGER, "%s :Re-create the channel.  The channel must be completely empty before it can be recreated.", "566" },
 /* 567 */
   { ERR_UPASS_SAME_APASS, "%s :Cannot use the same pass for both admin (+A) and user (+U) pass.", "567" },
 /* 568 */