properly abort if we fail to create debug files instead of crashing.
[citadel.git] / citadel / citserver.c
index ace58c5e713a35404bb8c42eb4daeb21d60d0cfc..d0902e266985afbaf7e8cb1658507e3955ceef84 100644 (file)
@@ -44,14 +44,15 @@ void cit_backtrace(void)
        size_t size, i;
        char **strings;
 
-
+       const char *p = IOSTR;
+       if (p == NULL) p = "";
        size = backtrace(stack_frames, sizeof(stack_frames) / sizeof(void*));
        strings = backtrace_symbols(stack_frames, size);
        for (i = 0; i < size; i++) {
                if (strings != NULL)
-                       syslog(LOG_ALERT, "%s\n", strings[i]);
+                       syslog(LOG_ALERT, "%s %s\n", p, strings[i]);
                else
-                       syslog(LOG_ALERT, "%p\n", stack_frames[i]);
+                       syslog(LOG_ALERT, "%s %p\n", p, stack_frames[i]);
        }
        free(strings);
 #endif
@@ -77,7 +78,7 @@ void cit_oneline_backtrace(void)
                                StrBufAppendPrintf(Buf, "%p : ", stack_frames[i]);
                }
                free(strings);
-               syslog(LOG_ALERT, "%s\n", ChrPtr(Buf));
+               syslog(LOG_ALERT, "%s %s\n", IOSTR, ChrPtr(Buf));
                FreeStrBuf(&Buf);
        }
 #endif
@@ -116,12 +117,25 @@ void master_startup(void) {
        FILE *urandom;
        struct ctdlroom qrbuf;
        int rv;
+       struct passwd *pw;
+       gid_t gid;
        
        syslog(LOG_DEBUG, "master_startup() started\n");
        time(&server_startup_time);
        get_config();
 
-       syslog(LOG_INFO, "Opening databases\n");
+       syslog(LOG_INFO, "Checking directory access");
+       if ((pw = getpwuid(CTDLUID)) == NULL) {
+               gid = getgid();
+       } else {
+               gid = pw->pw_gid;
+       }
+
+       if (create_run_directories(CTDLUID, gid) != 0) {
+               syslog(LOG_EMERG, "failed to access & create directories");
+               exit(1);
+       }
+       syslog(LOG_INFO, "Opening databases");
        open_databases();
        check_ref_counts();