diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2021-05-19 11:45:55 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-19 11:45:55 -0400 |
commit | 46832259a878a7e6438c7022be83a2170734eb48 (patch) | |
tree | ca6e4710bd3b6894c736b33f45199bd9519f012d /libpod/container_inspect.go | |
parent | 18efc5a3a78ba7352e42517ba251212833b4583d (diff) | |
parent | bc0e12a047cce2cc717320257545663073383f48 (diff) | |
download | podman-46832259a878a7e6438c7022be83a2170734eb48.tar.gz podman-46832259a878a7e6438c7022be83a2170734eb48.tar.bz2 podman-46832259a878a7e6438c7022be83a2170734eb48.zip |
Merge pull request #10327 from rhatdan/copy
Fix problem copying files when container is in host pid namespace
Diffstat (limited to 'libpod/container_inspect.go')
-rw-r--r-- | libpod/container_inspect.go | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/libpod/container_inspect.go b/libpod/container_inspect.go index 4210bc581..638e0b756 100644 --- a/libpod/container_inspect.go +++ b/libpod/container_inspect.go @@ -892,3 +892,26 @@ func (c *Container) generateInspectContainerHostConfig(ctrSpec *spec.Spec, named return hostConfig, nil } + +// Return true if the container is running in the host's PID NS. +func (c *Container) inHostPidNS() (bool, error) { + if c.config.PIDNsCtr != "" { + return false, nil + } + ctrSpec, err := c.specFromState() + if err != nil { + return false, err + } + if ctrSpec.Linux != nil { + // Locate the spec's PID namespace. + // If there is none, it's pid=host. + // If there is one and it has a path, it's "ns:". + // If there is no path, it's default - the empty string. + for _, ns := range ctrSpec.Linux.Namespaces { + if ns.Type == spec.PIDNamespace { + return false, nil + } + } + } + return true, nil +} |