aboutsummaryrefslogtreecommitdiff
path: root/cmd/podman/create.go
diff options
context:
space:
mode:
authorGiuseppe Scrivano <gscrivan@redhat.com>2019-01-11 11:23:19 +0100
committerGiuseppe Scrivano <gscrivan@redhat.com>2019-01-11 11:52:12 +0100
commit04a4ba9b7302b807b7a5d9a180d3fcd27560052a (patch)
treed8c53db1a1dbda6f5d111f5784b1804d24b14a62 /cmd/podman/create.go
parentc4f054f102101dd198cc6e12a28510edb7849552 (diff)
downloadpodman-04a4ba9b7302b807b7a5d9a180d3fcd27560052a.tar.gz
podman-04a4ba9b7302b807b7a5d9a180d3fcd27560052a.tar.bz2
podman-04a4ba9b7302b807b7a5d9a180d3fcd27560052a.zip
rootless: create the userns immediately when creating a new pod
Closes: https://github.com/containers/libpod/issues/2124 Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
Diffstat (limited to 'cmd/podman/create.go')
-rw-r--r--cmd/podman/create.go10
1 files changed, 10 insertions, 0 deletions
diff --git a/cmd/podman/create.go b/cmd/podman/create.go
index 7472426eb..87fa18e47 100644
--- a/cmd/podman/create.go
+++ b/cmd/podman/create.go
@@ -422,6 +422,16 @@ func parseCreateOpts(ctx context.Context, c *cli.Context, runtime *libpod.Runtim
}
if c.IsSet("pod") {
if strings.HasPrefix(originalPodName, "new:") {
+ if rootless.IsRootless() {
+ // To create a new pod, we must immediately create the userns.
+ became, ret, err := rootless.BecomeRootInUserNS()
+ if err != nil {
+ return nil, err
+ }
+ if became {
+ os.Exit(ret)
+ }
+ }
// pod does not exist; lets make it
var podOptions []libpod.PodCreateOption
podOptions = append(podOptions, libpod.WithPodName(podName), libpod.WithInfraContainer(), libpod.WithPodCgroups())