]> code.citadel.org Git - citadel.git/blobdiff - citadel/citserver.c
* When sending mail, copy to the sender's "Sent Items>" room instead of to
[citadel.git] / citadel / citserver.c
index 08f4c4f8c4a998fc1373a722890db2972c83116d..c03f9cdfe6f2f1f9b5dc83e81e82e3f988a3a99c 100644 (file)
@@ -5,13 +5,28 @@
  *
  */
 
+#ifdef DLL_EXPORT
+#define IN_LIBCIT
+#endif
+
 #include "sysdep.h"
 #include <stdlib.h>
 #include <unistd.h>
 #include <stdio.h>
 #include <fcntl.h>
 #include <signal.h>
-#include <time.h>
+
+#if TIME_WITH_SYS_TIME
+# include <sys/time.h>
+# include <time.h>
+#else
+# if HAVE_SYS_TIME_H
+#  include <sys/time.h>
+# else
+#  include <time.h>
+# endif
+#endif
+
 #include <ctype.h>
 #include <string.h>
 #include <errno.h>
 #include <netdb.h>
 #include <sys/types.h>
 #include <sys/socket.h>
-#include <sys/time.h>
 #include <netinet/in.h>
 #include <arpa/inet.h>
 #include "citadel.h"
 #include "server.h"
+#include "dynloader.h"
 #include "sysdep_decls.h"
 #include "citserver.h"
 #include "config.h"
 #include "locate_host.h"
 #include "room_ops.h"
 #include "file_ops.h"
-#include "dynloader.h"
 #include "policy.h"
 #include "control.h"
 #include "tools.h"
 
+#ifndef HAVE_SNPRINTF
+#include "snprintf.h"
+#endif
+
 struct CitContext *ContextList = NULL;
 char *unique_session_numbers;
 int ScheduledShutdown = 0;
@@ -65,10 +83,10 @@ void master_startup(void) {
        check_ref_counts();
 
        lprintf(7, "Creating base rooms (if necessary)\n");
-       create_room(BASEROOM,           0, "", 0);
-       create_room(AIDEROOM,           3, "", 0);
-       create_room(SYSCONFIGROOM,      3, "", 0);
-       create_room(config.c_twitroom,  0, "", 0);
+       create_room(BASEROOM,           0, "", 0, 1);
+       create_room(AIDEROOM,           3, "", 0, 1);
+       create_room(SYSCONFIGROOM,      3, "", 0, 1);
+       create_room(config.c_twitroom,  0, "", 0, 1);
 
        lprintf(7, "Seeding the pseudo-random number generator...\n");
        gettimeofday(&tv, NULL);
@@ -335,7 +353,7 @@ void cmd_time(void)
    
    tv = time(NULL);
    
-   cprintf("%d %ld\n", OK, tv);
+   cprintf("%d %ld\n", OK, (long)tv);
 }
 
 /*
@@ -630,32 +648,44 @@ void cmd_term(char *cmdbuf)
        int session_num;
        struct CitContext *ccptr;
        int found_it = 0;
-
-       if (CtdlAccessCheck(ac_aide)) return;
+       int allowed = 0;
 
        session_num = extract_int(cmdbuf, 0);
        if (session_num == CC->cs_pid) {
                cprintf("%d You can't kill your own session.\n", ERROR);
                return;
-               }
+       }
 
        lprintf(9, "Locating session to kill\n");
        begin_critical_section(S_SESSION_TABLE);
        for (ccptr = ContextList; ccptr != NULL; ccptr = ccptr->next) {
                if (session_num == ccptr->cs_pid) {
-                       ccptr->kill_me = 1;
                        found_it = 1;
+                       if ((ccptr->usersupp.usernum == CC->usersupp.usernum)
+                          || (CC->usersupp.axlevel >= 6)) {
+                               allowed = 1;
+                               ccptr->kill_me = 1;
+                       }
+                       else {
+                               allowed = 0;
                        }
                }
+       }
        end_critical_section(S_SESSION_TABLE);
 
        if (found_it) {
-               cprintf("%d Session terminated.\n", OK);
+               if (allowed) {
+                       cprintf("%d Session terminated.\n", OK);
+               }
+               else {
+                       cprintf("%d You are not allowed to do that.\n",
+                               ERROR + HIGHER_ACCESS_REQUIRED);
                }
+       }
        else {
                cprintf("%d No such session.\n", ERROR);
-               }
        }
+}
 
 
 
@@ -755,7 +785,7 @@ void generate_nonce(struct CitContext *con) {
        gettimeofday(&tv, NULL);
        memset(con->cs_nonce, NONCE_SIZE, 0);
        snprintf(con->cs_nonce, NONCE_SIZE, "<%d%ld@%s>",
-               rand(), tv.tv_usec, config.c_fqdn);
+               rand(), (long)tv.tv_usec, config.c_fqdn);
 }
 
 
@@ -1003,10 +1033,6 @@ void do_command_loop(void) {
                cmd_ent0(&cmdbuf[5]);
                }
 
-       else if (!strncasecmp(cmdbuf,"ENT3",4)) {
-               cmd_ent3(&cmdbuf[5]);
-               }
-
        else if (!strncasecmp(cmdbuf,"RINF",4)) {
                cmd_rinf();
                }
@@ -1111,10 +1137,6 @@ void do_command_loop(void) {
                cmd_more();
                }
 
-       else if (!strncasecmp(cmdbuf,"NETP",4)) {
-               cmd_netp(&cmdbuf[5]);
-               }
-
        else if (!strncasecmp(cmdbuf,"NDOP",4)) {
                cmd_ndop(&cmdbuf[5]);
                }
@@ -1191,6 +1213,10 @@ void do_command_loop(void) {
                cmd_conf(&cmdbuf[5]);
                }
 
+       else if (!strncasecmp(cmdbuf, "SEEN", 4)) {
+               cmd_seen(&cmdbuf[5]);
+               }
+
 #ifdef DEBUG_MEMORY_LEAKS
        else if (!strncasecmp(cmdbuf, "LEAK", 4)) {
                dump_tracked();