CC->kill_me now contains an enum indicating the REASON session was killed
[citadel.git] / citadel / citserver.c
index e1843eb209c2396a3684203f93eabc6ffb994d21..42fb045a49665adde0c52e2381cc996de92f3def 100644 (file)
@@ -82,6 +82,7 @@ char *unique_session_numbers;
 int ScheduledShutdown = 0;
 time_t server_startup_time;
 int panic_fd;
+int openid_level_supported = 0;
 
 /*
  * print the actual stack frame.
@@ -288,7 +289,7 @@ void cmd_info(char *cmdbuf) {
        cprintf("%s\n", config.c_moreprompt);
        cprintf("1\n"); /* 1 = yes, this system supports floors */
        cprintf("1\n"); /* 1 = we support the extended paging options */
-       cprintf("%s\n", CC->cs_nonce);
+       cprintf("\n");  /* nonce no longer supported */
        cprintf("1\n"); /* 1 = yes, this system supports the QNOP command */
 
 #ifdef HAVE_LDAP
@@ -316,7 +317,7 @@ void cmd_info(char *cmdbuf) {
        cprintf("%s\n", svn_revision());
 
        if (config.c_auth_mode == AUTHMODE_NATIVE) {
-               cprintf("1\n"); /* OpenID is enabled when using native auth */
+               cprintf("%d\n", openid_level_supported); /* OpenID is enabled when using native auth */
        }
        else {
                cprintf("0\n"); /* OpenID is disabled when using non-native auth */
@@ -790,7 +791,7 @@ void cmd_ipgm(char *argbuf)
                sleep(5);
                cprintf("%d Authentication failed.\n", ERROR + PASSWORD_REQUIRED);
                syslog(LOG_ERR, "Warning: ipgm authentication failed.\n");
-               CC->kill_me = 1;
+               CC->kill_me = KILLME_AUTHFAILED;
        }
 }
 
@@ -824,7 +825,7 @@ void cmd_down(char *argbuf) {
        {
                cprintf(Reply, CIT_OK + SERVER_SHUTTING_DOWN); 
        }
-       CC->kill_me = 1; /* Even the DOWN command has to follow correct proceedure when disconecting */
+       CC->kill_me = KILLME_SERVER_SHUTTING_DOWN;
        CtdlThreadStopAll();
 }
 
@@ -889,22 +890,6 @@ void cmd_asyn(char *argbuf)
 }
 
 
-/*
- * Generate a "nonce" for APOP-style authentication.
- *
- * RFC 1725 et al specify a PID to be placed in front of the nonce.
- * Quoth BTX: That would be stupid.
- */
-void generate_nonce(CitContext *con) {
-       struct timeval tv;
-
-       memset(con->cs_nonce, NONCE_SIZE, 0);
-       gettimeofday(&tv, NULL);
-       memset(con->cs_nonce, NONCE_SIZE, 0);
-       snprintf(con->cs_nonce, NONCE_SIZE, "<%d%ld@%s>",
-               rand(), (long)tv.tv_usec, config.c_fqdn);
-}
-
 
 /*
  * Back-end function for starting a session
@@ -921,6 +906,8 @@ void begin_session(CitContext *con)
        con->internal_pgm = 0;
        con->download_fp = NULL;
        con->upload_fp = NULL;
+       con->cached_msglist = NULL;
+       con->cached_num_msgs = 0;
        con->FirstExpressMessage = NULL;
        time(&con->lastcmd);
        time(&con->lastidle);
@@ -932,7 +919,6 @@ void begin_session(CitContext *con)
        *con->fake_hostname = '\0';
        *con->fake_roomname = '\0';
        *con->cs_clientinfo = '\0';
-       generate_nonce(con);
        safestrncpy(con->cs_host, config.c_fqdn, sizeof con->cs_host);
        safestrncpy(con->cs_addr, "", sizeof con->cs_addr);
        con->cs_UDSclientUID = -1;
@@ -1008,7 +994,7 @@ void citproto_begin_session() {
                        ERROR + MAX_SESSIONS_EXCEEDED,
                        config.c_nodename, config.c_maxsessions
                );
-               CC->kill_me = 1;
+               CC->kill_me = KILLME_MAX_SESSIONS_EXCEEDED;
        }
        else {
                cprintf("%d %s Citadel server ready.\n", CIT_OK, config.c_nodename);
@@ -1032,7 +1018,7 @@ void cmd_qnop(char *argbuf)
 void cmd_quit(char *argbuf)
 {
        cprintf("%d Goodbye.\n", CIT_OK);
-       CC->kill_me = 1;
+       CC->kill_me = KILLME_CLIENT_LOGGED_OUT;
 }
 
 
@@ -1057,7 +1043,7 @@ void do_command_loop(void) {
        memset(cmdbuf, 0, sizeof cmdbuf); /* Clear it, just in case */
        if (client_getln(cmdbuf, sizeof cmdbuf) < 1) {
                syslog(LOG_ERR, "Client disconnected: ending session.\n");
-               CC->kill_me = 1;
+               CC->kill_me = KILLME_CLIENT_DISCONNECTED;
                CtdlThreadName(old_name);
                return;
        }