Skip to content

Commit

Permalink
Enable sandboxing by default
Browse files Browse the repository at this point in the history
Closes #179.
  • Loading branch information
edolstra committed Nov 7, 2018
1 parent 5a3f140 commit 812e393
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 10 deletions.
1 change: 1 addition & 0 deletions doc/manual/release-notes/release-notes.xml
Expand Up @@ -12,6 +12,7 @@
</partintro> </partintro>
--> -->


<xi:include href="rl-2.3.xml" />
<xi:include href="rl-2.2.xml" /> <xi:include href="rl-2.2.xml" />
<xi:include href="rl-2.1.xml" /> <xi:include href="rl-2.1.xml" />
<xi:include href="rl-2.0.xml" /> <xi:include href="rl-2.0.xml" />
Expand Down
19 changes: 19 additions & 0 deletions doc/manual/release-notes/rl-2.3.xml
@@ -0,0 +1,19 @@
<section xmlns="http://docbook.org/ns/docbook"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:xi="http://www.w3.org/2001/XInclude"
version="5.0"
xml:id="ssec-relnotes-2.3">

<title>Release 2.3 (2019-??-??)</title>

<para>This release has the following changes:</para>

<itemizedlist>

<listitem>
<para>Sandbox builds are now enabled by default on Linux.</para>
</listitem>

</itemizedlist>

</section>
8 changes: 7 additions & 1 deletion src/libstore/globals.hh
Expand Up @@ -195,7 +195,13 @@ public:
Setting<bool> showTrace{this, false, "show-trace", Setting<bool> showTrace{this, false, "show-trace",
"Whether to show a stack trace on evaluation errors."}; "Whether to show a stack trace on evaluation errors."};


Setting<SandboxMode> sandboxMode{this, smDisabled, "sandbox", Setting<SandboxMode> sandboxMode{this,
#if __linux__
smEnabled
#else
smDisabled
#endif
, "sandbox",
"Whether to enable sandboxed builds. Can be \"true\", \"false\" or \"relaxed\".", "Whether to enable sandboxed builds. Can be \"true\", \"false\" or \"relaxed\".",
{"build-use-chroot", "build-use-sandbox"}}; {"build-use-chroot", "build-use-sandbox"}};


Expand Down
15 changes: 6 additions & 9 deletions tests/common.sh.in
Expand Up @@ -85,16 +85,13 @@ killDaemon() {
trap "" EXIT trap "" EXIT
} }


canUseSandbox() { if [[ $(uname) == Linux ]] && [[ -L /proc/self/ns/user ]] && unshare --user true; then
if [[ $(uname) != Linux ]]; then return 1; fi _canUseSandbox=1

fi
if [ ! -L /proc/self/ns/user ]; then
echo "Kernel doesn't support user namespaces, skipping this test..."
return 1
fi


if ! unshare --user true ; then canUseSandbox() {
echo "Unprivileged user namespaces disabled by sysctl, skipping this test..." if [[ ! $_canUseSandbox ]]; then
echo "Sandboxing not supported, skipping this test..."
return 1 return 1
fi fi


Expand Down
1 change: 1 addition & 0 deletions tests/init.sh
Expand Up @@ -16,6 +16,7 @@ mkdir "$NIX_CONF_DIR"
cat > "$NIX_CONF_DIR"/nix.conf <<EOF cat > "$NIX_CONF_DIR"/nix.conf <<EOF
build-users-group = build-users-group =
keep-derivations = false keep-derivations = false
sandbox = false
include nix.conf.extra include nix.conf.extra
EOF EOF


Expand Down

1 comment on commit 812e393

@copumpkin
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Holy shit!

Now I'm extra motivated to take that conditional out πŸ˜„

Please sign in to comment.