diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2020-06-04 13:41:44 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-04 13:41:44 +0200 |
commit | ff99c3ecb36f7a46165cae2f963efd94da61b1ac (patch) | |
tree | aad0682fe71341d8111c4c725f821f7d6191da7e /cmd | |
parent | 06d8c3dda3b5f5c0f671e068819291edf774c3fe (diff) | |
parent | bdfec451dc9c36c648c4bdc2a1fc6b7bf17b6288 (diff) | |
download | podman-ff99c3ecb36f7a46165cae2f963efd94da61b1ac.tar.gz podman-ff99c3ecb36f7a46165cae2f963efd94da61b1ac.tar.bz2 podman-ff99c3ecb36f7a46165cae2f963efd94da61b1ac.zip |
Merge pull request #6484 from rhatdan/namespace
Namespace fields were set with bogus values
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/podman/containers/create.go | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/cmd/podman/containers/create.go b/cmd/podman/containers/create.go index c8007bc2f..ed09585ba 100644 --- a/cmd/podman/containers/create.go +++ b/cmd/podman/containers/create.go @@ -161,24 +161,25 @@ func createInit(c *cobra.Command) error { if c.Flag("no-hosts").Changed && c.Flag("add-host").Changed { return errors.Errorf("--no-hosts and --add-host cannot be set together") } - if c.Flag("userns").Changed { - cliVals.UserNS = c.Flag("userns").Value.String() - } - if c.Flag("ipc").Changed { - cliVals.IPC = c.Flag("ipc").Value.String() - } - if c.Flag("uts").Changed { - cliVals.UTS = c.Flag("uts").Value.String() - } - if c.Flag("pid").Changed { - cliVals.PID = c.Flag("pid").Value.String() + cliVals.UserNS = c.Flag("userns").Value.String() + // if user did not modify --userns flag and did turn on + // uid/gid mappsings, set userns flag to "private" + if !c.Flag("userns").Changed && cliVals.UserNS == "host" { + if len(cliVals.UIDMap) > 0 || + len(cliVals.GIDMap) > 0 || + cliVals.SubUIDName != "" || + cliVals.SubGIDName != "" { + cliVals.UserNS = "private" + } } + + cliVals.IPC = c.Flag("ipc").Value.String() + cliVals.UTS = c.Flag("uts").Value.String() + cliVals.PID = c.Flag("pid").Value.String() + cliVals.CGroupsNS = c.Flag("cgroupns").Value.String() if !c.Flag("pids-limit").Changed { cliVals.PIDsLimit = -1 } - if c.Flag("cgroupns").Changed { - cliVals.CGroupsNS = c.Flag("cgroupns").Value.String() - } if c.Flag("entrypoint").Changed { val := c.Flag("entrypoint").Value.String() cliVals.Entrypoint = &val |