Message error handling fixed at nl_pid and EINTR. - nldev - NetLink DEVice manager; a lightweight netlink frontend for mdev.
       
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) LICENSE
       ---
 (DIR) commit 4671d8270e28dca692eec5cef1bb533a423cf1dc
 (DIR) parent e2d4a797b6364fd79fc6102d866f074409604815
 (HTM) Author: Christoph Lohmann <20h@r-36.net>
       Date:   Sat, 28 Apr 2012 11:13:07 +0200
       
       Message error handling fixed at nl_pid and EINTR.
       
       Diffstat:
         nldev.c                             |      16 +++++++---------
       
       1 file changed, 7 insertions(+), 9 deletions(-)
       ---
 (DIR) diff --git a/nldev.c b/nldev.c
       @@ -254,19 +254,18 @@ main(int argc, char *argv[])
                        hdr.msg_name = &cnls;
                        hdr.msg_namelen = sizeof(cnls);
        
       -                printf("recvmsg\n");
                        len = recvmsg(fds.fd, &hdr, 0);
       -                if (len < 0 && errno == EINTR)
       -                        continue;
       -                printf("check 2\n");
       +                if (len < 0) {
       +                        if (errno == EINTR)
       +                                continue;
       +                        edie("recvmsg");
       +                }
                        if (len < 32 || len >= sizeof(buf))
       -                        edie("recv");
       +                        continue;
        
       -                printf("chdr\n");
                        chdr = CMSG_FIRSTHDR(&hdr);
                        if (chdr == NULL || chdr->cmsg_type != SCM_CREDENTIALS)
                                continue;
       -                printf("cred\n");
        
                        /*
                         * Don't allow anyone but root to send us messages.
       @@ -279,7 +278,6 @@ main(int argc, char *argv[])
                        if (cred->uid != 0 && !showudev)
                                continue;
        
       -                printf("libudev\n");
                        if (!memcmp(buf, "libudev", 8)) {
                                /*
                                 * Receiving messages from udev is insecure.
       @@ -293,7 +291,7 @@ main(int argc, char *argv[])
                                 * Kernel messages shouldn't come from the
                                 * userspace.
                                 */
       -                        if (cnls.pid > 0)
       +                        if (cnls.nl_pid > 0)
                                        continue;
                        }