From 0bb761698cb64014d85c0b562db72dbfe793abce Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Sat, 12 Apr 2025 11:50:08 +0200 Subject: [PATCH] profiles/apparmor: loadprofile: fix double command in error message `exec.Cmd.Path` already contains the command that was executed, so we were printing the command twice. However, `exec.Cmd` implements a stringer interface, which provides a readable version of the command that was executed, so use that instead. While updating, lso change backticks in the error for regular quotes. Before: running `/usr/sbin/apparmor_parser apparmor_parser -Kr /no/such/file` failed with output: Cache read/write disabled: interface file missing. (Kernel needs AppArmor 2.4 compatibility patch.) Warning: unable to find a suitable fs in /proc/mounts, is it mounted? Use --subdomainfs to override. error: exit status 1 After: running '/usr/sbin/apparmor_parser -Kr /no/such/file' failed with output: Cache read/write disabled: interface file missing. (Kernel needs AppArmor 2.4 compatibility patch.) Warning: unable to find a suitable fs in /proc/mounts, is it mounted? Use --subdomainfs to override. error: exit status 1 Signed-off-by: Sebastiaan van Stijn --- profiles/apparmor/apparmor.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/profiles/apparmor/apparmor.go b/profiles/apparmor/apparmor.go index 97b0145b1e..36fb759003 100644 --- a/profiles/apparmor/apparmor.go +++ b/profiles/apparmor/apparmor.go @@ -130,9 +130,8 @@ func loadProfile(profilePath string) error { c := exec.Command("apparmor_parser", "-Kr", profilePath) c.Dir = "" - output, err := c.CombinedOutput() - if err != nil { - return fmt.Errorf("running `%s %s` failed with output: %s\nerror: %v", c.Path, strings.Join(c.Args, " "), output, err) + if output, err := c.CombinedOutput(); err != nil { + return fmt.Errorf("running '%s' failed with output: %s\nerror: %v", c, output, err) } return nil