|
Zbigniew Jędrzejewski-Szmek |
5509c0 |
From ab25a485218194a432a8238b772005f4506059f3 Mon Sep 17 00:00:00 2001
|
|
Zbigniew Jędrzejewski-Szmek |
5509c0 |
From: Ruediger Oertel <ro@suse.de>
|
|
Zbigniew Jędrzejewski-Szmek |
5509c0 |
Date: Fri, 13 Jun 2014 16:41:06 +0200
|
|
Zbigniew Jędrzejewski-Szmek |
5509c0 |
Subject: [PATCH] Reset signal-mask on re-exec to init=..
|
|
Zbigniew Jędrzejewski-Szmek |
5509c0 |
|
|
Zbigniew Jędrzejewski-Szmek |
5509c0 |
Process 1 (aka init) needs to be started with an empty signal mask.
|
|
Zbigniew Jędrzejewski-Szmek |
5509c0 |
That includes the process 1 that's started after the initrd is finished.
|
|
Zbigniew Jędrzejewski-Szmek |
5509c0 |
When the initrd is using systemd (as it does with dracut based initrds)
|
|
Zbigniew Jędrzejewski-Szmek |
5509c0 |
then it is systemd that calls the real init. Normally this is systemd
|
|
Zbigniew Jędrzejewski-Szmek |
5509c0 |
again, except when the user uses for instance "init=/bin/bash" on the
|
|
Zbigniew Jędrzejewski-Szmek |
5509c0 |
kernel command line.
|
|
Zbigniew Jędrzejewski-Szmek |
5509c0 |
|
|
Zbigniew Jędrzejewski-Szmek |
5509c0 |
(cherry picked from commit 5a85ca1cb622fda4a39c8a6f00dccea7f8a1e82a)
|
|
Zbigniew Jędrzejewski-Szmek |
5509c0 |
---
|
|
Zbigniew Jędrzejewski-Szmek |
5509c0 |
src/core/main.c | 8 ++++++++
|
|
Zbigniew Jędrzejewski-Szmek |
5509c0 |
1 file changed, 8 insertions(+)
|
|
Zbigniew Jędrzejewski-Szmek |
5509c0 |
|
|
Zbigniew Jędrzejewski-Szmek |
5509c0 |
diff --git a/src/core/main.c b/src/core/main.c
|
|
Zbigniew Jędrzejewski-Szmek |
5509c0 |
index d5d1ee2b..e87b8cc8 100644
|
|
Zbigniew Jędrzejewski-Szmek |
5509c0 |
--- a/src/core/main.c
|
|
Zbigniew Jędrzejewski-Szmek |
5509c0 |
+++ b/src/core/main.c
|
|
Zbigniew Jędrzejewski-Szmek |
5509c0 |
@@ -1831,6 +1831,7 @@ finish:
|
|
Zbigniew Jędrzejewski-Szmek |
5509c0 |
if (reexecute) {
|
|
Zbigniew Jędrzejewski-Szmek |
5509c0 |
const char **args;
|
|
Zbigniew Jędrzejewski-Szmek |
5509c0 |
unsigned i, args_size;
|
|
Zbigniew Jędrzejewski-Szmek |
5509c0 |
+ sigset_t ss, o_ss;
|
|
Zbigniew Jędrzejewski-Szmek |
5509c0 |
|
|
Zbigniew Jędrzejewski-Szmek |
5509c0 |
/* Close and disarm the watchdog, so that the new
|
|
Zbigniew Jędrzejewski-Szmek |
5509c0 |
* instance can reinitialize it, but doesn't get
|
|
Zbigniew Jędrzejewski-Szmek |
5509c0 |
@@ -1914,6 +1915,11 @@ finish:
|
|
Zbigniew Jędrzejewski-Szmek |
5509c0 |
args[i++] = NULL;
|
|
Zbigniew Jędrzejewski-Szmek |
5509c0 |
assert(i <= args_size);
|
|
Zbigniew Jędrzejewski-Szmek |
5509c0 |
|
|
Zbigniew Jędrzejewski-Szmek |
5509c0 |
+ /* reenable any blocked signals, especially important
|
|
Zbigniew Jędrzejewski-Szmek |
5509c0 |
+ * if we switch from initial ramdisk to init=... */
|
|
Zbigniew Jędrzejewski-Szmek |
5509c0 |
+ sigemptyset(&ss);
|
|
Zbigniew Jędrzejewski-Szmek |
5509c0 |
+ sigprocmask(SIG_SETMASK, &ss, &o_ss);
|
|
Zbigniew Jędrzejewski-Szmek |
5509c0 |
+
|
|
Zbigniew Jędrzejewski-Szmek |
5509c0 |
if (switch_root_init) {
|
|
Zbigniew Jędrzejewski-Szmek |
5509c0 |
args[0] = switch_root_init;
|
|
Zbigniew Jędrzejewski-Szmek |
5509c0 |
execv(args[0], (char* const*) args);
|
|
Zbigniew Jędrzejewski-Szmek |
5509c0 |
@@ -1932,6 +1938,8 @@ finish:
|
|
Zbigniew Jędrzejewski-Szmek |
5509c0 |
log_error("Failed to execute /bin/sh, giving up: %m");
|
|
Zbigniew Jędrzejewski-Szmek |
5509c0 |
} else
|
|
Zbigniew Jędrzejewski-Szmek |
5509c0 |
log_warning("Failed to execute /sbin/init, giving up: %m");
|
|
Zbigniew Jędrzejewski-Szmek |
5509c0 |
+
|
|
Zbigniew Jędrzejewski-Szmek |
5509c0 |
+ sigprocmask(SIG_SETMASK, &o_ss, NULL);
|
|
Zbigniew Jędrzejewski-Szmek |
5509c0 |
}
|
|
Zbigniew Jędrzejewski-Szmek |
5509c0 |
|
|
Zbigniew Jędrzejewski-Szmek |
5509c0 |
if (arg_serialization) {
|