Merge pull request #21433 from openshift-cherrypick-robot/cherry-pick-20769-to-v4.9

[v4.9] system: enhance check for re-exec into rootless userns
This commit is contained in:
openshift-merge-bot[bot] 2024-01-30 15:07:02 +00:00 • committed by GitHub
commit 96e2b96f6e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -87,7 +87,8 @@ func (ic *ContainerEngine) SetupRootless(_ context.Context, noMoveProcess bool)
if err != nil {
return err
}
if hasCapSysAdmin {
// check for both euid == 0 and CAP_SYS_ADMIN because we may be running in a container with CAP_SYS_ADMIN set.
if os.Geteuid() == 0 && hasCapSysAdmin {
ownsCgroup, err := cgroups.UserOwnsCurrentSystemdCgroup()
if err != nil {
logrus.Infof("Failed to detect the owner for the current cgroup: %v", err)