forked from joshuar/go-hass-agent
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
30 lines (25 loc) · 733 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// Copyright (c) 2024 Joshua Rich <[email protected]>
//
// 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()
}