/*
* Main source module for the Citadel server
*
- * Copyright (c) 1987-2011 by the citadel.org team
+ * Copyright (c) 1987-2014 by the citadel.org team
*
* This program is open source software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License, version 3.
* GNU General Public License for more details.
*/
-#include "sysdep.h"
-#include <stdlib.h>
-#include <unistd.h>
#include <stdio.h>
-#include <fcntl.h>
-#include <signal.h>
-#include <sys/types.h>
-#include <sys/stat.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 "sysdep.h"
+#include <time.h>
#if HAVE_BACKTRACE
#include <execinfo.h>
#endif
-
-#include <ctype.h>
-#include <string.h>
-#include <errno.h>
-#include <limits.h>
-#include <netdb.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
#include <libcitadel.h>
-#include "citadel.h"
-#include "server.h"
-#include "sysdep_decls.h"
-#include "threads.h"
-#include "citserver.h"
-#include "config.h"
-#include "database.h"
+
+#include "ctdl_module.h"
#include "housekeeping.h"
-#include "user_ops.h"
-#include "msgbase.h"
-#include "support.h"
#include "locate_host.h"
-#include "room_ops.h"
+#include "citserver.h"
+#include "user_ops.h"
#include "control.h"
-#include "euidindex.h"
-#include "context.h"
-#include "svn_revision.h"
-#include "ctdl_module.h"
+#include "config.h"
char *unique_session_numbers;
int ScheduledShutdown = 0;
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
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
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();
+ validate_config();
+
+ syslog(LOG_INFO, "Checking directory access");
+ if ((pw = getpwuid(CTDLUID)) == NULL) {
+ gid = getgid();
+ } else {
+ gid = pw->pw_gid;
+ }
- syslog(LOG_INFO, "Opening databases\n");
+ 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();