diff options
| author | 2009-12-04 00:38:36 +0000 | |
|---|---|---|
| committer | 2009-12-04 00:38:36 +0000 | |
| commit | eb2a2aac53ad20f15dc8c0e88e2cefa200325df2 (patch) | |
| tree | 47fc36997f292a1ece4adc3f3eb5f6ce05a17768 /src/configreader.cpp | |
| parent | backport r12164, fixes bug #921 reported by Sm0ke0ut (diff) | |
Correct fix by Namegduf for bug #922, as my earlier fix just made it worse
git-svn-id: http://svn.inspircd.org/repository/branches/1_2_stable@12232 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/configreader.cpp')
| -rw-r--r-- | src/configreader.cpp | 47 |
1 files changed, 33 insertions, 14 deletions
diff --git a/src/configreader.cpp b/src/configreader.cpp index 94699ce10..a1c0ed857 100644 --- a/src/configreader.cpp +++ b/src/configreader.cpp @@ -310,16 +310,27 @@ static bool ValidateDnsServer(ServerConfig* conf, const char*, const char*, Valu static bool ValidateServerName(ServerConfig* conf, const char*, const char*, ValueItem &data) { - conf->GetInstance()->Logs->Log("CONFIG",DEFAULT,"Validating server name"); - /* If we already have a servername, and they changed it, we should throw an exception. */ - if (!strchr(data.GetString(), '.')) + if (!*conf->ServerName) { - conf->GetInstance()->Logs->Log("CONFIG",DEFAULT,"WARNING: <server:name> '%s' is not a fully-qualified domain name. Changed to '%s.'", - data.GetString(),data.GetString()); - std::string moo = data.GetValue(); - data.Set(moo.append(".")); + conf->GetInstance()->Logs->Log("CONFIG",DEFAULT,"Validating server name"); + + /* If we already have a servername, and they changed it, we should throw an + * exception. */ + if (!strchr(data.GetString(), '.')) + { + conf->GetInstance()->Logs->Log("CONFIG",DEFAULT,"WARNING: <server:name> '%s' is not a fully-qualified domain name. Changed to '%s.'", + data.GetString(),data.GetString()); + std::string moo = data.GetValue(); + data.Set(moo.append(".")); + } + ValidateHostname(data.GetString(), "server", "name"); } - ValidateHostname(data.GetString(), "server", "name"); + else + { + conf->GetInstance()->Logs->Log("CONFIG",DEFAULT,"Ignoring server name; we already have one set."); + data.Set(conf->ServerName); + } + return true; } @@ -412,17 +423,25 @@ static bool ValidateInvite(ServerConfig* conf, const char*, const char*, ValueIt static bool ValidateSID(ServerConfig* conf, const char*, const char*, ValueItem &data) { - conf->GetInstance()->Logs->Log("CONFIG",DEFAULT,"Validating server id"); + if (!*conf->sid) + { + conf->GetInstance()->Logs->Log("CONFIG",DEFAULT,"Validating server id"); + + const char *sid = data.GetString(); - const char *sid = data.GetString(); + if (*sid && !conf->GetInstance()->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."); + } - if (*sid && !conf->GetInstance()->IsSID(sid)) + strlcpy(conf->sid, sid, 5); + } + else { - 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."); + conf->GetInstance()->Logs->Log("CONFIG",DEFAULT,"Ignoring server id; we already have one set."); + data.Set(conf->sid); } - strlcpy(conf->sid, sid, 5); - return true; } |
