argument to change uid/gid

This commit is contained in:
cathugger 2022-07-11 19:35:01 +03:00 committed by Neil
parent 9950d1225d
commit 7cd0f6b791
3 changed files with 92 additions and 0 deletions

View file

@ -52,6 +52,7 @@ func main() {
getsnet := flag.Bool("subnet", false, "use in combination with either -useconf or -useconffile, outputs your IPv6 subnet")
getpkey := flag.Bool("publickey", false, "use in combination with either -useconf or -useconffile, outputs your public key")
loglevel := flag.String("loglevel", "info", "loglevel to enable")
chuserto := flag.String("user", "", "user (and, optionally, group) to set UID/GID to")
flag.Parse()
done := make(chan struct{})
@ -280,6 +281,14 @@ func main() {
<-done
})
// Change user if requested
if *chuserto != "" {
err = chuser(*chuserto)
if err != nil {
panic(err)
}
}
// Block until we are told to shut down.
<-ctx.Done()