Skip to content

Commit

Permalink
Merge pull request #7892 from giuseppe/backport-fix-hang-no-newidmap
Browse files Browse the repository at this point in the history
[2.1] rootless: fix hang when newidmap is not installed
  • Loading branch information
openshift-merge-robot authored Oct 2, 2020
2 parents ce5b48b + ed5f1d6 commit 4f43055
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions pkg/rootless/rootless_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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 {
Expand Down

0 comments on commit 4f43055

Please sign in to comment.