From: Lennart Poettering Date: Thu, 24 Oct 2024 21:12:31 +0000 (+0200) Subject: tree-wide: use isatty_safe() everywhere X-Git-Tag: v257-rc1~141^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=988053eac355a414652ecc024fbd785f3196637c;p=thirdparty%2Fsystemd.git tree-wide: use isatty_safe() everywhere --- diff --git a/src/nspawn/nspawn.c b/src/nspawn/nspawn.c index d659937f3bf..41d10357ede 100644 --- a/src/nspawn/nspawn.c +++ b/src/nspawn/nspawn.c @@ -290,7 +290,7 @@ static int handle_arg_console(const char *arg) { else if (streq(arg, "passive")) arg_console_mode = CONSOLE_PASSIVE; else if (streq(arg, "pipe")) { - if (isatty_safe(STDIN_FILENO) && isatty(STDOUT_FILENO)) + if (isatty_safe(STDIN_FILENO) && isatty_safe(STDOUT_FILENO)) log_full(arg_quiet ? LOG_DEBUG : LOG_NOTICE, "Console mode 'pipe' selected, but standard input/output are connected to an interactive TTY. " "Most likely you want to use 'interactive' console mode for proper interactivity and shell job control. " @@ -298,7 +298,7 @@ static int handle_arg_console(const char *arg) { arg_console_mode = CONSOLE_PIPE; } else if (streq(arg, "autopipe")) { - if (isatty_safe(STDIN_FILENO) && isatty(STDOUT_FILENO)) + if (isatty_safe(STDIN_FILENO) && isatty_safe(STDOUT_FILENO)) arg_console_mode = CONSOLE_INTERACTIVE; else arg_console_mode = CONSOLE_PIPE; @@ -5981,7 +5981,7 @@ static int run(int argc, char *argv[]) { umask(0022); if (arg_console_mode < 0) - arg_console_mode = isatty_safe(STDIN_FILENO) && isatty(STDOUT_FILENO) ? + arg_console_mode = isatty_safe(STDIN_FILENO) && isatty_safe(STDOUT_FILENO) ? CONSOLE_INTERACTIVE : CONSOLE_READ_ONLY; if (arg_console_mode == CONSOLE_PIPE) /* if we pass STDERR on to the container, don't add our own logs into it too */ diff --git a/src/run/run.c b/src/run/run.c index 5d2298a5f6c..b2c8fececc6 100644 --- a/src/run/run.c +++ b/src/run/run.c @@ -674,7 +674,7 @@ static int parse_argv(int argc, char *argv[]) { /* If we both --pty and --pipe are specified we'll automatically pick --pty if we are connected fully * to a TTY and pick direct fd passing otherwise. This way, we automatically adapt to usage in a shell * pipeline, but we are neatly interactive with tty-level isolation otherwise. */ - arg_stdio = isatty_safe(STDIN_FILENO) && isatty(STDOUT_FILENO) && isatty(STDERR_FILENO) ? + arg_stdio = isatty_safe(STDIN_FILENO) && isatty_safe(STDOUT_FILENO) && isatty_safe(STDERR_FILENO) ? ARG_STDIO_PTY : ARG_STDIO_DIRECT; @@ -913,7 +913,7 @@ static int parse_argv_sudo_mode(int argc, char *argv[]) { arg_wait = true; arg_aggressive_gc = true; - arg_stdio = isatty_safe(STDIN_FILENO) && isatty(STDOUT_FILENO) && isatty(STDERR_FILENO) ? ARG_STDIO_PTY : ARG_STDIO_DIRECT; + arg_stdio = isatty_safe(STDIN_FILENO) && isatty_safe(STDOUT_FILENO) && isatty_safe(STDERR_FILENO) ? ARG_STDIO_PTY : ARG_STDIO_DIRECT; arg_expand_environment = false; arg_send_sighup = true; @@ -1181,7 +1181,7 @@ static int transient_service_set_properties(sd_bus_message *m, const char *pty_p if (r < 0) return bus_log_create_error(r); - send_term = isatty_safe(STDIN_FILENO) || isatty(STDOUT_FILENO) || isatty(STDERR_FILENO); + send_term = isatty_safe(STDIN_FILENO) || isatty_safe(STDOUT_FILENO) || isatty_safe(STDERR_FILENO); } if (send_term) {