From 4c60d7b5aeef46f9c3079779e4b436dfce2ee996 Mon Sep 17 00:00:00 2001 From: Adam Williamson Date: Jan 19 2017 23:37:04 +0000 Subject: Backport fix for boot failure in initrd-switch-root (#1414904) --- diff --git a/0005-core-make-sure-initrd-switch-root-command-survives-P.patch b/0005-core-make-sure-initrd-switch-root-command-survives-P.patch new file mode 100644 index 0000000..11d1f8c --- /dev/null +++ b/0005-core-make-sure-initrd-switch-root-command-survives-P.patch @@ -0,0 +1,58 @@ +From acc28e2e3037d689d6481e4664925cf31d4d087b Mon Sep 17 00:00:00 2001 +From: Franck Bui +Date: Thu, 24 Nov 2016 18:52:04 +0100 +Subject: [PATCH] core: make sure initrd-switch-root command survives PID1's + killing spree (#4730) + +This is a different way to implement the fix proposed by commit +a4021390fef27f4136497328f suggested by Lennart Poettering. + +In this patch we instruct PID1 to not kill "systemctl switch-root" command +started by initrd-switch-root service using the "argv[0][0]='@'" trick. + +See: https://www.freedesktop.org/wiki/Software/systemd/RootStorageDaemons/ for +more details. + +We had to backup argv[0] because argv is modified by dispatch_verb(). +--- + src/systemctl/systemctl.c | 10 ++++++++++ + 1 files changed, 10 insertions(+), 0 deletions(-) + +diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c +index 4fd8d7ba2..ed1c7178b 100644 +--- a/src/systemctl/systemctl.c ++++ b/src/systemctl/systemctl.c +@@ -142,6 +142,7 @@ static const char *arg_kill_who = NULL; + static int arg_signal = SIGTERM; + static char *arg_root = NULL; + static usec_t arg_when = 0; ++static char *argv_cmdline = NULL; + static enum action { + _ACTION_INVALID, + ACTION_SYSTEMCTL, +@@ -5638,6 +5639,13 @@ static int switch_root(int argc, char *argv[], void *userdata) { + init = NULL; + } + ++ /* Instruct PID1 to exclude us from its killing spree applied during ++ * the transition from the initrd to the main system otherwise we would ++ * exit with a failure status even though the switch to the new root ++ * has succeed. */ ++ if (in_initrd()) ++ argv_cmdline[0] = '@'; ++ + r = acquire_bus(BUS_MANAGER, &bus); + if (r < 0) + return r; +@@ -8373,6 +8381,8 @@ static int logind_cancel_shutdown(void) { + int main(int argc, char*argv[]) { + int r; + ++ argv_cmdline = argv[0]; ++ + setlocale(LC_ALL, ""); + log_parse_environment(); + log_open(); +-- +2.11.0 + diff --git a/systemd.spec b/systemd.spec index fbe6c5e..ba4fd40 100644 --- a/systemd.spec +++ b/systemd.spec @@ -12,7 +12,7 @@ Name: systemd Url: http://www.freedesktop.org/wiki/Software/systemd Version: 232 -Release: 9%{?gitcommit:.git%{gitcommitshort}}%{?dist} +Release: 10%{?gitcommit:.git%{gitcommitshort}}%{?dist} # For a breakdown of the licensing, see README License: LGPLv2+ and MIT and GPLv2+ Summary: System and Service Manager @@ -43,6 +43,10 @@ Patch0001: 0001-build-sys-link-test-seccomp-against-seccomp-libs-456.patch Patch0002: 0002-kernel-install-use-exit-instead-of-return-4565.patch Patch0003: 0003-kernel-install-avoid-process-substitution.patch Patch0004: 0004-build-sys-check-for-lz4-in-the-old-and-new-numbering.patch +# Fix periodic boot fail in initrd-switch-root.service +# https://github.com/systemd/systemd/commit/acc28e2e3037d689d6481e4664925cf31d4d087b +# re-diffed on v232 +Patch0005: 0005-core-make-sure-initrd-switch-root-command-survives-P.patch Patch0998: 0998-resolved-create-etc-resolv.conf-symlink-at-runtime.patch @@ -962,6 +966,9 @@ getent passwd systemd-journal-upload &>/dev/null || useradd -r -l -g systemd-jou %{_mandir}/man[1578]/systemd-journal-gateway* %changelog +* Thu Jan 19 2017 Adam Williamson - 232-10 +- Backport fix for boot failure in initrd-switch-root (#1414904) + * Wed Jan 18 2017 Zbigniew Jędrzejewski-Szmek - 232-9 - Add fake dependency on systemd-pam to systemd-devel to ensure systemd-pam is available as multilib (#1414153)