X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fcommand_parse.cpp;h=e751db6d338e55dcdd74950b9a1827ca8d5a2112;hb=45776df702235ec38625403778daff4c7aed4e4e;hp=9cef16ef40cdbcbd1203aa8e12331f86daf18c20;hpb=cd2406617f5c0c3c5e7f53519ea47b9178b7802a;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/command_parse.cpp b/src/command_parse.cpp index 9cef16ef4..e751db6d3 100644 --- a/src/command_parse.cpp +++ b/src/command_parse.cpp @@ -217,12 +217,15 @@ bool CommandParser::IsValidCommand(const std::string &commandname, int pcnt, use { if ((pcnt>=n->second->min_params) && (n->second->source != "")) { - if ((!n->second->flags_needed) || (user->IsModeSet(n->second->flags_needed))) + if (IS_LOCAL(user) && n->second->flags_needed) { - if (n->second->flags_needed) + if (user->IsModeSet(n->second->flags_needed)) { - return ((user->HasPermission(commandname)) || (ServerInstance->ULine(user->server))); + return (user->HasPermission(commandname)); } + } + else + { return true; } } @@ -249,20 +252,29 @@ CmdResult CommandParser::CallHandler(const std::string &commandname,const char** { if (pcnt >= n->second->min_params) { - if ((!n->second->flags_needed) || (user->IsModeSet(n->second->flags_needed))) + bool bOkay = false; + + if (IS_LOCAL(user) && n->second->flags_needed) { - if (n->second->flags_needed) - { - if ((user->HasPermission(commandname)) || (!IS_LOCAL(user))) - { - return n->second->Handle(parameters,pcnt,user); - } - } - else + /* if user is local, and flags are needed .. */ + + if (user->IsModeSet(n->second->flags_needed)) { - return n->second->Handle(parameters,pcnt,user); + /* if user has the flags, and now has the permissions, go ahead */ + if (user->HasPermission(commandname)) + bOkay = true; } } + else + { + /* remote or no flags required anyway */ + bOkay = true; + } + + if (bOkay) + { + return n->second->Handle(parameters,pcnt,user); + } } } return CMD_INVALID; @@ -346,8 +358,7 @@ void CommandParser::ProcessCommand(userrec *user, std::string &cmd) return; /* - * WARNING: nothing should come after this, as the user may be on a cull list to - * be nuked next loop iteration. be sensible. + * WARNING: be careful, the user may be deleted soon */ CmdResult result = cm->second->Handle(command_p,items,user); @@ -414,7 +425,7 @@ void CommandParser::ProcessBuffer(std::string &buffer,userrec *user) { if (!user->muted) { - ServerInstance->Log(DEBUG,"C[%d] -> :%s %s",user->GetFd(), user->nick, buffer.c_str()); + ServerInstance->Log(DEBUG,"C[%d] I :%s %s",user->GetFd(), user->nick, buffer.c_str()); this->ProcessCommand(user,buffer); } } @@ -447,13 +458,13 @@ CommandParser::CommandParser(InspIRCd* Instance) : ServerInstance(Instance) para.resize(128); } -bool CommandParser::FindSym(void** v, void* h) +bool CommandParser::FindSym(void** v, void* h, const std::string &name) { *v = dlsym(h, "init_command"); const char* err = dlerror(); if (err && !(*v)) { - ServerInstance->Log(SPARSE, "Error loading core command: %s\n", err); + ServerInstance->Log(SPARSE, "Error loading core command %s: %s\n", name, err); return false; } return true; @@ -535,11 +546,11 @@ const char* CommandParser::LoadCommand(const char* name) if (!h) { const char* n = dlerror(); - ServerInstance->Log(SPARSE, "Error loading core command: %s", n); + ServerInstance->Log(SPARSE, "Error loading core command %s: %s", name, n); return n; } - if (this->FindSym((void **)&cmd_factory_func, h)) + if (this->FindSym((void **)&cmd_factory_func, h, name)) { command_t* newcommand = cmd_factory_func(ServerInstance); this->CreateCommand(newcommand, h); @@ -597,21 +608,66 @@ void CommandParser::SetupCommandTable(userrec* user) int CommandParser::TranslateUIDs(TranslateType to, const std::string &source, std::string &dest) { userrec* user = NULL; + std::string item; + int translations = 0; + switch (to) { case TR_NICK: /* Translate single nickname */ + ServerInstance->Log(DEBUG,"TR_NICK"); user = ServerInstance->FindNick(source); if (user) + { + ServerInstance->Log(DEBUG,"Managed UUID"); dest = user->uuid; + translations++; + } else + { + ServerInstance->Log(DEBUG,"Had to use source.. (%s)", source.c_str()); dest = source; + } break; case TR_NICKLIST: + { /* Translate comma seperated list of nicknames */ + irc::commasepstream items(source); + while (items.GetToken(item)) + { + user = ServerInstance->FindNick(item); + if (user) + { + dest.append(user->uuid); + translations++; + } + else + dest.append(source); + dest.append(","); + } + if (!dest.empty()) + dest.erase(dest.end() - 1); + } break; case TR_SPACENICKLIST: + { /* Translate space seperated list of nicknames */ + irc::spacesepstream items(source); + while (items.GetToken(item)) + { + user = ServerInstance->FindNick(item); + if (user) + { + dest.append(user->uuid); + translations++; + } + else + dest.append(source); + dest.append(" "); + } + if (!dest.empty()) + dest.erase(dest.end() - 1); + } break; case TR_END: case TR_TEXT: @@ -620,5 +676,7 @@ int CommandParser::TranslateUIDs(TranslateType to, const std::string &source, st dest = source; break; } + + return translations; }