//go:build !windows package platform import ( "os" "os/exec" "runtime" "strings" ) // IsElevated reports whether the process is running as root. func IsElevated() bool { return os.Geteuid() == 0 } // ConsoleUser returns the user logged in at the macOS GUI console. Homebrew // refuses to run as root, so a root-context run (RMM, MDM) has to drop to this // user to touch brew. Returns "" when there is no console user or on Linux. func ConsoleUser() string { if runtime.GOOS != "darwin" { return "" } out, err := exec.Command("/usr/bin/stat", "-f", "%Su", "/dev/console").Output() if err != nil { return "" } u := strings.TrimSpace(string(out)) if u == "" || u == "root" { return "" } return u } // PrivilegeHint explains how to obtain the rights deployr needs. func PrivilegeHint() string { return "re-run deployr with sudo, or configure passwordless sudo for the account your RMM uses" }