Abort startup if run as root

This commit is contained in:
Christian Burkert 2023-01-23 00:00:00 +01:00
parent 3e6669828c
commit 4358ac628d
1 changed files with 5 additions and 0 deletions

View File

@ -14,6 +14,7 @@ import (
"fmt"
"os"
"strings"
"syscall"
"github.com/gorilla/mux"
"github.com/urfave/cli/v2"
@ -22,6 +23,10 @@ import (
)
func main() {
if syscall.Getuid() == 0 {
log.Error("Running as root is insecure. Use setcap for privileged resource access")
os.Exit(1)
}
cli.VersionPrinter = func(c *cli.Context) {
fmt.Printf("%s\n", c.App.Version)
}