diff options
| author | Ophestra <cat@gensokyo.uk> | 2025-02-18 17:36:58 +0900 |
|---|---|---|
| committer | Ophestra <cat@gensokyo.uk> | 2025-02-18 17:39:53 +0900 |
| commit | 2c9c7fee5b42d8f32be9ff55ad92345ae62c0af7 (patch) | |
| tree | 90209f024a847576033e5fdda340fa6d3b662d74 /test.nix | |
| parent | d0400f3c81ce6d1976d9e4e527b1d342f4bc270d (diff) | |
linux: wrap fsu lookup error
Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'test.nix')
| -rw-r--r-- | test.nix | 21 |
1 files changed, 19 insertions, 2 deletions
@@ -18,7 +18,12 @@ nixosTest { skipTypeCheck = true; nodes.machine = - { lib, pkgs, ... }: + { + lib, + pkgs, + config, + ... + }: { users.users = { alice = { @@ -32,6 +37,9 @@ nixosTest { description = "Untrusted user"; password = "foobar"; uid = 1001; + + # For deny unmapped uid test: + packages = [ config.environment.fortify.package ]; }; }; @@ -284,7 +292,16 @@ nixosTest { machine.wait_for_file("/tmp/sway-ipc.sock") # Deny unmapped uid: - print(machine.fail("sudo -u untrusted -i ${self.packages.${system}.fortify}/bin/fortify -v run")) + denyOutput = machine.fail("sudo -u untrusted -i fortify run &>/dev/stdout") + print(denyOutput) + denyOutputVerbose = machine.fail("sudo -u untrusted -i fortify -v run &>/dev/stdout") + print(denyOutputVerbose) + + # Verify PrintBaseError behaviour: + if denyOutput != "fsu: uid 1001 is not in the fsurc file\n": + raise Exception(f"unexpected deny output:\n{denyOutput}") + if denyOutputVerbose != "fsu: uid 1001 is not in the fsurc file\nfortify: *cannot obtain uid from fsu: permission denied\n": + raise Exception(f"unexpected deny verbose output:\n{denyOutputVerbose}") # Start fortify permissive defaults outside Wayland session: print(machine.succeed("sudo -u alice -i fortify -v run -a 0 touch /tmp/success-bare")) |
