diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2019-03-05 05:56:46 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-03-05 05:56:46 -0800 |
commit | 85b116707bf84125f00c3bf39e28ef33a7d49066 (patch) | |
tree | 73411249df3fecb0ccc41dc1978af67242cc976a /pkg | |
parent | 4b80517b6a638ff06f8ad432f0f0f5839283d058 (diff) | |
parent | 0b34327ad40e04861dac7f73870d87633a5c637e (diff) | |
download | podman-85b116707bf84125f00c3bf39e28ef33a7d49066.tar.gz podman-85b116707bf84125f00c3bf39e28ef33a7d49066.tar.bz2 podman-85b116707bf84125f00c3bf39e28ef33a7d49066.zip |
Merge pull request #2426 from giuseppe/exec-preserve-fds
exec: support --preserve-fds
Diffstat (limited to 'pkg')
-rw-r--r-- | pkg/rootless/rootless_linux.go | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/pkg/rootless/rootless_linux.go b/pkg/rootless/rootless_linux.go index 98692707f..55fba900e 100644 --- a/pkg/rootless/rootless_linux.go +++ b/pkg/rootless/rootless_linux.go @@ -102,7 +102,7 @@ func tryMappingTool(tool string, pid int, hostID int, mappings []idtools.IDMap) // JoinNS re-exec podman in a new userNS and join the user namespace of the specified // PID. -func JoinNS(pid uint) (bool, int, error) { +func JoinNS(pid uint, preserveFDs int) (bool, int, error) { if os.Geteuid() == 0 || os.Getenv("_LIBPOD_USERNS_CONFIGURED") != "" { return false, -1, nil } @@ -117,6 +117,13 @@ func JoinNS(pid uint) (bool, int, error) { if int(pidC) < 0 { return false, -1, errors.Errorf("cannot re-exec process") } + if preserveFDs > 0 { + for fd := 3; fd < 3+preserveFDs; fd++ { + // These fds were passed down to the runtime. Close them + // and not interfere + os.NewFile(uintptr(fd), fmt.Sprintf("fd-%d", fd)).Close() + } + } ret := C.reexec_in_user_namespace_wait(pidC) if ret < 0 { |