-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Test nested sandboxing, and make nicer error #8696
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
source common.sh | ||
# This test is run by `tests/nested-sandboxing/runner.nix` in an extra layer of sandboxing. | ||
[[ -d /nix/store ]] || skipTest "running this test without Nix's deps being drawn from /nix/store is not yet supported" | ||
|
||
requireSandboxSupport | ||
|
||
source ./nested-sandboxing/command.sh | ||
|
||
expectStderr 100 runNixBuild badStoreUrl 2 | grepQuiet '`sandbox-build-dir` must not contain' | ||
|
||
runNixBuild goodStoreUrl 5 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
export NIX_BIN_DIR=$(dirname $(type -p nix)) | ||
# TODO Get Nix and its closure more flexibly | ||
export EXTRA_SANDBOX="/nix/store $(dirname $NIX_BIN_DIR)" | ||
|
||
badStoreUrl () { | ||
local altitude=$1 | ||
echo $TEST_ROOT/store-$altitude | ||
} | ||
|
||
goodStoreUrl () { | ||
local altitude=$1 | ||
echo $("badStoreUrl" "$altitude")?store=/foo-$altitude | ||
} | ||
|
||
# The non-standard sandbox-build-dir helps ensure that we get the same behavior | ||
# whether this test is being run in a derivation as part of the nix build or | ||
# being manually run by a developer outside a derivation | ||
runNixBuild () { | ||
local storeFun=$1 | ||
local altitude=$2 | ||
nix-build \ | ||
--no-substitute --no-out-link \ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OT: nix should detect that it's in the non-FOD sandbox and turn these things off by itself. |
||
--store "$("$storeFun" "$altitude")" \ | ||
--extra-sandbox-paths "$EXTRA_SANDBOX" \ | ||
./nested-sandboxing/runner.nix \ | ||
--arg altitude "$((altitude - 1))" \ | ||
--argstr storeFun "$storeFun" \ | ||
--sandbox-build-dir /build-non-standard | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ altitude, storeFun }: | ||
|
||
with import ../config.nix; | ||
|
||
mkDerivation { | ||
name = "nested-sandboxing"; | ||
busybox = builtins.getEnv "busybox"; | ||
EXTRA_SANDBOX = builtins.getEnv "EXTRA_SANDBOX"; | ||
buildCommand = if altitude == 0 then '' | ||
echo Deep enough! > $out | ||
'' else '' | ||
cp -r ${../common} ./common | ||
cp ${../common.sh} ./common.sh | ||
cp ${../config.nix} ./config.nix | ||
cp -r ${./.} ./nested-sandboxing | ||
|
||
export PATH=${builtins.getEnv "NIX_BIN_DIR"}:$PATH | ||
|
||
source common.sh | ||
source ./nested-sandboxing/command.sh | ||
|
||
runNixBuild ${storeFun} ${toString altitude} >> $out | ||
''; | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.