diff options
Diffstat (limited to 'tests/nixos/no-new-privileges')
-rw-r--r-- | tests/nixos/no-new-privileges/no-sandbox.nix | 21 | ||||
-rw-r--r-- | tests/nixos/no-new-privileges/package.nix | 8 | ||||
-rw-r--r-- | tests/nixos/no-new-privileges/sandbox.nix | 18 |
3 files changed, 47 insertions, 0 deletions
diff --git a/tests/nixos/no-new-privileges/no-sandbox.nix b/tests/nixos/no-new-privileges/no-sandbox.nix new file mode 100644 index 000000000..d952a6862 --- /dev/null +++ b/tests/nixos/no-new-privileges/no-sandbox.nix @@ -0,0 +1,21 @@ +let + inherit (import ../util.nix) mkNixBuildTest; +in +mkNixBuildTest { + name = "no-new-privileges-outside-sandbox"; + extraMachineConfig = + { pkgs, ... }: + { + security.wrappers.ohno = { + owner = "root"; + group = "root"; + capabilities = "cap_sys_nice=eip"; + source = "${pkgs.libcap}/bin/getpcaps"; + }; + nix.settings = { + extra-sandbox-paths = [ "/run/wrappers/bin/ohno" ]; + sandbox = false; + }; + }; + expressionFile = ./package.nix; +} diff --git a/tests/nixos/no-new-privileges/package.nix b/tests/nixos/no-new-privileges/package.nix new file mode 100644 index 000000000..55c96bc2e --- /dev/null +++ b/tests/nixos/no-new-privileges/package.nix @@ -0,0 +1,8 @@ +{ runCommand, libcap }: +runCommand "cant-get-capabilities" { nativeBuildInputs = [ libcap.out ]; } '' + if [ "$(/run/wrappers/bin/ohno 2>&1)" != "failed to inherit capabilities: Operation not permitted" ]; then + echo "Oh no! We gained capabilities!" + exit 1 + fi + touch $out +'' diff --git a/tests/nixos/no-new-privileges/sandbox.nix b/tests/nixos/no-new-privileges/sandbox.nix new file mode 100644 index 000000000..e2475555e --- /dev/null +++ b/tests/nixos/no-new-privileges/sandbox.nix @@ -0,0 +1,18 @@ +let + inherit (import ../util.nix) mkNixBuildTest; +in +mkNixBuildTest { + name = "no-new-privileges-in-sandbox"; + extraMachineConfig = + { pkgs, ... }: + { + security.wrappers.ohno = { + owner = "root"; + group = "root"; + capabilities = "cap_sys_nice=eip"; + source = "${pkgs.libcap}/bin/getpcaps"; + }; + nix.settings.extra-sandbox-paths = [ "/run/wrappers/bin/ohno" ]; + }; + expressionFile = ./package.nix; +} |