]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_passforward.cpp
Use SQUERY instead of PRIVMSG in alias/passforward config.
[user/henk/code/inspircd.git] / src / modules / m_passforward.cpp
index 3050dba0b5343444dee22d5803601539960783f6..2eaabe247c8393e835f9abe1c05ba2019f606073 100644 (file)
@@ -18,6 +18,7 @@
 
 
 #include "inspircd.h"
+#include "modules/account.h"
 
 class ModulePassForward : public Module
 {
@@ -34,7 +35,7 @@ class ModulePassForward : public Module
                ConfigTag* tag = ServerInstance->Config->ConfValue("passforward");
                nickrequired = tag->getString("nick", "NickServ");
                forwardmsg = tag->getString("forwardmsg", "NOTICE $nick :*** Forwarding PASS to $nickrequired");
-               forwardcmd = tag->getString("cmd", "PRIVMSG $nickrequired :IDENTIFY $pass");
+               forwardcmd = tag->getString("cmd", "SQUERY $nickrequired :IDENTIFY $pass");
        }
 
        void FormatStr(std::string& result, const std::string& format, const LocalUser* user)
@@ -82,6 +83,13 @@ class ModulePassForward : public Module
                if (!user->MyClass->config->getString("password").empty())
                        return;
 
+               AccountExtItem* actext = GetAccountExtItem();
+               if (actext && actext->get(user))
+               {
+                       // User is logged in already (probably via SASL) don't forward the password
+                       return;
+               }
+
                if (!nickrequired.empty())
                {
                        /* Check if nick exists and its server is ulined */
@@ -91,12 +99,12 @@ class ModulePassForward : public Module
                }
 
                std::string tmp;
-               FormatStr(tmp,forwardmsg, user);
-               user->WriteServ(tmp);
+               FormatStr(tmp, forwardmsg, user);
+               ServerInstance->Parser.ProcessBuffer(user, tmp);
 
                tmp.clear();
                FormatStr(tmp,forwardcmd, user);
-               ServerInstance->Parser.ProcessBuffer(tmp,user);
+               ServerInstance->Parser.ProcessBuffer(user, tmp);
        }
 };