diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2019-07-26 15:06:06 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-07-26 15:06:06 +0200 |
commit | 0c4dfcfe57559d55786818b027ad12ad94574e71 (patch) | |
tree | f80b22ab5ccad6e896e4f96021891c81ec12b853 /cmd/podman/shared/create.go | |
parent | b212daa92f3a596efa87b6ccaa097f70cd34bb10 (diff) | |
parent | 1d72f651e4c5118c020a1ab7281d3de0bf31899e (diff) | |
download | podman-0c4dfcfe57559d55786818b027ad12ad94574e71.tar.gz podman-0c4dfcfe57559d55786818b027ad12ad94574e71.tar.bz2 podman-0c4dfcfe57559d55786818b027ad12ad94574e71.zip |
Merge pull request #3639 from giuseppe/user-ns-container
podman: support --userns=ns|container
Diffstat (limited to 'cmd/podman/shared/create.go')
-rw-r--r-- | cmd/podman/shared/create.go | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/cmd/podman/shared/create.go b/cmd/podman/shared/create.go index 815e2d304..9578eb17d 100644 --- a/cmd/podman/shared/create.go +++ b/cmd/podman/shared/create.go @@ -282,13 +282,26 @@ func configurePod(c *GenericCLIResults, runtime *libpod.Runtime, namespaces map[ if err != nil { return namespaces, err } + hasUserns := false + if podInfraID != "" { + podCtr, err := runtime.GetContainer(podInfraID) + if err != nil { + return namespaces, err + } + mappings, err := podCtr.IDMappings() + if err != nil { + return namespaces, err + } + hasUserns = len(mappings.UIDMap) > 0 + } + if (namespaces["pid"] == cc.Pod) || (!c.IsSet("pid") && pod.SharesPID()) { namespaces["pid"] = fmt.Sprintf("container:%s", podInfraID) } if (namespaces["net"] == cc.Pod) || (!c.IsSet("net") && !c.IsSet("network") && pod.SharesNet()) { namespaces["net"] = fmt.Sprintf("container:%s", podInfraID) } - if (namespaces["user"] == cc.Pod) || (!c.IsSet("user") && pod.SharesUser()) { + if hasUserns && (namespaces["user"] == cc.Pod) || (!c.IsSet("user") && pod.SharesUser()) { namespaces["user"] = fmt.Sprintf("container:%s", podInfraID) } if (namespaces["ipc"] == cc.Pod) || (!c.IsSet("ipc") && pod.SharesIPC()) { |