sanebox: don't assume 'readlink' is available in the environment

This commit is contained in:
2024-08-05 22:56:18 +00:00
parent d1b4e9c923
commit 566e15286b
2 changed files with 4 additions and 1 deletions

View File

@@ -31,6 +31,7 @@ stdenv.mkDerivation {
--replace-fail '@iptables@' '${lib.getExe' iptables "iptables"}' \
--replace-fail '@landlockSandboxer@' '${lib.getExe landlock-sandboxer}' \
--replace-fail '@pasta@' '${lib.getExe' passt "pasta"}' \
--replace-fail '@readlink@' '${lib.getExe' coreutils "readlink"}' \
runHook postBuild
'';

View File

@@ -9,6 +9,7 @@ IP_FALLBACK='@ip@'
IPTABLES_FALLBACK='@iptables@'
LANDLOCK_SANDBOXER_FALLBACK='@landlockSandboxer@'
PASTA_FALLBACK='@pasta@'
READLINK_FALLBACK='@readlink@'
## EARLY DEBUG HOOKS
@@ -316,7 +317,8 @@ readlinkOnce() {
linkTarget=${linkCache[$path]}
elif [ -L "$path" ]; then
# path is a link, but not in the cache
linkTarget=$(readlink "$path")
locate _readlink "readlink" "$READLINK_FALLBACK"
linkTarget=$("$_readlink" "$path")
# insert it into the cache, in case we traverse it again
linkCache[$path]=$linkTarget
else