diff options
-rw-r--r-- | src/configreader.cpp | 71 | ||||
-rw-r--r-- | src/users.cpp | 104 |
2 files changed, 100 insertions, 75 deletions
diff --git a/src/configreader.cpp b/src/configreader.cpp index 776793405..98092f57e 100644 --- a/src/configreader.cpp +++ b/src/configreader.cpp @@ -1777,3 +1777,74 @@ bool ValueItem::GetBool() { return (GetInteger() || v == "yes" || v == "true"); } + + + + +/* + * XXX should this be in a class? -- w00t + */ +bool InitTypes(ServerConfig* conf, const char* tag) +{ + if (conf->opertypes.size()) + { + for (opertype_t::iterator n = conf->opertypes.begin(); n != conf->opertypes.end(); n++) + { + if (n->second) + delete[] n->second; + } + } + + conf->opertypes.clear(); + return true; +} + +/* + * XXX should this be in a class? -- w00t + */ +bool InitClasses(ServerConfig* conf, const char* tag) +{ + if (conf->operclass.size()) + { + for (operclass_t::iterator n = conf->operclass.begin(); n != conf->operclass.end(); n++) + { + if (n->second) + delete[] n->second; + } + } + + conf->operclass.clear(); + return true; +} + +/* + * XXX should this be in a class? -- w00t + */ +bool DoType(ServerConfig* conf, const char* tag, char** entries, ValueList &values, int* types) +{ + const char* TypeName = values[0].GetString(); + const char* Classes = values[1].GetString(); + + conf->opertypes[TypeName] = strnewdup(Classes); + return true; +} + +/* + * XXX should this be in a class? -- w00t + */ +bool DoClass(ServerConfig* conf, const char* tag, char** entries, ValueList &values, int* types) +{ + const char* ClassName = values[0].GetString(); + const char* CommandList = values[1].GetString(); + + conf->operclass[ClassName] = strnewdup(CommandList); + return true; +} + +/* + * XXX should this be in a class? -- w00t + */ +bool DoneClassesAndTypes(ServerConfig* conf, const char* tag) +{ + return true; +} diff --git a/src/users.cpp b/src/users.cpp index a518b7ff3..04424dd9b 100644 --- a/src/users.cpp +++ b/src/users.cpp @@ -23,59 +23,6 @@ static unsigned long already_sent[MAX_DESCRIPTORS] = {0}; /* XXX: Used for speeding up WriteCommon operations */ unsigned long uniq_id = 0; -bool InitTypes(ServerConfig* conf, const char* tag) -{ - if (conf->opertypes.size()) - { - for (opertype_t::iterator n = conf->opertypes.begin(); n != conf->opertypes.end(); n++) - { - if (n->second) - delete[] n->second; - } - } - - conf->opertypes.clear(); - return true; -} - -bool InitClasses(ServerConfig* conf, const char* tag) -{ - if (conf->operclass.size()) - { - for (operclass_t::iterator n = conf->operclass.begin(); n != conf->operclass.end(); n++) - { - if (n->second) - delete[] n->second; - } - } - - conf->operclass.clear(); - return true; -} - -bool DoType(ServerConfig* conf, const char* tag, char** entries, ValueList &values, int* types) -{ - const char* TypeName = values[0].GetString(); - const char* Classes = values[1].GetString(); - - conf->opertypes[TypeName] = strnewdup(Classes); - return true; -} - -bool DoClass(ServerConfig* conf, const char* tag, char** entries, ValueList &values, int* types) -{ - const char* ClassName = values[0].GetString(); - const char* CommandList = values[1].GetString(); - - conf->operclass[ClassName] = strnewdup(CommandList); - return true; -} - -bool DoneClassesAndTypes(ServerConfig* conf, const char* tag) -{ - return true; -} - std::string User::ProcessNoticeMasks(const char *sm) { bool adding = true, oldadding = false; @@ -475,37 +422,44 @@ bool User::HasPermission(const std::string &command) return true; // are they even an oper at all? - if (IS_OPER(this)) + if (!IS_OPER(this)) + { + return false; + } + + // check their opertype exists (!). This won't affect local users, of course. + opertype_t::iterator iter_opertype = ServerInstance->Config->opertypes.find(this->oper); + if (iter_opertype == ServerInstance->Config->opertypes.end()) + { + return false; + } + + /* XXX all this strtok/strdup stuff is a bit ick and horrid -- w00t */ + char* Classes = strdup(iter_opertype->second); + char* myclass = strtok_r(Classes," ",&savept); + while (myclass) { - opertype_t::iterator iter_opertype = ServerInstance->Config->opertypes.find(this->oper); - if (iter_opertype != ServerInstance->Config->opertypes.end()) + operclass_t::iterator iter_operclass = ServerInstance->Config->operclass.find(myclass); + if (iter_operclass != ServerInstance->Config->operclass.end()) { - char* Classes = strdup(iter_opertype->second); - char* myclass = strtok_r(Classes," ",&savept); - while (myclass) + char* CommandList = strdup(iter_operclass->second); + mycmd = strtok_r(CommandList," ",&savept2); + while (mycmd) { - operclass_t::iterator iter_operclass = ServerInstance->Config->operclass.find(myclass); - if (iter_operclass != ServerInstance->Config->operclass.end()) + if ((!strcasecmp(mycmd,command.c_str())) || (*mycmd == '*')) { - char* CommandList = strdup(iter_operclass->second); - mycmd = strtok_r(CommandList," ",&savept2); - while (mycmd) - { - if ((!strcasecmp(mycmd,command.c_str())) || (*mycmd == '*')) - { - free(Classes); - free(CommandList); - return true; - } - mycmd = strtok_r(NULL," ",&savept2); - } + free(Classes); free(CommandList); + return true; } - myclass = strtok_r(NULL," ",&savept); + mycmd = strtok_r(NULL," ",&savept2); } - free(Classes); + free(CommandList); } + myclass = strtok_r(NULL," ",&savept); } + free(Classes); + return false; } |