summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>2009-10-21 23:46:05 +0000
committerdanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>2009-10-21 23:46:05 +0000
commit984cc96a1f832abf9b5fcfddcd8260c5b12bd2a9 (patch)
tree4c14d438e08c9b77119ba365971bb04c46a10bbb /src
parent4219a6e4145c839f166fddf8a2d5889b32ca0346 (diff)
Move AllowedPrivs and similar oper information from LocalUser to OperInfo
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@11947 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src')
-rw-r--r--src/users.cpp78
1 files changed, 14 insertions, 64 deletions
diff --git a/src/users.cpp b/src/users.cpp
index 0f760e27c..e8e4a4825 100644
--- a/src/users.cpp
+++ b/src/users.cpp
@@ -242,7 +242,6 @@ User::User(const std::string &uid)
LocalUser::LocalUser() : User(ServerInstance->GetUID())
{
- AllowedPrivs = AllowedOperCommands = NULL;
bytes_in = bytes_out = cmds_in = cmds_out = 0;
server_sa.sa.sa_family = AF_UNSPEC;
Penalty = 0;
@@ -434,7 +433,7 @@ bool LocalUser::HasModePermission(unsigned char mode, ModeType type)
if (mode < 'A' || mode > ('A' + 64)) return false;
- return ((type == MODETYPE_USER ? AllowedUserModes : AllowedChanModes))[(mode - 'A')];
+ return ((type == MODETYPE_USER ? oper->AllowedUserModes : oper->AllowedChanModes))[(mode - 'A')];
}
/*
@@ -457,12 +456,9 @@ bool LocalUser::HasPermission(const std::string &command)
return false;
}
- if (!AllowedOperCommands)
- return false;
-
- if (AllowedOperCommands->find(command) != AllowedOperCommands->end())
+ if (oper->AllowedOperCommands.find(command) != oper->AllowedOperCommands.end())
return true;
- else if (AllowedOperCommands->find("*") != AllowedOperCommands->end())
+ else if (oper->AllowedOperCommands.find("*") != oper->AllowedOperCommands.end())
return true;
return false;
@@ -482,18 +478,11 @@ bool LocalUser::HasPrivPermission(const std::string &privstr, bool noisy)
return false;
}
- if (!AllowedPrivs)
- {
- if (noisy)
- this->WriteServ("NOTICE %s :Privset empty(!?)", this->nick.c_str());
- return false;
- }
-
- if (AllowedPrivs->find(privstr) != AllowedPrivs->end())
+ if (oper->AllowedPrivs.find(privstr) != oper->AllowedPrivs.end())
{
return true;
}
- else if (AllowedPrivs->find("*") != AllowedPrivs->end())
+ else if (oper->AllowedPrivs.find("*") != oper->AllowedPrivs.end())
{
return true;
}
@@ -620,18 +609,6 @@ CullResult LocalUser::cull()
else
ServerInstance->Logs->Log("USERS", DEBUG, "Failed to remove user from vector");
- if (this->AllowedOperCommands)
- {
- delete AllowedOperCommands;
- AllowedOperCommands = NULL;
- }
-
- if (this->AllowedPrivs)
- {
- delete AllowedPrivs;
- AllowedPrivs = NULL;
- }
-
if (client_sa.sa.sa_family != AF_UNSPEC)
ServerInstance->Users->RemoveCloneCounts(this);
return User::cull();
@@ -658,29 +635,22 @@ void User::Oper(OperInfo* info)
ServerInstance->Logs->Log("OPER", DEFAULT, "%s!%s@%s opered as type: %s", this->nick.c_str(), this->ident.c_str(), this->host.c_str(), info->NameStr());
ServerInstance->Users->all_opers.push_back(this);
+ // Expand permissions from config for faster lookup
if (IS_LOCAL(this))
- IS_LOCAL(this)->OperInternal();
+ oper->init();
FOREACH_MOD(I_OnPostOper,OnPostOper(this, info->name, opername));
}
-void LocalUser::OperInternal()
+void OperInfo::init()
{
- if (AllowedOperCommands)
- AllowedOperCommands->clear();
- else
- AllowedOperCommands = new std::set<std::string>;
-
- if (AllowedPrivs)
- AllowedPrivs->clear();
- else
- AllowedPrivs = new std::set<std::string>;
-
+ AllowedOperCommands.clear();
+ AllowedPrivs.clear();
AllowedUserModes.reset();
AllowedChanModes.reset();
- this->AllowedUserModes['o' - 'A'] = true; // Call me paranoid if you want.
+ AllowedUserModes['o' - 'A'] = true; // Call me paranoid if you want.
- for(std::vector<reference<ConfigTag> >::iterator iter = oper->class_blocks.begin(); iter != oper->class_blocks.end(); ++iter)
+ for(std::vector<reference<ConfigTag> >::iterator iter = class_blocks.begin(); iter != class_blocks.end(); ++iter)
{
ConfigTag* tag = *iter;
std::string mycmd, mypriv;
@@ -688,13 +658,13 @@ void LocalUser::OperInternal()
irc::spacesepstream CommandList(tag->getString("commands"));
while (CommandList.GetToken(mycmd))
{
- this->AllowedOperCommands->insert(mycmd);
+ AllowedOperCommands.insert(mycmd);
}
irc::spacesepstream PrivList(tag->getString("privs"));
while (PrivList.GetToken(mypriv))
{
- this->AllowedPrivs->insert(mypriv);
+ AllowedPrivs.insert(mypriv);
}
for (unsigned char* c = (unsigned char*)tag->getString("usermodes").c_str(); *c; ++c)
@@ -756,29 +726,9 @@ void User::UnOper()
/* remove the user from the oper list. Will remove multiple entries as a safeguard against bug #404 */
ServerInstance->Users->all_opers.remove(this);
- if (IS_LOCAL(this))
- IS_LOCAL(this)->UnOperInternal();
this->modes[UM_OPERATOR] = 0;
}
-void LocalUser::UnOperInternal()
-{
- if (AllowedOperCommands)
- {
- delete AllowedOperCommands;
- AllowedOperCommands = NULL;
- }
-
- if (AllowedPrivs)
- {
- delete AllowedPrivs;
- AllowedPrivs = NULL;
- }
- AllowedUserModes.reset();
- AllowedChanModes.reset();
-}
-
-
/* adds or updates an entry in the whowas list */
void User::AddToWhoWas()
{