diff options
author | Giuseppe Scrivano <gscrivan@redhat.com> | 2019-01-11 11:23:19 +0100 |
---|---|---|
committer | Matthew Heon <matthew.heon@pm.me> | 2019-02-08 15:02:28 -0500 |
commit | c62efd08f75e97ba27d9e34068bcc2b3bf122896 (patch) | |
tree | 4b7bd59ccb4d0f30ef2bc706237a6a68e52d228b | |
parent | e95f4aa3b0715f87c55a60aa9bf395cbdfc2f3d9 (diff) | |
download | podman-c62efd08f75e97ba27d9e34068bcc2b3bf122896.tar.gz podman-c62efd08f75e97ba27d9e34068bcc2b3bf122896.tar.bz2 podman-c62efd08f75e97ba27d9e34068bcc2b3bf122896.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>
-rw-r--r-- | cmd/podman/create.go | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/cmd/podman/create.go b/cmd/podman/create.go index e10009971..a66603360 100644 --- a/cmd/podman/create.go +++ b/cmd/podman/create.go @@ -435,6 +435,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()) |