Skip to content

Commit

Permalink
Wait for reexec to finish when fileOutput is nil
Browse files Browse the repository at this point in the history
Currently, we're not cleanup up after ourselves when fileOutput is nil.
This patch fixes that.

Signed-off-by: Jonathan Dieter <[email protected]>
  • Loading branch information
jdieter committed Aug 15, 2020
1 parent ca4423e commit 0cd2f2d
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions pkg/rootless/rootless_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,11 @@ func becomeRootInUserNS(pausePid, fileToRead string, fileOutput *os.File) (_ boo
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 Expand Up @@ -294,6 +299,11 @@ func becomeRootInUserNS(pausePid, fileToRead string, fileOutput *os.File) (_ boo
}

if fileOutput != nil {
ret := C.reexec_in_user_namespace_wait(pidC, 0)
if ret < 0 {
return false, -1, errors.New("error waiting for the re-exec process")
}

return true, 0, nil
}

Expand Down

0 comments on commit 0cd2f2d

Please sign in to comment.