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