X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fcommands%2Fcmd_oper.cpp;h=e1018f805c4f73cca58857d1275f4514fab5c61b;hb=fd1d19d6345943ecdb5ce4ef947f9b3c5c8bca86;hp=1178137197e1e442cc4083e6dd117ef6930ef5f1;hpb=a5fe50aca04ca554d313e7361c571c6a497a9c4e;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/commands/cmd_oper.cpp b/src/commands/cmd_oper.cpp index 117813719..e1018f805 100644 --- a/src/commands/cmd_oper.cpp +++ b/src/commands/cmd_oper.cpp @@ -21,8 +21,6 @@ #include "inspircd.h" -bool OneOfMatches(const char* host, const char* ip, const char* hostlist); - /** Handle /OPER. These command handlers can be reloaded by the core, * and handle basic RFC1459 commands. Commands within modules work * the same way, however, they can be fully unloaded, where these @@ -43,30 +41,14 @@ class CommandOper : public SplitCommand CmdResult HandleLocal(const std::vector& parameters, LocalUser *user); }; -bool OneOfMatches(const char* host, const char* ip, const std::string& hostlist) -{ - std::stringstream hl(hostlist); - std::string xhost; - while (hl >> xhost) - { - if (InspIRCd::Match(host, xhost, ascii_case_insensitive_map) || InspIRCd::MatchCIDR(ip, xhost, ascii_case_insensitive_map)) - { - return true; - } - } - return false; -} - CmdResult CommandOper::HandleLocal(const std::vector& parameters, LocalUser *user) { - char TheHost[MAXBUF]; - char TheIP[MAXBUF]; bool match_login = false; bool match_pass = false; bool match_hosts = false; - snprintf(TheHost,MAXBUF,"%s@%s",user->ident.c_str(),user->host.c_str()); - snprintf(TheIP, MAXBUF,"%s@%s",user->ident.c_str(),user->GetIPString().c_str()); + const std::string userHost = user->ident + "@" + user->host; + const std::string userIP = user->ident + "@" + user->GetIPString(); OperIndex::iterator i = ServerInstance->Config->oper_blocks.find(parameters[0]); if (i != ServerInstance->Config->oper_blocks.end()) @@ -75,7 +57,7 @@ CmdResult CommandOper::HandleLocal(const std::vector& parameters, L ConfigTag* tag = ifo->oper_block; match_login = true; match_pass = !ServerInstance->PassCompare(user, tag->getString("password"), parameters[1], tag->getString("hash")); - match_hosts = OneOfMatches(TheHost,TheIP,tag->getString("host")); + match_hosts = InspIRCd::MatchMask(tag->getString("host"), userHost, userIP); if (match_pass && match_hosts) { @@ -98,7 +80,7 @@ CmdResult CommandOper::HandleLocal(const std::vector& parameters, L user->CommandFloodPenalty += 10000; ServerInstance->SNO->WriteGlobalSno('o', "WARNING! Failed oper attempt by %s using login '%s': The following fields do not match: %s", user->GetFullRealHost().c_str(), parameters[0].c_str(), fields.c_str()); - ServerInstance->Logs->Log("OPER",LOG_DEFAULT,"OPER: Failed oper attempt by %s using login '%s': The following fields did not match: %s", user->GetFullRealHost().c_str(), parameters[0].c_str(), fields.c_str()); + ServerInstance->Logs->Log("OPER", LOG_DEFAULT, "OPER: Failed oper attempt by %s using login '%s': The following fields did not match: %s", user->GetFullRealHost().c_str(), parameters[0].c_str(), fields.c_str()); return CMD_FAILURE; }