+2012-05-18 Nicolas François <nicolas.francois@centraliens.net>
+
+ * src/useradd.c: Keep the default file as much as possible to
+ avoid issue in case of crash. Use link instead of rename.
+
2012-05-18 Peter Vrabec <pvrabec@redhat.com>
* lib/commonio.c: Fix labeling of /etc/{passwd,shadow,group,gshadow}.
*/
wlen = snprintf (buf, sizeof buf, "%s-", USER_DEFAULTS_FILE);
assert (wlen < (int) sizeof buf);
- if ((rename (USER_DEFAULTS_FILE, buf) != 0) && (ENOENT != errno)) {
+ unlink (buf);
+ if ((link (USER_DEFAULTS_FILE, buf) != 0) && (ENOENT != errno)) {
int err = errno;
fprintf (stderr,
- _("%s: rename: %s: %s\n"),
- Prog, USER_DEFAULTS_FILE, strerror (err));
+ _("%s: Cannot create backup file (%s): %s\n"),
+ Prog, buf, strerror (err));
unlink (new_file);
return -1;
}