Skip to content

Commit

Permalink
rootless: propagate errors from info
Browse files Browse the repository at this point in the history
we use "podman info" to reconfigure the runtime after a reboot, but we
don't propagate the error message back if something goes wrong.

Closes: containers#2584

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
  • Loading branch information
giuseppe committed Mar 8, 2019
1 parent 8a21e23 commit cc411dd
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
9 changes: 6 additions & 3 deletions libpod/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -971,9 +971,12 @@ func (r *Runtime) refreshRootless() error {
// Take advantage of a command that requires a new userns
// so that we are running as the root user and able to use refresh()
cmd := exec.Command(os.Args[0], "info")
err := cmd.Run()
if err != nil {
return errors.Wrapf(err, "Error running %s info while refreshing state", os.Args[0])

if output, err := cmd.CombinedOutput(); err != nil {
if _, ok := err.(*exec.ExitError); !ok {
return errors.Wrapf(err, "Error waiting for info while refreshing state: %s", os.Args[0])
}
return errors.Wrapf(err, "Error running %s info while refreshing state: %s", os.Args[0], output)
}
return nil
}
Expand Down
2 changes: 2 additions & 0 deletions pkg/rootless/rootless_linux.c
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,8 @@ reexec_in_user_namespace (int ready)
_exit (EXIT_FAILURE);
}
close (ready);
if (b != '1')
_exit (EXIT_FAILURE);

if (syscall_setresgid (0, 0, 0) < 0)
{
Expand Down
1 change: 1 addition & 0 deletions pkg/rootless/rootless_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ func BecomeRootInUserNS() (bool, int, error) {
}
defer r.Close()
defer w.Close()
defer w.Write([]byte("0"))

pidC := C.reexec_in_user_namespace(C.int(r.Fd()))
pid := int(pidC)
Expand Down

0 comments on commit cc411dd

Please sign in to comment.