From: Michael Poole Date: Mon, 29 Aug 2005 21:39:26 +0000 (+0000) Subject: Make keys and passwords behave more uniformly. X-Git-Url: http://git.pk910.de/?p=ircu2.10.12-pk.git;a=commitdiff_plain;h=28bdf0b003cb7dae13a4e9d0f3cdb15f6244782c Make keys and passwords behave more uniformly. git-svn-id: file:///home/klmitch/undernet-ircu/undernet-ircu-svn/ircu2/trunk@1470 c9e4aea6-c8fd-4c43-8297-357d70d61c8c --- diff --git a/ChangeLog b/ChangeLog index 07ae22b..bf51a87 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2005-08-29 Michael Poole + + * 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 * ircd/channel.c (add_user_to_channel): Use SetOpLevel() instead diff --git a/include/numeric.h b/include/numeric.h index 0ce4bdc..26fbfb9 100644 --- a/include/numeric.h +++ b/include/numeric.h @@ -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 diff --git a/ircd/channel.c b/ircd/channel.c index b2007f8..4cf0ae8 100644 --- a/ircd/channel.c +++ b/ircd/channel.c @@ -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"); diff --git a/ircd/s_err.c b/ircd/s_err.c index 8ce4b1d..ed2e509 100644 --- a/ircd/s_err.c +++ b/ircd/s_err.c @@ -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 ", "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 */