From 821c67e3abd609a8d94c0f58075620fe4437baf0 Mon Sep 17 00:00:00 2001 From: michael Date: Wed, 18 Jun 2014 17:10:15 +0000 Subject: - m_message.c:handle_special(): removed user@server messages to local users, as this was an easy way to bypass +R/+G/+g usermodes. git-svn-id: svn://svn.ircd-hybrid.org/svnroot/ircd-hybrid/branches/8.1.x@3994 82007160-df01-0410-b94d-b575c5fd34c7 --- NEWS | 2 + modules/core/m_message.c | 125 ++++++++++------------------------------------- 2 files changed, 27 insertions(+), 100 deletions(-) diff --git a/NEWS b/NEWS index 1ddd980..d937e0d 100644 --- a/NEWS +++ b/NEWS @@ -2,6 +2,8 @@ o) Fixed EOB logic for remote servers o) Fixed bug where opers that have the +g/+G/+R umodes set won't receive server notices for remote CONNECT/KLINE/DLINE/XLINE/RESV attempts +o) Sending messages to user@server to local targets is now no longer possible, + as this was an easy way to bypass +R/+G/+g user modes. -- Noteworthy changes in version 8.1.18 (2014-06-09) diff --git a/modules/core/m_message.c b/modules/core/m_message.c index cb2d29c..9e10aa6 100644 --- a/modules/core/m_message.c +++ b/modules/core/m_message.c @@ -99,45 +99,6 @@ duplicate_ptr(const void *ptr) return 0; } -/* - * find_userhost - find a user@host (server or user). - * inputs - user name to look for - * - host name to look for - * - pointer to count of number of matches found - * outputs - pointer to client if found - * - count is updated - * side effects - none - * - */ -static struct Client * -find_userhost(char *user, char *host, int *count) -{ - struct Client *res = NULL; - dlink_node *lc2ptr = NULL; - - *count = 0; - - if (collapse(user)) - { - DLINK_FOREACH(lc2ptr, local_client_list.head) - { - struct Client *c2ptr = lc2ptr->data; - - if (!IsClient(c2ptr)) - continue; - - if ((!host || !match(host, c2ptr->host)) && - !irccmp(user, c2ptr->username)) - { - (*count)++; - res = c2ptr; - } - } - } - - return res; -} - /* flood_attack_client() * * inputs - flag 0 if PRIVMSG 1 if NOTICE. RFC @@ -481,86 +442,50 @@ msg_client(int p_or_n, const char *command, struct Client *source_p, */ static void handle_special(int p_or_n, const char *command, struct Client *client_p, - struct Client *source_p, char *nick, char *text) + struct Client *source_p, char *nick, const char *text) { struct Client *target_p; - char *host; - char *server; - char *s; - int count; + const char *server = NULL, *s = NULL; /* * user[%host]@server addressed? */ if ((server = strchr(nick, '@'))) { - count = 0; - - if ((host = strchr(nick, '%')) && !HasUMode(source_p, UMODE_OPER)) + if ((target_p = hash_find_server(server + 1)) == NULL) { - sendto_one(source_p, form_str(ERR_NOPRIVILEGES), + sendto_one(source_p, form_str(ERR_NOSUCHSERVER), ID_or_name(&me, client_p), - ID_or_name(source_p, client_p)); + ID_or_name(source_p, client_p), server + 1); return; } - if ((target_p = hash_find_server(server + 1))) + if (!HasUMode(source_p, UMODE_OPER) && strchr(nick, '%')) { - if (!IsMe(target_p)) - { - /* - * Not destined for a user on me :-( - */ - sendto_one(target_p, ":%s %s %s :%s", - ID_or_name(source_p, target_p), - command, nick, text); - if ((p_or_n != NOTICE) && MyClient(source_p)) - source_p->localClient->last_privmsg = CurrentTime; - - return; - } - - *server = '\0'; - - if (host != NULL) - *host++ = '\0'; + sendto_one(source_p, form_str(ERR_NOSUCHNICK), + ID_or_name(&me, client_p), + ID_or_name(source_p, client_p), nick); + return; + } + if (!IsMe(target_p)) + { /* - * Look for users which match the destination host - * (no host == wildcard) and if one and one only is - * found connected to me, deliver message! + * Not destined for a user on me :-( */ - if ((target_p = find_userhost(nick, host, &count))) - { - if (server != NULL) - *server = '@'; - if (host != NULL) - *--host = '%'; + sendto_one(target_p, ":%s %s %s :%s", + ID_or_name(source_p, target_p), + command, nick, text); - if (count == 1) - { - sendto_one(target_p, ":%s!%s@%s %s %s :%s", - source_p->name, source_p->username, - source_p->host, command, nick, text); + if ((p_or_n != NOTICE) && MyClient(source_p)) + source_p->localClient->last_privmsg = CurrentTime; - if ((p_or_n != NOTICE) && MyClient(source_p)) - source_p->localClient->last_privmsg = CurrentTime; - } - else - sendto_one(source_p, form_str(ERR_TOOMANYTARGETS), - ID_or_name(&me, client_p), - ID_or_name(source_p, client_p), nick, - ConfigFileEntry.max_targets); - } + return; } - else if (server && *(server + 1) && (target_p == NULL)) - sendto_one(source_p, form_str(ERR_NOSUCHSERVER), - ID_or_name(&me, client_p), - ID_or_name(source_p, client_p), server + 1); - else if (server && (target_p == NULL)) - sendto_one(source_p, form_str(ERR_NOSUCHNICK), - ID_or_name(&me, client_p), - ID_or_name(source_p, client_p), nick); + + sendto_one(source_p, form_str(ERR_NOSUCHNICK), + ID_or_name(&me, client_p), + ID_or_name(source_p, client_p), nick); return; } @@ -582,7 +507,7 @@ handle_special(int p_or_n, const char *command, struct Client *client_p, { if ((*(nick + 1) == '$' || *(nick + 1) == '#')) ++nick; - else if (MyClient(source_p) && HasUMode(source_p, UMODE_OPER)) + else if (MyClient(source_p)) { sendto_one(source_p, ":%s NOTICE %s :The command %s %s is no longer supported, please use $%s", -- cgit