diff options
author | Matthew Heon <matthew.heon@gmail.com> | 2018-07-19 11:24:42 -0400 |
---|---|---|
committer | Matthew Heon <matthew.heon@gmail.com> | 2018-07-24 16:12:31 -0400 |
commit | 7b30659629deaddafc7fc925d869324ae754c216 (patch) | |
tree | 21d3a23fe7ff811e67603eecbaae37f56b0cf1b4 /libpod/in_memory_state.go | |
parent | 572fd75d226550ac1576bf38812e5417a9eddeee (diff) | |
download | podman-7b30659629deaddafc7fc925d869324ae754c216.tar.gz podman-7b30659629deaddafc7fc925d869324ae754c216.tar.bz2 podman-7b30659629deaddafc7fc925d869324ae754c216.zip |
Enforce namespace checks on container add
Signed-off-by: Matthew Heon <matthew.heon@gmail.com>
Diffstat (limited to 'libpod/in_memory_state.go')
-rw-r--r-- | libpod/in_memory_state.go | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/libpod/in_memory_state.go b/libpod/in_memory_state.go index 265170284..55be89d4c 100644 --- a/libpod/in_memory_state.go +++ b/libpod/in_memory_state.go @@ -172,6 +172,10 @@ func (s *InMemoryState) AddContainer(ctr *Container) error { return errors.Wrapf(ErrInvalidArg, "cannot add a container that is in a pod with AddContainer, use AddContainerToPod") } + if err := s.checkNSMatch(ctr.ID(), ctr.Namespace()); err != nil { + return err + } + // There are potential race conditions with this // But in-memory state is intended purely for testing and not production // use, so this should be fine. @@ -692,6 +696,10 @@ func (s *InMemoryState) AddContainerToPod(pod *Pod, ctr *Container) error { ctr.ID(), ctr.config.Namespace, pod.ID(), pod.config.Namespace) } + if err := s.checkNSMatch(ctr.ID(), ctr.Namespace()); err != nil { + return err + } + // Retrieve pod containers list podCtrs, ok := s.podContainers[pod.ID()] if !ok { |