summaryrefslogtreecommitdiff
path: root/libpod/networking_linux.go
diff options
context:
space:
mode:
authorGiuseppe Scrivano <gscrivan@redhat.com>2020-02-18 11:46:27 +0100
committerGiuseppe Scrivano <gscrivan@redhat.com>2020-02-18 15:33:38 +0100
commit170fd7b038757228bf169e6180cab19a1e412f26 (patch)
treee661b9c68b90260514d405b15ad9b642f6666760 /libpod/networking_linux.go
parent0bd29f89e9d26c9012c76e58050e1bdfd90faaf0 (diff)
downloadpodman-170fd7b038757228bf169e6180cab19a1e412f26.tar.gz
podman-170fd7b038757228bf169e6180cab19a1e412f26.tar.bz2
podman-170fd7b038757228bf169e6180cab19a1e412f26.zip
rootless: fix a regression when using -d
when using -d and port mapping, make sure the correct fd is injected into conmon. Move the pipe creation earlier as the fd must be known at the time we create the container through conmon. Closes: https://github.com/containers/libpod/issues/5167 Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
Diffstat (limited to 'libpod/networking_linux.go')
-rw-r--r--libpod/networking_linux.go14
1 files changed, 11 insertions, 3 deletions
diff --git a/libpod/networking_linux.go b/libpod/networking_linux.go
index d90bcb708..fa8593f20 100644
--- a/libpod/networking_linux.go
+++ b/libpod/networking_linux.go
@@ -335,10 +335,13 @@ func (r *Runtime) setupRootlessPortMapping(ctr *Container, netnsPath string) (er
return errors.Wrapf(err, "delete file %s", logPath)
}
- ctr.rootlessPortSyncR, ctr.rootlessPortSyncW, err = os.Pipe()
- if err != nil {
- return errors.Wrapf(err, "failed to create rootless port sync pipe")
+ if !ctr.config.PostConfigureNetNS {
+ ctr.rootlessPortSyncR, ctr.rootlessPortSyncW, err = os.Pipe()
+ if err != nil {
+ return errors.Wrapf(err, "failed to create rootless port sync pipe")
+ }
}
+
cfg := rootlessport.Config{
Mappings: ctr.config.PortMappings,
NetNSPath: netnsPath,
@@ -355,6 +358,11 @@ func (r *Runtime) setupRootlessPortMapping(ctr *Container, netnsPath string) (er
cmd := exec.Command(fmt.Sprintf("/proc/%d/exe", os.Getpid()))
cmd.Args = []string{rootlessport.ReexecKey}
// Leak one end of the pipe in rootlessport process, the other will be sent to conmon
+
+ if ctr.rootlessPortSyncR != nil {
+ defer errorhandling.CloseQuiet(ctr.rootlessPortSyncR)
+ }
+
cmd.ExtraFiles = append(cmd.ExtraFiles, ctr.rootlessPortSyncR, syncW)
cmd.Stdin = cfgR
// stdout is for human-readable error, stderr is for debug log