joshuar-go-hass-agent/main.go

31 lines
733 B
Go

// Copyright (c) 2024 Joshua Rich <joshua.rich@gmail.com>
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
package main
import (
"log"
"syscall"
"github.com/joshuar/go-hass-agent/cmd"
)
func init() {
// Following is copied from https://git.kernel.org/pub/scm/libs/libcap/libcap.git/tree/goapps/web/web.go
// ensureNotEUID aborts the program if it is running setuid something,
// or being invoked by root.
euid := syscall.Geteuid()
uid := syscall.Getuid()
egid := syscall.Getegid()
gid := syscall.Getgid()
if uid != euid || gid != egid || uid == 0 {
log.Fatalf("go-hass-agent should not be run with additional privileges or as root.")
}
}
func main() {
cmd.Execute()
}