* as ubuntu for example purges /var/run, we need to make sure that we can open our...
authorWilfried Göesgens <willi@citadel.org>
Mon, 10 Jul 2006 23:08:39 +0000 (23:08 +0000)
committerWilfried Göesgens <willi@citadel.org>
Mon, 10 Jul 2006 23:08:39 +0000 (23:08 +0000)
citadel/server_main.c

index d777897000dfe2e88977ebe1efb8cc074bdd4b79..68f663b4dda06ef58be8033ea12fbbcaf2eb68bb 100644 (file)
@@ -37,6 +37,7 @@
 #include <errno.h>
 #include <stdarg.h>
 #include <grp.h>
+#include <pwd.h>
 #ifdef HAVE_PTHREAD_H
 #include <pthread.h>
 #endif
@@ -79,6 +80,7 @@ int main(int argc, char **argv)
        int home=0;
        char relhome[PATH_MAX]="";
        char ctdldir[PATH_MAX]=CTDLDIR;
+       struct stat filestats;
        
        /* initialize the master context */
        InitializeMasterCC();
@@ -183,6 +185,19 @@ int main(int argc, char **argv)
        config.c_ipgm_secret = rand();
        put_config();
 
+#ifdef HAVE_RUN_DIR
+       /* on some dists rundir gets purged on startup. so we need to recreate it. */
+
+       if (stat(ctdl_run_dir, &filestats)==-1){
+               pw=getpwuid(config.c_ctdluid);
+               mkdir(ctdl_run_dir, 0755);
+               chown(ctdl_run_dir, config.c_ctdluid, (pw==NULL)?-1:pw->pw_gid);
+
+       }
+                       
+
+#endif
+
        /* Initialize... */
        init_sysdep();