summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorw00t <w00t@e03df62e-2008-0410-955e-edbf42e46eb7>2008-08-27 19:23:17 +0000
committerw00t <w00t@e03df62e-2008-0410-955e-edbf42e46eb7>2008-08-27 19:23:17 +0000
commit19e6882591a46c35a1c2e5b4b37479ff073b5957 (patch)
treebe92b84d9dbb0515c784b4940935236bb260ba07 /src
parent4f7adb7d8b36353fc752e2f4b4b79dfc9e452afa (diff)
Clean up opering a tiny bit.. pave the way for SVSOPER
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@10324 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src')
-rw-r--r--src/commands/cmd_oper.cpp5
-rw-r--r--src/modules/extra/m_sqloper.cpp7
-rw-r--r--src/users.cpp127
3 files changed, 63 insertions, 76 deletions
diff --git a/src/commands/cmd_oper.cpp b/src/commands/cmd_oper.cpp
index aada9c09d..076a77df2 100644
--- a/src/commands/cmd_oper.cpp
+++ b/src/commands/cmd_oper.cpp
@@ -106,10 +106,7 @@ CmdResult CommandOper::Handle (const std::vector<std::string>& parameters, User
if (found)
{
/* correct oper credentials */
- ServerInstance->SNO->WriteToSnoMask('o',"%s (%s@%s) is now an IRC operator of type %s (using oper '%s')", user->nick.c_str(), user->ident.c_str(), user->host.c_str(), irc::Spacify(OperType), parameters[0].c_str());
- user->WriteNumeric(381, "%s :You are now %s %s",user->nick.c_str(), strchr("aeiouAEIOU", *OperType) ? "an" : "a", irc::Spacify(OperType));
- if (!user->IsModeSet('o'))
- user->Oper(OperType, LoginName);
+ user->Oper(OperType, LoginName);
}
else
{
diff --git a/src/modules/extra/m_sqloper.cpp b/src/modules/extra/m_sqloper.cpp
index ecb655913..64256ee87 100644
--- a/src/modules/extra/m_sqloper.cpp
+++ b/src/modules/extra/m_sqloper.cpp
@@ -306,12 +306,7 @@ public:
if (operhost.size())
user->ChangeDisplayedHost(operhost.c_str());
- ServerInstance->SNO->WriteToSnoMask('o',"%s (%s@%s) is now an IRC operator of type %s", user->nick.c_str(), user->ident.c_str(), user->host.c_str(), type.c_str());
- user->WriteNumeric(RPL_YOUAREOPER, "%s :You are now %s %s",user->nick.c_str(), strchr("aeiouAEIOU", type[0]) ? "an" : "a", irc::Spacify(type.c_str()));
-
- if (!user->modes[UM_OPERATOR])
- user->Oper(type, tname);
-
+ user->Oper(type, tname);
return true;
}
}
diff --git a/src/users.cpp b/src/users.cpp
index a98adb044..7523c1ff8 100644
--- a/src/users.cpp
+++ b/src/users.cpp
@@ -701,84 +701,83 @@ void User::Oper(const std::string &opertype, const std::string &opername)
char* savept;
char* savept2;
- try
- {
- this->modes[UM_OPERATOR] = 1;
- this->WriteServ("MODE %s :+o", this->nick.c_str());
- FOREACH_MOD(I_OnOper, OnOper(this, opertype));
- ServerInstance->Logs->Log("OPER", DEFAULT, "%s!%s@%s opered as type: %s", this->nick.c_str(), this->ident.c_str(), this->host.c_str(), opertype.c_str());
- this->oper.assign(opertype, 0, 512);
- ServerInstance->Users->all_opers.push_back(this);
+ if (user->IsModeSet('o'))
+ user->Deoper();
- opertype_t::iterator iter_opertype = ServerInstance->Config->opertypes.find(this->oper.c_str());
- if (iter_opertype != ServerInstance->Config->opertypes.end())
- {
+ this->modes[UM_OPERATOR] = 1;
+ this->WriteServ("MODE %s :+o", this->nick.c_str());
+ FOREACH_MOD(I_OnOper, OnOper(this, opertype));
- if (AllowedOperCommands)
- AllowedOperCommands->clear();
- else
- AllowedOperCommands = new std::map<std::string, bool>;
+ ServerInstance->SNO->WriteToSnoMask('o',"%s (%s@%s) is now an IRC operator of type %s (using oper '%s')", this->nick.c_str(), this->ident.c_str(), this->host.c_str(), irc::Spacify(opertype.c_str()), opername.c_str());
+ this->WriteNumeric(381, "%s :You are now %s %s", this->nick.c_str(), strchr("aeiouAEIOU", *opertype.c_str()) ? "an" : "a", irc::Spacify(opertype.c_str()));
+
+ ServerInstance->Logs->Log("OPER", DEFAULT, "%s!%s@%s opered as type: %s", this->nick.c_str(), this->ident.c_str(), this->host.c_str(), opertype.c_str());
+ this->oper.assign(opertype, 0, 512);
+ ServerInstance->Users->all_opers.push_back(this);
+
+ opertype_t::iterator iter_opertype = ServerInstance->Config->opertypes.find(this->oper.c_str());
+ if (iter_opertype != ServerInstance->Config->opertypes.end())
+ {
+
+ if (AllowedOperCommands)
+ AllowedOperCommands->clear();
+ else
+ AllowedOperCommands = new std::map<std::string, bool>;
- if (!AllowedChanModes)
- AllowedChanModes = new bool[64];
+ if (!AllowedChanModes)
+ AllowedChanModes = new bool[64];
- if (!AllowedUserModes)
- AllowedUserModes = new bool[64];
+ if (!AllowedUserModes)
+ AllowedUserModes = new bool[64];
- memset(AllowedUserModes, 0, 64);
- memset(AllowedChanModes, 0, 64);
+ memset(AllowedUserModes, 0, 64);
+ memset(AllowedChanModes, 0, 64);
- char* Classes = strdup(iter_opertype->second);
- char* myclass = strtok_r(Classes," ",&savept);
- while (myclass)
+ char* Classes = strdup(iter_opertype->second);
+ char* myclass = strtok_r(Classes," ",&savept);
+ while (myclass)
+ {
+ operclass_t::iterator iter_operclass = ServerInstance->Config->operclass.find(myclass);
+ if (iter_operclass != ServerInstance->Config->operclass.end())
{
- operclass_t::iterator iter_operclass = ServerInstance->Config->operclass.find(myclass);
- if (iter_operclass != ServerInstance->Config->operclass.end())
+ char* CommandList = strdup(iter_operclass->second.commandlist);
+ mycmd = strtok_r(CommandList," ",&savept2);
+ while (mycmd)
+ {
+ this->AllowedOperCommands->insert(std::make_pair(mycmd, true));
+ mycmd = strtok_r(NULL," ",&savept2);
+ }
+ free(CommandList);
+ this->AllowedUserModes['o' - 'A'] = true; // Call me paranoid if you want.
+ for (unsigned char* c = (unsigned char*)iter_operclass->second.umodelist; *c; ++c)
{
- char* CommandList = strdup(iter_operclass->second.commandlist);
- mycmd = strtok_r(CommandList," ",&savept2);
- while (mycmd)
+ if (*c == '*')
{
- this->AllowedOperCommands->insert(std::make_pair(mycmd, true));
- mycmd = strtok_r(NULL," ",&savept2);
+ memset(this->AllowedUserModes, (int)(true), 64);
}
- free(CommandList);
- this->AllowedUserModes['o' - 'A'] = true; // Call me paranoid if you want.
- for (unsigned char* c = (unsigned char*)iter_operclass->second.umodelist; *c; ++c)
+ else
{
- if (*c == '*')
- {
- memset(this->AllowedUserModes, (int)(true), 64);
- }
- else
- {
- this->AllowedUserModes[*c - 'A'] = true;
- }
+ this->AllowedUserModes[*c - 'A'] = true;
}
- for (unsigned char* c = (unsigned char*)iter_operclass->second.cmodelist; *c; ++c)
+ }
+ for (unsigned char* c = (unsigned char*)iter_operclass->second.cmodelist; *c; ++c)
+ {
+ if (*c == '*')
{
- if (*c == '*')
- {
- memset(this->AllowedChanModes, (int)(true), 64);
- }
- else
- {
- this->AllowedChanModes[*c - 'A'] = true;
- }
+ memset(this->AllowedChanModes, (int)(true), 64);
+ }
+ else
+ {
+ this->AllowedChanModes[*c - 'A'] = true;
}
}
- myclass = strtok_r(NULL," ",&savept);
}
- free(Classes);
+ myclass = strtok_r(NULL," ",&savept);
}
-
- FOREACH_MOD(I_OnPostOper,OnPostOper(this, opertype, opername));
+ free(Classes);
}
- catch (...)
- {
- ServerInstance->Logs->Log("OPER", DEBUG,"Exception in User::Oper()");
- }
+ FOREACH_MOD(I_OnPostOper,OnPostOper(this, opertype, opername));
}
void User::UnOper()
@@ -790,12 +789,9 @@ void User::UnOper()
for (unsigned char letter = 'A'; letter <= 'z'; letter++)
{
- if (letter != 'o')
- {
- ModeHandler* mh = ServerInstance->Modes->FindMode(letter, MODETYPE_USER);
- if (mh && mh->NeedsOper())
- moderemove += letter;
- }
+ ModeHandler* mh = ServerInstance->Modes->FindMode(letter, MODETYPE_USER);
+ if (mh && mh->NeedsOper())
+ moderemove += letter;
}
std::vector<std::string> parameters;
@@ -806,7 +802,6 @@ void User::UnOper()
/* unset their oper type (what IS_OPER checks), and remove +o */
this->oper.clear();
- this->modes[UM_OPERATOR] = 0;
/* remove the user from the oper list. Will remove multiple entries as a safeguard against bug #404 */
ServerInstance->Users->all_opers.remove(this);