From: Zbigniew Jędrzejewski-Szmek Date: Mon, 8 Jul 2019 13:16:41 +0000 (+0200) Subject: nspawn: fix abort when we cannot execve X-Git-Tag: v243-rc1~179 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=cd132992bb52b921387289006cb8eb481e7d33a1;p=thirdparty%2Fsystemd.git nspawn: fix abort when we cannot execve If execve failed, we would die in safe_close(), because master was already closed by fdset_close_others() on line 3123. IIUC, we don't need to keep the fd open after sending it, so let's just close it immediately. Reproducer: sudo build/systemd-nspawn -M rawhide fooooooo Fixup for 3acc84ebd9aebe8cf1771b42644ebbfbecdfaa37. --- diff --git a/src/nspawn/nspawn.c b/src/nspawn/nspawn.c index 7ada4116368..a563c026dd6 100644 --- a/src/nspawn/nspawn.c +++ b/src/nspawn/nspawn.c @@ -2798,7 +2798,6 @@ static int inner_child( int master_pty_socket, FDSet *fds) { - _cleanup_close_ int master = -1; _cleanup_free_ char *home = NULL; char as_uuid[37]; size_t n_env = 1; @@ -2931,6 +2930,7 @@ static int inner_child( } if (arg_console_mode != CONSOLE_PIPE) { + _cleanup_close_ int master = -1; _cleanup_free_ char *console = NULL; /* Allocate a pty and make it available as /dev/console. */