]> code.citadel.org Git - citadel.git/blobdiff - citadel/config.c
fix dnamlen, they missed the e, so we need to follow.
[citadel.git] / citadel / config.c
index cc48c8d11c7f3a586e5650d178e0a01e04a2595c..aea5d4bf3bac045fd701e85432a5c51172dbe867 100644 (file)
@@ -42,9 +42,7 @@ void brand_new_installation_set_defaults(void) {
        uname(&my_utsname);
 
        /* set some sample/default values in place of blanks... */
-       char c_nodename[256];
-       safestrncpy(c_nodename, my_utsname.nodename, sizeof c_nodename);
-       strtok(config.c_nodename, ".");
+       extract_token(config.c_nodename, my_utsname.nodename, 0, '.', sizeof config.c_nodename);
        if (IsEmptyStr(config.c_fqdn) ) {
                if ((he = gethostbyname(my_utsname.nodename)) != NULL) {
                        safestrncpy(config.c_fqdn, he->h_name, sizeof config.c_fqdn);
@@ -63,7 +61,6 @@ void brand_new_installation_set_defaults(void) {
        safestrncpy(config.c_aideroom, "Aide", sizeof config.c_aideroom);
        config.c_port_number = 504;
        config.c_sleeping = 900;
-       config.c_instant_expunge = 1;
 
        if (config.c_ctdluid == 0) {
                pw = getpwnam("citadel");
@@ -130,7 +127,8 @@ void get_config(void) {
                {
                        fprintf(stderr, 
                                "Warning: The config file %s has unexpected size. \n",
-                               file_citadel_config);
+                               file_citadel_config
+                       );
                }
                fclose(cfp);
        }
@@ -206,15 +204,18 @@ void get_config(void) {
 void put_config(void)
 {
        FILE *cfp;
-       int rv;
+       int blocks_written = 0;
 
-       if ((cfp = fopen(file_citadel_config, "rb+")) == NULL)
-               perror(file_citadel_config);
-       else {
-               rv = fwrite((char *) &config, sizeof(struct config), 1, cfp);
-               if (rv == -1)
-                       syslog(LOG_EMERG, "Failed to write: %s [%s]\n", 
-                              file_citadel_config, strerror(errno));
+       cfp = fopen(file_citadel_config, "w");
+       if (cfp != NULL) {
+               blocks_written = fwrite((char *) &config, sizeof(struct config), 1, cfp);
+               if (blocks_written == 1) {
+                       chown(file_citadel_config, CTDLUID, (-1));
+                       chmod(file_citadel_config, 0600);
+                       fclose(cfp);
+                       return;
+               }
                fclose(cfp);
        }
+       syslog(LOG_EMERG, "%s: %s", file_citadel_config, strerror(errno));
 }