in integration/utils/user.go [155:172]
func SetCredential(cmd *exec.Cmd, user *UnixUser) {
if user == nil || user.UID == os.Getuid() {
return
}
if cmd.SysProcAttr == nil {
cmd.SysProcAttr = &syscall.SysProcAttr{}
}
if cmd.SysProcAttr.Credential != nil {
// This function is intended to be used exclusively from tests, and as such we
// expect the given cmd object to not have credentials set. If that were the case,
// it'd indicate a bug in the code that must be fixed: there is no point in
// returning this as an error.
panic("SetCredential invoked on a cmd object that already includes user credentials")
}
cmd.SysProcAttr.Credential = user.ToCredential()
cmd.SysProcAttr.Credential.NoSetGroups = true
}