From 995a44a897884dd7c896d6fbd059ce44eb6a365f Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Tue, 20 Mar 2012 10:25:11 +0000 Subject: [PATCH] * Fix a race condition in mountall: the USR1 signal handler must be installed before we daemonise, otherwise another job might send USR1 to mountall before the handler is installed, killing it. svn path=/nixpkgs/trunk/; revision=33289 --- pkgs/os-specific/linux/mountall/default.nix | 2 +- .../linux/mountall/fix-usr1-race.patch | 27 +++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 pkgs/os-specific/linux/mountall/fix-usr1-race.patch diff --git a/pkgs/os-specific/linux/mountall/default.nix b/pkgs/os-specific/linux/mountall/default.nix index aed55dc37e34..b563b80f9a9f 100644 --- a/pkgs/os-specific/linux/mountall/default.nix +++ b/pkgs/os-specific/linux/mountall/default.nix @@ -8,7 +8,7 @@ stdenv.mkDerivation { sha256 = "1k52d4x75balnwcsqgznvzrdqgbp2dqnrzw0n25kajdcwr192wwy"; }; - patches = [ ./no-plymouth.patch ]; + patches = [ ./no-plymouth.patch ./fix-usr1-race.patch ]; preConfigure = "rm -R aclocal.m4; gettextize -f; autoreconf -vfi"; diff --git a/pkgs/os-specific/linux/mountall/fix-usr1-race.patch b/pkgs/os-specific/linux/mountall/fix-usr1-race.patch new file mode 100644 index 000000000000..e970b77733cc --- /dev/null +++ b/pkgs/os-specific/linux/mountall/fix-usr1-race.patch @@ -0,0 +1,27 @@ +diff -ru mountall-2.35-orig/src/mountall.c mountall-2.35/src/mountall.c +--- mountall-2.35-orig/src/mountall.c 2012-03-20 11:01:14.035898815 +0100 ++++ mountall-2.35/src/mountall.c 2012-03-20 11:20:39.194786311 +0100 +@@ -3746,6 +3746,12 @@ + exit (EXIT_ERROR); + } + ++ /* SIGUSR1 tells us that a network device came up. Install ++ the handler before daemonising so that the mountall-net job ++ won't kill us by sending USR1. */ ++ nih_signal_set_handler (SIGUSR1, nih_signal_handler); ++ NIH_MUST (nih_signal_add_handler (NULL, SIGUSR1, usr1_handler, NULL)); ++ + /* Become daemon */ + if (daemonise) { + pid_t pid; +@@ -3799,10 +3805,6 @@ + nih_signal_set_handler (SIGTERM, nih_signal_handler); + NIH_MUST (nih_signal_add_handler (NULL, SIGTERM, nih_main_term_signal, NULL)); + +- /* SIGUSR1 tells us that a network device came up */ +- nih_signal_set_handler (SIGUSR1, nih_signal_handler); +- NIH_MUST (nih_signal_add_handler (NULL, SIGUSR1, usr1_handler, NULL)); +- + /* Check for force-fsck on the kernel command line */ + cmdline = fopen ("/proc/cmdline", "r"); + if (cmdline) {