X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fconfigreader.cpp;h=7729cee6958b37f7788f1726e633feb153acaabe;hb=f559b94fa33063e02b67fe589af04fddc20325ef;hp=c854d2ec4cef248114b02f1bb4b77455db9d9453;hpb=91f17cace8a3ef7ae69cb9597df62c84aef8339c;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/configreader.cpp b/src/configreader.cpp index c854d2ec4..7729cee69 100644 --- a/src/configreader.cpp +++ b/src/configreader.cpp @@ -25,7 +25,7 @@ std::vector old_module_names, new_module_names, added_modules, remo ServerConfig::ServerConfig(InspIRCd* Instance) : ServerInstance(Instance) { this->ClearStack(); - *TempDir = *ServerName = *Network = *ServerDesc = *AdminName = '\0'; + *ServerName = *Network = *ServerDesc = *AdminName = '\0'; *HideWhoisServer = *AdminEmail = *AdminNick = *diepass = *restartpass = '\0'; *CustomVersion = *motd = *rules = *PrefixQuit = *DieValue = *DNSServer = '\0'; *UserStats = *ModPath = *MyExecutable = *DisabledCommands = *PID = '\0'; @@ -57,6 +57,12 @@ Module* ServerConfig::GetIOHook(int port) return (x != IOHookModule.end() ? x->second : NULL); } +Module* ServerConfig::GetIOHook(InspSocket* is) +{ + std::map::iterator x = SocketIOHookModule.find(is); + return (x != SocketIOHookModule.end() ? x->second : NULL); +} + bool ServerConfig::AddIOHook(int port, Module* iomod) { if (!GetIOHook(port)) @@ -66,8 +72,22 @@ bool ServerConfig::AddIOHook(int port, Module* iomod) } else { - ModuleException err("Port already hooked by another module"); - throw(err); + throw ModuleException("Port already hooked by another module"); + return false; + } +} + +bool ServerConfig::AddIOHook(Module* iomod, InspSocket* is) +{ + if (!GetIOHook(is)) + { + SocketIOHookModule[is] = iomod; + is->IsIOHooked = true; + return true; + } + else + { + throw ModuleException("InspSocket derived class already hooked by another module"); return false; } } @@ -83,6 +103,17 @@ bool ServerConfig::DelIOHook(int port) return false; } +bool ServerConfig::DelIOHook(InspSocket* is) +{ + std::map::iterator x = SocketIOHookModule.find(is); + if (x != SocketIOHookModule.end()) + { + SocketIOHookModule.erase(x); + return true; + } + return false; +} + bool ServerConfig::CheckOnce(char* tag, bool bail, userrec* user) { int count = ConfValueEnum(this->config_data, tag); @@ -140,13 +171,6 @@ bool NoValidation(ServerConfig* conf, const char* tag, const char* value, ValueI return true; } -bool ValidateTempDir(ServerConfig* conf, const char* tag, const char* value, ValueItem &data) -{ - if (!*(data.GetString())) - data.Set("/tmp"); - return true; -} - bool ValidateMaxTargets(ServerConfig* conf, const char* tag, const char* value, ValueItem &data) { if ((data.GetInteger() < 0) || (data.GetInteger() > 31)) @@ -564,7 +588,6 @@ void ServerConfig::Read(bool bail, userrec* user) {"options", "hidebans", new ValueContainerBool (&this->HideBans), DT_BOOLEAN, NoValidation}, {"options", "hidewhois", new ValueContainerChar (this->HideWhoisServer), DT_CHARPTR, NoValidation}, {"options", "operspywhois", new ValueContainerBool (&this->OperSpyWhois), DT_BOOLEAN, NoValidation}, - {"options", "tempdir", new ValueContainerChar (this->TempDir), DT_CHARPTR, ValidateTempDir}, {"options", "nouserdns", new ValueContainerBool (&this->NoUserDns), DT_BOOLEAN, NoValidation}, {"options", "syntaxhints", new ValueContainerBool (&this->SyntaxHints), DT_BOOLEAN, NoValidation}, {"options", "cyclehosts", new ValueContainerBool (&this->CycleHosts), DT_BOOLEAN, NoValidation}, @@ -572,6 +595,7 @@ void ServerConfig::Read(bool bail, userrec* user) {"whowas", "groupsize", new ValueContainerInt (&this->WhoWasGroupSize), DT_INTEGER, NoValidation}, {"whowas", "maxgroups", new ValueContainerInt (&this->WhoWasMaxGroups), DT_INTEGER, NoValidation}, {"whowas", "maxkeep", new ValueContainerChar (maxkeep), DT_CHARPTR, ValidateWhoWas}, + {"die", "value", new ValueContainerChar (this->DieValue), DT_CHARPTR, NoValidation}, {NULL} }; @@ -1310,7 +1334,7 @@ int ServerConfig::ConfVarEnum(ConfigDataHash &target, const std::string &tag, in */ bool ServerConfig::ReadFile(file_cache &F, const char* fname) { - FILE* file; + FILE* file = NULL; char linebuf[MAXBUF]; F.clear(); @@ -1334,8 +1358,10 @@ bool ServerConfig::ReadFile(file_cache &F, const char* fname) { while (!feof(file)) { - fgets(linebuf, sizeof(linebuf), file); - linebuf[strlen(linebuf)-1] = 0; + if (fgets(linebuf, sizeof(linebuf), file)) + linebuf[strlen(linebuf)-1] = 0; + else + *linebuf = 0; if (!feof(file)) { @@ -1399,12 +1425,14 @@ bool ServerConfig::DirValid(const char* dirandfile) if (getcwd(buffer, MAXBUF ) == NULL ) return false; - chdir(work); + if (chdir(work) == -1) + return false; if (getcwd(otherdir, MAXBUF ) == NULL ) return false; - chdir(buffer); + if (chdir(buffer) == -1) + return false; size_t t = strlen(work); @@ -1451,12 +1479,15 @@ std::string ServerConfig::GetFullProgDir(char** argv, int argc) if (getcwd(buffer, MAXBUF) == NULL) return ""; - chdir(work); + if (chdir(work) == -1) + return ""; if (getcwd(otherdir, MAXBUF) == NULL) return ""; - chdir(buffer); + if (chdir(buffer) == -1) + return ""; + return otherdir; }