X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fshutdownd%2Fshutdownd.c;h=6e4511ecea718e7a97a274e8039210891ffe12c5;hb=adfe5671ef794099068038dfccbf1eb5134433c8;hp=826efbfeabb12a139508fa35d5c5dd47829e579a;hpb=56f64d95763a799ba4475daf44d8e9f72a1bd474;p=elogind.git diff --git a/src/shutdownd/shutdownd.c b/src/shutdownd/shutdownd.c index 826efbfea..6e4511ece 100644 --- a/src/shutdownd/shutdownd.c +++ b/src/shutdownd/shutdownd.c @@ -20,14 +20,10 @@ ***/ #include -#include -#include +#include #include -#include -#include #include #include -#include #include #include "systemd/sd-daemon.h" @@ -70,12 +66,7 @@ static int read_packet(int fd, union shutdown_buffer *_b) { assert(_b); n = recvmsg(fd, &msghdr, MSG_DONTWAIT); - if (n <= 0) { - if (n == 0) { - log_error("Short read"); - return -EIO; - } - + if (n < 0) { if (errno == EAGAIN || errno == EINTR) return 0; @@ -83,6 +74,13 @@ static int read_packet(int fd, union shutdown_buffer *_b) { return -errno; } + cmsg_close_all(&msghdr); + + if (n == 0) { + log_error("Short read"); + return -EIO; + } + if (msghdr.msg_controllen < CMSG_LEN(sizeof(struct ucred)) || control.cmsghdr.cmsg_level != SOL_SOCKET || control.cmsghdr.cmsg_type != SCM_CREDENTIALS ||