diff --git a/man/kernel-command-line.xml b/man/kernel-command-line.xml
index 8f179deec8..d4b005f876 100644
--- a/man/kernel-command-line.xml
+++ b/man/kernel-command-line.xml
@@ -86,6 +86,7 @@
systemd.mask=systemd.wants=systemd.debug_shell
+ systemd.default_debug_tty=Additional parameters understood by
systemd-debug-generator8,
diff --git a/man/systemd-debug-generator.xml b/man/systemd-debug-generator.xml
index 5d2dbe2cd5..2f27f0fe4e 100644
--- a/man/systemd-debug-generator.xml
+++ b/man/systemd-debug-generator.xml
@@ -55,19 +55,16 @@
RAM disk (initrd) while is
honored only in the main system.
- If the or
- option is
- specified, the debug shell service
- debug-shell.service is pulled into the boot
- transaction and a debug shell will be spawned during early boot.
- By default, &DEBUGTTY; is used, but a specific tty can also be set,
- either with or without the /dev/ prefix.
- Note that the shell may also be turned on persistently by enabling it with
- systemctl1's
- enable command.
- is honored only by initial
- RAM disk (initrd) while is
- honored only in the main system.
+ If the or option is
+ specified, the debug shell service debug-shell.service is pulled into the boot
+ transaction and a debug shell will be spawned during early boot. By default,
+ &DEBUGTTY; is used, but a specific tty can also be specified, either with or without
+ the /dev/ prefix. To set the tty to use without enabling the debug shell, the
+ option can be used which also takes a tty with or without the
+ /dev/ prefix. Note that the shell may also be turned on persistently by enabling it
+ with systemctl1's
+ enable command. is honored only by initial
+ RAM disk (initrd) while is honored only in the main system.systemd-debug-generator implements
systemd.generator7.
diff --git a/src/debug-generator/debug-generator.c b/src/debug-generator/debug-generator.c
index 8a474c58cf..741b59f320 100644
--- a/src/debug-generator/debug-generator.c
+++ b/src/debug-generator/debug-generator.c
@@ -20,12 +20,15 @@ static const char *arg_dest = NULL;
static char *arg_default_unit = NULL;
static char **arg_mask = NULL;
static char **arg_wants = NULL;
-static char *arg_debug_shell = NULL;
+static bool arg_debug_shell = false;
+static char *arg_debug_tty = NULL;
+static char *arg_default_debug_tty = NULL;
STATIC_DESTRUCTOR_REGISTER(arg_default_unit, freep);
STATIC_DESTRUCTOR_REGISTER(arg_mask, strv_freep);
STATIC_DESTRUCTOR_REGISTER(arg_wants, strv_freep);
-STATIC_DESTRUCTOR_REGISTER(arg_debug_shell, freep);
+STATIC_DESTRUCTOR_REGISTER(arg_debug_tty, freep);
+STATIC_DESTRUCTOR_REGISTER(arg_default_debug_tty, freep);
static int parse_proc_cmdline_item(const char *key, const char *value, void *data) {
int r;
@@ -61,15 +64,18 @@ static int parse_proc_cmdline_item(const char *key, const char *value, void *dat
return log_oom();
} else if (proc_cmdline_key_streq(key, "systemd.debug_shell")) {
- const char *t = NULL;
-
r = value ? parse_boolean(value) : 1;
- if (r < 0)
- t = skip_dev_prefix(value);
- else if (r > 0)
- t = skip_dev_prefix(DEBUGTTY);
+ arg_debug_shell = r != 0;
+ if (r >= 0)
+ return 0;
- return free_and_strdup_warn(&arg_debug_shell, t);
+ return free_and_strdup_warn(&arg_debug_tty, skip_dev_prefix(value));
+
+ } else if (proc_cmdline_key_streq(key, "systemd.default_debug_tty")) {
+ if (proc_cmdline_value_missing(key, value))
+ return 0;
+
+ return free_and_strdup_warn(&arg_default_debug_tty, skip_dev_prefix(value));
} else if (streq(key, "systemd.unit")) {
@@ -136,9 +142,10 @@ static int generate_wants_symlinks(void) {
}
static void install_debug_shell_dropin(const char *dir) {
+ const char *tty = arg_debug_tty ?: arg_default_debug_tty;
int r;
- if (streq(arg_debug_shell, skip_dev_prefix(DEBUGTTY)))
+ if (!tty || path_equal(tty, skip_dev_prefix(DEBUGTTY)))
return;
r = write_drop_in_format(dir, "debug-shell.service", 50, "tty",
@@ -147,7 +154,7 @@ static void install_debug_shell_dropin(const char *dir) {
"ConditionPathExists=\n"
"[Service]\n"
"TTYPath=/dev/%s",
- arg_debug_shell, arg_debug_shell);
+ tty, tty);
if (r < 0)
log_warning_errno(r, "Failed to write drop-in for debug-shell.service, ignoring: %m");
}
diff --git a/test/units/testsuite-81.debug-generator.sh b/test/units/testsuite-81.debug-generator.sh
index fddf85a54c..ef1e205aac 100755
--- a/test/units/testsuite-81.debug-generator.sh
+++ b/test/units/testsuite-81.debug-generator.sh
@@ -62,6 +62,13 @@ SYSTEMD_PROC_CMDLINE="$CMDLINE" run_and_list "$GENERATOR_BIN" "$OUT_DIR"
link_endswith "$OUT_DIR/early/default.target.wants/debug-shell.service" /lib/systemd/system/debug-shell.service
grep -F "/dev/tty666" "$OUT_DIR/early/debug-shell.service.d/50-tty.conf"
+# Same thing, but with custom tty using systemd.default_debug_tty
+: "debug-shell: regular + systemd.default_debug_tty=/dev/tty666 systemd.debug_shell=yes"
+CMDLINE="$CMDLINE systemd.default_debug_tty=/dev/tty666 systemd.debug_shell=yes"
+SYSTEMD_PROC_CMDLINE="$CMDLINE" run_and_list "$GENERATOR_BIN" "$OUT_DIR"
+link_endswith "$OUT_DIR/early/default.target.wants/debug-shell.service" /lib/systemd/system/debug-shell.service
+grep -F "/dev/tty666" "$OUT_DIR/early/debug-shell.service.d/50-tty.conf"
+
# Now override the default target via systemd.unit=
: "debug-shell: regular + systemd.unit="
CMDLINE="$CMDLINE systemd.unit=my-fancy.target"