Split RPL_APASSWARN and ERR_NOTMANAGER into multiple messages to avoid
authorMichael Poole <mdpoole@troilus.org>
Thu, 7 Apr 2005 02:10:23 +0000 (02:10 +0000)
committerMichael Poole <mdpoole@troilus.org>
Thu, 7 Apr 2005 02:10:23 +0000 (02:10 +0000)
embedding message strings in the logic implementation.

git-svn-id: file:///home/klmitch/undernet-ircu/undernet-ircu-svn/ircu2/trunk@1356 c9e4aea6-c8fd-4c43-8297-357d70d61c8c

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

index daafc2fcc3326ce089e78a1a35edb440e03af4d8..434aa74002deb5a71668046e010786e932916b58 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,19 @@
+2005-04-06  Michael Poole <mdpoole@troilus.org>
+
+       * include/numeric.h (RPL_APASSWARN): Replace with three distinct
+       values.
+       (ERR_NOMANAGER_LONG): Assign new numeric.
+       (ERR_NOMANAGER_SHORT): Assign new numeric.
+
+       * ircd/channel.c (parse_mode_upass): Adapt to new formats for
+       ERR_NOTMANAGER separation.
+       (parse_mode_apass): Likewise.  Also adapt to RPL_APASSWARN split.
+
+       * ircd/s_err.c (RPL_APASSWARN): Replace with three message
+       strings, to avoid embedding long message strings in the logic
+       implementation.
+       (ERR_NOTMANAGER): Likewise (but not the same strings).
+
 2005-04-06  Michael Poole <mdpoole@troilus.org>
 
        * ircd/ircd_parser.y (clientblock): Use the password field.
index 5ca0458441c1099fcc8f4baee47e2f510c57fd11..bf82848fcae761ade2ecb00ad1ae0ed9bc7c0194 100644 (file)
@@ -63,7 +63,9 @@ extern const struct Numeric* get_error_numeric(int err);
 #define RPL_MAP               15        /* Undernet extension */
 #define RPL_MAPMORE           16        /* Undernet extension */
 #define RPL_MAPEND            17        /* Undernet extension */
-#define RPL_APASSWARN         30       /* Undernet extension */
+#define RPL_APASSWARN_SET     30       /* Undernet extension */
+#define RPL_APASSWARN_SECRET  31       /* Undernet extension */
+#define RPL_APASSWARN_CLEAR   32       /* Undernet extension */
 /*     RPL_YOURID            42        IRCnet extension */
 /*      RPL_ATTEMPTINGJUNC    50           aircd extension */
 /*      RPL_ATTEMPTINGREROUTE 51           aircd extension */
@@ -459,7 +461,9 @@ extern const struct Numeric* get_error_numeric(int err);
 #define ERR_CHANSECURED      552       /* Undernet extension */
 #define ERR_UPASSSET         553       /* Undernet extension */
 #define ERR_UPASSNOTSET      554       /* Undernet extension */
-#define ERR_LASTERROR        555
+#define ERR_NOMANAGER_LONG   555       /* Undernet extension */
+#define ERR_NOMANAGER_SHORT  556       /* Undernet extension */
+#define ERR_LASTERROR        557
 
 /*     RPL_LOGON            600        dalnet,unreal
        RPL_LOGOFF           601        dalnet,unreal
index 3b9818be90bbc494bb35ca5c47b8eba7ce7747e9..db4e7f9a51a60a3fc7519d19f335e0b309d34dfa 100644 (file)
@@ -2439,7 +2439,7 @@ mode_parse_upass(struct ParseState *state, int *flag_p)
   if (state->flags & MODE_PARSE_FORCE && MyUser(state->sptr)
       && !HasPriv(state->sptr, PRIV_APASS_OPMODE)) {
     send_reply(state->sptr, ERR_NOTMANAGER, state->chptr->chname,
-               "Use /JOIN", state->chptr->chname, " <AdminPass>.");
+               state->chptr->chname);
     return;
   }
 
@@ -2447,16 +2447,15 @@ mode_parse_upass(struct ParseState *state, int *flag_p)
   if (MyUser(state->sptr) && !(state->flags & MODE_PARSE_FORCE || IsChannelManager(state->member))) {
     if (*state->chptr->mode.apass) {
       send_reply(state->sptr, ERR_NOTMANAGER, state->chptr->chname,
-         "Use /JOIN", state->chptr->chname, "<AdminPass>.");
+                 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_NOTMANAGER, state->chptr->chname,
-         "Re-create the channel.  The channel must be *empty* for",
-         TStime() - state->chptr->creationtime >= 171000 ? "48 contiguous hours" : "a minute or two",
-         "before it can be recreated.");
+      send_reply(state->sptr, ERR_NOMANAGER_SHORT, state->chptr->chname);
     }
     return;
   }
+
   if (state->done & DONE_UPASS) /* allow upass to be set only once */
     return;
   state->done |= DONE_UPASS;
@@ -2479,7 +2478,7 @@ mode_parse_upass(struct ParseState *state, int *flag_p)
   if (!state->mbuf)
     return;
 
-  if (!(state->flags & MODE_PARSE_FORCE))
+  if (!(state->flags & MODE_PARSE_FORCE)) {
     /* can't add the upass while apass is not set */
     if (state->dir == MODE_ADD && !*state->chptr->mode.apass) {
       send_reply(state->sptr, ERR_UPASSNOTSET, state->chptr->chname, state->chptr->chname);
@@ -2492,6 +2491,7 @@ mode_parse_upass(struct ParseState *state, int *flag_p)
       send_reply(state->sptr, ERR_KEYSET, state->chptr->chname);
       return;
     }
+  }
 
   if (!(state->flags & MODE_PARSE_WIPEOUT) && state->dir == MODE_ADD &&
       !ircd_strcmp(state->chptr->mode.upass, t_str))
@@ -2547,7 +2547,7 @@ mode_parse_apass(struct ParseState *state, int *flag_p)
   if (state->flags & MODE_PARSE_FORCE && MyUser(state->sptr)
       && !HasPriv(state->sptr, PRIV_APASS_OPMODE)) {
     send_reply(state->sptr, ERR_NOTMANAGER, state->chptr->chname,
-               "Use /JOIN", state->chptr->chname, " <AdminPass>.");
+               state->chptr->chname);
     return;
   }
 
@@ -2561,15 +2561,15 @@ mode_parse_apass(struct ParseState *state, int *flag_p)
   if (MyUser(state->sptr) && !(state->flags & MODE_PARSE_FORCE || IsChannelManager(state->member))) {
     if (*state->chptr->mode.apass) {
       send_reply(state->sptr, ERR_NOTMANAGER, state->chptr->chname,
-         "Use /JOIN", state->chptr->chname, "<AdminPass>.");
+                 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_NOTMANAGER, state->chptr->chname,
-         "Re-create the channel.  The channel must be *empty* for",
-         "at least a whole minute", "before it can be recreated.");
+      send_reply(state->sptr, ERR_NOMANAGER_SHORT, state->chptr->chname);
     }
     return;
   }
+
   if (state->done & DONE_APASS) /* allow apass to be set only once */
     return;
   state->done |= DONE_APASS;
@@ -2624,25 +2624,14 @@ mode_parse_apass(struct ParseState *state, int *flag_p)
       /* Make it VERY clear to the user that this is a one-time password */
       ircd_strncpy(state->chptr->mode.apass, t_str, PASSLEN);
       if (MyUser(state->sptr)) {
-       send_reply(state->sptr, RPL_APASSWARN,
-           "Channel Admin password (+A) set to '", state->chptr->mode.apass, "'. ",
-           "Are you SURE you want to use this as Admin password? ",
-           "You will NOT be able to change this password anymore once the channel is more than 48 hours old!");
-       send_reply(state->sptr, RPL_APASSWARN,
-           "Use \"/MODE ", state->chptr->chname, " -A ", state->chptr->mode.apass,
-           "\" to remove the password and then immediately set a new one. "
-           "IMPORTANT: YOU CANNOT RECOVER THIS PASSWORD, EVER; "
-           "WRITE THE PASSWORD DOWN (don't store this rescue password on disk)! "
-           "Now set the channel user password (+U).");
+       send_reply(state->sptr, RPL_APASSWARN_SET, state->chptr->mode.apass);
+       send_reply(state->sptr, RPL_APASSWARN_SECRET, state->chptr->chname,
+                   state->chptr->mode.apass);
       }
     } else { /* remove the old apass */
       *state->chptr->mode.apass = '\0';
       if (MyUser(state->sptr))
-       send_reply(state->sptr, RPL_APASSWARN,
-           "WARNING: You removed the channel Admin password MODE (+A). ",
-           "If you would disconnect or leave the channel without setting a new password then you will ",
-           "not be able to set it again and lose ownership of this channel! ",
-           "SET A NEW PASSWORD NOW!", "");
+        send_reply(state->sptr, RPL_APASSWARN_CLEAR);
     }
   }
 }
index 6a55cf5a0c00ed69d4f57145b98ad3837be8000d..45a34daaff53f99b5eec2b01fc52f78a112e74fc 100644 (file)
@@ -92,11 +92,11 @@ static Numeric replyTable[] = {
 /* 029 */
   { 0 },
 /* 030 */
-  { RPL_APASSWARN, ":%s%s%s%s%s", "030" },
+  { RPL_APASSWARN_SET, ":Channel Admin password (+A) set to '%s'.  Are you SURE you want to use this as Admin password? You will NOT be able to change this password anymore once the channel is more than 48 hours old!", "030" },
 /* 031 */
-  { 0 },
+  { RPL_APASSWARN_SECRET, ":Use \"/MODE %s -A %s\" to remove the password and then immediately set a new one.  IMPORTANT: YOU CANNOT RECOVER THIS PASSWORD, EVER; WRITE THE PASSWORD DOWN (don't store this rescue password on disk)! Now set the channel user password (+U).", "031" },
 /* 032 */
-  { 0 },
+  { RPL_APASSWARN_CLEAR, ":WARNING: You removed the channel Admin password (+A). If you disconnect or leave the channel without setting a new password then you will not be able to set it again!  SET A NEW PASSWORD NOW!", "032" },
 /* 033 */
   { 0 },
 /* 034 */
@@ -1134,7 +1134,7 @@ static Numeric replyTable[] = {
 /* 550 */
   { ERR_NOTLOWEROPLEVEL, "%s %s %hu %hu :Cannot %s someone with %s op-level", "550" },
 /* 551 */
-  { ERR_NOTMANAGER, "%s :You must be channel Admin to add or remove a password. %s %s %s", "551" },
+  { ERR_NOTMANAGER, "%s :You must be channel Admin to add or remove a password. Use /JOIN %s <AdminPass>.", "551" },
 /* 552 */
   { ERR_CHANSECURED, "%s :Channel is older than 48 hours and secured. Cannot change Admin pass anymore", "552" },
 /* 553 */
@@ -1142,9 +1142,9 @@ static Numeric replyTable[] = {
 /* 554 */
   { ERR_UPASSNOTSET, "%s :Cannot set user pass (+U) until Admin pass (+A) is set.  First use /MODE %s +A <adminpass>", "554" },
 /* 555 */
-  { 0 },
+  { ERR_NOMANAGER_LONG, "%s :Re-create the channel.  The channel must be *empty* for 48 continuous hours before it can be recreated.", "555" },
 /* 556 */
-  { 0 },
+  { ERR_NOMANAGER_SHORT, "%s :Re-create the channel.  The channel must be *empty* for a minute or two before it can be recreated.", "556" },
 /* 557 */
   { 0 },
 /* 558 */