From e564b5bdec2ff43a5d559596448e96b24ee4f71e Mon Sep 17 00:00:00 2001 From: Ophestra Date: Wed, 26 Feb 2025 20:10:32 +0900 Subject: [PATCH] fortify: print comp values early Signed-off-by: Ophestra --- cmd/fpkg/main.go | 4 ++++ main.go | 4 ++++ test/test.py | 5 +++-- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/cmd/fpkg/main.go b/cmd/fpkg/main.go index 8075ba1..d166b2d 100644 --- a/cmd/fpkg/main.go +++ b/cmd/fpkg/main.go @@ -62,6 +62,10 @@ func main() { if flagVerbose { seccomp.CPrintln = log.Println } + + // read comp values early to allow for early failure + fmsg.Verbosef("version %s", internal.Version()) + fmsg.Verbosef("setuid helper at %s", internal.MustFsuPath()) return nil }). Flag(&flagVerbose, "v", command.BoolFlag(false), "Print debug messages to the console"). diff --git a/main.go b/main.go index 9a47b2f..8a01db6 100644 --- a/main.go +++ b/main.go @@ -73,6 +73,10 @@ func buildCommand(out io.Writer) command.Command { if flagVerbose { seccomp.CPrintln = log.Println } + + // read comp values early to allow for early failure + fmsg.Verbosef("version %s", internal.Version()) + fmsg.Verbosef("setuid helper at %s", internal.MustFsuPath()) return nil }). Flag(&flagVerbose, "v", command.BoolFlag(false), "Print debug messages to the console"). diff --git a/test/test.py b/test/test.py index 12a7e48..1371b0f 100644 --- a/test/test.py +++ b/test/test.py @@ -83,7 +83,8 @@ machine.succeed( "fortify-fhs -c '(cd /tmp/src && go generate ./... && go test ./... && touch /tmp/success-gotest)' &> /tmp/gotest &") # To check fortify's version: -print(machine.succeed("sudo -u alice -i fortify version")) +fortifyVersion = machine.succeed("sudo -u alice -i fortify version") +print(fortifyVersion) # Wait for Sway to complete startup: machine.wait_for_file("/run/user/1000/wayland-1") @@ -101,7 +102,7 @@ print(machine.fail("sudo -u alice -i fsu")) # 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": +if denyOutputVerbose != f"fortify: version {fortifyVersion}fortify: setuid helper at /run/wrappers/bin/fsu\nfsu: 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: