]> code.citadel.org Git - citadel.git/blobdiff - citadel/citserver.c
by jimcuclamath: use defines instead of numbers for logging; Change some loglevels...
[citadel.git] / citadel / citserver.c
index 51916926c1a1d83acea824058ece1d7b6a61f7d8..a8db75c6115cd0e5e4a32e093b3ec35d5ae7ee7e 100644 (file)
@@ -1,6 +1,4 @@
 /* 
- * $Id$
- *
  * Main source module for the Citadel server
  *
  * Copyright (c) 1987-2010 by the citadel.org team
@@ -100,9 +98,9 @@ void cit_backtrace(void)
        strings = backtrace_symbols(stack_frames, size);
        for (i = 0; i < size; i++) {
                if (strings != NULL)
-                       CtdlLogPrintf(1, "%s\n", strings[i]);
+                       CtdlLogPrintf(CTDL_ALERT, "%s\n", strings[i]);
                else
-                       CtdlLogPrintf(1, "%p\n", stack_frames[i]);
+                       CtdlLogPrintf(CTDL_ALERT, "%p\n", stack_frames[i]);
        }
        free(strings);
 #endif
@@ -123,9 +121,9 @@ void cit_panic_backtrace(int SigNum)
        strings = backtrace_symbols(stack_frames, size);
        for (i = 0; i < size; i++) {
                if (strings != NULL)
-                       CtdlLogPrintf(1, "%s\n", strings[i]);
+                       CtdlLogPrintf(CTDL_ALERT, "%s\n", strings[i]);
                else
-                       CtdlLogPrintf(1, "%p\n", stack_frames[i]);
+                       CtdlLogPrintf(CTDL_ALERT, "%p\n", stack_frames[i]);
        }
        free(strings);
 #endif
@@ -661,6 +659,11 @@ int CtdlAccessCheck(int required_level) {
                return(-1);
        }
 
+       if ((required_level >= ac_logged_in_or_guest) && (CC->logged_in == 0) && (!config.c_guest_logins)) {
+               cprintf("%d Not logged in.\n", ERROR + NOT_LOGGED_IN);
+               return(-1);
+       }
+
        if ((required_level >= ac_logged_in) && (CC->logged_in == 0)) {
                cprintf("%d Not logged in.\n", ERROR + NOT_LOGGED_IN);
                return(-1);
@@ -902,6 +905,7 @@ void begin_session(CitContext *con)
        *con->fake_username = '\0';
        *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);
@@ -942,6 +946,11 @@ void begin_session(CitContext *con)
                                   database, after a reverse lookup on the UID to get the account name.
                                   We can take this opportunity to check to see if this is a legit account.
                                */
+                               snprintf(con->cs_clientinfo, sizeof(con->cs_clientinfo),
+                                        "PID: "F_PID_T"; UID: "F_UID_T"; GID: "F_XPID_T" ", 
+                                        credentials.pid,
+                                        credentials.uid,
+                                        credentials.gid);
                        }
                }
 #endif
@@ -1029,10 +1038,10 @@ void do_command_loop(void) {
 
        /* Log the server command, but don't show passwords... */
        if ( (strncasecmp(cmdbuf, "PASS", 4)) && (strncasecmp(cmdbuf, "SETP", 4)) ) {
-               CtdlLogPrintf(CTDL_INFO, "%s\n", cmdbuf);
+               CtdlLogPrintf(CTDL_INFO, "CtdlCommand [%s] [%s] %s\n", CTDLUSERIP, CC->curr_user, cmdbuf);
        }
        else {
-               CtdlLogPrintf(CTDL_INFO, "<password command hidden from log>\n");
+               CtdlLogPrintf(CTDL_INFO, "CtdlCommand [%s] [%s] <password command hidden from log>\n", CTDLUSERIP, CC->curr_user);
        }
 
        buffer_output();
@@ -1106,6 +1115,6 @@ CTDL_MODULE_INIT(citserver)
                CtdlRegisterProtoHook(cmd_scdn, "SCDN", "schedule or cancel a server shutdown");
                CtdlRegisterProtoHook(cmd_time, "TIME", "fetch the date and time from the server");
        }
-        /* return our Subversion id for the Log */
-       return "$Id$";
+        /* return our id for the Log */
+       return "citserver";
 }