From 0cd2f2d974789b82ad8e5471963df45211dafaea Mon Sep 17 00:00:00 2001 From: Jonathan Dieter Date: Tue, 11 Aug 2020 15:47:32 +0100 Subject: Wait for reexec to finish when fileOutput is nil Currently, we're not cleanup up after ourselves when fileOutput is nil. This patch fixes that. Signed-off-by: Jonathan Dieter --- pkg/rootless/rootless_linux.go | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'pkg/rootless/rootless_linux.go') diff --git a/pkg/rootless/rootless_linux.go b/pkg/rootless/rootless_linux.go index ecd309d36..bbd797817 100644 --- a/pkg/rootless/rootless_linux.go +++ b/pkg/rootless/rootless_linux.go @@ -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 { @@ -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 } -- cgit v1.2.3-54-g00ecf