Skip to content

Commit

Permalink
Fix command exec's WithUid (RunAsUser) when running as self (#1682)
Browse files Browse the repository at this point in the history
  • Loading branch information
Micah-Kolide authored Apr 19, 2024
1 parent 0228b3d commit 227fef9
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion ee/tables/tablehelpers/run_as_user_posix.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ func WithUid(uid string) ExecOps {
return fmt.Errorf("looking up user with uid %s: %w", uid, err)
}

if currentUser.Uid != "0" && currentUser.Uid != runningUser.Uid {
// If the current user is the user to run as, then early return to avoid needing NoSetGroups.
if currentUser.Uid == runningUser.Uid {
return nil
} else if currentUser.Uid != "0" {
return fmt.Errorf("current user %s is not root and can't start process for other user %s", currentUser.Uid, uid)
}

Expand Down

0 comments on commit 227fef9

Please sign in to comment.