- /* append to config.private. We might create it along the way (though this
- * is unlikely) in which case it had better be 640 root:jukebox */
- if(!(c = config_private()))
- fatal(0, "cannot determine private config file");
- if((fd = open(c, O_WRONLY|O_APPEND|O_CREAT, 0600)) < 0)
- fatal(errno, "error opening %s", c);
- if(fchown(fd, 0, jbgid) < 0)
- fatal(errno, "error chowning %s", c);
- if(fchmod(fd, 0640) < 0)
- fatal(errno, "error chmoding %s", t);
- if(!(fp = fdopen(fd, "a")))
- fatal(errno, "error calling fdopen");
- if(fprintf(fp, "allow %s %s\n", user, pwhex) < 0
- || fclose(fp) < 0)
- fatal(errno, "error appending to %s", c);
+ /* Rename config file into place */
+ if(rename(configpathtmp, configpath) < 0)
+ fatal(errno, "error renaming %s to %s", configpathtmp, configpath);
+
+ /* Put our identity back */
+ if(seteuid(old_uid) < 0)
+ fatal(errno, "seteuid %lu", (unsigned long)old_uid);
+ if(setegid(old_gid) < 0)
+ fatal(errno, "setegid %lu", (unsigned long)old_gid);
+