firstboot: Don't skip passwd/shadow logic if only one of the files exists

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.
This commit is contained in:
Daan De Meyer 2022-07-05 14:53:45 +02:00 committed by Lennart Poettering
parent e386a6d69b
commit 87a3a4a802

View 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))