+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
}
}
+/** 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;
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");
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;
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;
}
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");
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;
}
/* 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;
}
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;
}
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");
/* 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 */