* Final bit of patching for the IPGM exploit. Random number generator is
authorArt Cancro <ajc@citadel.org>
Tue, 15 Jul 2003 04:09:20 +0000 (04:09 +0000)
committerArt Cancro <ajc@citadel.org>
Tue, 15 Jul 2003 04:09:20 +0000 (04:09 +0000)
  now seeded from /dev/urandom if available, otherwise it is seeded from
  tv.tv_usec.  (The latter seed was actually getting done elsewhere already.)
* EBIO command now limits input to config.c_maxmsglen bytes.

citadel/citserver.c
citadel/docs/citadel.html
citadel/serv_bio.c
citadel/server_main.c

index b07a0d637404c65ace2b454d55ae924acc99166e..b2c3641982f407d49d746dbbf6127ba9a9e9c06e 100644 (file)
@@ -74,6 +74,8 @@ time_t server_startup_time;
  */
 void master_startup(void) {
        struct timeval tv;
+       unsigned int seed;
+       FILE *urandom;
        struct ctdlroom qrbuf;
        
        lprintf(9, "master_startup() started\n");
@@ -100,15 +102,27 @@ void master_startup(void) {
                 lputroom(&qrbuf);
         }
 
-
        lprintf(7, "Seeding the pseudo-random number generator...\n");
-       gettimeofday(&tv, NULL);
-       srand(tv.tv_usec);
+       urandom = fopen("/dev/urandom", "r");
+       if (urandom != NULL) {
+               fread(&seed, sizeof seed, 1, urandom);
+               fclose(urandom);
+       }
+       else {
+               gettimeofday(&tv, NULL);
+               seed = tv.tv_usec;
+       }
+       srandom(seed);
+
+       lprintf(7, "Initializing ipgm secret\n");
+       get_config();
+       config.c_ipgm_secret = rand();
+       put_config();
+
        lprintf(9, "master_startup() finished\n");
 }
 
 
-
 /*
  * Cleanup routine to be called when the server is shutting down.
  * WARNING: It's no longer safe to call this function to force a shutdown.
@@ -774,7 +788,7 @@ void cmd_ipgm(char *argbuf)
                CC->internal_pgm = 1;
                strcpy(CC->curr_user, "<internal program>");
                CC->cs_flags = CC->cs_flags|CS_STEALTH;
-               cprintf("%d Authenticated as an internal program.\n",CIT_OK);
+               cprintf("%d Authenticated as an internal program.\n", CIT_OK);
        }
        else {
                sleep(5);
index 10424f30c4390ca8cca66aa85097f28e8ff90c4e..0c1f38acd280ba957fcb25bc451b1753e4371553 100644 (file)
@@ -1965,7 +1965,7 @@ don't  exist (and you've configured them properly) then Citadel should  enable
 them at startup.  You can check your logs to be sure, or you can  start the
 server from a shell and watch it load.  It might look something like this:</p>
         <font size="-2"> </font>     
-<pre><font size="-2">smw @ pixel % ./citserver<br><br>Multithreaded message server for Citadel/UX<br>Copyright (C) 1987-2000 by the Citadel/UX development team.<br>Citadel/UX is open source, covered by the GNU General Public License, and<br>you are welcome to change it and/or distribute copies of it under certain<br>conditions.  There is absolutely no warranty for this software.  Please<br>read the 'COPYING.txt' file for details.<br><br>Loading citadel.config<br>Opening databases<br>This is GDBM version 1.8.0, as of May 19, 1999.<br>Checking floor reference counts<br>Creating base rooms (if necessary)<br>Registered a new service (TCP port 504)<br>Registered a new service (TCP port 0)<br>Initializing loadable modules<br>Registered server command CHAT (Begin real-time chat)<br>Registered server command PEXP (Poll for express messages)<br>Registered server command GEXP (Get express messages)<br>Registered server command SEXP (Send an express message)<br>Registered server command DEXP (Disable express messages)<br>Registered a new session function (type 0)<br>Registered a new x-msg function (priority 0)<br>Loaded module: $Id$<br>Registered a new session function (type 1)<br>Registered a new message function (type 201)<br>Registered a new message function (type 202)<br>Registered server command REGI (Enter registration info)<br>Registered server command GREG (Get registration info)<br>Registered a new user function (type 100)<br>Loaded module: $Id$<br>Server-hosted upgrade level is 5.62<br>Loaded module: $Id$<br>Registered server command EXPI (Expire old system objects)<br>Registered server command FSCK (Check message ref counts)<br>Loaded module: $Id$<br><b>citserver: Can't bind: Address already in use<br>ERROR: could not bind to TCP port 25.</b><br>Registered a new service (TCP port 0)<br>Registered a new session function (type 50)<br>Loaded module: $Id$<br><b>citserver: Can't bind: Address already in use<br>ERROR: could not bind to TCP port 110.</b><br>Registered a new session function (type 0)<br>Loaded module: $Id$<br>Registered a new message function (type 202)Loaded module: $Id$<br>Registered server command RWHO (Display who is online)<br>Registered server command HCHG (Masquerade hostname)<br>Registered server command RCHG (Masquerade roomname)<br>Registered server command UCHG (Masquerade username)<br>Registered server command STEL (Enter/exit stealth mode)<br>Loaded module: $Id$<br>Changing uid to 513<br>Starting housekeeper thread<br></font></pre>
+<pre><font size="-2">smw @ pixel % ./citserver<br><br>Multithreaded message server for Citadel/UX<br>Copyright (C) 1987-2003 by the Citadel/UX development team.<br>Citadel/UX is open source, covered by the GNU General Public License, and<br>you are welcome to change it and/or distribute copies of it under certain<br>conditions.  There is absolutely no warranty for this software.  Please<br>read the 'COPYING.txt' file for details.<br><br>Loading citadel.config<br>Opening databases<br>This is GDBM version 1.8.0, as of May 19, 1999.<br>Checking floor reference counts<br>Creating base rooms (if necessary)<br>Registered a new service (TCP port 504)<br>Registered a new service (TCP port 0)<br>Initializing loadable modules<br>Registered server command CHAT (Begin real-time chat)<br>Registered server command PEXP (Poll for express messages)<br>Registered server command GEXP (Get express messages)<br>Registered server command SEXP (Send an express message)<br>Registered server command DEXP (Disable express messages)<br>Registered a new session function (type 0)<br>Registered a new x-msg function (priority 0)<br>Loaded module: $Id$<br>Registered a new session function (type 1)<br>Registered a new message function (type 201)<br>Registered a new message function (type 202)<br>Registered server command REGI (Enter registration info)<br>Registered server command GREG (Get registration info)<br>Registered a new user function (type 100)<br>Loaded module: $Id$<br>Server-hosted upgrade level is 5.62<br>Loaded module: $Id$<br>Registered server command EXPI (Expire old system objects)<br>Registered server command FSCK (Check message ref counts)<br>Loaded module: $Id$<br><b>citserver: Can't bind: Address already in use<br>ERROR: could not bind to TCP port 25.</b><br>Registered a new service (TCP port 0)<br>Registered a new session function (type 50)<br>Loaded module: $Id$<br><b>citserver: Can't bind: Address already in use<br>ERROR: could not bind to TCP port 110.</b><br>Registered a new session function (type 0)<br>Loaded module: $Id$<br>Registered a new message function (type 202)Loaded module: $Id$<br>Registered server command RWHO (Display who is online)<br>Registered server command HCHG (Masquerade hostname)<br>Registered server command RCHG (Masquerade roomname)<br>Registered server command UCHG (Masquerade username)<br>Registered server command STEL (Enter/exit stealth mode)<br>Loaded module: $Id$<br>Changing uid to 513<br>Starting housekeeper thread<br></font></pre>
               
 <p>The lines emphasized in boldface in the above log output tell you that 
    Citadel "can't bind" to various ports.  The error 'address already in use'
index cfb23d1083bebe29b6fe6af242c5c0e8c03d5d1a..a8313a62e3231b494b8221a621b2c95bd448d324 100644 (file)
@@ -68,7 +68,9 @@ void cmd_ebio(char *cmdbuf) {
        }
        cprintf("%d  \n",SEND_LISTING);
        while(client_gets(buf), strcmp(buf,"000")) {
-               fprintf(fp,"%s\n",buf);
+               if (ftell(fp) < config.c_maxmsglen) {
+                       fprintf(fp,"%s\n",buf);
+               }
        }
        fclose(fp);
 }
index c2d3b46e5dfda90b623c7643f227c2374924a0e8..4e574bb64b9dad00b5095cf0e8fea4917ee2fc15 100644 (file)
@@ -143,7 +143,6 @@ int main(int argc, char **argv)
        /* Load site-specific parameters, and set the ipgm secret */
        lprintf(7, "Loading citadel.config\n");
        get_config();
-       srand(getpid());
        config.c_ipgm_secret = rand();
        put_config();