mirror of
https://github.com/containers/podman.git
synced 2025-07-15 03:02:52 +08:00
rootless: child exits immediately on userns errors
if the parent process failed to create the user namespace, let the child exit immediately. Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
This commit is contained in:
@ -860,7 +860,7 @@ reexec_in_user_namespace (int ready, char *pause_pid_file_path, char *file_to_re
|
||||
fprintf (stderr, "cannot read from sync pipe: %s\n", strerror (errno));
|
||||
_exit (EXIT_FAILURE);
|
||||
}
|
||||
if (b != '0')
|
||||
if (ret != 1 || b != '0')
|
||||
_exit (EXIT_FAILURE);
|
||||
|
||||
if (syscall_setresgid (0, 0, 0) < 0)
|
||||
|
@ -175,7 +175,7 @@ func GetConfiguredMappings() ([]idtools.IDMap, []idtools.IDMap, error) {
|
||||
return uids, gids, nil
|
||||
}
|
||||
|
||||
func becomeRootInUserNS(pausePid, fileToRead string, fileOutput *os.File) (bool, int, error) {
|
||||
func becomeRootInUserNS(pausePid, fileToRead string, fileOutput *os.File) (_ bool, _ int, retErr error) {
|
||||
if os.Geteuid() == 0 || os.Getenv("_CONTAINERS_USERNS_CONFIGURED") != "" {
|
||||
if os.Getenv("_CONTAINERS_USERNS_CONFIGURED") == "init" {
|
||||
return false, 0, runInUser()
|
||||
@ -205,7 +205,11 @@ func becomeRootInUserNS(pausePid, fileToRead string, fileOutput *os.File) (bool,
|
||||
defer errorhandling.CloseQuiet(r)
|
||||
defer errorhandling.CloseQuiet(w)
|
||||
defer func() {
|
||||
if _, err := w.Write([]byte("0")); err != nil {
|
||||
toWrite := []byte("0")
|
||||
if retErr != nil {
|
||||
toWrite = []byte("1")
|
||||
}
|
||||
if _, err := w.Write(toWrite); err != nil {
|
||||
logrus.Errorf("failed to write byte 0: %q", err)
|
||||
}
|
||||
}()
|
||||
|
Reference in New Issue
Block a user