summaryrefslogtreecommitdiff
path: root/pkg/domain/infra/abi/system.go
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2021-04-26 09:19:00 -0400
committerGitHub <noreply@github.com>2021-04-26 09:19:00 -0400
commit333817a187f7811919b9f5fb75a829fe5abfbc44 (patch)
treed9e27e24f5edaabfd3ee8245370b405ba6f64815 /pkg/domain/infra/abi/system.go
parent9ca53cfb4fa137ef1fcfeaff4ab871c488a235f7 (diff)
parent722ea2f1f82ff16271b50b508d709e5da275e32a (diff)
downloadpodman-333817a187f7811919b9f5fb75a829fe5abfbc44.tar.gz
podman-333817a187f7811919b9f5fb75a829fe5abfbc44.tar.bz2
podman-333817a187f7811919b9f5fb75a829fe5abfbc44.zip
Merge pull request #10079 from giuseppe/create-userns-for-root-without-CAP_SYS_ADMIN
runtime: create userns when CAP_SYS_ADMIN is not present
Diffstat (limited to 'pkg/domain/infra/abi/system.go')
-rw-r--r--pkg/domain/infra/abi/system.go7
1 files changed, 6 insertions, 1 deletions
diff --git a/pkg/domain/infra/abi/system.go b/pkg/domain/infra/abi/system.go
index 6319c1ab1..9bba0fa6c 100644
--- a/pkg/domain/infra/abi/system.go
+++ b/pkg/domain/infra/abi/system.go
@@ -21,6 +21,7 @@ import (
"github.com/containers/podman/v3/pkg/util"
"github.com/containers/podman/v3/utils"
"github.com/containers/storage"
+ "github.com/containers/storage/pkg/unshare"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
@@ -58,7 +59,11 @@ func (ic *ContainerEngine) Info(ctx context.Context) (*define.Info, error) {
func (ic *ContainerEngine) SetupRootless(_ context.Context, cmd *cobra.Command) error {
// do it only after podman has already re-execed and running with uid==0.
- if os.Geteuid() == 0 {
+ hasCapSysAdmin, err := unshare.HasCapSysAdmin()
+ if err != nil {
+ return err
+ }
+ if hasCapSysAdmin {
ownsCgroup, err := cgroups.UserOwnsCurrentSystemdCgroup()
if err != nil {
logrus.Infof("Failed to detect the owner for the current cgroup: %v", err)