podman: allow to specify the UTS namespace to join

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>

Closes: #1145
Approved by: rhatdan
This commit is contained in:
Giuseppe Scrivano 2018-07-24 17:53:10 +02:00 committed by Atomic Bot
parent 8223fbaac6
commit 977c8a9cd6
4 changed files with 6 additions and 1 deletions

View File

@ -389,7 +389,7 @@ func parseCreateOpts(ctx context.Context, c *cli.Context, runtime *libpod.Runtim
}
utsMode := container.UTSMode(c.String("uts"))
if !utsMode.Valid() {
if !cc.IsNS(string(utsMode)) && !utsMode.Valid() {
return nil, errors.Errorf("--uts %q is not valid", c.String("uts"))
}
ipcMode := container.IpcMode(c.String("ipc"))

View File

@ -589,6 +589,7 @@ Set the usernamespace mode for the container. The use of userns is disabled by d
Set the UTS mode for the container
**host**: use the host's UTS namespace inside the container.
**ns**: specify the usernamespace to use.
Note: the host mode gives the container access to changing the host's hostname and is therefore considered insecure.
**-v**|**--volume**[=*[HOST-DIR:CONTAINER-DIR[:OPTIONS]]*]

View File

@ -620,6 +620,7 @@ Set the usernamespace mode for the container. The use of userns is disabled by d
Set the UTS mode for the container
`host`: use the host's UTS namespace inside the container.
`ns`: specify the usernamespace to use.
**NOTE**: the host mode gives the container access to changing the host's hostname and is therefore considered insecure.

View File

@ -369,6 +369,9 @@ func addNetNS(config *CreateConfig, g *generate.Generator) error {
func addUTSNS(config *CreateConfig, g *generate.Generator) error {
utsMode := config.UtsMode
if IsNS(string(utsMode)) {
return g.AddOrReplaceLinuxNamespace(string(spec.UTSNamespace), NS(string(utsMode)))
}
if utsMode.IsHost() {
return g.RemoveLinuxNamespace(spec.UTSNamespace)
}