Skip to content

Commit

Permalink
rootless: skip NS_GET_PARENT on old kernels
Browse files Browse the repository at this point in the history
on old kernels the ioctl NS_GET_PARENT is not available.

Handle the error code and immediately return the same fd.  It should
be fine now that we use the namespace resolution using the conmon pid,
so the namespace parent resolution is just a safety measure.

Closes: containers#2968

Signed-off-by: Giuseppe Scrivano <[email protected]>
  • Loading branch information
giuseppe committed Jun 6, 2019
1 parent 6d285b8 commit 4dca13e
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pkg/rootless/rootless_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,9 @@ func getUserNSFirstChild(fd uintptr) (*os.File, error) {
for {
nextFd, err := getParentUserNs(fd)
if err != nil {
if err == syscall.ENOTTY {
return os.NewFile(fd, "userns child"), nil
}
return nil, errors.Wrapf(err, "cannot get parent user namespace")
}

Expand Down

0 comments on commit 4dca13e

Please sign in to comment.