diff options
author | danieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7> | 2010-03-11 16:21:20 +0000 |
---|---|---|
committer | danieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7> | 2010-03-11 16:21:20 +0000 |
commit | 2ef771819922c8ae04e35744340257c9b740a170 (patch) | |
tree | 15fc9b7557d1b1d33cba5857006b18e2e808abf5 | |
parent | 07a31be32927bf8ab7a9c1084b47ccc28d7f181b (diff) |
Fix empty SID when applying config-specified X:lines
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@12618 e03df62e-2008-0410-955e-edbf42e46eb7
-rw-r--r-- | src/configreader.cpp | 39 |
1 files changed, 26 insertions, 13 deletions
diff --git a/src/configreader.cpp b/src/configreader.cpp index c8603f155..d63377bbe 100644 --- a/src/configreader.cpp +++ b/src/configreader.cpp @@ -429,6 +429,22 @@ void ServerConfig::Fill() { ConfigTag* options = ConfValue("options"); ConfigTag* security = ConfValue("security"); + if (sid.empty()) + { + ServerName = ConfValue("server")->getString("name"); + sid = ConfValue("server")->getString("id"); + ValidHost(ServerName, "<server:name>"); + if (!sid.empty() && !ServerInstance->IsSID(sid)) + 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."); + } + else + { + if (ServerName != ConfValue("server")->getString("name")) + throw CoreException("You must restart to change the server name or SID"); + std::string nsid = ConfValue("server")->getString("id"); + if (!nsid.empty() && nsid != sid) + throw CoreException("You must restart to change the server name or SID"); + } diepass = ConfValue("power")->getString("diepass"); restartpass = ConfValue("power")->getString("restartpass"); powerhash = ConfValue("power")->getString("hash"); @@ -441,10 +457,8 @@ void ServerConfig::Fill() SoftLimit = ConfValue("performance")->getInt("softlimit", ServerInstance->SE->GetMaxFds()); MaxConn = ConfValue("performance")->getInt("somaxconn", SOMAXCONN); MoronBanner = options->getString("moronbanner", "You're banned!"); - ServerName = ConfValue("server")->getString("name"); ServerDesc = ConfValue("server")->getString("description", "Configure Me"); Network = ConfValue("server")->getString("network", "Network"); - sid = ConfValue("server")->getString("id", ""); AdminName = ConfValue("admin")->getString("name", ""); AdminEmail = ConfValue("admin")->getString("email", "null@example.com"); AdminNick = ConfValue("admin")->getString("nick", "admin"); @@ -497,9 +511,6 @@ void ServerConfig::Fill() range(WhoWasMaxKeep, 3600, INT_MAX, 3600, "<whowas:maxkeep>"); ValidIP(DNSServer, "<dns:server>"); - ValidHost(ServerName, "<server:name>"); - if (!sid.empty() && !ServerInstance->IsSID(sid)) - 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."); std::string defbind = options->getString("defaultbind"); if (assign(defbind) == "ipv4") @@ -602,6 +613,15 @@ void ServerConfig::Read() void ServerConfig::Apply(ServerConfig* old, const std::string &useruid) { valid = true; + if (old) + { + /* + * These values can only be set on boot. Keep their old values. Do it before we send messages so we actually have a servername. + */ + this->ServerName = old->ServerName; + this->sid = old->sid; + this->cmdline = old->cmdline; + } /* The stuff in here may throw CoreException, be sure we're in a position to catch it. */ try @@ -632,16 +652,9 @@ void ServerConfig::Apply(ServerConfig* old, const std::string &useruid) // Check errors before dealing with failed binds, since continuing on failed bind is wanted in some circumstances. valid = errstr.str().empty(); - /* - * 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) { - this->ServerName = old->ServerName; - this->sid = old->sid; - this->cmdline = old->cmdline; - - // Same for ports... they're bound later on first run. + // On first run, ports are bound later on FailedPortList pl; ServerInstance->BindPorts(pl); if (pl.size()) |