Add IS_SERVER() and REG_ALL checks to (mostly oper only) commands taking a target nickname

If a SID was passed as the target user parameter or when it's an unregistered user reply with the "no such nick" (or the moral equivalent) message
This commit is contained in:
attilamolnar 2012-11-19 03:37:59 +01:00
parent 71d53e4883
commit e3e3a35899
25 changed files with 34 additions and 34 deletions

View File

@ -50,15 +50,15 @@ CmdResult CommandEline::Handle (const std::vector<std::string>& parameters, User
if (parameters.size() >= 3)
{
IdentHostPair ih;
User* find = ServerInstance->FindNick(target.c_str());
if (find)
User* find = ServerInstance->FindNick(target);
if ((find) && (find->registered == REG_ALL))
{
ih.first = "*";
ih.second = find->GetIPString();
target = std::string("*@") + find->GetIPString();
}
else
ih = ServerInstance->XLines->IdentSplit(target.c_str());
ih = ServerInstance->XLines->IdentSplit(target);
if (ih.first.empty())
{

View File

@ -51,15 +51,15 @@ CmdResult CommandGline::Handle (const std::vector<std::string>& parameters, User
if (parameters.size() >= 3)
{
IdentHostPair ih;
User* find = ServerInstance->FindNick(target.c_str());
if (find)
User* find = ServerInstance->FindNick(target);
if ((find) && (find->registered == REG_ALL))
{
ih.first = "*";
ih.second = find->GetIPString();
target = std::string("*@") + find->GetIPString();
}
else
ih = ServerInstance->XLines->IdentSplit(target.c_str());
ih = ServerInstance->XLines->IdentSplit(target);
if (ih.first.empty())
{

View File

@ -51,15 +51,15 @@ CmdResult CommandKline::Handle (const std::vector<std::string>& parameters, User
if (parameters.size() >= 3)
{
IdentHostPair ih;
User* find = ServerInstance->FindNick(target.c_str());
if (find)
User* find = ServerInstance->FindNick(target);
if ((find) && (find->registered == REG_ALL))
{
ih.first = "*";
ih.second = find->GetIPString();
target = std::string("*@") + find->GetIPString();
}
else
ih = ServerInstance->XLines->IdentSplit(target.c_str());
ih = ServerInstance->XLines->IdentSplit(target);
if (ih.first.empty())
{

View File

@ -64,7 +64,7 @@ CmdResult CommandWhois::Handle (const std::vector<std::string>& parameters, User
else
dest = ServerInstance->FindNick(parameters[userindex]);
if (dest)
if ((dest) && (dest->registered == REG_ALL))
{
/*
* Okay. Umpteenth attempt at doing this, so let's re-comment...

View File

@ -53,9 +53,9 @@ CmdResult CommandZline::Handle (const std::vector<std::string>& parameters, User
return CMD_FAILURE;
}
User *u = ServerInstance->FindNick(target.c_str());
User *u = ServerInstance->FindNick(target);
if (u)
if ((u) && (u->registered == REG_ALL))
{
target = u->GetIPString();
}

View File

@ -387,7 +387,7 @@ void ModeParser::Process(const std::vector<std::string>& parameters, User *user,
LastParseParams.clear();
LastParseTranslate.clear();
if (!targetchannel && !targetuser)
if ((!targetchannel) && ((!targetuser) || (IS_SERVER(targetuser))))
{
user->WriteNumeric(ERR_NOSUCHNICK, "%s %s :No such nick/channel",user->nick.c_str(),target.c_str());
return;

View File

@ -58,7 +58,7 @@ class CommandChghost : public Command
User* dest = ServerInstance->FindNick(parameters[0]);
if (!dest)
if ((!dest) || (dest->registered != REG_ALL))
{
user->WriteNumeric(ERR_NOSUCHNICK, "%s %s :No such nick/channel", user->nick.c_str(), parameters[0].c_str());
return CMD_FAILURE;

View File

@ -40,7 +40,7 @@ class CommandChgident : public Command
{
User* dest = ServerInstance->FindNick(parameters[0]);
if (!dest)
if ((!dest) || (dest->registered != REG_ALL))
{
user->WriteNumeric(ERR_NOSUCHNICK, "%s %s :No such nick/channel", user->nick.c_str(), parameters[0].c_str());
return CMD_FAILURE;

View File

@ -38,7 +38,7 @@ class CommandChgname : public Command
{
User* dest = ServerInstance->FindNick(parameters[0]);
if (!dest)
if ((!dest) || (dest->registered != REG_ALL))
{
user->WriteNumeric(ERR_NOSUCHNICK, "%s %s :No such nick/channel", user->nick.c_str(), parameters[0].c_str());
return CMD_FAILURE;

View File

@ -42,7 +42,7 @@ class CommandNicklock : public Command
{
User* target = ServerInstance->FindNick(parameters[0]);
if (!target)
if ((!target) || (target->registered != REG_ALL))
{
user->WriteServ("NOTICE %s :*** No such nickname: '%s'", user->nick.c_str(), parameters[0].c_str());
return CMD_FAILURE;

View File

@ -69,9 +69,9 @@ class RemoveBase : public Command
channel = ServerInstance->FindChan(channame);
/* Fix by brain - someone needs to learn to validate their input! */
if (!target || !channel)
if ((!target) || (target->registered != REG_ALL) || (!channel))
{
user->WriteNumeric(ERR_NOSUCHNICK, "%s %s :No such nick/channel", user->nick.c_str(), !target ? username.c_str() : channame.c_str());
user->WriteNumeric(ERR_NOSUCHNICK, "%s %s :No such nick/channel", user->nick.c_str(), !channel ? channame.c_str() : username.c_str());
return CMD_FAILURE;
}

View File

@ -37,7 +37,7 @@ class CommandSajoin : public Command
CmdResult Handle (const std::vector<std::string>& parameters, User *user)
{
User* dest = ServerInstance->FindNick(parameters[0]);
if (dest)
if ((dest) && (dest->registered == REG_ALL))
{
if (ServerInstance->ULine(dest->server))
{

View File

@ -39,7 +39,7 @@ class CommandSakick : public Command
Channel* channel = ServerInstance->FindChan(parameters[0]);
const char* reason = "";
if (dest && channel)
if ((dest) && (dest->registered == REG_ALL) && (channel))
{
if (parameters.size() > 2)
{

View File

@ -47,7 +47,7 @@ class CommandSanick : public Command
return CMD_FAILURE;
}
if (!target)
if ((!target) || (target->registered != REG_ALL))
{
user->WriteServ("NOTICE %s :*** No such nickname: '%s'", user->nick.c_str(), parameters[0].c_str());
return CMD_FAILURE;

View File

@ -40,7 +40,7 @@ class CommandSapart : public Command
Channel* channel = ServerInstance->FindChan(parameters[1]);
std::string reason;
if (dest && channel)
if ((dest) && (dest->registered == REG_ALL) && (channel))
{
if (parameters.size() > 2)
reason = parameters[2];

View File

@ -37,7 +37,7 @@ class CommandSaquit : public Command
CmdResult Handle (const std::vector<std::string>& parameters, User *user)
{
User* dest = ServerInstance->FindNick(parameters[0]);
if (dest)
if ((dest) && (!IS_SERVER(dest)))
{
if (ServerInstance->ULine(dest->server))
{

View File

@ -208,7 +208,7 @@ class CommandSASL : public Command
CmdResult Handle(const std::vector<std::string>& parameters, User *user)
{
User* target = ServerInstance->FindNick(parameters[1]);
if (!target)
if ((!target) || (IS_SERVER(target)))
{
ServerInstance->Logs->Log("m_sasl", DEBUG,"User not found in sasl ENCAP event: %s", parameters[1].c_str());
return CMD_FAILURE;

View File

@ -108,8 +108,8 @@ class CommandShun : public Command
std::string target = parameters[0];
User *find = ServerInstance->FindNick(target.c_str());
if (find)
User *find = ServerInstance->FindNick(target);
if ((find) && (find->registered == REG_ALL))
target = std::string("*!*@") + find->GetIPString();
if (parameters.size() == 1)

View File

@ -27,7 +27,7 @@
bool TreeSocket::Away(const std::string &prefix, parameterlist &params)
{
User* u = ServerInstance->FindNick(prefix);
if (!u)
if ((!u) || (IS_SERVER(u)))
return true;
if (params.size())
{

View File

@ -46,7 +46,7 @@ CmdResult CommandMetadata::Handle(const std::vector<std::string>& params, User *
else if (*(params[0].c_str()) != '#')
{
User* u = ServerInstance->FindUUID(params[0]);
if (u)
if ((u) && (!IS_SERVER(u)))
{
if (item)
item->unserialize(FORMAT_NETWORK, u, value);

View File

@ -34,7 +34,7 @@ bool TreeSocket::OperQuit(const std::string &prefix, parameterlist &params)
User* u = ServerInstance->FindUUID(prefix);
if (u)
if ((u) && (!IS_SERVER(u)))
{
ServerInstance->OperQuit.set(u, params[0]);
params[0] = ":" + params[0];

View File

@ -40,7 +40,7 @@ bool TreeSocket::ForceNick(const std::string &prefix, parameterlist &params)
User* u = ServerInstance->FindNick(params[0]);
time_t ts = atol(params[1].c_str());
if (u && u->age == ts)
if ((u) && (!IS_SERVER(u)) && (u->age == ts))
{
Utils->DoOneToAllButSender(prefix,"SAVE",params,prefix);

View File

@ -91,7 +91,7 @@ class CommandSSLInfo : public Command
{
User* target = ServerInstance->FindNickOnly(parameters[0]);
if (!target)
if ((!target) || (target->registered != REG_ALL))
{
user->WriteNumeric(ERR_NOSUCHNICK, "%s %s :No such nickname", user->nick.c_str(), parameters[0].c_str());
return CMD_FAILURE;

View File

@ -43,7 +43,7 @@ class CommandSwhois : public Command
{
User* dest = ServerInstance->FindNick(parameters[0]);
if (!dest)
if ((!dest) || (IS_SERVER(dest))) // allow setting swhois using SWHOIS before reg
{
user->WriteNumeric(ERR_NOSUCHNICK, "%s %s :No such nick/channel", user->nick.c_str(), parameters[0].c_str());
return CMD_FAILURE;

View File

@ -40,7 +40,7 @@ class CommandUninvite : public Command
User* u = ServerInstance->FindNick(parameters[0]);
Channel* c = ServerInstance->FindChan(parameters[1]);
if ((!c) || (!u))
if ((!c) || (!u) || (u->registered != REG_ALL))
{
if (!c)
{