Skip to content
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

nixos/wrappers: add per-wrapper enable option #376196

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion nixos/modules/security/wrappers/default.nix
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
{ config, lib, pkgs, ... }:
let

inherit (config.security) wrapperDir wrappers;
inherit (config.security) wrapperDir;

wrappers = lib.filterAttrs (name: value: value.enable) config.security.wrappers;

parentWrapperDir = dirOf wrapperDir;

Expand Down Expand Up @@ -41,6 +43,11 @@ let
// { description = "file mode string"; };

wrapperType = lib.types.submodule ({ name, config, ... }: {
options.enable = lib.mkOption
{ type = lib.types.bool;
default = true;
description = "Whether to enable the wrapper.";
};
options.source = lib.mkOption
{ type = lib.types.path;
description = "The absolute path to the program to be wrapped.";
Expand Down
11 changes: 11 additions & 0 deletions nixos/tests/wrappers.nix
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@ import ./make-test-python.nix (
security.apparmor.enable = true;

security.wrappers = {
disabled = {
enable = false;
owner = "root";
group = "root";
setuid = true;
source = "${busybox pkgs}/bin/busybox";
program = "disabled_busybox";
};
suidRoot = {
owner = "root";
group = "root";
Expand Down Expand Up @@ -112,6 +120,9 @@ import ./make-test-python.nix (
# actually makes the apparmor policy for ping, but there's no convenient
# test for that one.
machine.succeed("ping -c 1 127.0.0.1")

# Test that the disabled wrapper is not present.
machine.fail("test -e /run/wrappers/bin/disabled_busybox")
'';
}
)