2023-05-15 21:41:51 +00:00
|
|
|
source common.sh
|
|
|
|
|
|
|
|
requireSandboxSupport
|
|
|
|
[[ $busybox =~ busybox ]] || skipTest "no busybox"
|
|
|
|
if ! command -p -v unshare; then skipTest "Need unshare"; fi
|
|
|
|
needLocalStore "The test uses --store always so we would just be bypassing the daemon"
|
|
|
|
|
|
|
|
unshare --mount --map-root-user bash <<EOF
|
|
|
|
source common.sh
|
|
|
|
|
2023-07-13 19:23:24 +00:00
|
|
|
# Avoid store dir being inside sandbox build-dir
|
|
|
|
unset NIX_STORE_DIR
|
|
|
|
unset NIX_STATE_DIR
|
|
|
|
|
2023-05-15 21:41:51 +00:00
|
|
|
setLocalStore () {
|
|
|
|
export NIX_REMOTE=\$TEST_ROOT/\$1
|
|
|
|
mkdir -p \$NIX_REMOTE
|
|
|
|
}
|
|
|
|
|
2023-05-15 21:49:04 +00:00
|
|
|
cmd=(nix-build ./hermetic.nix --arg busybox "$busybox" --arg seed 1 --no-out-link)
|
2023-05-15 21:41:51 +00:00
|
|
|
|
|
|
|
# Fails with default setting
|
|
|
|
# TODO better error
|
|
|
|
setLocalStore store1
|
|
|
|
expectStderr 1 "\${cmd[@]}" | grepQuiet "unable to start build process"
|
|
|
|
|
2023-07-11 09:44:03 +00:00
|
|
|
# Fails with `require-drop-supplementary-groups`
|
2023-05-15 21:41:51 +00:00
|
|
|
# TODO better error
|
|
|
|
setLocalStore store2
|
2023-07-11 09:44:03 +00:00
|
|
|
NIX_CONFIG='require-drop-supplementary-groups = true' \
|
2023-05-15 21:41:51 +00:00
|
|
|
expectStderr 1 "\${cmd[@]}" | grepQuiet "unable to start build process"
|
|
|
|
|
2023-07-11 09:44:03 +00:00
|
|
|
# Works without `require-drop-supplementary-groups`
|
2023-05-15 21:41:51 +00:00
|
|
|
setLocalStore store3
|
2023-07-11 09:44:03 +00:00
|
|
|
NIX_CONFIG='require-drop-supplementary-groups = false' \
|
2023-05-15 21:41:51 +00:00
|
|
|
"\${cmd[@]}"
|
|
|
|
EOF
|