]> code.citadel.org Git - citadel.git/blobdiff - citadel/setup.c
* Applied a patch sent in by Wilfried Goesgens which allows the various
[citadel.git] / citadel / setup.c
index 261662671b4ed651f0812940012f70856ab56f4c..cfd3acc0769fa2a574b880b80d17e1a6b8241be8 100644 (file)
@@ -796,7 +796,7 @@ void edit_value(int curr)
 {
        int i;
        struct passwd *pw;
-       char bbsuidname[SIZ];
+       char ctdluidname[SIZ];
 
        switch (curr) {
 
@@ -806,23 +806,23 @@ void edit_value(int curr)
 
        case 2:
 #ifdef __CYGWIN__
-               config.c_bbsuid = 0;    /* XXX Windows hack, prob. insecure */
+               config.c_ctdluid = 0;   /* XXX Windows hack, prob. insecure */
 #else
-               i = config.c_bbsuid;
+               i = config.c_ctdluid;
                pw = getpwuid(i);
                if (pw == NULL) {
                        set_int_val(curr, &i);
-                       config.c_bbsuid = i;
+                       config.c_ctdluid = i;
                }
                else {
-                       strcpy(bbsuidname, pw->pw_name);
-                       set_str_val(curr, bbsuidname);
-                       pw = getpwnam(bbsuidname);
+                       strcpy(ctdluidname, pw->pw_name);
+                       set_str_val(curr, ctdluidname);
+                       pw = getpwnam(ctdluidname);
                        if (pw != NULL) {
-                               config.c_bbsuid = pw->pw_uid;
+                               config.c_ctdluid = pw->pw_uid;
                        }
-                       else if (atoi(bbsuidname) > 0) {
-                               config.c_bbsuid = atoi(bbsuidname);
+                       else if (atoi(ctdluidname) > 0) {
+                               config.c_ctdluid = atoi(ctdluidname);
                        }
                }
 #endif
@@ -848,7 +848,13 @@ void write_config_to_disk(void)
        FILE *fp;
        int fd;
 
-       if ((fd = creat("citadel.config", S_IRUSR | S_IWUSR)) == -1) {
+       if ((fd = creat(
+#ifndef HAVE_ETC_DIR
+                                       "."
+#else
+                                       ETC_DIR
+#endif
+                                       "/citadel.config", S_IRUSR | S_IWUSR)) == -1) {
                display_error("setup: cannot open citadel.config");
                cleanup(1);
        }
@@ -938,7 +944,7 @@ int main(int argc, char *argv[])
        }
 
        /* Get started in a valid setup directory. */
-       strcpy(setup_directory, BBSDIR);
+       strcpy(setup_directory, CTDLDIR);
        if ( (using_web_installer) && (getenv("CITADEL") != NULL) ) {
                strcpy(setup_directory, getenv("CITADEL"));
        }
@@ -992,7 +998,13 @@ int main(int argc, char *argv[])
         * completely new copy.
         */
 
-       if ((a = open("citadel.config", O_WRONLY | O_CREAT | O_APPEND,
+       if ((a = open(
+#ifndef HAVE_ETC_DIR
+                                 "."
+#else
+                                 ETC_DIR
+#endif
+                                 "/citadel.config", O_WRONLY | O_CREAT | O_APPEND,
                      S_IRUSR | S_IWUSR)) == -1) {
                display_error("setup: cannot append citadel.config");
                cleanup(errno);
@@ -1007,7 +1019,13 @@ int main(int argc, char *argv[])
        fclose(fp);
 
        /* now we re-open it, and read the old or blank configuration */
-       fp = fopen("citadel.config", "rb");
+       fp = fopen(
+#ifndef HAVE_ETC_DIR
+                          "."
+#else
+                          ETC_DIR
+#endif
+                          "/citadel.config", "rb");
        if (fp == NULL) {
                display_error("setup: cannot open citadel.config");
                cleanup(errno);
@@ -1040,7 +1058,7 @@ int main(int argc, char *argv[])
        if (strlen(config.c_twitroom) == 0)
                strcpy(config.c_twitroom, "Trashcan");
        if (strlen(config.c_baseroom) == 0)
-               strcpy(config.c_baseroom, "Lobby");
+               strcpy(config.c_baseroom, BASEROOM);
        if (strlen(config.c_aideroom) == 0)
                strcpy(config.c_aideroom, "Aide");
        if (config.c_port_number == 0) {
@@ -1049,20 +1067,20 @@ int main(int argc, char *argv[])
        if (config.c_sleeping == 0) {
                config.c_sleeping = 900;
        }
-       if (config.c_bbsuid == 0) {
+       if (config.c_ctdluid == 0) {
                pw = getpwnam("citadel");
                if (pw != NULL)
-                       config.c_bbsuid = pw->pw_uid;
+                       config.c_ctdluid = pw->pw_uid;
        }
-       if (config.c_bbsuid == 0) {
+       if (config.c_ctdluid == 0) {
                pw = getpwnam("bbs");
                if (pw != NULL)
-                       config.c_bbsuid = pw->pw_uid;
+                       config.c_ctdluid = pw->pw_uid;
        }
-       if (config.c_bbsuid == 0) {
+       if (config.c_ctdluid == 0) {
                pw = getpwnam("guest");
                if (pw != NULL)
-                       config.c_bbsuid = pw->pw_uid;
+                       config.c_ctdluid = pw->pw_uid;
        }
        if (config.c_createax == 0) {
                config.c_createax = 3;
@@ -1075,10 +1093,11 @@ int main(int argc, char *argv[])
        }
        /* We need a system default message expiry policy, because this is
         * the top level and there's no 'higher' policy to fall back on.
+        * By default, do not expire messages at all.
         */
        if (config.c_ep.expire_mode == 0) {
-               config.c_ep.expire_mode = EXPIRE_NUMMSGS;
-               config.c_ep.expire_value = 150;
+               config.c_ep.expire_mode = EXPIRE_MANUAL;
+               config.c_ep.expire_value = 0;
        }
 
        /*
@@ -1100,7 +1119,7 @@ int main(int argc, char *argv[])
        }
 
        /*
-          if (setuid(config.c_bbsuid) != 0) {
+          if (setuid(config.c_ctdluid) != 0) {
           important_message("Citadel Setup",
           "Failed to change the user ID to your Citadel user.");
           cleanup(errno);
@@ -1183,25 +1202,37 @@ NEW_INST:
        disable_other_mta("hula");
 #endif
 
-       if ((pw = getpwuid(config.c_bbsuid)) == NULL)
+       if ((pw = getpwuid(config.c_ctdluid)) == NULL)
                gid = getgid();
        else
                gid = pw->pw_gid;
 
        progress("Setting file permissions", 0, 4);
-       chown(".", config.c_bbsuid, gid);
+       chown(".", config.c_ctdluid, gid);
        sleep(1);
        progress("Setting file permissions", 1, 4);
-       chown("citadel.config", config.c_bbsuid, gid);
+       chown(
+#ifndef HAVE_ETC_DIR
+                 "."
+#else
+                 ETC_DIR
+#endif
+                 "/citadel.config", config.c_ctdluid, gid);
        sleep(1);
        progress("Setting file permissions", 2, 4);
        snprintf(aaa, sizeof aaa,
                "find . | grep -v chkpwd | xargs chown %ld:%ld 2>/dev/null",
-               (long)config.c_bbsuid, (long)gid);
+               (long)config.c_ctdluid, (long)gid);
        system(aaa);
        sleep(1);
        progress("Setting file permissions", 3, 4);
-       chmod("citadel.config", S_IRUSR | S_IWUSR);
+       chmod(
+#ifndef HAVE_ETC_DIR
+                 "."
+#else
+                 ETC_DIR
+#endif
+                 "/citadel.config", S_IRUSR | S_IWUSR);
        sleep(1);
        progress("Setting file permissions", 4, 4);