]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/users.cpp
Fix the operlog module double logging when tosnomask is enabled.
[user/henk/code/inspircd.git] / src / users.cpp
index 0f1ee74660968c2abb73dae51619dc9eb3d34c4b..bd7d046b8b9e7d6db909e536603229064039d5e7 100644 (file)
@@ -229,6 +229,19 @@ bool LocalUser::HasPrivPermission(const std::string& privstr)
        return oper->AllowedPrivs.Contains(privstr);
 }
 
+bool User::HasSnomaskPermission(char chr) const
+{
+       return true;
+}
+
+bool LocalUser::HasSnomaskPermission(char chr) const
+{
+       if (!this->IsOper() || !ModeParser::IsModeChar(chr))
+               return false;
+
+       return this->oper->AllowedSnomasks[chr - 'A'];
+}
+
 void UserIOHandler::OnDataReady()
 {
        if (user->quitting)
@@ -419,6 +432,7 @@ void OperInfo::init()
        AllowedPrivs.Clear();
        AllowedUserModes.reset();
        AllowedChanModes.reset();
+       AllowedSnomasks.reset();
        AllowedUserModes['o' - 'A'] = true; // Call me paranoid if you want.
 
        for(std::vector<reference<ConfigTag> >::iterator iter = class_blocks.begin(); iter != class_blocks.end(); ++iter)
@@ -428,30 +442,34 @@ void OperInfo::init()
                AllowedOperCommands.AddList(tag->getString("commands"));
                AllowedPrivs.AddList(tag->getString("privs"));
 
-               std::string modes = tag->getString("usermodes");
-               for (std::string::const_iterator c = modes.begin(); c != modes.end(); ++c)
+               const std::string umodes = tag->getString("usermodes");
+               for (std::string::const_iterator c = umodes.begin(); c != umodes.end(); ++c)
                {
-                       if (*c == '*')
-                       {
+                       const char& chr = *c;
+                       if (chr == '*')
                                this->AllowedUserModes.set();
-                       }
-                       else if (*c >= 'A' && *c <= 'z')
-                       {
-                               this->AllowedUserModes[*c - 'A'] = true;
-                       }
+                       else if (ModeParser::IsModeChar(chr))
+                               this->AllowedUserModes[chr - 'A'] = true;
                }
 
-               modes = tag->getString("chanmodes");
-               for (std::string::const_iterator c = modes.begin(); c != modes.end(); ++c)
+               const std::string cmodes = tag->getString("chanmodes");
+               for (std::string::const_iterator c = cmodes.begin(); c != cmodes.end(); ++c)
                {
-                       if (*c == '*')
-                       {
+                       const char& chr = *c;
+                       if (chr == '*')
                                this->AllowedChanModes.set();
-                       }
-                       else if (*c >= 'A' && *c <= 'z')
-                       {
-                               this->AllowedChanModes[*c - 'A'] = true;
-                       }
+                       else if (ModeParser::IsModeChar(chr))
+                               this->AllowedChanModes[chr - 'A'] = true;
+               }
+
+               const std::string snomasks = tag->getString("snomasks", "*");
+               for (std::string::const_iterator c = snomasks.begin(); c != snomasks.end(); ++c)
+               {
+                       const char& chr = *c;
+                       if (chr == '*')
+                               this->AllowedSnomasks.set();
+                       else if (ModeParser::IsModeChar(chr))
+                               this->AllowedSnomasks[chr - 'A'] = true;
                }
        }
 }
@@ -508,7 +526,7 @@ void LocalUser::CheckClass(bool clone_count)
        }
        else if (a->type == CC_DENY)
        {
-               ServerInstance->Users->QuitUser(this, a->config->getString("reason", "Unauthorised connection"));
+               ServerInstance->Users->QuitUser(this, a->config->getString("reason", "Unauthorised connection", 1));
                return;
        }
        else if (clone_count)