Merge pull request #33959 from DaanDeMeyer/crash

Two crash handler improvements
This commit is contained in:
Daan De Meyer
2024-08-08 08:14:46 +02:00
committed by GitHub
5 changed files with 19 additions and 6 deletions
+2 -3
View File
@@ -843,9 +843,8 @@
<listitem><para>Takes a boolean argument or enables the option if specified
without an argument. If enabled, the system manager (PID 1) spawns a shell
when it crashes, after a 10s delay. Otherwise, no shell is spawned. Defaults
to disabled, for security reasons, as the shell is not protected by password
authentication.</para>
when it crashes. Otherwise, no shell is spawned. Defaults to disabled, for
security reasons, as the shell is not protected by password authentication.</para>
<xi:include href="version-info.xml" xpointer="v233"/></listitem>
</varlistentry>
+3
View File
@@ -0,0 +1,3 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
set debuginfod enabled off
+12
View File
@@ -434,6 +434,18 @@ int terminal_vhangup_fd(int fd) {
return RET_NERRNO(ioctl(fd, TIOCVHANGUP));
}
int terminal_vhangup(const char *tty) {
_cleanup_close_ int fd = -EBADF;
assert(tty);
fd = open_terminal(tty, O_RDWR|O_NOCTTY|O_CLOEXEC);
if (fd < 0)
return fd;
return terminal_vhangup_fd(fd);
}
int vt_disallocate(const char *tty_path) {
assert(tty_path);
+1
View File
@@ -68,6 +68,7 @@ const char* color_mode_to_string(ColorMode m) _const_;
ColorMode color_mode_from_string(const char *s) _pure_;
int terminal_vhangup_fd(int fd);
int terminal_vhangup(const char *tty);
int terminal_set_size_fd(int fd, const char *ident, unsigned rows, unsigned cols);
int proc_cmdline_tty_size(const char *tty, unsigned *ret_rows, unsigned *ret_cols);
+1 -3
View File
@@ -155,9 +155,6 @@ _noreturn_ static void crash(int sig, siginfo_t *siginfo, void *context) {
(void) sigaction(SIGCHLD, &sa, NULL);
if (arg_crash_shell) {
log_notice("Executing crash shell in 10s...");
(void) sleep(10);
pid = raw_clone(SIGCHLD);
if (pid < 0)
log_struct_errno(LOG_EMERG, errno,
@@ -165,6 +162,7 @@ _noreturn_ static void crash(int sig, siginfo_t *siginfo, void *context) {
"MESSAGE_ID=" SD_MESSAGE_CRASH_SHELL_FORK_FAILED_STR);
else if (pid == 0) {
(void) setsid();
(void) terminal_vhangup("/dev/console");
(void) make_console_stdio();
(void) rlimit_nofile_safe();
(void) execle("/bin/sh", "/bin/sh", NULL, environ);