]> code.citadel.org Git - citadel.git/blobdiff - citadel/citserver.c
* Merge LDAP code; bindings are not yet complete
[citadel.git] / citadel / citserver.c
index bf23951560ba3a933500bcfe8b4cad5c6d27a50c..f127449d434ffd3f085506d936827993f9a65dec 100644 (file)
@@ -170,6 +170,7 @@ void master_startup(void) {
                gettimeofday(&tv, NULL);
                seed = tv.tv_usec;
        }
+       srand(seed);
        srandom(seed);
 
        CtdlLogPrintf(CTDL_INFO, "Initializing ipgm secret\n");
@@ -227,6 +228,8 @@ void master_cleanup(int exitcode) {
        
        if (restart_server != 0)
                exit(1);
+       if ((running_as_daemon != 0) && (exitcode == 0))
+               exitcode = CTDLEXIT_SHUTDOWN;
        exit(exitcode);
 }
 
@@ -259,6 +262,12 @@ void RemoveContext (struct CitContext *con)
        CtdlLogPrintf(CTDL_DEBUG, "Closing socket %d\n", con->client_socket);
        close(con->client_socket);
 
+       /* If using AUTHMODE_LDAP, free the DN */
+       if (con->ldap_dn) {
+               free(con->ldap_dn);
+               con->ldap_dn = NULL;
+       }
+
        CtdlLogPrintf(CTDL_DEBUG, "Done with RemoveContext()\n");
 }
 
@@ -309,6 +318,13 @@ void cmd_info(void) {
        cprintf("1\n");         /* yes, Sieve mail filtering is supported */
        cprintf("%d\n", config.c_enable_fulltext);
        cprintf("%s\n", svn_revision());
+
+       if (config.c_auth_mode == AUTHMODE_NATIVE) {
+               cprintf("1\n"); /* OpenID is enabled when using native auth */
+       }
+       else {
+               cprintf("0\n"); /* OpenID is disabled when using non-native auth */
+       }
        
        cprintf("000\n");
 }
@@ -809,16 +825,6 @@ void cmd_ipgm(char *argbuf)
                CtdlLogPrintf(CTDL_ERR, "Warning: ipgm authentication failed.\n");
                CC->kill_me = 1;
        }
-
-       /* Now change the ipgm secret for the next round.
-        * (Disabled because it breaks concurrent scripts.  The fact that
-        * we no longer accept IPGM over the network should be sufficient
-        * to prevent brute-force attacks.  If you don't agree, uncomment
-        * this block.)
-       get_config();
-       config.c_ipgm_secret = rand();
-       put_config();
-       */
 }
 
 
@@ -836,18 +842,20 @@ void cmd_down(char *argbuf) {
                restart_server = extract_int(argbuf, 0);
                
                if (restart_server > 0)
-                       Reply = "%d Restarting server.  See you soon.\n";
+               {
+                       Reply = "%d citserver will now shut down and automatically restart.\n";
+               }
                if ((restart_server > 0) && !running_as_daemon)
                {
-                       CtdlLogPrintf(CTDL_ERR, "The user requested restart, but not running as deamon! Geronimooooooo!\n");
-                       Reply = "%d Warning, not running in deamon mode. maybe we will come up again, but don't lean on it.\n";
+                       CtdlLogPrintf(CTDL_ERR, "The user requested restart, but not running as daemon! Geronimooooooo!\n");
+                       Reply = "%d Warning: citserver is not running in daemon mode and is therefore unlikely to restart automatically.\n";
                        state = ERROR;
                }
                cprintf(Reply, state);
        }
        else
        {
-               cprintf(Reply, CIT_OK + SERVER_SHUTTING_DOWN);
+               cprintf(Reply, CIT_OK + SERVER_SHUTTING_DOWN); 
        }
        CtdlThreadStopAll();
 }
@@ -976,7 +984,7 @@ void begin_session(struct CitContext *con)
        con->dl_is_net = 0;
 
        con->nologin = 0;
-       if ((config.c_maxsessions > 0)&&(num_sessions > config.c_maxsessions)) {
+       if (((config.c_maxsessions > 0)&&(num_sessions > config.c_maxsessions)) || CtdlWantSingleUser()) {
                con->nologin = 1;
        }
 
@@ -1284,10 +1292,6 @@ void do_command_loop(void) {
                cmd_movf(&cmdbuf[5]);
        }
 
-       else if (!strncasecmp(cmdbuf,"NETF",4)) {
-               cmd_netf(&cmdbuf[5]);
-       }
-
        else if (!strncasecmp(cmdbuf,"OPEN",4)) {
                cmd_open(&cmdbuf[5]);
        }