diff --git a/cmd/launcher/uninstall_linux.go b/cmd/launcher/uninstall_linux.go index 8ce9041c65..441f07dd19 100644 --- a/cmd/launcher/uninstall_linux.go +++ b/cmd/launcher/uninstall_linux.go @@ -33,19 +33,12 @@ func removeLauncher(ctx context.Context, identifier string) error { fmt.Printf("error occurred while stopping/disabling launcher service, systemctl output %s: err: %s\n", string(out), err) } - fileExists := func(f string) bool { - if _, err := os.Stat(f); err == nil { - return true - } - return false - } - // Tell the appropriate package manager to remove launcher - if cmd, err := allowedpaths.CommandContextWithLookup("dpkg", []string{"--purge", packageName}...); err == nil { + if cmd, err := allowedpaths.CommandContextWithLookup(ctx, "dpkg", []string{"--purge", packageName}...); err == nil { if out, err := cmd.CombinedOutput(); err != nil { fmt.Printf("error occurred while running dpkg --purge, output %s: err: %s\n", string(out), err) } - } else if cmd, err := allowedpaths.CommandContextWithLookup("rpm", []string{"-e", packageName}...); err == nil { + } else if cmd, err := allowedpaths.CommandContextWithLookup(ctx, "rpm", []string{"-e", packageName}...); err == nil { if out, err := cmd.CombinedOutput(); err != nil { fmt.Printf("error occurred while running rpm -e, output %s: err: %s\n", string(out), err) } diff --git a/ee/desktop/user/notify/notify_linux.go b/ee/desktop/user/notify/notify_linux.go index 50cf88c4d3..f6af230a9b 100644 --- a/ee/desktop/user/notify/notify_linux.go +++ b/ee/desktop/user/notify/notify_linux.go @@ -12,6 +12,7 @@ import ( "github.com/go-kit/kit/log" "github.com/go-kit/kit/log/level" "github.com/godbus/dbus/v5" + "github.com/kolide/launcher/pkg/allowedpaths" ) type dbusNotifier struct { @@ -180,7 +181,7 @@ func (d *dbusNotifier) sendNotificationViaNotifySend(n Notification) error { args = append(args, "-i", d.iconFilepath) } - cmd, err := allowedpaths.Command("notify-send", args...) + cmd, err := allowedpaths.CommandContextWithLookup("notify-send", args...) if err != nil { return fmt.Errorf("creating command: %w", err) } diff --git a/pkg/allowedpaths/cmd_linux.go b/pkg/allowedpaths/cmd_linux.go index a253d6ffda..5c13190a3c 100644 --- a/pkg/allowedpaths/cmd_linux.go +++ b/pkg/allowedpaths/cmd_linux.go @@ -6,7 +6,7 @@ package allowedpaths var knownPaths = map[string]map[string]bool{ "cryptsetup": { "/usr/sbin/cryptsetup": true, - "/sbin/cryptsetup", true + "/sbin/cryptsetup": true, }, "dpkg": { "/usr/bin/dpkg": true, @@ -64,7 +64,7 @@ var knownPaths = map[string]map[string]bool{ }, "zpool": { "/usr/sbin/zpool": true, - } + }, } var knownPathPrefixes = []string{ diff --git a/pkg/execwrapper/exec_windows.go b/pkg/execwrapper/exec_windows.go index a6916866fb..72d980baf0 100644 --- a/pkg/execwrapper/exec_windows.go +++ b/pkg/execwrapper/exec_windows.go @@ -37,7 +37,7 @@ func Exec(ctx context.Context, argv0 string, argv []string, envv []string) error // Now run it. This is faking exec, we need to distinguish // between a failure to execute, and a failure in in the called program. // I think https://github.com/golang/go/issues/26539 adds this functionality. - err := cmd.Run() + err = cmd.Run() if cmd.ProcessState.ExitCode() == -1 { if err == nil {