Committer : isomer
CVSROOT : /cvsroot/undernet-ircu
Module : ircu2.10
Branch tags: u2_10_12_branch
Commit time: 2007-07-21 04:52:13 UTC
Modified files:
Tag: u2_10_12_branch
ChangeLog ircd/s_user.c
Log message:
Author: Perry Lorier <[EMAIL PROTECTED]>
Log message:
Extend set_user_mode() to parse +r <account> umodes (like are sent
server<->server), then use set_user_mode() to parse usermode on s<->s NICK
messages.
This fixes a bug where remote users weren't being counted properly either.
This leaves room for someone to cleanup set_user_mode()'s API a bit to make it
a bit less tied to
m_nick().
---------------------- diff included ----------------------
Index: ircu2.10/ChangeLog
diff -u ircu2.10/ChangeLog:1.710.2.196 ircu2.10/ChangeLog:1.710.2.197
--- ircu2.10/ChangeLog:1.710.2.196 Fri Jul 20 16:32:18 2007
+++ ircu2.10/ChangeLog Fri Jul 20 21:52:02 2007
@@ -1,3 +1,10 @@
+2007-07-21 Perry Lorier <[EMAIL PROTECTED]>
+
+ * ircd/s_user.c: Move set_nick_name() to use set_user_mode(),
+ set_user_mode() now interprets +r usermodes properly (and ignores
+ them from non servers). This fixes a problem where remote users
+ weren't being counted properly anymore.
+
2007-07-20 Kevin L. Mitchell <[EMAIL PROTECTED]>
* ircd/m_gline.c: create abs_expire() macro to convert an expire
Index: ircu2.10/ircd/s_user.c
diff -u ircu2.10/ircd/s_user.c:1.99.2.7 ircu2.10/ircd/s_user.c:1.99.2.8
--- ircu2.10/ircd/s_user.c:1.99.2.7 Fri Jul 13 19:40:01 2007
+++ ircu2.10/ircd/s_user.c Fri Jul 20 21:52:03 2007
@@ -22,7 +22,7 @@
*/
/** @file
* @brief Miscellaneous user-related helper functions.
- * @version $Id: s_user.c,v 1.99.2.7 2007/07/14 02:40:01 isomer Exp $
+ * @version $Id: s_user.c,v 1.99.2.8 2007/07/21 04:52:03 isomer Exp $
*/
#include "config.h"
@@ -389,36 +389,15 @@
* Set user's initial modes
*/
tmpstr = (char*)client_get_default_umode(sptr);
- if (tmpstr) for (; *tmpstr; ++tmpstr) {
- switch (*tmpstr) {
- case 's':
- if (!feature_bool(FEAT_HIS_SNOTICES_OPER_ONLY)) {
- SetServNotice(sptr);
- set_snomask(sptr, SNO_DEFAULT, SNO_SET);
- }
- break;
- case 'w':
- if (!feature_bool(FEAT_WALLOPS_OPER_ONLY))
- SetWallops(sptr);
- break;
- case 'i':
- SetInvisible(sptr);
- break;
- case 'd':
- SetDeaf(sptr);
- break;
- case 'g':
- if (!feature_bool(FEAT_HIS_DEBUG_OPER_ONLY))
- SetDebug(sptr);
- break;
- }
+ if (tmpstr) {
+ char *umodev[] = { NULL, NULL, tmpstr, NULL };
+ set_user_mode(cptr, sptr, 1, umodev, ALLOWMODES_ANY);
}
+
}
else {
struct Client *acptr = user->server;
- Count_newremoteclient(UserStats, acptr);
-
if (cli_from(acptr) != cli_from(sptr))
{
sendcmdto_one(&me, CMD_KILL, cptr, "%C :%s (%s != %s[%s])",
@@ -539,9 +518,6 @@
const char* nick, int parc, char* parv[])
{
if (IsServer(sptr)) {
- int i;
- const char* account = 0;
- const char* p;
/*
* A server introducing a new client, change source
@@ -551,22 +527,7 @@
cli_hopcount(new_client) = atoi(parv[2]);
cli_lastnick(new_client) = atoi(parv[3]);
- if (Protocol(cptr) > 9 && parc > 7 && *parv[6] == '+')
- {
- for (p = parv[6] + 1; *p; p++)
- {
- for (i = 0; i < USERMODELIST_SIZE; ++i)
- {
- if (userModeList[i].c == *p)
- {
- SetFlag(new_client, userModeList[i].flag);
- if (userModeList[i].flag == FLAG_ACCOUNT)
- account = parv[7];
- break;
- }
- }
- }
- }
+
client_set_privs(new_client, NULL); /* set privs on user */
/*
* Set new nick name.
@@ -589,21 +550,13 @@
ircd_strncpy(cli_user(new_client)->host, parv[5], HOSTLEN);
ircd_strncpy(cli_user(new_client)->realhost, parv[5], HOSTLEN);
ircd_strncpy(cli_info(new_client), parv[parc - 1], REALLEN);
- if (account) {
- int len = ACCOUNTLEN;
- if ((p = strchr(account, ':'))) {
- len = (p++) - account;
- cli_user(new_client)->acc_create = atoi(p);
- Debug((DEBUG_DEBUG, "Received timestamped account in user mode; "
- "account \"%s\", timestamp %Tu", account,
- cli_user(new_client)->acc_create));
- }
- ircd_strncpy(cli_user(new_client)->account, account, len);
+
+ Count_newremoteclient(UserStats, sptr);
+
+ if (parc > 7 && *parv[6] == '+') {
+ /* (parc-4) -3 for the ip, numeric nick, realname */
+ set_user_mode(cptr, new_client, parc-7, parv+4, ALLOWMODES_ANY);
}
- if (HasHiddenHost(new_client))
- ircd_snprintf(0, cli_user(new_client)->host, HOSTLEN, "%s.%s",
- cli_user(new_client)->account,
- feature_str(FEAT_HIDDEN_HOST));
return register_user(cptr, new_client);
}
@@ -998,6 +951,7 @@
char buf[BUFSIZE];
int prop = 0;
int do_host_hiding = 0;
+ char* account = NULL;
what = MODE_ADD;
@@ -1032,7 +986,7 @@
/*
* parse mode change string(s)
*/
- for (p = &parv[2]; *p; p++) { /* p is changed in loop too */
+ for (p = &parv[2]; *p && p<&parv[parc]; p++) { /* p is changed in loop
too */
for (m = *p; *m; m++) {
switch (*m) {
case '+':
@@ -1116,6 +1070,13 @@
if (what == MODE_ADD)
do_host_hiding = 1;
break;
+ case 'r':
+ if (what == MODE_ADD) {
+ account = *(++p);
+ SetAccount(sptr);
+ }
+ /* There is no -r */
+ break;
default:
send_reply(sptr, ERR_UMODEUNKNOWNFLAG, *m);
break;
@@ -1132,6 +1093,8 @@
ClearOper(sptr);
if (!FlagHas(&setflags, FLAG_LOCOP) && IsLocOp(sptr))
ClearLocOp(sptr);
+ if (!FlagHas(&setflags, FLAG_ACCOUNT) && IsAccount(sptr))
+ ClrFlag(sptr, FLAG_ACCOUNT);
/*
* new umode; servers can set it, local users cannot;
* prevents users from /kick'ing or /mode -o'ing
@@ -1196,6 +1159,18 @@
}
if (!FlagHas(&setflags, FLAG_INVISIBLE) && IsInvisible(sptr))
++UserStats.inv_clients;
+ if (!FlagHas(&setflags, FLAG_ACCOUNT) && IsAccount(sptr)) {
+ int len = ACCOUNTLEN;
+ char *ts;
+ if ((ts = strchr(account, ':'))) {
+ len = (ts++) - account;
+ cli_user(sptr)->acc_create = atoi(ts);
+ Debug((DEBUG_DEBUG, "Received timestamped account in user mode; "
+ "account \"%s\", timestamp %Tu", account,
+ cli_user(sptr)->acc_create));
+ }
+ ircd_strncpy(cli_user(sptr)->account, account, len);
+ }
if (!FlagHas(&setflags, FLAG_HIDDENHOST) && do_host_hiding && allow_modes !=
ALLOWMODES_DEFAULT)
hide_hostmask(sptr, FLAG_HIDDENHOST);
if (IsRegistered(sptr))
@@ -1510,3 +1485,6 @@
return 0; /* convenience return, if it's ever needed */
}
+
+/* vim: shiftwidth=2
+ */
----------------------- End of diff -----------------------
_______________________________________________
Patches mailing list
[email protected]
http://undernet.sbg.org/mailman/listinfo/patches