webhook/droppriv_unix.go
christopher-conley f108a2b38e Allow Linux setuid/setgid
This commit allows webhook to setuid/setgid when running on Linux.

Tested with:

go get -d

CGO_ENABLED=0 go build -ldflags="-s -w"

Correctly compiled, ran, setuid/setgid properly, and answered hook requests.
2023-07-22 23:01:40 -04:00

21 lines
242 B
Go

// +build linux !windows
package main
import (
"syscall"
)
func dropPrivileges(uid, gid int) error {
err := syscall.Setgid(gid)
if err != nil {
return err
}
err = syscall.Setuid(uid)
if err != nil {
return err
}
return nil
}