summaryrefslogtreecommitdiff
path: root/libpod/in_memory_state.go
diff options
context:
space:
mode:
authorMatthew Heon <matthew.heon@gmail.com>2018-07-19 11:24:42 -0400
committerMatthew Heon <matthew.heon@gmail.com>2018-07-24 16:12:31 -0400
commit7b30659629deaddafc7fc925d869324ae754c216 (patch)
tree21d3a23fe7ff811e67603eecbaae37f56b0cf1b4 /libpod/in_memory_state.go
parent572fd75d226550ac1576bf38812e5417a9eddeee (diff)
downloadpodman-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.go8
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 {