summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--docs/ENVIRONMENT.md4
-rw-r--r--src/nspawn/nspawn.c3
-rw-r--r--src/run/run.c4
-rw-r--r--src/shared/ptyfwd.c16
-rw-r--r--src/shared/ptyfwd.h2
-rw-r--r--src/vmspawn/vmspawn.c3
6 files changed, 32 insertions, 0 deletions
diff --git a/docs/ENVIRONMENT.md b/docs/ENVIRONMENT.md
index 7d712c0990..1352d31b91 100644
--- a/docs/ENVIRONMENT.md
+++ b/docs/ENVIRONMENT.md
@@ -715,6 +715,10 @@ Tools using the Varlink protocol (such as `varlinkctl`) or sd-bus (such as
no effect if the background color is explicitly selected via the relevant
`--background=` switch of the tool.
+* `$SYSTEMD_ADJUST_TERMINAL_TITLE` – Takes a boolean. When false the terminal
+ window title will not be updated for interactive invocation of the mentioned
+ tools.
+
`systemd-hostnamed`, `systemd-importd`, `systemd-localed`, `systemd-machined`,
`systemd-portabled`, `systemd-timedated`:
diff --git a/src/nspawn/nspawn.c b/src/nspawn/nspawn.c
index 6eec5a27a0..01c3a432a5 100644
--- a/src/nspawn/nspawn.c
+++ b/src/nspawn/nspawn.c
@@ -4557,6 +4557,9 @@ static void set_window_title(PTYForward *f) {
assert(f);
+ if (!shall_set_terminal_title())
+ return;
+
(void) gethostname_strict(&hn);
if (emoji_enabled())
diff --git a/src/run/run.c b/src/run/run.c
index 975b8ddf17..6565336866 100644
--- a/src/run/run.c
+++ b/src/run/run.c
@@ -1634,8 +1634,12 @@ static int acquire_invocation_id(sd_bus *bus, const char *unit, sd_id128_t *ret)
static void set_window_title(PTYForward *f) {
_cleanup_free_ char *hn = NULL, *cl = NULL, *dot = NULL;
+
assert(f);
+ if (!shall_set_terminal_title())
+ return;
+
if (!arg_host)
(void) gethostname_strict(&hn);
diff --git a/src/shared/ptyfwd.c b/src/shared/ptyfwd.c
index 998ce96b54..842aef9270 100644
--- a/src/shared/ptyfwd.c
+++ b/src/shared/ptyfwd.c
@@ -17,6 +17,7 @@
#include "sd-event.h"
#include "alloc-util.h"
+#include "env-util.h"
#include "errno-util.h"
#include "extract-word.h"
#include "fd-util.h"
@@ -367,6 +368,21 @@ static int insert_background_fix(PTYForward *f, size_t offset) {
return insert_string(f, offset, s);
}
+bool shall_set_terminal_title(void) {
+ static int cache = -1;
+
+ if (cache >= 0)
+ return cache;
+
+ cache = getenv_bool("SYSTEMD_ADJUST_TERMINAL_TITLE");
+ if (cache == -ENXIO)
+ return (cache = true);
+ if (cache < 0)
+ log_debug_errno(cache, "Failed to parse $SYSTEMD_ADJUST_TERMINAL_TITLE, leaving terminal title setting enabled: %m");
+
+ return cache != 0;
+}
+
static int insert_window_title_fix(PTYForward *f, size_t offset) {
assert(f);
diff --git a/src/shared/ptyfwd.h b/src/shared/ptyfwd.h
index 248646d764..b86027e9bc 100644
--- a/src/shared/ptyfwd.h
+++ b/src/shared/ptyfwd.h
@@ -50,4 +50,6 @@ int pty_forward_set_titlef(PTYForward *f, const char *format, ...) _printf_(2,3)
int pty_forward_set_title_prefix(PTYForward *f, const char *prefix);
+bool shall_set_terminal_title(void);
+
DEFINE_TRIVIAL_CLEANUP_FUNC(PTYForward*, pty_forward_free);
diff --git a/src/vmspawn/vmspawn.c b/src/vmspawn/vmspawn.c
index 05eb443bd0..584e8062b0 100644
--- a/src/vmspawn/vmspawn.c
+++ b/src/vmspawn/vmspawn.c
@@ -1266,6 +1266,9 @@ static void set_window_title(PTYForward *f) {
assert(f);
+ if (!shall_set_terminal_title())
+ return;
+
(void) gethostname_strict(&hn);
if (emoji_enabled())