X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fconfigreader.cpp;h=70c99e8ae4f7257a7a28a6b315b336d91bc43dfb;hb=37fd031da06761c8a050105b55d73a8ab499fb74;hp=3fb60034d0f816f3965228dd4c5dd884167df717;hpb=6d03943426dcce76ba66567a9b18425a5ebb4c0c;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/configreader.cpp b/src/configreader.cpp index 3fb60034d..70c99e8ae 100644 --- a/src/configreader.cpp +++ b/src/configreader.cpp @@ -34,10 +34,6 @@ ServerConfig::ServerConfig() { - *sid = *ServerName = *Network = *ServerDesc = *AdminName = '\0'; - *HideWhoisServer = *AdminEmail = *AdminNick = *diepass = *restartpass = *FixedQuit = *HideKillsServer = '\0'; - *DefaultModes = *CustomVersion = *motd = *rules = *PrefixQuit = *DieValue = *DNSServer = '\0'; - *UserStats = *DisabledCommands = *SuffixQuit = '\0'; WhoWasGroupSize = WhoWasMaxGroups = WhoWasMaxKeep = 0; log_file = NULL; NoUserDns = forcedebug = OperSpyWhois = nofork = HideBans = HideSplits = UndernetMsgPrefix = false; @@ -222,7 +218,7 @@ static bool ValidateMaxConn(ServerConfig* conf, const char*, const char*, ValueI return true; } -bool ServerConfig::ApplyDisabledCommands(const char* data) +bool ServerConfig::ApplyDisabledCommands(const std::string& data) { std::stringstream dcmds(data); std::string thiscmd; @@ -338,8 +334,8 @@ static bool ValidateMaxWho(ServerConfig* conf, const char*, const char*, ValueIt { if ((data.GetInteger() > 65535) || (data.GetInteger() < 1)) { - ServerInstance->Logs->Log("CONFIG",DEFAULT," size out of range, setting to default of 128."); - data.Set(128); + ServerInstance->Logs->Log("CONFIG",DEFAULT," size out of range, setting to default of 1024."); + data.Set(1024); } return true; } @@ -386,14 +382,6 @@ static bool ValidateModeLists(ServerConfig* conf, const char*, const char*, Valu return true; } -static bool ValidateExemptChanOps(ServerConfig* conf, const char*, const char*, ValueItem &data) -{ - memset(conf->ExemptChanOps, 0, sizeof(conf->ExemptChanOps)); - for (const unsigned char* x = (const unsigned char*)data.GetString(); *x; ++x) - conf->ExemptChanOps[*x] = true; - return true; -} - static bool ValidateInvite(ServerConfig* conf, const char*, const char*, ValueItem &data) { const std::string& v = data.GetValue(); @@ -414,14 +402,14 @@ static bool ValidateSID(ServerConfig* conf, const char*, const char*, ValueItem { ServerInstance->Logs->Log("CONFIG",DEFAULT,"Validating server id"); - const char *sid = data.GetString(); + const std::string& sid = data.GetValue(); - if (*sid && !ServerInstance->IsSID(sid)) + if (!sid.empty() && !ServerInstance->IsSID(sid)) { - throw CoreException(std::string(sid) + " is not a valid server ID. A server ID must be 3 characters long, with the first character a digit and the next two characters a digit or letter."); + throw CoreException(sid + " is not a valid server ID. A server ID must be 3 characters long, with the first character a digit and the next two characters a digit or letter."); } - strlcpy(conf->sid, sid, 5); + conf->sid = sid; return true; } @@ -688,7 +676,19 @@ void ServerConfig::CrossCheckConnectBlocks(ServerConfig* current) if (ConfValue("connect", "pingfreq", i, tmpv, false)) me->pingtime = atol(tmpv.c_str()); if (ConfValue("connect", "sendq", i, tmpv, false)) - me->sendqmax = atol(tmpv.c_str()); + { + // attempt to guess a good hard/soft sendq from a single value + long value = atol(tmpv.c_str()); + if (value > 16384) + me->softsendqmax = value / 16; + else + me->softsendqmax = value; + me->hardsendqmax = value * 8; + } + if (ConfValue("connect", "softsendq", i, tmpv, false)) + me->softsendqmax = atol(tmpv.c_str()); + if (ConfValue("connect", "hardsendq", i, tmpv, false)) + me->hardsendqmax = atol(tmpv.c_str()); if (ConfValue("connect", "recvq", i, tmpv, false)) me->recvqmax = atol(tmpv.c_str()); if (ConfValue("connect", "localmax", i, tmpv, false)) @@ -715,11 +715,6 @@ void ServerConfig::CrossCheckConnectBlocks(ServerConfig* current) Classes[i] = me; } } - - for(ClassMap::iterator toRemove = oldBlocksByMask.begin(); toRemove != oldBlocksByMask.end(); toRemove++) - { - removed_classes.push_back(toRemove->second); - } } @@ -749,45 +744,45 @@ static const Deprecated ChangedConfig[] = { static const InitialConfig Values[] = { {"performance", "softlimit", "0", new ValueContainerUInt (&ServerConfig::SoftLimit), DT_INTEGER, ValidateSoftLimit}, {"performance", "somaxconn", SOMAXCONN_S, new ValueContainerInt (&ServerConfig::MaxConn), DT_INTEGER, ValidateMaxConn}, - {"options", "moronbanner", "You're banned!", new ValueContainerChar (&ServerConfig::MoronBanner), DT_CHARPTR, NULL}, - {"server", "name", "", new ValueContainerChar (&ServerConfig::ServerName), DT_HOSTNAME, ValidateServerName}, - {"server", "description", "Configure Me", new ValueContainerChar (&ServerConfig::ServerDesc), DT_CHARPTR, NULL}, - {"server", "network", "Network", new ValueContainerChar (&ServerConfig::Network), DT_NOSPACES, NULL}, - {"server", "id", "", new ValueContainerChar (&ServerConfig::sid), DT_CHARPTR, ValidateSID}, - {"admin", "name", "", new ValueContainerChar (&ServerConfig::AdminName), DT_CHARPTR, NULL}, - {"admin", "email", "Mis@configu.red", new ValueContainerChar (&ServerConfig::AdminEmail), DT_CHARPTR, NULL}, - {"admin", "nick", "Misconfigured", new ValueContainerChar (&ServerConfig::AdminNick), DT_CHARPTR, NULL}, - {"files", "motd", "", new ValueContainerChar (&ServerConfig::motd), DT_CHARPTR, ValidateMotd}, - {"files", "rules", "", new ValueContainerChar (&ServerConfig::rules), DT_CHARPTR, ValidateRules}, - {"power", "diepass", "", new ValueContainerChar (&ServerConfig::diepass), DT_CHARPTR, ValidateNotEmpty}, + {"options", "moronbanner", "You're banned!", new ValueContainerString (&ServerConfig::MoronBanner), DT_CHARPTR, NULL}, + {"server", "name", "", new ValueContainerString (&ServerConfig::ServerName), DT_HOSTNAME, ValidateServerName}, + {"server", "description", "Configure Me", new ValueContainerString (&ServerConfig::ServerDesc), DT_CHARPTR, NULL}, + {"server", "network", "Network", new ValueContainerString (&ServerConfig::Network), DT_NOSPACES, NULL}, + {"server", "id", "", new ValueContainerString (&ServerConfig::sid), DT_CHARPTR, ValidateSID}, + {"admin", "name", "", new ValueContainerString (&ServerConfig::AdminName), DT_CHARPTR, NULL}, + {"admin", "email", "Mis@configu.red", new ValueContainerString (&ServerConfig::AdminEmail), DT_CHARPTR, NULL}, + {"admin", "nick", "Misconfigured", new ValueContainerString (&ServerConfig::AdminNick), DT_CHARPTR, NULL}, + {"files", "motd", "", new ValueContainerString (&ServerConfig::motd), DT_CHARPTR, ValidateMotd}, + {"files", "rules", "", new ValueContainerString (&ServerConfig::rules), DT_CHARPTR, ValidateRules}, + {"power", "diepass", "", new ValueContainerString (&ServerConfig::diepass), DT_CHARPTR, ValidateNotEmpty}, {"power", "pause", "", new ValueContainerInt (&ServerConfig::DieDelay), DT_INTEGER, NULL}, - {"power", "hash", "", new ValueContainerChar (&ServerConfig::powerhash), DT_CHARPTR, NULL}, - {"power", "restartpass", "", new ValueContainerChar (&ServerConfig::restartpass), DT_CHARPTR, ValidateNotEmpty}, - {"options", "prefixquit", "", new ValueContainerChar (&ServerConfig::PrefixQuit), DT_CHARPTR, NULL}, - {"options", "suffixquit", "", new ValueContainerChar (&ServerConfig::SuffixQuit), DT_CHARPTR, NULL}, - {"options", "fixedquit", "", new ValueContainerChar (&ServerConfig::FixedQuit), DT_CHARPTR, NULL}, - {"options", "prefixpart", "", new ValueContainerChar (&ServerConfig::PrefixPart), DT_CHARPTR, NULL}, - {"options", "suffixpart", "", new ValueContainerChar (&ServerConfig::SuffixPart), DT_CHARPTR, NULL}, - {"options", "fixedpart", "", new ValueContainerChar (&ServerConfig::FixedPart), DT_CHARPTR, NULL}, + {"power", "hash", "", new ValueContainerString (&ServerConfig::powerhash), DT_CHARPTR, NULL}, + {"power", "restartpass", "", new ValueContainerString (&ServerConfig::restartpass), DT_CHARPTR, ValidateNotEmpty}, + {"options", "prefixquit", "", new ValueContainerString (&ServerConfig::PrefixQuit), DT_CHARPTR, NULL}, + {"options", "suffixquit", "", new ValueContainerString (&ServerConfig::SuffixQuit), DT_CHARPTR, NULL}, + {"options", "fixedquit", "", new ValueContainerString (&ServerConfig::FixedQuit), DT_CHARPTR, NULL}, + {"options", "prefixpart", "", new ValueContainerString (&ServerConfig::PrefixPart), DT_CHARPTR, NULL}, + {"options", "suffixpart", "", new ValueContainerString (&ServerConfig::SuffixPart), DT_CHARPTR, NULL}, + {"options", "fixedpart", "", new ValueContainerString (&ServerConfig::FixedPart), DT_CHARPTR, NULL}, {"performance", "netbuffersize","10240", new ValueContainerInt (&ServerConfig::NetBufferSize), DT_INTEGER, ValidateNetBufferSize}, - {"performance", "maxwho", "128", new ValueContainerInt (&ServerConfig::MaxWhoResults), DT_INTEGER, ValidateMaxWho}, + {"performance", "maxwho", "1024", new ValueContainerInt (&ServerConfig::MaxWhoResults), DT_INTEGER, ValidateMaxWho}, {"options", "allowhalfop", "0", new ValueContainerBool (&ServerConfig::AllowHalfop), DT_BOOLEAN, ValidateHalfOp}, - {"dns", "server", "", new ValueContainerChar (&ServerConfig::DNSServer), DT_IPADDRESS,ValidateDnsServer}, + {"dns", "server", "", new ValueContainerString (&ServerConfig::DNSServer), DT_IPADDRESS,ValidateDnsServer}, {"dns", "timeout", "5", new ValueContainerInt (&ServerConfig::dns_timeout), DT_INTEGER, NULL}, {"options", "moduledir", MOD_PATH, new ValueContainerString (&ServerConfig::ModPath), DT_CHARPTR, NULL}, - {"disabled", "commands", "", new ValueContainerChar (&ServerConfig::DisabledCommands), DT_CHARPTR, NULL}, + {"disabled", "commands", "", new ValueContainerString (&ServerConfig::DisabledCommands), DT_CHARPTR, NULL}, {"disabled", "usermodes", "", NULL, DT_NOTHING, ValidateDisabledUModes}, {"disabled", "chanmodes", "", NULL, DT_NOTHING, ValidateDisabledCModes}, {"disabled", "fakenonexistant", "0", new ValueContainerBool (&ServerConfig::DisabledDontExist), DT_BOOLEAN, NULL}, - {"security", "runasuser", "", new ValueContainerChar(&ServerConfig::SetUser), DT_CHARPTR, NULL}, - {"security", "runasgroup", "", new ValueContainerChar(&ServerConfig::SetGroup), DT_CHARPTR, NULL}, - {"security", "userstats", "", new ValueContainerChar (&ServerConfig::UserStats), DT_CHARPTR, NULL}, - {"security", "customversion","", new ValueContainerChar (&ServerConfig::CustomVersion), DT_CHARPTR, NULL}, + {"security", "runasuser", "", new ValueContainerString(&ServerConfig::SetUser), DT_CHARPTR, NULL}, + {"security", "runasgroup", "", new ValueContainerString(&ServerConfig::SetGroup), DT_CHARPTR, NULL}, + {"security", "userstats", "", new ValueContainerString (&ServerConfig::UserStats), DT_CHARPTR, NULL}, + {"security", "customversion","", new ValueContainerString (&ServerConfig::CustomVersion), DT_CHARPTR, NULL}, {"security", "hidesplits", "0", new ValueContainerBool (&ServerConfig::HideSplits), DT_BOOLEAN, NULL}, {"security", "hidebans", "0", new ValueContainerBool (&ServerConfig::HideBans), DT_BOOLEAN, NULL}, - {"security", "hidewhois", "", new ValueContainerChar (&ServerConfig::HideWhoisServer), DT_NOSPACES, NULL}, - {"security", "hidekills", "", new ValueContainerChar (&ServerConfig::HideKillsServer), DT_NOSPACES, NULL}, + {"security", "hidewhois", "", new ValueContainerString (&ServerConfig::HideWhoisServer), DT_NOSPACES, NULL}, + {"security", "hidekills", "", new ValueContainerString (&ServerConfig::HideKillsServer), DT_NOSPACES, NULL}, {"security", "operspywhois", "0", new ValueContainerBool (&ServerConfig::OperSpyWhois), DT_BOOLEAN, NULL}, {"security", "restrictbannedusers", "1", new ValueContainerBool (&ServerConfig::RestrictBannedUsers), DT_BOOLEAN, NULL}, {"security", "genericoper", "0", new ValueContainerBool (&ServerConfig::GenericOper), DT_BOOLEAN, NULL}, @@ -798,14 +793,13 @@ static const InitialConfig Values[] = { {"security", "announceinvites", "1", NULL, DT_NOTHING, ValidateInvite}, {"options", "hostintopic", "1", new ValueContainerBool (&ServerConfig::FullHostInTopic), DT_BOOLEAN, NULL}, {"security", "hidemodes", "", NULL, DT_NOTHING, ValidateModeLists}, - {"options", "exemptchanops","", NULL, DT_NOTHING, ValidateExemptChanOps}, {"security", "maxtargets", "20", new ValueContainerUInt (&ServerConfig::MaxTargets), DT_INTEGER, ValidateMaxTargets}, - {"options", "defaultmodes", "nt", new ValueContainerChar (&ServerConfig::DefaultModes), DT_CHARPTR, NULL}, + {"options", "defaultmodes", "nt", new ValueContainerString (&ServerConfig::DefaultModes), DT_CHARPTR, NULL}, {"pid", "file", "", new ValueContainerString (&ServerConfig::PID), DT_CHARPTR, NULL}, {"whowas", "groupsize", "10", new ValueContainerInt (&ServerConfig::WhoWasGroupSize), DT_INTEGER, NULL}, {"whowas", "maxgroups", "10240", new ValueContainerInt (&ServerConfig::WhoWasMaxGroups), DT_INTEGER, NULL}, {"whowas", "maxkeep", "3600", NULL, DT_NOTHING, ValidateWhoWas}, - {"die", "value", "", new ValueContainerChar (&ServerConfig::DieValue), DT_CHARPTR, NULL}, + {"die", "value", "", new ValueContainerString (&ServerConfig::DieValue), DT_CHARPTR, NULL}, {"channels", "users", "20", new ValueContainerUInt (&ServerConfig::MaxChans), DT_INTEGER, NULL}, {"channels", "opers", "60", new ValueContainerUInt (&ServerConfig::OperMaxChans), DT_INTEGER, NULL}, {"cidr", "ipv4clone", "32", new ValueContainerInt (&ServerConfig::c_ipv4_range), DT_INTEGER, NULL}, @@ -957,40 +951,37 @@ void ServerConfig::Apply(ServerConfig* old, const std::string &useruid) { case DT_NOSPACES: { - ValueContainerChar* vcc = (ValueContainerChar*)Values[Index].val; + ValueContainerString* vcc = (ValueContainerString*)Values[Index].val; ValidateNoSpaces(vi.GetString(), Values[Index].tag, Values[Index].value); - vcc->Set(this, vi); + vcc->Set(this, vi.GetValue()); } break; case DT_HOSTNAME: { - ValueContainerChar* vcc = (ValueContainerChar*)Values[Index].val; + ValueContainerString* vcc = (ValueContainerString*)Values[Index].val; ValidateHostname(vi.GetString(), Values[Index].tag, Values[Index].value); - vcc->Set(this, vi); + vcc->Set(this, vi.GetValue()); } break; case DT_IPADDRESS: { - ValueContainerChar* vcc = (ValueContainerChar*)Values[Index].val; + ValueContainerString* vcc = (ValueContainerString*)Values[Index].val; ValidateIP(vi.GetString(), Values[Index].tag, Values[Index].value, allow_wild); - vcc->Set(this, vi); + vcc->Set(this, vi.GetValue()); } break; case DT_CHANNEL: { - ValueContainerChar* vcc = (ValueContainerChar*)Values[Index].val; + ValueContainerString* vcc = (ValueContainerString*)Values[Index].val; if (*(vi.GetString()) && !ServerInstance->IsChannel(vi.GetString(), MAXBUF)) { throw CoreException("The value of <"+std::string(Values[Index].tag)+":"+Values[Index].value+"> is not a valid channel name"); } - vcc->Set(this, vi); + vcc->Set(this, vi.GetValue()); } break; case DT_CHARPTR: { - ValueContainerChar* vcc = dynamic_cast(Values[Index].val); - if (vcc) - vcc->Set(this, vi); ValueContainerString* vcs = dynamic_cast(Values[Index].val); if (vcs) vcs->Set(this, vi.GetValue()); @@ -1131,28 +1122,30 @@ void ServerConfig::Apply(ServerConfig* old, const std::string &useruid) // write once here, to try it out and make sure its ok ServerInstance->WritePID(this->PID); - FailedPortList pl; - ServerInstance->BindPorts(pl); - /* * These values can only be set on boot. Keep their old values. Do it before we send messages so we actually have a servername. */ if (old) { - memcpy(this->ServerName, old->ServerName, sizeof(this->ServerName)); - memcpy(this->sid, old->sid, sizeof(this->sid)); - } - - if (pl.size()) - { - errstr << "Not all your client ports could be bound.\nThe following port(s) failed to bind:\n"; - - int j = 1; - for (FailedPortList::iterator i = pl.begin(); i != pl.end(); i++, j++) + this->ServerName = old->ServerName; + this->sid = old->sid; + this->argv = old->argv; + this->argc = old->argc; + + // Same for ports... they're bound later on first run. + FailedPortList pl; + ServerInstance->BindPorts(pl); + if (pl.size()) { - char buf[MAXBUF]; - snprintf(buf, MAXBUF, "%d. Address: %s Reason: %s\n", j, i->first.empty() ? "" : i->first.c_str(), i->second.c_str()); - errstr << buf; + errstr << "Not all your client ports could be bound.\nThe following port(s) failed to bind:\n"; + + int j = 1; + for (FailedPortList::iterator i = pl.begin(); i != pl.end(); i++, j++) + { + char buf[MAXBUF]; + snprintf(buf, MAXBUF, "%d. Address: %s Reason: %s\n", j, i->first.empty() ? "" : i->first.c_str(), i->second.c_str()); + errstr << buf; + } } } @@ -1200,12 +1193,6 @@ void ServerConfig::Apply(ServerConfig* old, const std::string &useruid) return; ApplyModules(user); - for (std::vector::iterator i = removed_classes.begin(); i != removed_classes.end(); i++) - { - ConnectClass* c = *i; - if (0 == --c->RefCount) - delete c; - } } void ServerConfig::ApplyModules(User* user) @@ -1234,19 +1221,19 @@ void ServerConfig::ApplyModules(User* user) continue; if (ServerInstance->Modules->Unload(removing->c_str())) { - ServerInstance->SNO->WriteToSnoMask('a', "*** REHASH UNLOADED MODULE: %s",removing->c_str()); + ServerInstance->SNO->WriteGlobalSno('a', "*** REHASH UNLOADED MODULE: %s",removing->c_str()); if (user) user->WriteNumeric(RPL_UNLOADEDMODULE, "%s %s :Module %s successfully unloaded.",user->nick.c_str(), removing->c_str(), removing->c_str()); else - ServerInstance->SNO->WriteToSnoMask('a', "Module %s successfully unloaded.", removing->c_str()); + ServerInstance->SNO->WriteGlobalSno('a', "Module %s successfully unloaded.", removing->c_str()); } else { if (user) user->WriteNumeric(ERR_CANTUNLOADMODULE, "%s %s :Failed to unload module %s: %s",user->nick.c_str(), removing->c_str(), removing->c_str(), ServerInstance->Modules->LastError().c_str()); else - ServerInstance->SNO->WriteToSnoMask('a', "Failed to unload module %s: %s", removing->c_str(), ServerInstance->Modules->LastError().c_str()); + ServerInstance->SNO->WriteGlobalSno('a', "Failed to unload module %s: %s", removing->c_str(), ServerInstance->Modules->LastError().c_str()); } } @@ -1254,25 +1241,25 @@ void ServerConfig::ApplyModules(User* user) { if (ServerInstance->Modules->Load(adding->c_str())) { - ServerInstance->SNO->WriteToSnoMask('a', "*** REHASH LOADED MODULE: %s",adding->c_str()); + ServerInstance->SNO->WriteGlobalSno('a', "*** REHASH LOADED MODULE: %s",adding->c_str()); if (user) user->WriteNumeric(RPL_LOADEDMODULE, "%s %s :Module %s successfully loaded.",user->nick.c_str(), adding->c_str(), adding->c_str()); else - ServerInstance->SNO->WriteToSnoMask('a', "Module %s successfully loaded.", adding->c_str()); + ServerInstance->SNO->WriteGlobalSno('a', "Module %s successfully loaded.", adding->c_str()); } else { if (user) user->WriteNumeric(ERR_CANTLOADMODULE, "%s %s :Failed to load module %s: %s",user->nick.c_str(), adding->c_str(), adding->c_str(), ServerInstance->Modules->LastError().c_str()); else - ServerInstance->SNO->WriteToSnoMask('a', "Failed to load module %s: %s", adding->c_str(), ServerInstance->Modules->LastError().c_str()); + ServerInstance->SNO->WriteGlobalSno('a', "Failed to load module %s: %s", adding->c_str(), ServerInstance->Modules->LastError().c_str()); } } if (user) user->WriteServ("NOTICE %s :*** Successfully rehashed server.", user->nick.c_str()); else - ServerInstance->SNO->WriteToSnoMask('a', "*** Successfully rehashed server."); + ServerInstance->SNO->WriteGlobalSno('a', "*** Successfully rehashed server."); } bool ServerConfig::LoadConf(FILE* &conf, const char* filename, bool allowexeinc) @@ -1674,36 +1661,12 @@ bool ServerConfig::StartsWithWindowsDriveLetter(const std::string &path) bool ServerConfig::DoInclude(const std::string &file, bool allowexeinc) { - std::string confpath; - std::string newfile; - std::string::size_type pos; - - confpath = ServerInstance->ConfigFileName; - newfile = file; - - std::replace(newfile.begin(),newfile.end(),'\\','/'); - std::replace(confpath.begin(),confpath.end(),'\\','/'); - - if ((newfile[0] != '/') && (!StartsWithWindowsDriveLetter(newfile))) - { - if((pos = confpath.rfind("/")) != std::string::npos) - { - /* Leaves us with just the path */ - newfile = confpath.substr(0, pos) + std::string("/") + newfile; - } - else - { - errstr << "Couldn't get config path from: " << ServerInstance->ConfigFileName << std::endl; - return false; - } - } - - FILE* conf = fopen(newfile.c_str(), "r"); + FILE* conf = fopen(file.c_str(), "r"); bool ret = false; if (conf) { - ret = LoadConf(conf, newfile, allowexeinc); + ret = LoadConf(conf, file, allowexeinc); fclose(conf); } else @@ -1906,29 +1869,9 @@ bool ServerConfig::ReadFile(file_cache &F, const char* fname) F.clear(); - if ((*fname != '/') && (*fname != '\\') && (!StartsWithWindowsDriveLetter(fname))) - { - std::string::size_type pos; - std::string confpath = ServerInstance->ConfigFileName; - std::string newfile = fname; - - if (((pos = confpath.rfind("/"))) != std::string::npos) - newfile = confpath.substr(0, pos) + std::string("/") + fname; - else if (((pos = confpath.rfind("\\"))) != std::string::npos) - newfile = confpath.substr(0, pos) + std::string("\\") + fname; - - ServerInstance->Logs->Log("config", DEBUG, "Filename: %s", newfile.c_str()); - - if (!FileExists(newfile.c_str())) - return false; - file = fopen(newfile.c_str(), "r"); - } - else - { - if (!FileExists(fname)) - return false; - file = fopen(fname, "r"); - } + if (!FileExists(fname)) + return false; + file = fopen(fname, "r"); if (file) { @@ -1959,8 +1902,8 @@ bool ServerConfig::FileExists(const char* file) if ((sb.st_mode & S_IFDIR) > 0) return false; - FILE *input; - if ((input = fopen (file, "r")) == NULL) + FILE *input = fopen(file, "r"); + if (input == NULL) return false; else { @@ -1977,41 +1920,6 @@ const char* ServerConfig::CleanFilename(const char* name) } -std::string ServerConfig::GetFullProgDir() -{ - char buffer[PATH_MAX]; -#ifdef WINDOWS - /* Windows has specific api calls to get the exe path that never fail. - * For once, windows has something of use, compared to the POSIX code - * for this, this is positively neato. - */ - if (GetModuleFileName(NULL, buffer, MAX_PATH)) - { - std::string fullpath = buffer; - std::string::size_type n = fullpath.rfind("\\inspircd.exe"); - return std::string(fullpath, 0, n); - } -#else - // Get the current working directory - if (getcwd(buffer, PATH_MAX)) - { - std::string remainder = this->argv[0]; - - /* Does argv[0] start with /? its a full path, use it */ - if (remainder[0] == '/') - { - std::string::size_type n = remainder.rfind("/inspircd"); - return std::string(remainder, 0, n); - } - - std::string fullpath = std::string(buffer) + "/" + remainder; - std::string::size_type n = fullpath.rfind("/inspircd"); - return std::string(fullpath, 0, n); - } -#endif - return "/"; -} - std::string ServerConfig::GetSID() { return sid; @@ -2106,9 +2014,3 @@ void ConfigReaderThread::Finish() delete this->Config; } } - -template<> -void ValueContainer::Set(ServerConfig* conf, ValueItem const& item) -{ - strlcpy(conf->*vptr, item.GetString(), MAXBUF); -}