diff options
author | Daniel J Walsh <dwalsh@redhat.com> | 2019-02-17 21:55:30 -0500 |
---|---|---|
committer | Daniel J Walsh <dwalsh@redhat.com> | 2019-02-23 05:47:27 -0500 |
commit | b87bdced1fa967846916b47cba5f093f72f3d11f (patch) | |
tree | 27342efd5d84839584260b9e2883e27ed8fbbd22 /pkg/spec/createconfig.go | |
parent | b223d4e1367463a32eeeb31a4b9d8a351641d83c (diff) | |
download | podman-b87bdced1fa967846916b47cba5f093f72f3d11f.tar.gz podman-b87bdced1fa967846916b47cba5f093f72f3d11f.tar.bz2 podman-b87bdced1fa967846916b47cba5f093f72f3d11f.zip |
Fix up handling of user defined network namespaces
If user specifies network namespace and the /etc/netns/XXX/resolv.conf
exists, we should use this rather then /etc/resolv.conf
Also fail cleaner if the user specifies an invalid Network Namespace.
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
Diffstat (limited to 'pkg/spec/createconfig.go')
-rw-r--r-- | pkg/spec/createconfig.go | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/pkg/spec/createconfig.go b/pkg/spec/createconfig.go index 8da44a2f0..50e07ee74 100644 --- a/pkg/spec/createconfig.go +++ b/pkg/spec/createconfig.go @@ -446,7 +446,15 @@ func (c *CreateConfig) GetContainerCreateOptions(runtime *libpod.Runtime, pod *l } if IsNS(string(c.NetMode)) { - // pass + split := strings.SplitN(string(c.NetMode), ":", 2) + if len(split[0]) != 2 { + return nil, errors.Errorf("invalid user defined network namespace %q", c.NetMode.UserDefined()) + } + _, err := os.Stat(split[1]) + if err != nil { + return nil, err + } + options = append(options, libpod.WithNetNS(portBindings, false, string(c.NetMode), networks)) } else if c.NetMode.IsContainer() { connectedCtr, err := c.Runtime.LookupContainer(c.NetMode.Container()) if err != nil { |