Skip to content

Commit ece0ac9

Browse files
authored
nixos/wrappers: add per-wrapper enable option (#376196)
2 parents d32f7e4 + d267ea8 commit ece0ac9

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

nixos/modules/security/wrappers/default.nix

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
{ config, lib, pkgs, ... }:
22
let
33

4-
inherit (config.security) wrapperDir wrappers;
4+
inherit (config.security) wrapperDir;
5+
6+
wrappers = lib.filterAttrs (name: value: value.enable) config.security.wrappers;
57

68
parentWrapperDir = dirOf wrapperDir;
79

@@ -41,6 +43,11 @@ let
4143
// { description = "file mode string"; };
4244

4345
wrapperType = lib.types.submodule ({ name, config, ... }: {
46+
options.enable = lib.mkOption
47+
{ type = lib.types.bool;
48+
default = true;
49+
description = "Whether to enable the wrapper.";
50+
};
4451
options.source = lib.mkOption
4552
{ type = lib.types.path;
4653
description = "The absolute path to the program to be wrapped.";

nixos/tests/wrappers.nix

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,14 @@ import ./make-test-python.nix (
2929
security.apparmor.enable = true;
3030

3131
security.wrappers = {
32+
disabled = {
33+
enable = false;
34+
owner = "root";
35+
group = "root";
36+
setuid = true;
37+
source = "${busybox pkgs}/bin/busybox";
38+
program = "disabled_busybox";
39+
};
3240
suidRoot = {
3341
owner = "root";
3442
group = "root";
@@ -112,6 +120,9 @@ import ./make-test-python.nix (
112120
# actually makes the apparmor policy for ping, but there's no convenient
113121
# test for that one.
114122
machine.succeed("ping -c 1 127.0.0.1")
123+
124+
# Test that the disabled wrapper is not present.
125+
machine.fail("test -e /run/wrappers/bin/disabled_busybox")
115126
'';
116127
}
117128
)

0 commit comments

Comments
 (0)