MCPcopy Create free account
hub / github.com/PatchMon/PatchMon / checkRoot

Function checkRoot

agent-source-code/cmd/patchmon-agent/commands/root.go:132–141  ·  view source on GitHub ↗

checkRoot ensures the command is run as root (Unix) or Administrator (Windows)

()

Source from the content-addressed store, hash-verified

130
131// checkRoot ensures the command is run as root (Unix) or Administrator (Windows)
132func checkRoot() error {
133 if runtime.GOOS == "windows" {
134 // On Windows, admin check is done at install time; agent runs as Administrator
135 return nil
136 }
137 if os.Geteuid() != 0 {
138 return fmt.Errorf("this command requires root privileges, please run with sudo or as root user")
139 }
140 return nil
141}

Callers 5

version_update.goFile · 0.85
serve.goFile · 0.85
config.goFile · 0.85
report.goFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected