summaryrefslogtreecommitdiff
path: root/src/inspircd.cpp
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2007-08-27 22:32:40 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2007-08-27 22:32:40 +0000
commit1211f840f16bacb21425eedba6794dfc8b39da40 (patch)
tree7b85b3ad18d152747c9c1de8425036e5cf6a3818 /src/inspircd.cpp
parentf8e460b127b3d8f57e42276016dc94dd5d4ecf82 (diff)
Fix potential for duplicate SID if the SID is auto generated.
Auto generated SIDs are initialized too late after modules are loaded rather than before. Fixed. git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@7924 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/inspircd.cpp')
-rw-r--r--src/inspircd.cpp68
1 files changed, 33 insertions, 35 deletions
diff --git a/src/inspircd.cpp b/src/inspircd.cpp
index 1618266c0..bc968e87e 100644
--- a/src/inspircd.cpp
+++ b/src/inspircd.cpp
@@ -6,7 +6,7 @@
* See: http://www.inspircd.org/wiki/index.php/Credits
*
* This program is free but copyrighted software; see
- * the file COPYING for details.
+ * the file COPYING for details.
*
* ---------------------------------------------------
*/
@@ -309,7 +309,7 @@ InspIRCd::InspIRCd(int argc, char** argv)
memset(&server, 0, sizeof(server));
memset(&client, 0, sizeof(client));
- SocketEngineFactory* SEF = new SocketEngineFactory();
+ SocketEngineFactory* SEF = new SocketEngineFactory();
SE = SEF->Create(this);
delete SEF;
@@ -432,6 +432,37 @@ InspIRCd::InspIRCd(int argc, char** argv)
Config->ClearStack();
Config->Read(true, NULL);
+ /*
+ * Initialise UID. XXX, we need to read SID from config, and use it instead of 000.
+ * For an explanation as to exactly how this works, and why it works this way, see GetUID().
+ * -- w00t
+ */
+ int i;
+
+ /* Generate SID */
+ size_t sid = 0;
+ if (Config->sid)
+ {
+ sid = Config->sid;
+ }
+ else
+ {
+ for (const char* x = Config->ServerName; *x; ++x)
+ sid = 5 * sid + *x;
+ for (const char* y = Config->ServerDesc; *y; ++y)
+ sid = 5 * sid + *y;
+ sid = sid % 999;
+
+ Config->sid = sid;
+ }
+ current_uid[0] = sid / 100 + 48;
+ current_uid[1] = ((sid / 10) % 10) + 48;
+ current_uid[2] = sid % 10 + 48;
+
+ /* Initialise UID */
+ for(i = 3; i < UUID_LENGTH - 1; i++)
+ current_uid[i] = 'A';
+
if (!do_root)
this->CheckRoot();
else
@@ -533,39 +564,6 @@ InspIRCd::InspIRCd(int argc, char** argv)
}
#endif
-
- /*
- * Initialise UID. XXX, we need to read SID from config, and use it instead of 000.
- * For an explanation as to exactly how this works, and why it works this way, see GetUID().
- * -- w00t
- */
- int i;
-
-
- /* Generate SID */
- size_t sid = 0;
- if (Config->sid)
- {
- sid = Config->sid;
- }
- else
- {
- for (const char* x = Config->ServerName; *x; ++x)
- sid = 5 * sid + *x;
- for (const char* y = Config->ServerDesc; *y; ++y)
- sid = 5 * sid + *y;
- sid = sid % 999;
-
- Config->sid = sid;
- }
- current_uid[0] = sid / 100 + 48;
- current_uid[1] = ((sid / 10) % 10) + 48;
- current_uid[2] = sid % 10 + 48;
-
- /* Initialise UID */
- for(i = 3; i < UUID_LENGTH - 1; i++)
- current_uid[i] = 'A';
-
printf("\nInspIRCd is now running!\n");
Log(DEFAULT,"Startup complete.");