summary refs log tree commit diff
path: root/nixos/tests/sudo.nix
diff options
context:
space:
mode:
authorgithub-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>2021-05-09 12:23:16 +0000
committerGitHub <noreply@github.com>2021-05-09 12:23:16 +0000
commitbc1f4b790e211dc578c2655b76c525707a07bc07 (patch)
tree1c1e0569f09e82935784a6d6f43f3b85b42e4e8a /nixos/tests/sudo.nix
parent5663b2b2d385c06bffeb8514dec22d5e2838bdcb (diff)
parent2c1a792911ae079699ea8ec9860987de525e7351 (diff)
downloadnixpkgs-bc1f4b790e211dc578c2655b76c525707a07bc07.tar
nixpkgs-bc1f4b790e211dc578c2655b76c525707a07bc07.tar.gz
nixpkgs-bc1f4b790e211dc578c2655b76c525707a07bc07.tar.bz2
nixpkgs-bc1f4b790e211dc578c2655b76c525707a07bc07.tar.lz
nixpkgs-bc1f4b790e211dc578c2655b76c525707a07bc07.tar.xz
nixpkgs-bc1f4b790e211dc578c2655b76c525707a07bc07.tar.zst
nixpkgs-bc1f4b790e211dc578c2655b76c525707a07bc07.zip
Merge master into staging-next
Diffstat (limited to 'nixos/tests/sudo.nix')
-rw-r--r--nixos/tests/sudo.nix21
1 files changed, 20 insertions, 1 deletions
diff --git a/nixos/tests/sudo.nix b/nixos/tests/sudo.nix
index 2a85c490665..4885d6e17b8 100644
--- a/nixos/tests/sudo.nix
+++ b/nixos/tests/sudo.nix
@@ -10,7 +10,7 @@ in
       maintainers = [ lschuermann ];
     };
 
-    machine =
+    nodes.machine =
       { lib, ... }:
       with lib;
       {
@@ -48,6 +48,19 @@ in
         };
       };
 
+    nodes.strict = { ... }: {
+      users.users = {
+        admin = { isNormalUser = true; extraGroups = [ "wheel" ]; };
+        noadmin = { isNormalUser = true; };
+      };
+
+      security.sudo = {
+        enable = true;
+        wheelNeedsPassword = false;
+        execWheelOnly = true;
+      };
+    };
+
     testScript =
       ''
         with subtest("users in wheel group should have passwordless sudo"):
@@ -79,5 +92,11 @@ in
 
         with subtest("users in group 'barfoo' should not be able to keep their environment"):
             machine.fail("sudo -u test3 sudo -n -E -u root true")
+
+        with subtest("users in wheel should be able to run sudo despite execWheelOnly"):
+            strict.succeed('su - admin -c "sudo -u root true"')
+
+        with subtest("non-wheel users should be unable to run sudo thanks to execWheelOnly"):
+            strict.fail('su - noadmin -c "sudo --help"')
       '';
   })