mirror of
https://github.com/fleetdm/fleet
synced 2026-04-21 21:47:20 +00:00
Adding telemetry for catching issue #19172 # Docs changes In another PR: https://github.com/fleetdm/fleet/pull/23423/files # Demo <div> <a href="https://www.loom.com/share/233625875eec46508c26ae315cd52d19"> <p>[Demo] Add telemetry for vital fleetd errors - Issue #23413 - Watch Video</p> </a> <a href="https://www.loom.com/share/233625875eec46508c26ae315cd52d19"> <img style="max-width:300px;" src="https://cdn.loom.com/sessions/thumbnails/233625875eec46508c26ae315cd52d19-45ca0ec1b7b5e9e7-full-play.gif"> </a> </div> # Checklist for submitter - [x] Changes file added for user-visible changes in `changes/`, `orbit/changes/` or `ee/fleetd-chrome/changes`. See [Changes files](https://github.com/fleetdm/fleet/blob/main/docs/Contributing/Committing-Changes.md#changes-files) for more information. - [x] Added/updated tests - [x] Manual QA for all new/changed functionality - For Orbit and Fleet Desktop changes: - [x] Orbit runs on macOS, Linux and Windows. Check if the orbit feature/bugfix should only apply to one platform (`runtime.GOOS`). - [x] Manual QA must be performed in the three main OSs, macOS, Windows and Linux. - [x] Auto-update manual QA, from released version of component to new version (see [tools/tuf/test](../tools/tuf/test/README.md)).
49 lines
1.1 KiB
Go
49 lines
1.1 KiB
Go
package execuser
|
|
|
|
import (
|
|
"fmt"
|
|
"io"
|
|
"os"
|
|
"os/exec"
|
|
)
|
|
|
|
// run uses macOS open command to start application as the current login user.
|
|
func run(path string, opts eopts) (lastLogs string, err error) {
|
|
info, err := os.Stat(path)
|
|
if err != nil {
|
|
return "", fmt.Errorf("stat path %q: %w", path, err)
|
|
}
|
|
|
|
if !info.IsDir() {
|
|
return "", fmt.Errorf("path is not an .app directory: %s", path)
|
|
}
|
|
var arg []string
|
|
if opts.stderrPath != "" {
|
|
arg = append(arg, "--stderr", opts.stderrPath)
|
|
}
|
|
|
|
// set environment variables
|
|
for _, nv := range opts.env {
|
|
arg = append(arg, "--env", fmt.Sprintf("%s=%s", nv[0], nv[1]))
|
|
}
|
|
|
|
// set the path to be executed
|
|
arg = append(arg, path)
|
|
|
|
// set the program arguments
|
|
if len(opts.args) > 0 {
|
|
arg = append(arg, "--args")
|
|
for _, nv := range opts.args {
|
|
arg = append(arg, nv[0], nv[1])
|
|
}
|
|
}
|
|
|
|
cmd := exec.Command("/usr/bin/open", arg...)
|
|
tw := &TransientWriter{}
|
|
cmd.Stderr = io.MultiWriter(tw, os.Stderr)
|
|
cmd.Stdout = io.MultiWriter(tw, os.Stdout)
|
|
if err := cmd.Run(); err != nil {
|
|
return tw.String(), fmt.Errorf("open path %q: %w", path, err)
|
|
}
|
|
return tw.String(), nil
|
|
}
|