]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
nspawn: print log notice when we are invoked from a tty but in "pipe" mode
authorLennart Poettering <lennart@poettering.net>
Wed, 16 Sep 2020 20:12:29 +0000 (22:12 +0200)
committerLennart Poettering <lennart@poettering.net>
Thu, 17 Sep 2020 14:39:16 +0000 (16:39 +0200)
If people do this then things are weird, and they should probably use
--console=interactive (i.e. the default) instead.

Prompted-by: #17070
src/nspawn/nspawn.c

index 38339478e0048c3960ca8a5249a4dfd9c9ec66cb..de9f1f534cae13352d3f0601d23309b03c1da876 100644 (file)
@@ -267,9 +267,15 @@ static int handle_arg_console(const char *arg) {
                 arg_console_mode = CONSOLE_READ_ONLY;
         else if (streq(arg, "passive"))
                 arg_console_mode = CONSOLE_PASSIVE;
-        else if (streq(arg, "pipe"))
+        else if (streq(arg, "pipe")) {
+                if (isatty(STDIN_FILENO) > 0 && isatty(STDOUT_FILENO) > 0)
+                        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. "
+                                 "Proceeding anyway.");
+
                 arg_console_mode = CONSOLE_PIPE;
-        else
+        else
                 return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Unknown console mode: %s", optarg);
 
         arg_settings_mask |= SETTING_CONSOLE_MODE;