- /* create config.USER, to end up with mode 400 user:<anything> */
- if((fd = open(t, O_WRONLY|O_CREAT|O_EXCL, 0600)) < 0)
- fatal(errno, "error creating %s", t);
- if(fchown(fd, pw->pw_uid, -1) < 0)
- fatal(errno, "error chowning %s", t);
- if(fchmod(fd, 0400) < 0)
- fatal(errno, "error chmoding %s", t);
+ /* Make sure the configuration file does not exist */
+ byte_xasprintf(&configpath, "%s/passwd", configdir);
+ if(lstat(configpath, &sb) == 0)
+ disorder_fatal(0, "%s already exists", configpath);
+ if(errno != ENOENT)
+ disorder_fatal(errno, " checking %s", configpath);
+
+ byte_xasprintf(&configpathtmp, "%s.new", configpath);
+
+ /* Create config file with mode 600 */
+ if((fd = open(configpathtmp, O_WRONLY|O_CREAT, 0600)) < 0)
+ disorder_fatal(errno, "error creating %s", configpathtmp);
+
+ /* Write password */