diff --git a/src/firstboot/firstboot.c b/src/firstboot/firstboot.c index f3ea57ec92..5ebaf89764 100644 --- a/src/firstboot/firstboot.c +++ b/src/firstboot/firstboot.c @@ -998,6 +998,10 @@ static int prompt_root_shell(int rfd, sd_varlink **mute_console_link) { if (r < 0) log_debug_errno(r, "Failed to read credential passwd.shell.root, ignoring: %m"); else { + r = find_shell(rfd, arg_root_shell); + if (r < 0) + return r; + log_debug("Acquired root shell from credential."); return 0; } diff --git a/test/units/TEST-74-AUX-UTILS.firstboot.sh b/test/units/TEST-74-AUX-UTILS.firstboot.sh index 8c3c222c88..4fbbb18efa 100755 --- a/test/units/TEST-74-AUX-UTILS.firstboot.sh +++ b/test/units/TEST-74-AUX-UTILS.firstboot.sh @@ -352,6 +352,11 @@ grep -q "^root::" "$ROOT/etc/shadow" rm -fv "$ROOT/etc/passwd" "$ROOT/etc/shadow" (! systemd-firstboot --root="$ROOT" --root-shell=/bin/nonexistentshell) +WCREDS="$(mktemp -d)" +printf '/bin/nonexistentshell' >"$WCREDS/passwd.shell.root" +(! CREDENTIALS_DIRECTORY="$WCREDS" systemd-firstboot --root="$ROOT") +[[ ! -e "$ROOT/etc/passwd" ]] +rm -rf "$WCREDS" (! systemd-firstboot --root="$ROOT" --machine-id=invalidmachineid) (! systemd-firstboot --root="$ROOT" --timezone=Foo/Bar)