diff options
author | attilamolnar <attilamolnar@hush.com> | 2013-05-16 01:56:06 +0200 |
---|---|---|
committer | attilamolnar <attilamolnar@hush.com> | 2013-05-16 01:56:06 +0200 |
commit | c5a46583800374344d8676eccd7061a15a5ac1ce (patch) | |
tree | 486f8ecdc4abd23795c871a59fd0ec707c6a49d8 /src | |
parent | 4b41feea830fc84e8c1b2fd0982f3e8d8840af96 (diff) |
Allow spaces (and more) in oper types
The spaces are converted to '_' characters in OPERTYPE for 2.0 servers
Issue #533 suggested by @ankitkv
Diffstat (limited to 'src')
-rw-r--r-- | src/command_parse.cpp | 2 | ||||
-rw-r--r-- | src/commands/cmd_stats.cpp | 2 | ||||
-rw-r--r-- | src/commands/cmd_whois.cpp | 2 | ||||
-rw-r--r-- | src/configreader.cpp | 2 | ||||
-rw-r--r-- | src/mode.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_check.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_httpd_stats.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_spanningtree/compat.cpp | 13 | ||||
-rw-r--r-- | src/modules/m_spanningtree/main.cpp | 6 | ||||
-rw-r--r-- | src/modules/m_spanningtree/netburst.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_spanningtree/opertype.cpp | 2 | ||||
-rw-r--r-- | src/users.cpp | 8 |
12 files changed, 29 insertions, 16 deletions
diff --git a/src/command_parse.cpp b/src/command_parse.cpp index a7fd810a3..d386337f2 100644 --- a/src/command_parse.cpp +++ b/src/command_parse.cpp @@ -296,7 +296,7 @@ bool CommandParser::ProcessCommand(LocalUser *user, std::string &cmd) if (!user->HasPermission(command)) { user->WriteNumeric(ERR_NOPRIVILEGES, "%s :Permission Denied - Oper type %s does not have access to command %s", - user->nick.c_str(), user->oper->NameStr(), command.c_str()); + user->nick.c_str(), user->oper->name.c_str(), command.c_str()); return do_more; } } diff --git a/src/commands/cmd_stats.cpp b/src/commands/cmd_stats.cpp index d9f3c1496..692b0d2ec 100644 --- a/src/commands/cmd_stats.cpp +++ b/src/commands/cmd_stats.cpp @@ -345,7 +345,7 @@ void CommandStats::DoStats(char statschar, User* user, string_list &results) if (mh && mh->NeedsOper() && tag->AllowedChanModes[c - 'A']) cmodes.push_back(c); } - results.push_back(sn+" 243 "+user->nick+" O "+tag->NameStr() + " " + umodes + " " + cmodes); + results.push_back(sn+" 243 "+user->nick+" O "+tag->name.c_str() + " " + umodes + " " + cmodes); } } break; diff --git a/src/commands/cmd_whois.cpp b/src/commands/cmd_whois.cpp index b4483d8bb..fea14f375 100644 --- a/src/commands/cmd_whois.cpp +++ b/src/commands/cmd_whois.cpp @@ -145,7 +145,7 @@ void CommandWhois::DoWhois(User* user, User* dest, unsigned long signon, unsigne if (ServerInstance->Config->GenericOper) ServerInstance->SendWhoisLine(user, dest, 313, "%s %s :is an IRC operator",user->nick.c_str(), dest->nick.c_str()); else - ServerInstance->SendWhoisLine(user, dest, 313, "%s %s :is %s %s on %s",user->nick.c_str(), dest->nick.c_str(), (strchr("AEIOUaeiou",dest->oper->name[0]) ? "an" : "a"),dest->oper->NameStr(), ServerInstance->Config->Network.c_str()); + ServerInstance->SendWhoisLine(user, dest, 313, "%s %s :is %s %s on %s",user->nick.c_str(), dest->nick.c_str(), (strchr("AEIOUaeiou",dest->oper->name[0]) ? "an" : "a"),dest->oper->name.c_str(), ServerInstance->Config->Network.c_str()); } if (user == dest || user->HasPrivPermission("users/auspex")) diff --git a/src/configreader.cpp b/src/configreader.cpp index cd6122b25..943fa5a41 100644 --- a/src/configreader.cpp +++ b/src/configreader.cpp @@ -135,8 +135,6 @@ void ServerConfig::CrossCheckOperClassType() std::string name = tag->getString("name"); if (name.empty()) throw CoreException("<type:name> is missing from tag at " + tag->getTagLocation()); - if (!ServerInstance->IsNick(name, Limits.NickMax)) - throw CoreException("<type:name> is invalid (value '" + name + "')"); if (oper_blocks.find(" " + name) != oper_blocks.end()) throw CoreException("Duplicate type block with name " + name + " at " + tag->getTagLocation()); diff --git a/src/mode.cpp b/src/mode.cpp index 768623bd5..cd5c1d158 100644 --- a/src/mode.cpp +++ b/src/mode.cpp @@ -313,7 +313,7 @@ ModeAction ModeParser::TryMode(User* user, User* targetuser, Channel* chan, bool if (user->IsOper()) { user->WriteNumeric(ERR_NOPRIVILEGES, "%s :Permission Denied - Oper type %s does not have access to set %s mode %c", - user->nick.c_str(), user->oper->NameStr(), type == MODETYPE_CHANNEL ? "channel" : "user", modechar); + user->nick.c_str(), user->oper->name.c_str(), type == MODETYPE_CHANNEL ? "channel" : "user", modechar); } else { diff --git a/src/modules/m_check.cpp b/src/modules/m_check.cpp index e8f077a7b..fda211cf8 100644 --- a/src/modules/m_check.cpp +++ b/src/modules/m_check.cpp @@ -113,7 +113,7 @@ class CommandCheck : public Command { OperInfo* oper = targuser->oper; /* user is an oper of type ____ */ - user->SendText(checkstr + " opertype " + oper->NameStr()); + user->SendText(checkstr + " opertype " + oper->name); if (loctarg) { std::string umodes; diff --git a/src/modules/m_httpd_stats.cpp b/src/modules/m_httpd_stats.cpp index 0330b3073..8f25415a9 100644 --- a/src/modules/m_httpd_stats.cpp +++ b/src/modules/m_httpd_stats.cpp @@ -196,7 +196,7 @@ class ModuleHttpStats : public Module if (u->IsAway()) data << "<away>" << Sanitize(u->awaymsg) << "</away><awaytime>" << u->awaytime << "</awaytime>"; if (u->IsOper()) - data << "<opertype>" << Sanitize(u->oper->NameStr()) << "</opertype>"; + data << "<opertype>" << Sanitize(u->oper->name) << "</opertype>"; data << "<modes>" << u->FormatModes() << "</modes><ident>" << Sanitize(u->ident) << "</ident>"; LocalUser* lu = IS_LOCAL(u); if (lu) diff --git a/src/modules/m_spanningtree/compat.cpp b/src/modules/m_spanningtree/compat.cpp index 433da9847..17266afe9 100644 --- a/src/modules/m_spanningtree/compat.cpp +++ b/src/modules/m_spanningtree/compat.cpp @@ -140,6 +140,19 @@ void TreeSocket::WriteLine(std::string line) // Insert the source SID (and a space) between the command and the first parameter line.insert(10, line.substr(1, 4)); } + else if (command == "OPERTYPE") + { + std::string::size_type colon = line.find(':', b); + if (colon != std::string::npos) + { + for (std::string::iterator i = line.begin()+colon; i != line.end(); ++i) + { + if (*i == ' ') + *i = '_'; + } + line.erase(colon, 1); + } + } } } } diff --git a/src/modules/m_spanningtree/main.cpp b/src/modules/m_spanningtree/main.cpp index bfd3f75ea..92d274679 100644 --- a/src/modules/m_spanningtree/main.cpp +++ b/src/modules/m_spanningtree/main.cpp @@ -537,7 +537,8 @@ void ModuleSpanningTree::OnUserConnect(LocalUser* user) if (user->IsOper()) { params.clear(); - params.push_back(user->oper->name); + params.push_back(":"); + params[0].append(user->oper->name); Utils->DoOneToMany(user->uuid,"OPERTYPE",params); } @@ -775,7 +776,8 @@ void ModuleSpanningTree::OnOper(User* user, const std::string &opertype) if (user->registered != REG_ALL || !IS_LOCAL(user)) return; parameterlist params; - params.push_back(opertype); + params.push_back(":"); + params[0].append(opertype); Utils->DoOneToMany(user->uuid,"OPERTYPE",params); } diff --git a/src/modules/m_spanningtree/netburst.cpp b/src/modules/m_spanningtree/netburst.cpp index 21404e68e..c22ad3acb 100644 --- a/src/modules/m_spanningtree/netburst.cpp +++ b/src/modules/m_spanningtree/netburst.cpp @@ -204,7 +204,7 @@ void TreeSocket::SendUsers() this->WriteLine(data); if (u->second->IsOper()) { - snprintf(data,MAXBUF,":%s OPERTYPE %s", u->second->uuid.c_str(), u->second->oper->name.c_str()); + snprintf(data,MAXBUF,":%s OPERTYPE :%s", u->second->uuid.c_str(), u->second->oper->name.c_str()); this->WriteLine(data); } if (u->second->IsAway()) diff --git a/src/modules/m_spanningtree/opertype.cpp b/src/modules/m_spanningtree/opertype.cpp index 4772e9222..021100870 100644 --- a/src/modules/m_spanningtree/opertype.cpp +++ b/src/modules/m_spanningtree/opertype.cpp @@ -53,7 +53,7 @@ CmdResult CommandOpertype::Handle(const std::vector<std::string>& params, User * return CMD_SUCCESS; } - ServerInstance->SNO->WriteToSnoMask('O',"From %s: User %s (%s@%s) is now an IRC operator of type %s",u->server.c_str(), u->nick.c_str(),u->ident.c_str(), u->host.c_str(), irc::Spacify(opertype.c_str())); + ServerInstance->SNO->WriteToSnoMask('O',"From %s: User %s (%s@%s) is now an IRC operator of type %s",u->server.c_str(), u->nick.c_str(),u->ident.c_str(), u->host.c_str(), opertype.c_str()); return CMD_SUCCESS; } diff --git a/src/users.cpp b/src/users.cpp index 9f4060968..3fd558daf 100644 --- a/src/users.cpp +++ b/src/users.cpp @@ -402,7 +402,7 @@ bool LocalUser::HasPrivPermission(const std::string &privstr, bool noisy) } if (noisy) - this->WriteNotice("Oper type " + std::string(oper->NameStr()) + " does not have access to priv " + privstr); + this->WriteNotice("Oper type " + oper->name + " does not have access to priv " + privstr); return false; } @@ -551,10 +551,10 @@ void User::Oper(OperInfo* info) } ServerInstance->SNO->WriteToSnoMask('o',"%s (%s@%s) is now an IRC operator of type %s (using oper '%s')", - nick.c_str(), ident.c_str(), host.c_str(), oper->NameStr(), opername.c_str()); - this->WriteNumeric(381, "%s :You are now %s %s", nick.c_str(), strchr("aeiouAEIOU", oper->name[0]) ? "an" : "a", oper->NameStr()); + nick.c_str(), ident.c_str(), host.c_str(), oper->name.c_str(), opername.c_str()); + this->WriteNumeric(381, "%s :You are now %s %s", nick.c_str(), strchr("aeiouAEIOU", oper->name[0]) ? "an" : "a", oper->name.c_str()); - ServerInstance->Logs->Log("OPER", LOG_DEFAULT, "%s opered as type: %s", GetFullRealHost().c_str(), oper->NameStr()); + ServerInstance->Logs->Log("OPER", LOG_DEFAULT, "%s opered as type: %s", GetFullRealHost().c_str(), oper->name.c_str()); ServerInstance->Users->all_opers.push_back(this); // Expand permissions from config for faster lookup |