chiark / gitweb /
udev/udev-ctrl.c:udev_ctrl_new_from_fd() enable SO_PASSCRED
authorHarald Hoyer <harald@redhat.com>
Mon, 8 Apr 2013 17:59:20 +0000 (19:59 +0200)
committerHarald Hoyer <harald@redhat.com>
Mon, 8 Apr 2013 18:03:50 +0000 (20:03 +0200)
Avoid "sender uid=65534, message ignored" case, where no credentials can
be read on the sender side.

Seems, the server socket does not enable credential receiving fast
enough, and the message from the client (without credential) sometimes
is queued before the credential passing was active.

src/udev/udev-ctrl.c

index 6ee6b04b1b39ee3acae55a46f195518fb1963620..e60da906c5417eafae1605c7319ad70620294cbb 100644 (file)
@@ -73,6 +73,7 @@ struct udev_ctrl_connection {
 struct udev_ctrl *udev_ctrl_new_from_fd(struct udev *udev, int fd)
 {
         struct udev_ctrl *uctrl;
+        const int on = 1;
 
         uctrl = calloc(1, sizeof(struct udev_ctrl));
         if (uctrl == NULL)
@@ -91,6 +92,7 @@ struct udev_ctrl *udev_ctrl_new_from_fd(struct udev *udev, int fd)
                 uctrl->bound = true;
                 uctrl->sock = fd;
         }
+        setsockopt(uctrl->sock, SOL_SOCKET, SO_PASSCRED, &on, sizeof(on));
 
         uctrl->saddr.sun_family = AF_LOCAL;
         strscpy(uctrl->saddr.sun_path, sizeof(uctrl->saddr.sun_path), "/run/udev/control");