From c01b7746d57a34a3e5b455bca1b3e54318af14de Mon Sep 17 00:00:00 2001 From: Michael Poole Date: Thu, 7 Apr 2005 02:10:23 +0000 Subject: [PATCH] Split RPL_APASSWARN and ERR_NOTMANAGER into multiple messages to avoid 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 | 16 ++++++++++++++++ include/numeric.h | 8 ++++++-- ircd/channel.c | 47 ++++++++++++++++++----------------------------- ircd/s_err.c | 12 ++++++------ 4 files changed, 46 insertions(+), 37 deletions(-) diff --git a/ChangeLog b/ChangeLog index daafc2f..434aa74 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,19 @@ +2005-04-06 Michael Poole + + * 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 * ircd/ircd_parser.y (clientblock): Use the password field. diff --git a/include/numeric.h b/include/numeric.h index 5ca0458..bf82848 100644 --- a/include/numeric.h +++ b/include/numeric.h @@ -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 diff --git a/ircd/channel.c b/ircd/channel.c index 3b9818b..db4e7f9 100644 --- a/ircd/channel.c +++ b/ircd/channel.c @@ -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, " ."); + 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, "."); + 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, " ."); + 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, "."); + 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); } } } diff --git a/ircd/s_err.c b/ircd/s_err.c index 6a55cf5..45a34da 100644 --- a/ircd/s_err.c +++ b/ircd/s_err.c @@ -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 .", "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 ", "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 */ -- 2.20.1