summaryrefslogtreecommitdiff
path: root/pkg
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2020-09-25 20:21:28 +0000
committerGitHub <noreply@github.com>2020-09-25 20:21:28 +0000
commit03d01abec6d028e9d5f60615b0451e42d0611d1d (patch)
treeb229d4f99a426efe4129618b0a80583a3f543815 /pkg
parenta1045adbf4294d5afb27533eeeb99c4079baa846 (diff)
parent7147c935aa29dca2f89083bfbe2c058a0ca69857 (diff)
downloadpodman-03d01abec6d028e9d5f60615b0451e42d0611d1d.tar.gz
podman-03d01abec6d028e9d5f60615b0451e42d0611d1d.tar.bz2
podman-03d01abec6d028e9d5f60615b0451e42d0611d1d.zip
Merge pull request #7784 from giuseppe/no-newidmap-fix-hang
rootless: fix hang when newidmap is not installed
Diffstat (limited to 'pkg')
-rw-r--r--pkg/rootless/rootless_linux.go15
1 files changed, 9 insertions, 6 deletions
diff --git a/pkg/rootless/rootless_linux.go b/pkg/rootless/rootless_linux.go
index bbd797817..3025825db 100644
--- a/pkg/rootless/rootless_linux.go
+++ b/pkg/rootless/rootless_linux.go
@@ -216,6 +216,8 @@ func becomeRootInUserNS(pausePid, fileToRead string, fileOutput *os.File) (_ boo
}
r, w := os.NewFile(uintptr(fds[0]), "sync host"), os.NewFile(uintptr(fds[1]), "sync child")
+ var pid int
+
defer errorhandling.CloseQuiet(r)
defer errorhandling.CloseQuiet(w)
defer func() {
@@ -226,18 +228,19 @@ func becomeRootInUserNS(pausePid, fileToRead string, fileOutput *os.File) (_ boo
if _, err := w.Write(toWrite); err != nil {
logrus.Errorf("failed to write byte 0: %q", err)
}
+ if retErr != nil && pid > 0 {
+ if err := unix.Kill(pid, unix.SIGKILL); err != nil {
+ logrus.Errorf("failed to kill %d", pid)
+ }
+ C.reexec_in_user_namespace_wait(C.int(pid), 0)
+ }
}()
pidC := C.reexec_in_user_namespace(C.int(r.Fd()), cPausePid, cFileToRead, fileOutputFD)
- pid := int(pidC)
+ pid = int(pidC)
if pid < 0 {
return false, -1, errors.Errorf("cannot re-exec process")
}
- defer func() {
- if retErr != nil {
- C.reexec_in_user_namespace_wait(pidC, 0)
- }
- }()
uids, gids, err := GetConfiguredMappings()
if err != nil {