]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
login-utils: Use /etc/passwd- as backup file
authorTobias Stoeckmann <tobias@stoeckmann.org>
Tue, 6 Jan 2026 17:20:33 +0000 (18:20 +0100)
committerTobias Stoeckmann <tobias@stoeckmann.org>
Wed, 7 Jan 2026 16:11:47 +0000 (17:11 +0100)
The name /etc/passwd- is used as backup file by shadow and systemd.

Let's join the group and use /etc/passwd- instead of /etc/passwd.OLD as
well. One backup file on a system is enough.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
login-utils/setpwnam.c
login-utils/vipw.c

index 55fb174d0d0a4aef439b9d4e0621bcf5e73ac95d..e48e4cedc0595cb9f5f48b96f18909fb35c942a2 100644 (file)
@@ -138,9 +138,9 @@ int setpwnam(struct passwd *pwd, const char *prefix)
        }
 
        /* we don't care if we can't remove the backup file */
-       unlink(PASSWD_FILE ".OLD");
+       unlink(PASSWD_FILE "-");
        /* we don't care if we can't create the backup file */
-       ignore_result(link(PASSWD_FILE, PASSWD_FILE ".OLD"));
+       ignore_result(link(PASSWD_FILE, PASSWD_FILE "-"));
        /* we DO care if we can't rename to the passwd file */
        if (rename(tmpname, PASSWD_FILE) < 0)
                goto fail;
index 5d8644c8234d221460172d80c24be20cb4ad6cb6..30a4e17011781c684d28168a8e003aeca445f39f 100644 (file)
@@ -145,7 +145,7 @@ static void pw_write(void)
 {
        char tmp[FILENAMELEN + 4];
 
-       snprintf(tmp, sizeof(tmp), "%s%s", orig_file, ".OLD");
+       snprintf(tmp, sizeof(tmp), "%s%s", orig_file, "-");
        unlink(tmp);
 
        if (link(orig_file, tmp))