]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Add deop protection for services, bug #554
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>
Tue, 10 Jun 2008 23:14:32 +0000 (23:14 +0000)
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>
Tue, 10 Jun 2008 23:14:32 +0000 (23:14 +0000)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@9884 e03df62e-2008-0410-955e-edbf42e46eb7

src/modules/m_servprotect.cpp

index d79e40bef77384b2576e71de951b688d7d1a173b..cb4f0e1af07524826da260de277446bcf6c2a643 100644 (file)
@@ -48,8 +48,8 @@ class ModuleServProtectMode : public Module
                bm = new ServProtectMode(ServerInstance);
                if (!ServerInstance->Modes->AddMode(bm))
                        throw ModuleException("Could not add new modes!");
-               Implementation eventlist[] = { I_OnWhois, I_OnKill, I_OnWhoisLine };
-               ServerInstance->Modules->Attach(eventlist, this, 3);
+               Implementation eventlist[] = { I_OnWhois, I_OnKill, I_OnWhoisLine, I_OnRawMode };
+               ServerInstance->Modules->Attach(eventlist, this, 4);
        }
 
        
@@ -72,6 +72,23 @@ class ModuleServProtectMode : public Module
                }
        }
 
+       virtual int OnRawMode(User* user, Channel* chan, const char mode, const std::string &param, bool adding, int pcnt, bool servermode)
+       {
+               if (!servermode && (mode == 'o') && !adding && chan && IS_LOCAL(user) && !ServerInstance->ULine(user->server))
+               {
+                       User *u = ServerInstance->FindNick(param);
+                       if (u)
+                       {
+                               if (u->IsModeSet('k'))
+                               {
+                                       user->WriteNumeric(482, "%s %s :You are not permitted to deop %s services", user->nick.c_str(), chan->name.c_str(), ServerInstance->Config->Network);
+                                       return ACR_DENY;
+                               }
+                       }
+               }
+               return 0;
+       }
+
        virtual int OnKill(User* src, User* dst, const std::string &reason)
        {
                if (src == NULL)
@@ -79,7 +96,7 @@ class ModuleServProtectMode : public Module
 
                if (dst->IsModeSet('k'))
                {
-                       src->WriteNumeric(485, "%s :You are not allowed to kill %s Services!", src->nick.c_str(), ServerInstance->Config->Network);
+                       src->WriteNumeric(485, "%s :You are not permitted to kill %s services!", src->nick.c_str(), ServerInstance->Config->Network);
                        ServerInstance->SNO->WriteToSnoMask('A', std::string(src->nick)+" tried to kill service "+dst->nick+" ("+reason+")");
                        return 1;
                }