Ported hivectl
This commit is contained in:
11
cli/cli.go
11
cli/cli.go
@@ -24,3 +24,14 @@ func Printf (format string, values ...any) {
|
||||
func ServiceUser (service string) string {
|
||||
return "hn-" + strings.ToLower(service)
|
||||
}
|
||||
|
||||
// NeedRoot halts the program and displays an error if it is not being run as
|
||||
// root. This should be called whenever an operation takes place that requires
|
||||
// root privelages.
|
||||
func NeedRoot() {
|
||||
uid := os.Getuid()
|
||||
if uid != 0 {
|
||||
Sayf("this utility must be run as root")
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user