summaryrefslogtreecommitdiffstats
path: root/nixos
diff options
context:
space:
mode:
authorLinus Heckemann <git@sphalerite.org>2018-10-31 15:59:18 +0100
committerLinus Heckemann <git@sphalerite.org>2018-10-31 15:59:18 +0100
commit817369d4c1c5abaf792827a4770e513e115f8644 (patch)
treee4bc0cee54552e53fcdc1c192e62594a09482550 /nixos
parent42cfc436ceae4861a6ef6737bab500ad0e82677b (diff)
nixos stage-1: fix init existence test
The previous version contained a false positive case, where boot would continue when the stage 2 init did not exist at all, and a false negative case, where boot would stop if the stage 2 init was a symlink which cannot be resolved in the initramfs root. Fixes #49519. Thanks @michas2 for finding and reporting the issue!
Diffstat (limited to 'nixos')
-rw-r--r--nixos/modules/system/boot/stage-1-init.sh2
1 files changed, 1 insertions, 1 deletions
diff --git a/nixos/modules/system/boot/stage-1-init.sh b/nixos/modules/system/boot/stage-1-init.sh
index 3bc33a20a09f..2f9c53efbe1f 100644
--- a/nixos/modules/system/boot/stage-1-init.sh
+++ b/nixos/modules/system/boot/stage-1-init.sh
@@ -554,7 +554,7 @@ echo /sbin/modprobe > /proc/sys/kernel/modprobe
# Start stage 2. `switch_root' deletes all files in the ramfs on the
# current root. Note that $stage2Init might be an absolute symlink,
# in which case "-e" won't work because we're not in the chroot yet.
-if ! test -e "$targetRoot/$stage2Init" -o ! -L "$targetRoot/$stage2Init"; then
+if [ ! -e "$targetRoot/$stage2Init" ] && [ ! -L "$targetRoot/$stage2Init" ] ; then
echo "stage 2 init script ($targetRoot/$stage2Init) not found"
fail
fi