authentricity/internal/hostagent/priv.go

16 lines
293 B
Go
Raw Permalink Normal View History

2022-07-11 22:49:26 +01:00
package hostagent
import (
"github.com/varlink/go/varlink"
"go.e43.eu/authentricity/internal/peercred"
)
func AllowPrivileged(conn varlink.ReadWriterContext, uid uint32) bool {
creds := peercred.Get(conn)
if creds == nil {
return false
}
return creds.Uid == 0 || creds.Uid == uid
}