chiark / gitweb /
unblock signals we might want to handle
authorKay Sievers <kay.sievers@vrfy.org>
Sat, 31 Oct 2009 10:53:41 +0000 (11:53 +0100)
committerKay Sievers <kay.sievers@vrfy.org>
Sat, 31 Oct 2009 10:53:41 +0000 (11:53 +0100)
On Thu, Oct 29, 2009 at 19:15, Christian P. Schmidt <schmidt@digadd.de> wrote:
> After the getty replaces itself with login the pam module pam_mount
> calls mount. This in turn determines that the partition to be mounted is
> LUKS encrypted, and calls cryptsetup. Cryptsetup receives the password,
> unlocks the partition, and calls udevadm settle in order to avoid some
> problems in interaction with LVM.
>
> udevadm settle never returns.
>
> The problem here is that SIGUSR1 and SIGALRM are both blocked in oldmask
> already, and never reach udevadm. No care is ever taken to ensure those
> signals are not blocked.

udev/test-udev.c
udev/udevadm-monitor.c
udev/udevadm-settle.c

index 0806fbf9ce5fb04a8b480c104b928a285c00f86e..bd61aa0695021082495b9cd1e0ece06b0fb8e819 100644 (file)
@@ -52,6 +52,7 @@ int main(int argc, char *argv[])
        const char *action;
        const char *subsystem;
        struct sigaction act;
+       sigset_t mask;
        int err = -EINVAL;
 
        udev = udev_new();
@@ -68,6 +69,11 @@ int main(int argc, char *argv[])
        sigaction(SIGALRM, &act, NULL);
        sigaction(SIGINT, &act, NULL);
        sigaction(SIGTERM, &act, NULL);
+       sigemptyset(&mask);
+       sigaddset(&mask, SIGALRM);
+       sigaddset(&mask, SIGINT);
+       sigaddset(&mask, SIGTERM);
+       sigprocmask(SIG_UNBLOCK, &mask, NULL);
 
        /* trigger timeout to prevent hanging processes */
        alarm(UDEV_EVENT_TIMEOUT);
index 90388db58e38c3113d67f4c5f0552e886a1656d6..00b130dafea6a823183e4da61e1fe50fe3189721 100644 (file)
@@ -67,6 +67,7 @@ static void print_device(struct udev_device *device, const char *source, int pro
 int udevadm_monitor(struct udev *udev, int argc, char *argv[])
 {
        struct sigaction act;
+       sigset_t mask;
        int option;
        int prop = 0;
        int print_kernel = 0;
@@ -142,6 +143,10 @@ int udevadm_monitor(struct udev *udev, int argc, char *argv[])
        act.sa_flags = SA_RESTART;
        sigaction(SIGINT, &act, NULL);
        sigaction(SIGTERM, &act, NULL);
+       sigemptyset(&mask);
+       sigaddset(&mask, SIGINT);
+       sigaddset(&mask, SIGTERM);
+       sigprocmask(SIG_UNBLOCK, &mask, NULL);
 
        printf("monitor will print the received events for:\n");
        if (print_udev) {
index 5030f18602c9e8a8bd3163b80f6b1f5379987157..4f422f90927d410b3287721245fed26444435840 100644 (file)
@@ -66,6 +66,7 @@ int udevadm_settle(struct udev *udev, int argc, char *argv[])
        const char *exists = NULL;
        int timeout = DEFAULT_TIMEOUT;
        struct sigaction act;
+       sigset_t mask;
        struct udev_queue *udev_queue = NULL;
        int rc = 1;
 
@@ -78,6 +79,10 @@ int udevadm_settle(struct udev *udev, int argc, char *argv[])
        act.sa_flags = 0;
        sigaction(SIGALRM, &act, NULL);
        sigaction(SIGUSR1, &act, NULL);
+       sigemptyset(&mask);
+       sigaddset(&mask, SIGUSR1);
+       sigaddset(&mask, SIGALRM);
+       sigprocmask(SIG_UNBLOCK, &mask, NULL);
 
        while (1) {
                int option;
@@ -163,7 +168,7 @@ int udevadm_settle(struct udev *udev, int argc, char *argv[])
 
                uctrl = udev_ctrl_new_from_socket(udev, UDEV_CTRL_SOCK_PATH);
                if (uctrl != NULL) {
-                       sigset_t mask, oldmask;
+                       sigset_t oldmask;
 
                        sigemptyset(&mask);
                        sigaddset(&mask, SIGUSR1);