Skip to content

Commit

Permalink
Fix hang when path doesn't exist
Browse files Browse the repository at this point in the history
I'm not sure if this is an OS-specific issue, but on CentOS 8, if `path`
doesn't exist, this hangs while waiting to read from this socket, even
though the socket is closed by the `reexec_in_user_namespace`.  Switching
to a pipe fixes the problem, and pipes shouldn't be an issue since this is
Linux-specific code.

Signed-off-by: Jonathan Dieter <[email protected]>
  • Loading branch information
jdieter authored and mheon committed Aug 20, 2020
1 parent cb4c5fc commit ceae3a9
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions pkg/rootless/rootless_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -363,14 +363,12 @@ func TryJoinFromFilePaths(pausePidPath string, needNewNamespace bool, paths []st
lastErr = nil
break
} else {
fds, err := unix.Socketpair(unix.AF_UNIX, unix.SOCK_DGRAM, 0)
r, w, err := os.Pipe()
if err != nil {
lastErr = err
continue
}

r, w := os.NewFile(uintptr(fds[0]), "read file"), os.NewFile(uintptr(fds[1]), "write file")

defer errorhandling.CloseQuiet(r)

if _, _, err := becomeRootInUserNS("", path, w); err != nil {
Expand Down

0 comments on commit ceae3a9

Please sign in to comment.