From 741d011543756850397ab7453cc13c9f5210e2b5 Mon Sep 17 00:00:00 2001 From: Ophestra Date: Wed, 26 Feb 2025 17:19:36 +0900 Subject: [PATCH] fortify: configure seccomp logger early Signed-off-by: Ophestra --- main.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/main.go b/main.go index dc738e5..8df2659 100644 --- a/main.go +++ b/main.go @@ -68,7 +68,13 @@ func buildCommand(out io.Writer) command.Command { flagVerbose bool flagJSON bool ) - c := command.New(out, log.Printf, "fortify", func([]string) error { fmsg.Store(flagVerbose); return nil }). + c := command.New(out, log.Printf, "fortify", func([]string) error { + fmsg.Store(flagVerbose) + if flagVerbose { + seccomp.CPrintln = log.Println + } + return nil + }). Flag(&flagVerbose, "v", command.BoolFlag(false), "Print debug messages to the console"). Flag(&flagJSON, "json", command.BoolFlag(false), "Serialise output as JSON when applicable") @@ -285,10 +291,6 @@ func runApp(a fst.App, config *fst.Config) { syscall.SIGINT, syscall.SIGTERM) defer stop() // unreachable - if fmsg.Load() { - seccomp.CPrintln = log.Println - } - if sa, err := a.Seal(config); err != nil { fmsg.PrintBaseError(err, "cannot seal app:") internal.Exit(1)