Skip to content

Commit f065a81

Browse files
nixos/systemd-stage-1: Use chroot-realpath
1 parent ec02a76 commit f065a81

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

nixos/modules/system/boot/systemd/initrd.nix

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,9 @@ in {
482482

483483
# so NSS can look up usernames
484484
"${pkgs.glibc}/lib/libnss_files.so.2"
485+
486+
# Resolving sysroot symlinks without code exec
487+
"${pkgs.chroot-realpath}/bin/chroot-realpath"
485488
] ++ optionals cfg.package.withCryptsetup [
486489
# fido2 support
487490
"${cfg.package}/lib/cryptsetup/libcryptsetup-token-systemd-fido2.so"
@@ -522,7 +525,7 @@ in {
522525

523526
script = /* bash */ ''
524527
set -uo pipefail
525-
export PATH="/bin:${cfg.package.util-linux}/bin"
528+
export PATH="/bin:${cfg.package.util-linux}/bin:${pkgs.chroot-realpath}/bin"
526529
527530
# Figure out what closure to boot
528531
closure=
@@ -543,7 +546,7 @@ in {
543546
544547
# Resolve symlinks in the init parameter. We need this for some boot loaders
545548
# (e.g. boot.loader.generationsDir).
546-
closure="$(chroot /sysroot ${pkgs.coreutils}/bin/realpath "$closure")"
549+
closure="$(chroot-realpath /sysroot "$closure")"
547550
548551
# Assume the directory containing the init script is the closure.
549552
closure="$(dirname "$closure")"

nixos/modules/system/etc/etc-activation.nix

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,10 +139,10 @@
139139
140140
closure="$(realpath /nixos-closure)"
141141
142-
metadata_image="$(chroot /sysroot ${lib.getExe' pkgs.coreutils "realpath"} "$closure/etc-metadata-image")"
142+
metadata_image="$(${pkgs.chroot-realpath}/bin/chroot-realpath /sysroot "$closure/etc-metadata-image")"
143143
ln -s "/sysroot$metadata_image" /etc-metadata-image
144144
145-
basedir="$(chroot /sysroot ${lib.getExe' pkgs.coreutils "realpath"} "$closure/etc-basedir")"
145+
basedir="$(${pkgs.chroot-realpath}/bin/chroot-realpath /sysroot "$closure/etc-basedir")"
146146
ln -s "/sysroot$basedir" /etc-basedir
147147
'';
148148
};

0 commit comments

Comments
 (0)