From ffaabe3b67d11ff6b01d33dd69bc469c7a8c16fa Mon Sep 17 00:00:00 2001 From: Perry Lorier Date: Sat, 21 Jul 2007 04:52:03 +0000 Subject: [PATCH] Author: Perry Lorier Log message: Extend set_user_mode() to parse +r 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(). git-svn-id: file:///home/klmitch/undernet-ircu/undernet-ircu-svn/ircu2/branches/u2_10_12_branch@1820 c9e4aea6-c8fd-4c43-8297-357d70d61c8c --- ChangeLog | 7 ++++ ircd/s_user.c | 96 ++++++++++++++++++++------------------------------- 2 files changed, 44 insertions(+), 59 deletions(-) diff --git a/ChangeLog b/ChangeLog index 679f92b..bcdd6c5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2007-07-21 Perry Lorier + + * 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 * ircd/m_gline.c: create abs_expire() macro to convert an expire diff --git a/ircd/s_user.c b/ircd/s_user.c index a5a75a1..ed5951f 100644 --- a/ircd/s_user.c +++ b/ircd/s_user.c @@ -389,36 +389,15 @@ int register_user(struct Client *cptr, struct Client *sptr) * 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 @@ int set_nick_name(struct Client* cptr, struct Client* sptr, 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 @@ int set_nick_name(struct Client* cptr, struct Client* sptr, 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 @@ int set_nick_name(struct Client* cptr, struct Client* sptr, 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 @@ int set_user_mode(struct Client *cptr, struct Client *sptr, int parc, char buf[BUFSIZE]; int prop = 0; int do_host_hiding = 0; + char* account = NULL; what = MODE_ADD; @@ -1032,7 +986,7 @@ int set_user_mode(struct Client *cptr, struct Client *sptr, int parc, /* * 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 @@ int set_user_mode(struct Client *cptr, struct Client *sptr, int parc, 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 @@ int set_user_mode(struct Client *cptr, struct Client *sptr, int parc, 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 @@ int set_user_mode(struct Client *cptr, struct Client *sptr, int parc, } 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 @@ send_supported(struct Client *cptr) return 0; /* convenience return, if it's ever needed */ } + +/* vim: shiftwidth=2 + */ -- 2.20.1