diff options
author | Adam <Adam@anope.org> | 2012-03-13 17:45:07 -0400 |
---|---|---|
committer | Adam <Adam@anope.org> | 2012-03-13 17:45:07 -0400 |
commit | a26f4b9a9a4e96ba88214e50dd49783aa1695559 (patch) | |
tree | b713988011e52b42cee6dab33052d39f642acccb | |
parent | 053d6a22470062e8eee08c5522788f432d8146ab (diff) |
Bug #1389 - readd RNG seed in the config and start DNS query ids off on a random number
-rw-r--r-- | data/example.conf | 13 | ||||
-rw-r--r-- | include/config.h | 3 | ||||
-rw-r--r-- | src/config.cpp | 5 | ||||
-rw-r--r-- | src/dns.cpp | 2 | ||||
-rw-r--r-- | src/init.cpp | 2 |
5 files changed, 23 insertions, 2 deletions
diff --git a/data/example.conf b/data/example.conf index 5744265f0..0ed88ae13 100644 --- a/data/example.conf +++ b/data/example.conf @@ -282,6 +282,19 @@ options passlen = 32 /* + * This key is used to initiate the random number generator. This number + * MUST be random as you want your passcodes to be random. Don't give this + * key to anyone! Keep it private! + * + * NOTE: If you don't uncomment this or keep the default values, any talented + * programmer would be able to easily "guess" random strings used to mask + * information. Be safe, and come up with a 7-digit numbers. + * + * This directive is optional, but highly recommended. + */ + #seed = 9866235 + + /* * Allows Services to continue file write operations (i.e. database saving) * even if the original file cannot be backed up. Enabling this option may * allow Services to continue operation under conditions where it might diff --git a/include/config.h b/include/config.h index ef452e8e0..ac8c10fbd 100644 --- a/include/config.h +++ b/include/config.h @@ -661,6 +661,9 @@ class CoreExport ServerConfig /* List of modules to autoload */ std::list<Anope::string> ModulesAutoLoad; + /* Seed to use for RNG */ + unsigned long Seed; + /* Numeric */ Anope::string Numeric; /* Array of ulined servers */ diff --git a/src/config.cpp b/src/config.cpp index f597158ea..790f5c82f 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -158,6 +158,10 @@ ServerConfig::ServerConfig() : config_data(), NSDefFlags(NickCoreFlagStrings), C this->SessionAutoKillExpiry = 1800; /* 30 minutes */ } + /* Check the user keys */ + if (this->Seed == 0) + Log() << "Configuration option options:seed should be set. It's for YOUR safety! Remember that!"; + SetDefaultMLock(this); if (IsFile(this->NameServer)) @@ -1135,6 +1139,7 @@ ConfigItems::ConfigItems(ServerConfig *conf) {"networkinfo", "userlen", "10", new ValueContainerUInt(&conf->UserLen), DT_UINTEGER | DT_NORELOAD, NoValidation}, {"networkinfo", "hostlen", "64", new ValueContainerUInt(&conf->HostLen), DT_UINTEGER | DT_NORELOAD, NoValidation}, {"options", "passlen", "32", new ValueContainerUInt(&conf->PassLen), DT_UINTEGER | DT_NORELOAD, NoValidation}, + {"options", "seed", "0", new ValueContainerLUInt(&conf->Seed), DT_LUINTEGER, NoValidation}, {"options", "nobackupokay", "no", new ValueContainerBool(&conf->NoBackupOkay), DT_BOOLEAN, NoValidation}, {"options", "strictpasswords", "no", new ValueContainerBool(&conf->StrictPasswords), DT_BOOLEAN, NoValidation}, {"options", "badpasslimit", "0", new ValueContainerUInt(&conf->BadPassLimit), DT_UINTEGER, NoValidation}, diff --git a/src/dns.cpp b/src/dns.cpp index d9010b8f9..0a016624b 100644 --- a/src/dns.cpp +++ b/src/dns.cpp @@ -72,7 +72,7 @@ DNSRequest::DNSRequest(const Anope::string &addr, QueryType qt, bool cache, Modu do { - static unsigned short cur_id = 0; + static unsigned short cur_id = rand(); this->id = cur_id++; } while (DNSEngine->requests.count(this->id)); diff --git a/src/init.cpp b/src/init.cpp index 1b31c0682..4fc9c1eef 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -472,7 +472,7 @@ void Init(int ac, char **av) InitLanguages(); /* Initialize random number generator */ - srand(time(NULL)); + srand(Config->Seed); /* load modules */ Log() << "Loading modules..."; |