diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2022-04-22 08:40:34 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-22 08:40:34 -0400 |
commit | 1bafde2d226067257d430c367ec2c53208d3eeeb (patch) | |
tree | 9d5fb9b77482e7c1284eef11c18a83927dc91da8 /pkg/specgen/generate | |
parent | 22500d797aba09eada894a69ad88f2699a560d02 (diff) | |
parent | 80c0fceb24b70a85f3f2ca8be29f4a131c0881d4 (diff) | |
download | podman-1bafde2d226067257d430c367ec2c53208d3eeeb.tar.gz podman-1bafde2d226067257d430c367ec2c53208d3eeeb.tar.bz2 podman-1bafde2d226067257d430c367ec2c53208d3eeeb.zip |
Merge pull request #13881 from rhatdan/userns
Add support for --userns=nomap
Diffstat (limited to 'pkg/specgen/generate')
-rw-r--r-- | pkg/specgen/generate/namespaces.go | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/pkg/specgen/generate/namespaces.go b/pkg/specgen/generate/namespaces.go index 05c2d1741..d8d1ae652 100644 --- a/pkg/specgen/generate/namespaces.go +++ b/pkg/specgen/generate/namespaces.go @@ -165,21 +165,19 @@ func namespaceOptions(ctx context.Context, s *specgen.SpecGenerator, rt *libpod. // User switch s.UserNS.NSMode { case specgen.KeepID: - if rootless.IsRootless() { - toReturn = append(toReturn, libpod.WithAddCurrentUserPasswdEntry()) - - // If user is not overridden, set user in the container - // to user running Podman. - if s.User == "" { - _, uid, gid, err := util.GetKeepIDMapping() - if err != nil { - return nil, err - } - toReturn = append(toReturn, libpod.WithUser(fmt.Sprintf("%d:%d", uid, gid))) + if !rootless.IsRootless() { + return nil, errors.New("keep-id is only supported in rootless mode") + } + toReturn = append(toReturn, libpod.WithAddCurrentUserPasswdEntry()) + + // If user is not overridden, set user in the container + // to user running Podman. + if s.User == "" { + _, uid, gid, err := util.GetKeepIDMapping() + if err != nil { + return nil, err } - } else { - // keep-id as root doesn't need a user namespace - s.UserNS.NSMode = specgen.Host + toReturn = append(toReturn, libpod.WithUser(fmt.Sprintf("%d:%d", uid, gid))) } case specgen.FromPod: if pod == nil || infraCtr == nil { |