Committer : entrope
CVSROOT : /cvsroot/undernet-ircu
Module : ircu2.10
Commit time: 2005-08-29 21:39:36 UTC
Modified files:
ChangeLog include/numeric.h ircd/channel.c ircd/s_err.c
Log message:
Make keys and passwords behave more uniformly.
---------------------- diff included ----------------------
Index: ircu2.10/ChangeLog
diff -u ircu2.10/ChangeLog:1.683 ircu2.10/ChangeLog:1.684
--- ircu2.10/ChangeLog:1.683 Sat Aug 27 07:20:41 2005
+++ ircu2.10/ChangeLog Mon Aug 29 14:39:25 2005
@@ -1,3 +1,15 @@
+2005-08-29 Michael Poole <[EMAIL PROTECTED]>
+
+ * 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 <[EMAIL PROTECTED]>
* ircd/channel.c (add_user_to_channel): Use SetOpLevel() instead
Index: ircu2.10/include/numeric.h
diff -u ircu2.10/include/numeric.h:1.40 ircu2.10/include/numeric.h:1.41
--- ircu2.10/include/numeric.h:1.40 Mon May 30 11:46:19 2005
+++ ircu2.10/include/numeric.h Mon Aug 29 14:39:26 2005
@@ -18,7 +18,7 @@
*/
/** @file
* @brief Declarations of numeric replies and supporting functions.
- * @version $Id: numeric.h,v 1.40 2005/05/30 18:46:19 entrope Exp $
+ * @version $Id: numeric.h,v 1.41 2005/08/29 21:39:26 entrope Exp $
*/
#ifndef INCLUDED_numeric_h
#define INCLUDED_numeric_h
@@ -461,8 +461,8 @@
#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: ircu2.10/ircd/channel.c
diff -u ircu2.10/ircd/channel.c:1.146 ircu2.10/ircd/channel.c:1.147
--- ircu2.10/ircd/channel.c:1.146 Sat Aug 27 07:20:41 2005
+++ ircu2.10/ircd/channel.c Mon Aug 29 14:39:26 2005
@@ -19,7 +19,7 @@
*/
/** @file
* @brief Channel management and maintenance
- * @version $Id: channel.c,v 1.146 2005/08/27 14:20:41 entrope Exp $
+ * @version $Id: channel.c,v 1.147 2005/08/29 21:39:26 entrope Exp $
*/
#include "config.h"
@@ -2337,14 +2337,24 @@
}
}
+/** 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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
}
/* 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 @@
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 @@
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: ircu2.10/ircd/s_err.c
diff -u ircu2.10/ircd/s_err.c:1.71 ircu2.10/ircd/s_err.c:1.72
--- ircu2.10/ircd/s_err.c:1.71 Mon May 30 11:46:19 2005
+++ ircu2.10/ircd/s_err.c Mon Aug 29 14:39:26 2005
@@ -18,7 +18,7 @@
*/
/** @file
* @brief Error handling support.
- * @version $Id: s_err.c,v 1.71 2005/05/30 18:46:19 entrope Exp $
+ * @version $Id: s_err.c,v 1.72 2005/08/29 21:39:26 entrope Exp $
*/
#include "config.h"
@@ -1162,9 +1162,9 @@
/* 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 */
----------------------- End of diff -----------------------
_______________________________________________
Patches mailing list
[email protected]
http://undernet.sbg.org/mailman/listinfo/patches