Remove which in builtin passwd combinator

This remove the requirement on `which` binary when running any jail.
This was preventing jailed apps from running within nix sandbox without
manually specifying `pkgs.which` as a build input.
This commit is contained in:
Alex David 2025-07-17 20:22:17 -07:00
commit 921b443cc9

View file

@ -55,9 +55,10 @@ in {
(add-runtime ''
if [ ! -e ${helpers.dataDirSubPath "passwd"} ] || [ ! -e ${helpers.dataDirSubPath "group"} ]; then
NOLOGIN=${pkgs.shadow}/bin/nologin
mkdir -p ${helpers.dataDir}
echo "root:x:0:0:System administrator:/root:$(which nologin)" > ${helpers.dataDirSubPath "passwd"}
echo "$(id -un):x:$(id -u):$(id -g)::$HOME:$(which nologin)" >> ${helpers.dataDirSubPath "passwd"}
echo "root:x:0:0:System administrator:/root:$NOLOGIN" > ${helpers.dataDirSubPath "passwd"}
echo "$(id -un):x:$(id -u):$(id -g)::$HOME:$NOLOGIN" >> ${helpers.dataDirSubPath "passwd"}
echo "root:x:0:" > ${helpers.dataDirSubPath "group"}
echo "$(id -gn):x:$(id -g):" >> ${helpers.dataDirSubPath "group"}
fi