diff options
author | Giuseppe Scrivano <gscrivan@redhat.com> | 2020-07-30 21:45:41 +0200 |
---|---|---|
committer | Giuseppe Scrivano <gscrivan@redhat.com> | 2020-07-30 21:46:04 +0200 |
commit | d86ef45441635bf12a9ba78ace91050622a5eac3 (patch) | |
tree | e80de4a52ccfa6526fd8c3a046c861293a86865f /pkg/rootless/rootless_linux.go | |
parent | 8408cfd35c8aaa8cfcd08ee8b0874442f7430ede (diff) | |
download | podman-d86ef45441635bf12a9ba78ace91050622a5eac3.tar.gz podman-d86ef45441635bf12a9ba78ace91050622a5eac3.tar.bz2 podman-d86ef45441635bf12a9ba78ace91050622a5eac3.zip |
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>
Diffstat (limited to 'pkg/rootless/rootless_linux.go')
-rw-r--r-- | pkg/rootless/rootless_linux.go | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/pkg/rootless/rootless_linux.go b/pkg/rootless/rootless_linux.go index 529e90586..fc4393927 100644 --- a/pkg/rootless/rootless_linux.go +++ b/pkg/rootless/rootless_linux.go @@ -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) } }() |