mirror of
https://github.com/empayre/fleet.git
synced 2024-11-06 17:05:18 +00:00
c82c580716
* Orbit: Add Fleet Desktop support to Windows * Rename workflow, fix linux build * Do not compile systray on linux * nolint on unused * Fix lint properly * nolint both checkers * Fix monitor logic in desktopRunner * Fix interrupt and execute order
31 lines
829 B
Go
31 lines
829 B
Go
// Package execuser is used to run applications from a high privilege user (root on Unix,
|
|
// SYSTEM service on Windows) as the current login user.
|
|
package execuser
|
|
|
|
type eopts struct {
|
|
env [][2]string
|
|
stderrPath string //nolint:structcheck,unused
|
|
}
|
|
|
|
// Option allows configuring the application.
|
|
type Option func(*eopts)
|
|
|
|
// WithEnv sets environment variables for the application.
|
|
func WithEnv(name, value string) Option {
|
|
return func(a *eopts) {
|
|
a.env = append(a.env, [2]string{name, value})
|
|
}
|
|
}
|
|
|
|
// Run runs an application as the current login user.
|
|
// It assumes the caller is running with high privileges (root on Unix, SYSTEM on Windows).
|
|
//
|
|
// It returns after starting the child process.
|
|
func Run(path string, opts ...Option) error {
|
|
var o eopts
|
|
for _, fn := range opts {
|
|
fn(&o)
|
|
}
|
|
return run(path, o)
|
|
}
|