]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
firstboot: Don't skip passwd/shadow logic if only one of the files exists
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Tue, 5 Jul 2022 12:53:45 +0000 (14:53 +0200)
committerLennart Poettering <lennart@poettering.net>
Tue, 5 Jul 2022 15:09:16 +0000 (17:09 +0200)
If one of the files exists but not the other one, we want to make sure
we create the other file to make sure the passwd database is in a valid
state.

src/firstboot/firstboot.c

index 39160182ef5a7681e4a27e4c003c0e9dd6a4c209..0716914b26f38bc9ddca8fa43748330f0a6fc1e5 100644 (file)
@@ -871,11 +871,9 @@ static int process_root_args(void) {
         etc_passwd = prefix_roota(arg_root, "/etc/passwd");
         etc_shadow = prefix_roota(arg_root, "/etc/shadow");
 
-        /* We only mess with passwd and shadow if both do not exist or --force is specified. These files are
-         * tightly coupled and hence we make sure we have permission from the user to create/modify both
-         * files. */
-        if ((laccess(etc_passwd, F_OK) >= 0 || laccess(etc_shadow, F_OK) >= 0) && !arg_force)
+        if (laccess(etc_passwd, F_OK) >= 0 && laccess(etc_shadow, F_OK) >= 0 && !arg_force)
                 return 0;
+
         /* Don't create/modify passwd and shadow if not asked */
         if (!(arg_root_password || arg_prompt_root_password || arg_copy_root_password || arg_delete_root_password ||
               arg_root_shell || arg_prompt_root_shell || arg_copy_root_shell))