1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2025-01-04 05:17:43 +03:00

nspawn: fix fd leak on failure path

(cherry picked from commit 2fef50cd9e)
(cherry picked from commit f2763ff6cd)
(cherry picked from commit 8bc7ff600f)
(cherry picked from commit ecbb5a4f67)
This commit is contained in:
Lennart Poettering 2020-09-16 22:16:10 +02:00 committed by Zbigniew Jędrzejewski-Szmek
parent 7f0787e8fc
commit 6eecf08562

View File

@ -2083,7 +2083,7 @@ static int setup_pts(const char *dest) {
}
static int setup_stdio_as_dev_console(void) {
int terminal;
_cleanup_close_ int terminal = -1;
int r;
terminal = open_terminal("/dev/console", O_RDWR);
@ -2098,6 +2098,7 @@ static int setup_stdio_as_dev_console(void) {
/* invalidates 'terminal' on success and failure */
r = rearrange_stdio(terminal, terminal, terminal);
TAKE_FD(terminal);
if (r < 0)
return log_error_errno(r, "Failed to move console to stdin/stdout/stderr: %m");