]> code.citadel.org Git - citadel.git/blobdiff - citadel/sysdep.c
* Found and removed a large section of the old LDAP connector.
[citadel.git] / citadel / sysdep.c
index ac654ac52c1d171e06b19b1c572cb3426f11a6cb..c06575888d9aead47d8f2c3298fdad465b3ae64b 100644 (file)
@@ -171,18 +171,19 @@ void vCtdlLogPrintf(enum LogLevel loglevel, const char *format, va_list arg_ptr)
                struct timeval tv;
                struct tm tim;
                time_t unixtime;
+               struct CitContext *CCC = CC;
 
                gettimeofday(&tv, NULL);
                /* Promote to time_t; types differ on some OSes (like darwin) */
                unixtime = tv.tv_sec;
                localtime_r(&unixtime, &tim);
-               if (CC->cs_pid != 0) {
+               if ((CCC != NULL) && (CCC->cs_pid != 0)) {
                        sprintf(buf,
                                "%04d/%02d/%02d %2d:%02d:%02d.%06ld [%3d] ",
                                tim.tm_year + 1900, tim.tm_mon + 1,
                                tim.tm_mday, tim.tm_hour, tim.tm_min,
                                tim.tm_sec, (long)tv.tv_usec,
-                               CC->cs_pid);
+                               CCC->cs_pid);
                } else {
                        sprintf(buf,
                                "%04d/%02d/%02d %2d:%02d:%02d.%06ld ",
@@ -375,6 +376,9 @@ int ig_uds_server(char *sockpath, int queue_len, char **errormessage)
        int s;
        int i;
        int actual_queue_len;
+#ifdef HAVE_STRUCT_UCRED
+       int passcred = 1;
+#endif
 
        actual_queue_len = queue_len;
        if (actual_queue_len < 5) actual_queue_len = 5;
@@ -431,6 +435,10 @@ int ig_uds_server(char *sockpath, int queue_len, char **errormessage)
                return(-1);
        }
 
+#ifdef HAVE_STRUCT_UCRED
+       setsockopt(s, SOL_SOCKET, SO_PASSCRED, &passcred, sizeof(passcred));
+#endif
+
        chmod(sockpath, S_ISGID|S_IRUSR|S_IWUSR|S_IXUSR|S_IRGRP|S_IWGRP|S_IXGRP|S_IROTH|S_IWOTH|S_IXOTH);
        return(s);
 }
@@ -566,17 +574,19 @@ static unsigned on = 1, off = 0;
 
 void buffer_output(void) {
 #ifdef HAVE_TCP_BUFFERING
-       if (!CC->redirect_ssl) {
+#ifdef HAVE_OPENSSL
+       if (!CC->redirect_ssl)
+#endif
                setsockopt(CC->client_socket, IPPROTO_TCP, TCP_CORK, &on, 4);
-       }
 #endif
 }
 
 void unbuffer_output(void) {
 #ifdef HAVE_TCP_BUFFERING
-       if (!CC->redirect_ssl) {
+#ifdef HAVE_OPENSSL
+       if (!CC->redirect_ssl)
+#endif
                setsockopt(CC->client_socket, IPPROTO_TCP, TCP_CORK, &off, 4);
-       }
 #endif
 }
 
@@ -868,7 +878,6 @@ void sysdep_master_cleanup(void) {
        CtdlDestroySessionHooks();
        CtdlDestroyServiceHook();
        CtdlDestroyRoomHooks();
-       CtdlDestroyDirectoryServiceFuncs();
        #ifdef HAVE_BACKTRACE
        eCrash_Uninit();
        #endif
@@ -960,35 +969,19 @@ void start_daemon(int unused) {
                }
                do_restart = 0;
                nFireUpsNonRestart = nFireUps;
-               /* Did the main process exit with an actual exit code? */
-               if (WIFEXITED(status)) {
                
-                       CtdlLogPrintf(CTDL_DEBUG, "\e[31m WIFEXITED! \e[0m\n");
-
-                       /* Exit code 0 means the watcher should exit */
-                       if (WEXITSTATUS(status) == CTDLEXIT_SHUTDOWN) {
-                               CtdlLogPrintf(CTDL_DEBUG, "\e[31m CTDLEXIT_SHUTDOWN \e[0m\n");
-                               do_restart = 0;
-                       }
-
-                       /* Exit code 101-109 means the watcher should exit */
-                       else if ( (WEXITSTATUS(status) >= 101) && (WEXITSTATUS(status) <= 109) ) {
-                               CtdlLogPrintf(CTDL_DEBUG, "\e[31m CTDLEXIT NO RESTART \e[0m\n");
-                               do_restart = 0;
-                       }
+               /* Exit code 0 means the watcher should exit */
+               if (WIFEXITED(status) && (WEXITSTATUS(status) == CTDLEXIT_SHUTDOWN)) {
+                       do_restart = 0;
+               }
 
-                       /* Any other exit code means we should restart. */
-                       else {
-                               CtdlLogPrintf(CTDL_DEBUG, "\e[31m ANY OTHER EXIT CODE \e[0m\n");
-                               do_restart = 1;
-                               nFireUps++;
-                               ForkedPid = current_child;
-                       }
+               /* Exit code 101-109 means the watcher should exit */
+               else if (WIFEXITED(status) && (WEXITSTATUS(status) >= 101) && (WEXITSTATUS(status) <= 109)) {
+                       do_restart = 0;
                }
 
-               /* Any other type of termination (signals, etc.) should also restart. */
+               /* Any other exit code, or no exit code, means we should restart. */
                else {
-                       CtdlLogPrintf(CTDL_DEBUG, "\e[31m NON-EXIT TERMINATION \e[0m\n");
                        do_restart = 1;
                        nFireUps++;
                        ForkedPid = current_child;
@@ -1009,16 +1002,20 @@ void checkcrash(void)
                StrBuf *CrashMail;
 
                CrashMail = NewStrBuf();
-               CtdlLogPrintf (CTDL_ALERT, "----------------sending crash mail\n");
+               CtdlLogPrintf(CTDL_ALERT, "Posting crash message\n");
                StrBufPrintf(CrashMail, 
-                            "Your CitServer is just recovering from an unexpected termination.\n"
-                            " this maybe the result of an error in citserver or an external influence.\n"
-                            " You can get more information on this by enabling coredumping; for more information see\n"
-                            " http://citadel.org/doku.php/faq:mastering_your_os:gdb#how.do.i.make.my.system.produce.core-files\n"
-                            " If you already did, the file you're looking for most probably is %score.%d\n"
-                            " Yours faithfully...",
-                            ctdl_run_dir, ForkedPid);
-               aide_message(ChrPtr(CrashMail), "Citadel server crashed.");
+                       " \n"
+                       " The Citadel server process (citserver) terminated unexpectedly."
+                       "\n \n"
+                       " This could be the result of a bug in the server program, or some external "
+                       "factor.  You can obtain more information about this by enabling core dumps. "
+                       "For more information, please see: "
+                       "http://citadel.org/doku.php/faq:mastering_your_os:gdb#how.do.i.make.my.system.produce.core-files"
+                       "\n \n"
+                       " If you have already done this, the core dump is likely to be found at %score.%d\n"
+                       ,
+                       ctdl_run_dir, ForkedPid);
+               aide_message(ChrPtr(CrashMail), "Citadel server process terminated unexpectedly");
                FreeStrBuf(&CrashMail);
        }
 }