]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Use FindNickOnly() in a few more places if a local user is performing an action to...
authorAttila Molnar <attilamolnar@hush.com>
Sun, 19 Jan 2014 15:48:41 +0000 (16:48 +0100)
committerAttila Molnar <attilamolnar@hush.com>
Sun, 19 Jan 2014 15:48:41 +0000 (16:48 +0100)
src/mode.cpp
src/modules/m_callerid.cpp
src/modules/m_remove.cpp
src/modules/m_uninvite.cpp
src/modules/m_userip.cpp

index 16751e7121d0ca3b7cf1fc6f5cd364d085c03b4a..2a32dfac27defefabea4c9c7ec7c46956efcc6f5 100644 (file)
@@ -346,10 +346,19 @@ ModeAction ModeParser::TryMode(User* user, User* targetuser, Channel* chan, bool
                return MODEACTION_DENY;
        }
 
-       if (mh->GetTranslateType() == TR_NICK && !ServerInstance->FindNick(parameter))
+       if (mh->GetTranslateType() == TR_NICK)
        {
-               user->WriteNumeric(ERR_NOSUCHNICK, "%s %s :No such nick/channel", user->nick.c_str(), parameter.c_str());
-               return MODEACTION_DENY;
+               User* prefixtarget;
+               if (IS_LOCAL(user))
+                       prefixtarget = ServerInstance->FindNickOnly(parameter);
+               else
+                       prefixtarget = ServerInstance->FindNick(parameter);
+
+               if (!prefixtarget)
+               {
+                       user->WriteNumeric(ERR_NOSUCHNICK, "%s %s :No such nick/channel", user->nick.c_str(), parameter.c_str());
+                       return MODEACTION_DENY;
+               }
        }
 
        if (mh->GetPrefixRank() && chan)
@@ -378,9 +387,16 @@ ModeAction ModeParser::TryMode(User* user, User* targetuser, Channel* chan, bool
 
 void ModeParser::Process(const std::vector<std::string>& parameters, User *user, bool merge)
 {
-       std::string target = parameters[0];
+       const std::string& target = parameters[0];
        Channel* targetchannel = ServerInstance->FindChan(target);
-       User* targetuser  = ServerInstance->FindNick(target);
+       User* targetuser = NULL;
+       if (!targetchannel)
+       {
+               if (IS_LOCAL(user))
+                       targetuser = ServerInstance->FindNickOnly(target);
+               else
+                       targetuser = ServerInstance->FindNick(target);
+       }
        ModeType type = targetchannel ? MODETYPE_CHANNEL : MODETYPE_USER;
 
        LastParse.clear();
index 74428f543a58005532786799de0ca79123fa3006..09c5c3f244e9040f7491d485d9833af316502405 100644 (file)
@@ -197,7 +197,7 @@ public:
                /* Even if callerid mode is not set, we let them manage their ACCEPT list so that if they go +g they can
                 * have a list already setup. */
 
-               std::string tok = parameters[0];
+               const std::string& tok = parameters[0];
 
                if (tok == "*")
                {
@@ -207,7 +207,12 @@ public:
                }
                else if (tok[0] == '-')
                {
-                       User* whotoremove = ServerInstance->FindNick(tok.substr(1));
+                       User* whotoremove;
+                       if (IS_LOCAL(user))
+                               whotoremove = ServerInstance->FindNickOnly(tok.substr(1));
+                       else
+                               whotoremove = ServerInstance->FindNick(tok.substr(1));
+
                        if (whotoremove)
                                return (RemoveAccept(user, whotoremove) ? CMD_SUCCESS : CMD_FAILURE);
                        else
@@ -215,7 +220,13 @@ public:
                }
                else
                {
-                       User* whotoadd = ServerInstance->FindNick(tok[0] == '+' ? tok.substr(1) : tok);
+                       const std::string target = (tok[0] == '+' ? tok.substr(1) : tok);
+                       User* whotoadd;
+                       if (IS_LOCAL(user))
+                               whotoadd = ServerInstance->FindNickOnly(target);
+                       else
+                               whotoadd = ServerInstance->FindNick(target);
+
                        if ((whotoadd) && (whotoadd->registered == REG_ALL) && (!whotoadd->quitting) && (!IS_SERVER(whotoadd)))
                                return (AddAccept(user, whotoadd) ? CMD_SUCCESS : CMD_FAILURE);
                        else
index 86f50ad625d9ad351dda7687f9e982c6063aabab..cf139f4a3d5dbe9032039dd18009e5ad872e3fff 100644 (file)
@@ -63,7 +63,10 @@ class RemoveBase : public Command
                const std::string& username = parameters[neworder ? 1 : 0];
 
                /* Look up the user we're meant to be removing from the channel */
-               target = ServerInstance->FindNick(username);
+               if (IS_LOCAL(user))
+                       target = ServerInstance->FindNickOnly(username);
+               else
+                       target = ServerInstance->FindNick(username);
 
                /* And the channel we're meant to be removing them from */
                channel = ServerInstance->FindChan(channame);
index 10fd7c7b63605ef7eb04bb3e441b0b589434c2e2..ff392edc31efb35c9ef6870192a836f390c38b3d 100644 (file)
@@ -37,7 +37,12 @@ class CommandUninvite : public Command
 
        CmdResult Handle (const std::vector<std::string> &parameters, User *user)
        {
-               User* u = ServerInstance->FindNick(parameters[0]);
+               User* u;
+               if (IS_LOCAL(user))
+                       u = ServerInstance->FindNickOnly(parameters[0]);
+               else
+                       u = ServerInstance->FindNick(parameters[0]);
+
                Channel* c = ServerInstance->FindChan(parameters[1]);
 
                if ((!c) || (!u) || (u->registered != REG_ALL))
index 5ea84c04aa8b925c382b48a12db83d0a70ac300e..33b261ca1bba79f64935c0d79ce6ec24ac0f9b5d 100644 (file)
@@ -42,7 +42,7 @@ class CommandUserip : public Command
 
                for (int i = 0; i < (int)parameters.size(); i++)
                {
-                       User *u = ServerInstance->FindNick(parameters[i]);
+                       User *u = ServerInstance->FindNickOnly(parameters[i]);
                        if ((u) && (u->registered == REG_ALL))
                        {
                                // Anyone may query their own IP