Committer : isomer
CVSROOT : /cvsroot/undernet-ircu
Module : ircu2.10
Branch tags: u2_10_12_branch
Commit time: 2007-07-14 02:40:11 UTC
Modified files:
Tag: u2_10_12_branch
ChangeLog include/s_user.h ircd/m_lusers.c ircd/m_mode.c
ircd/m_user.c ircd/s_auth.c ircd/s_misc.c ircd/s_user.c
Log message:
Author: Perry Lorier <[EMAIL PROTECTED]>
Log message:
Try and fix issues with large numbers of invisible (or non invisible) users.
Do this by always calling set_user_mode() for all mode setting/unsetting.
This requires an extra flag so we can limit which userflags can be set in
some situations.
---------------------- diff included ----------------------
Index: ircu2.10/ChangeLog
diff -u ircu2.10/ChangeLog:1.710.2.194 ircu2.10/ChangeLog:1.710.2.195
--- ircu2.10/ChangeLog:1.710.2.194 Wed Jul 11 05:27:51 2007
+++ ircu2.10/ChangeLog Fri Jul 13 19:40:00 2007
@@ -1,4 +1,27 @@
2007-07-12 Perry Lorier <[EMAIL PROTECTED]>
+ Reconsider how we manage modes before registration, to avoid stats
+ getting out of sync.
+
+ * ircd/s_user.c (set_user_mode): Add new parameter to set_user_mode to
+ ignore some modes.
+ (register_user): Use set_user_mode to parse default usermode for
+ users.
+
+ * ircd/m_user.c: Add extra parameter to set_user_mode call
+
+ * ircd/s_auth.c: Add extra parameter to set_user_mode call
+
+ * ircd/m_mode.c: Add extra parameter to set_user_mode call
+
+ * ircd/s_misc.c: Verify stats are consistant.
+
+ * include/s_user.h: Change prototype, add flag definitions.
+
+ * ircd/m_lusers.c (m_users): Assert that we're generating sane stats,
+ include "unknowns" in the total user connections to avoid negative
+ wrap arounds.
+
+2007-07-12 Perry Lorier <[EMAIL PROTECTED]>
* ircd/m_user.c (m_luser): Fix broken RFC 2812 on connect user mode
setting
Index: ircu2.10/include/s_user.h
diff -u ircu2.10/include/s_user.h:1.20.2.1 ircu2.10/include/s_user.h:1.20.2.2
--- ircu2.10/include/s_user.h:1.20.2.1 Wed Feb 15 19:49:54 2006
+++ ircu2.10/include/s_user.h Fri Jul 13 19:40:00 2007
@@ -1,6 +1,6 @@
/** @file s_user.h
* @brief Miscellaneous user-related helper functions.
- * @version $Id: s_user.h,v 1.20.2.1 2006/02/16 03:49:54 entrope Exp $
+ * @version $Id: s_user.h,v 1.20.2.2 2007/07/14 02:40:00 isomer Exp $
*/
#ifndef INCLUDED_s_user_h
#define INCLUDED_s_user_h
@@ -50,6 +50,10 @@
#define MATCH_SERVER 1 /**< flag for relay_masked_message (etc) to indicate
the mask matches a server name */
#define MATCH_HOST 2 /**< flag for relay_masked_message (etc) to indicate
the mask matches host name */
+/* used for parsing user modes */
+#define ALLOWMODES_ANY 0 /**< Allow any user mode */
+#define ALLOWMODES_DEFAULT 1 /**< Only allow the subset of modes that are
legit defaults */
+
/** Formatter function for send_user_info().
* @param who Client being displayed.
* @param sptr Client requesting information.
@@ -77,7 +81,7 @@
extern int hide_hostmask(struct Client *cptr, unsigned int flags);
extern int set_user_mode(struct Client *cptr, struct Client *sptr,
- int parc, char *parv[]);
+ int parc, char *parv[], int allow_modes);
extern int is_silenced(struct Client *sptr, struct Client *acptr);
extern int hunt_server_cmd(struct Client *from, const char *cmd,
const char *tok, struct Client *one,
Index: ircu2.10/ircd/m_lusers.c
diff -u ircu2.10/ircd/m_lusers.c:1.9 ircu2.10/ircd/m_lusers.c:1.9.2.1
--- ircu2.10/ircd/m_lusers.c:1.9 Fri Dec 10 21:13:47 2004
+++ ircu2.10/ircd/m_lusers.c Fri Jul 13 19:40:01 2007
@@ -20,7 +20,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: m_lusers.c,v 1.9 2004/12/11 05:13:47 klmitch Exp $
+ * $Id: m_lusers.c,v 1.9.2.1 2007/07/14 02:40:01 isomer Exp $
*/
/*
@@ -112,7 +112,10 @@
"%s :%C", 2, parc, parv) != HUNTED_ISME)
return 0;
- send_reply(sptr, RPL_LUSERCLIENT, UserStats.clients - UserStats.inv_clients,
+ assert(UserStats.inv_clients <= UserStats.clients + UserStats.unknowns);
+
+ send_reply(sptr, RPL_LUSERCLIENT,
+ UserStats.clients - UserStats.inv_clients + UserStats.unknowns,
UserStats.inv_clients, UserStats.servers);
if (longoutput && UserStats.opers)
send_reply(sptr, RPL_LUSEROP, UserStats.opers);
Index: ircu2.10/ircd/m_mode.c
diff -u ircu2.10/ircd/m_mode.c:1.15.2.5 ircu2.10/ircd/m_mode.c:1.15.2.6
--- ircu2.10/ircd/m_mode.c:1.15.2.5 Sat Mar 31 19:14:59 2007
+++ ircu2.10/ircd/m_mode.c Fri Jul 13 19:40:01 2007
@@ -20,7 +20,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: m_mode.c,v 1.15.2.5 2007/04/01 02:14:59 entrope Exp $
+ * $Id: m_mode.c,v 1.15.2.6 2007/07/14 02:40:01 isomer Exp $
*/
/*
@@ -127,7 +127,7 @@
send_reply(sptr, ERR_USERSDONTMATCH);
return 0;
}
- return set_user_mode(cptr, sptr, parc, parv);
+ return set_user_mode(cptr, sptr, parc, parv, ALLOWMODES_ANY);
}
ClrFlag(sptr, FLAG_TS8);
@@ -198,7 +198,7 @@
cli_name(cptr), cli_name(sptr));
return 0;
}
- return set_user_mode(cptr, sptr, parc, parv);
+ return set_user_mode(cptr, sptr, parc, parv, ALLOWMODES_ANY);
}
ClrFlag(sptr, FLAG_TS8);
Index: ircu2.10/ircd/m_user.c
diff -u ircu2.10/ircd/m_user.c:1.9.2.4 ircu2.10/ircd/m_user.c:1.9.2.5
--- ircu2.10/ircd/m_user.c:1.9.2.4 Wed Jul 11 14:39:52 2007
+++ ircu2.10/ircd/m_user.c Fri Jul 13 19:40:01 2007
@@ -20,7 +20,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: m_user.c,v 1.9.2.4 2007/07/11 21:39:52 isomer Exp $
+ * $Id: m_user.c,v 1.9.2.5 2007/07/14 02:40:01 isomer Exp $
*/
/*
@@ -142,13 +142,15 @@
if ((mode_request = strtoul(parv[2], &term, 10)) != 0
&& term != NULL && *term == '\0')
{
+ char *invisible[4] = { NULL, NULL, "+i", NULL };
+ char *wallops[4] = { NULL, NULL, "+w" , NULL };
/* These bitmask values are codified in RFC 2812, showing
* ... well, something that is probably best not said.
*/
if (mode_request & 8)
- SetInvisible(cptr);
+ set_user_mode(cptr, sptr, 3, invisible, ALLOWMODES_ANY);
if (mode_request & 4)
- SetWallops(cptr);
+ set_user_mode(cptr, sptr, 3, wallops, ALLOWMODES_ANY);
}
else if (parv[2][0] == '+')
{
@@ -157,7 +159,7 @@
user_modes[1] = NULL;
user_modes[2] = parv[2];
user_modes[3] = NULL;
- set_user_mode(cptr, sptr, 3, user_modes);
+ set_user_mode(cptr, sptr, 3, user_modes, ALLOWMODES_ANY);
}
info = (EmptyString(parv[4])) ? "No Info" : parv[4];
Index: ircu2.10/ircd/s_auth.c
diff -u ircu2.10/ircd/s_auth.c:1.37.2.23 ircu2.10/ircd/s_auth.c:1.37.2.24
--- ircu2.10/ircd/s_auth.c:1.37.2.23 Sat Mar 31 20:01:16 2007
+++ ircu2.10/ircd/s_auth.c Fri Jul 13 19:40:01 2007
@@ -31,7 +31,7 @@
*/
/** @file
* @brief Implementation of DNS and ident lookups.
- * @version $Id: s_auth.c,v 1.37.2.23 2007/04/01 03:01:16 entrope Exp $
+ * @version $Id: s_auth.c,v 1.37.2.24 2007/07/14 02:40:01 isomer Exp $
*/
#include "config.h"
@@ -1917,7 +1917,7 @@
{
if (params[0][0] == '+')
{
- set_user_mode(cli, cli, parc + 2, params - 2);
+ set_user_mode(cli, cli, parc + 2, params - 2, ALLOWMODES_ANY);
}
return 0;
}
Index: ircu2.10/ircd/s_misc.c
diff -u ircu2.10/ircd/s_misc.c:1.50.2.1 ircu2.10/ircd/s_misc.c:1.50.2.2
--- ircu2.10/ircd/s_misc.c:1.50.2.1 Wed Feb 15 19:49:54 2006
+++ ircu2.10/ircd/s_misc.c Fri Jul 13 19:40:01 2007
@@ -22,7 +22,7 @@
*/
/** @file
* @brief Miscellaneous support functions.
- * @version $Id: s_misc.c,v 1.50.2.1 2006/02/16 03:49:54 entrope Exp $
+ * @version $Id: s_misc.c,v 1.50.2.2 2007/07/14 02:40:01 isomer Exp $
*/
#include "config.h"
@@ -223,10 +223,14 @@
if (MyUser(bcptr))
set_snomask(bcptr, ~0, SNO_DEL);
- if (IsInvisible(bcptr))
+ if (IsInvisible(bcptr)) {
+ assert(UserStats.inv_clients > 0);
--UserStats.inv_clients;
- if (IsOper(bcptr))
+ }
+ if (IsOper(bcptr)) {
+ assert(UserStats.opers > 0);
--UserStats.opers;
+ }
if (MyConnect(bcptr))
Count_clientdisconnects(bcptr, UserStats);
else
Index: ircu2.10/ircd/s_user.c
diff -u ircu2.10/ircd/s_user.c:1.99.2.6 ircu2.10/ircd/s_user.c:1.99.2.7
--- ircu2.10/ircd/s_user.c:1.99.2.6 Wed Apr 4 18:39:38 2007
+++ ircu2.10/ircd/s_user.c Fri Jul 13 19:40:01 2007
@@ -22,7 +22,7 @@
*/
/** @file
* @brief Miscellaneous user-related helper functions.
- * @version $Id: s_user.c,v 1.99.2.6 2007/04/05 01:39:38 entrope Exp $
+ * @version $Id: s_user.c,v 1.99.2.7 2007/07/14 02:40:01 isomer Exp $
*/
#include "config.h"
@@ -118,6 +118,7 @@
assert(0 == user->channel);
MyFree(user);
+ assert(userCount>0);
--userCount;
}
}
@@ -452,10 +453,6 @@
SetUser(sptr);
}
- if (IsInvisible(sptr))
- ++UserStats.inv_clients;
- if (IsOper(sptr))
- ++UserStats.opers;
/* If they get both +x and an account during registration, hide
* their hostmask here. Calling hide_hostmask() from IAuth's
* account assignment causes a numeric reply during registration.
@@ -984,9 +981,12 @@
* @param[in] sptr Client who sent the mode change message.
* @param[in] parc Number of parameters in \a parv.
* @param[in] parv Parameters to MODE.
+ * @param[in] allow_modes ALLOWMODES_ANY for any mode, ALLOWMODES_DEFAULT for
+ * only permitting legitimate default user modes.
* @return Zero.
*/
-int set_user_mode(struct Client *cptr, struct Client *sptr, int parc, char
*parv[])
+int set_user_mode(struct Client *cptr, struct Client *sptr, int parc,
+ char *parv[], int allow_modes)
{
char** p;
char* m;
@@ -1186,18 +1186,23 @@
if (FlagHas(&setflags, FLAG_OPER) && !IsOper(sptr))
{
/* user no longer oper */
+ assert(UserStats.opers > 0);
--UserStats.opers;
client_set_privs(sptr, NULL); /* will clear propagate privilege */
}
- if (FlagHas(&setflags, FLAG_INVISIBLE) && !IsInvisible(sptr))
+ if (FlagHas(&setflags, FLAG_INVISIBLE) && !IsInvisible(sptr)) {
+ assert(UserStats.inv_clients > 0);
--UserStats.inv_clients;
+ }
if (!FlagHas(&setflags, FLAG_INVISIBLE) && IsInvisible(sptr))
++UserStats.inv_clients;
- if (!FlagHas(&setflags, FLAG_HIDDENHOST) && do_host_hiding)
+ if (!FlagHas(&setflags, FLAG_HIDDENHOST) && do_host_hiding && allow_modes !=
ALLOWMODES_DEFAULT)
hide_hostmask(sptr, FLAG_HIDDENHOST);
if (IsRegistered(sptr))
send_umode_out(cptr, sptr, &setflags, prop);
+ assert(UserStats.opers <= UserStats.clients + UserStats.unknowns);
+ assert(UserStats.inv_clients <= UserStats.clients + UserStats.unknowns);
return 0;
}
----------------------- End of diff -----------------------
_______________________________________________
Patches mailing list
[email protected]
http://undernet.sbg.org/mailman/listinfo/patches