mirror of
https://github.com/systemd/systemd
synced 2024-10-06 16:21:34 +00:00
debug-generator: enable custom systemd.debug_shell tty
This commit is contained in:
parent
8fabb625ac
commit
93912e872f
|
@ -8,3 +8,4 @@
|
||||||
<!ENTITY CERTIFICATE_ROOT @CERTIFICATE_ROOT@>
|
<!ENTITY CERTIFICATE_ROOT @CERTIFICATE_ROOT@>
|
||||||
<!ENTITY MEMORY_ACCOUNTING_DEFAULT @MEMORY_ACCOUNTING_DEFAULT_YES_NO@>
|
<!ENTITY MEMORY_ACCOUNTING_DEFAULT @MEMORY_ACCOUNTING_DEFAULT_YES_NO@>
|
||||||
<!ENTITY KILL_USER_PROCESSES @KILL_USER_PROCESSES_YES_NO@>
|
<!ENTITY KILL_USER_PROCESSES @KILL_USER_PROCESSES_YES_NO@>
|
||||||
|
<!ENTITY DEBUGTTY @DEBUGTTY@>
|
||||||
|
|
|
@ -1,7 +1,10 @@
|
||||||
<?xml version="1.0"?>
|
<?xml version="1.0"?>
|
||||||
<!--*-nxml-*-->
|
<!--*-nxml-*-->
|
||||||
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
|
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
|
||||||
"http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
|
"http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd" [
|
||||||
|
<!ENTITY % entities SYSTEM "custom-entities.ent" >
|
||||||
|
%entities;
|
||||||
|
]>
|
||||||
<!-- SPDX-License-Identifier: LGPL-2.1+ -->
|
<!-- SPDX-License-Identifier: LGPL-2.1+ -->
|
||||||
<refentry id="systemd-debug-generator">
|
<refentry id="systemd-debug-generator">
|
||||||
|
|
||||||
|
@ -56,9 +59,10 @@
|
||||||
<option>rd.systemd.debug_shell</option> option is
|
<option>rd.systemd.debug_shell</option> option is
|
||||||
specified, the debug shell service
|
specified, the debug shell service
|
||||||
<literal>debug-shell.service</literal> is pulled into the boot
|
<literal>debug-shell.service</literal> is pulled into the boot
|
||||||
transaction. It will spawn a debug shell on tty9 during early
|
transaction and a debug shell will be spawned during early boot.
|
||||||
system startup. Note that the shell may also be turned on
|
By default, <filename>&DEBUGTTY;</filename> is used, but a specific tty can also be set,
|
||||||
persistently by enabling it with
|
either with or without the <filename>/dev/</filename> prefix.
|
||||||
|
Note that the shell may also be turned on persistently by enabling it with
|
||||||
<citerefentry><refentrytitle>systemctl</refentrytitle><manvolnum>1</manvolnum></citerefentry>'s
|
<citerefentry><refentrytitle>systemctl</refentrytitle><manvolnum>1</manvolnum></citerefentry>'s
|
||||||
<command>enable</command> command.
|
<command>enable</command> command.
|
||||||
<option>rd.systemd.debug_shell=</option> is honored only by initial
|
<option>rd.systemd.debug_shell=</option> is honored only by initial
|
||||||
|
|
|
@ -789,6 +789,7 @@ conf.set_quoted('GETTEXT_PACKAGE', meson.project_name())
|
||||||
|
|
||||||
substs.set('SUSHELL', get_option('debug-shell'))
|
substs.set('SUSHELL', get_option('debug-shell'))
|
||||||
substs.set('DEBUGTTY', get_option('debug-tty'))
|
substs.set('DEBUGTTY', get_option('debug-tty'))
|
||||||
|
conf.set_quoted('DEBUGTTY', get_option('debug-tty'))
|
||||||
|
|
||||||
enable_debug_hashmap = false
|
enable_debug_hashmap = false
|
||||||
enable_debug_mmap_cache = false
|
enable_debug_mmap_cache = false
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "alloc-util.h"
|
#include "alloc-util.h"
|
||||||
|
#include "dropin.h"
|
||||||
#include "generator.h"
|
#include "generator.h"
|
||||||
#include "mkdir.h"
|
#include "mkdir.h"
|
||||||
#include "parse-util.h"
|
#include "parse-util.h"
|
||||||
|
@ -17,11 +18,12 @@ static const char *arg_dest = NULL;
|
||||||
static char *arg_default_unit = NULL;
|
static char *arg_default_unit = NULL;
|
||||||
static char **arg_mask = NULL;
|
static char **arg_mask = NULL;
|
||||||
static char **arg_wants = NULL;
|
static char **arg_wants = NULL;
|
||||||
static bool arg_debug_shell = false;
|
static char *arg_debug_shell = NULL;
|
||||||
|
|
||||||
STATIC_DESTRUCTOR_REGISTER(arg_default_unit, freep);
|
STATIC_DESTRUCTOR_REGISTER(arg_default_unit, freep);
|
||||||
STATIC_DESTRUCTOR_REGISTER(arg_mask, strv_freep);
|
STATIC_DESTRUCTOR_REGISTER(arg_mask, strv_freep);
|
||||||
STATIC_DESTRUCTOR_REGISTER(arg_wants, strv_freep);
|
STATIC_DESTRUCTOR_REGISTER(arg_wants, strv_freep);
|
||||||
|
STATIC_DESTRUCTOR_REGISTER(arg_debug_shell, freep);
|
||||||
|
|
||||||
static int parse_proc_cmdline_item(const char *key, const char *value, void *data) {
|
static int parse_proc_cmdline_item(const char *key, const char *value, void *data) {
|
||||||
int r;
|
int r;
|
||||||
|
@ -57,15 +59,16 @@ static int parse_proc_cmdline_item(const char *key, const char *value, void *dat
|
||||||
return log_oom();
|
return log_oom();
|
||||||
|
|
||||||
} else if (proc_cmdline_key_streq(key, "systemd.debug_shell")) {
|
} else if (proc_cmdline_key_streq(key, "systemd.debug_shell")) {
|
||||||
|
const char *t = NULL;
|
||||||
|
|
||||||
if (value) {
|
r = value ? parse_boolean(value) : 1;
|
||||||
r = parse_boolean(value);
|
if (r < 0)
|
||||||
if (r < 0)
|
t = skip_dev_prefix(value);
|
||||||
log_error("Failed to parse systemd.debug_shell= argument '%s', ignoring.", value);
|
else if (r > 0)
|
||||||
else
|
t = skip_dev_prefix(DEBUGTTY);
|
||||||
arg_debug_shell = r;
|
|
||||||
} else
|
if (free_and_strdup(&arg_debug_shell, t) < 0)
|
||||||
arg_debug_shell = true;
|
return log_oom();
|
||||||
|
|
||||||
} else if (streq(key, "systemd.unit")) {
|
} else if (streq(key, "systemd.unit")) {
|
||||||
|
|
||||||
|
@ -143,6 +146,23 @@ static int generate_wants_symlinks(void) {
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void install_debug_shell_dropin(const char *dir) {
|
||||||
|
int r;
|
||||||
|
|
||||||
|
if (streq(arg_debug_shell, skip_dev_prefix(DEBUGTTY)))
|
||||||
|
return;
|
||||||
|
|
||||||
|
r = write_drop_in_format(dir, "debug-shell.service", 50, "tty",
|
||||||
|
"[Unit]\n"
|
||||||
|
"Description=Early root shell on /dev/%s FOR DEBUGGING ONLY\n"
|
||||||
|
"ConditionPathExists=\n"
|
||||||
|
"[Service]\n"
|
||||||
|
"TTYPath=/dev/%s",
|
||||||
|
arg_debug_shell, arg_debug_shell);
|
||||||
|
if (r < 0)
|
||||||
|
log_warning_errno(r, "Failed to write drop-in for debug-shell.service, ignoring: %m");
|
||||||
|
}
|
||||||
|
|
||||||
static int run(const char *dest, const char *dest_early, const char *dest_late) {
|
static int run(const char *dest, const char *dest_early, const char *dest_late) {
|
||||||
int r, q;
|
int r, q;
|
||||||
|
|
||||||
|
@ -156,6 +176,8 @@ static int run(const char *dest, const char *dest_early, const char *dest_late)
|
||||||
r = strv_extend(&arg_wants, "debug-shell.service");
|
r = strv_extend(&arg_wants, "debug-shell.service");
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return log_oom();
|
return log_oom();
|
||||||
|
|
||||||
|
install_debug_shell_dropin(arg_dest);
|
||||||
}
|
}
|
||||||
|
|
||||||
r = generate_mask_symlinks();
|
r = generate_mask_symlinks();
|
||||||
|
|
Loading…
Reference in a new issue