summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2007-02-04 16:22:09 +0000
committerLennart Poettering <lennart@poettering.net>2007-02-04 16:22:09 +0000
commita702940e7f28eeef5ab820ac903db48df11ce987 (patch)
tree3394d35a1c8314893dd20ed9caf0ecbf28232fbc
parentd53beee9e511af84fb39cd2aa6c1c1cc3cfd06d2 (diff)
minor cleanups it netlink handling code:
* fix warning message * don't warn if netlink messages from other processes have been received * don't access ucreds before checking cmsg validity git-svn-id: file:///home/lennart/svn/public/avahi/trunk@1382 941a03a8-eaeb-0310-b9a0-b1bbd8fe43fe
-rw-r--r--avahi-core/netlink.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/avahi-core/netlink.c b/avahi-core/netlink.c
index 7411c90..5050801 100644
--- a/avahi-core/netlink.c
+++ b/avahi-core/netlink.c
@@ -59,7 +59,7 @@ int avahi_netlink_work(AvahiNetlink *nl, int block) {
iov.iov_base = nl->buffer;
iov.iov_len = nl->buffer_length;
- smsg.msg_name = (void*) NULL;
+ smsg.msg_name = NULL;
smsg.msg_namelen = 0;
smsg.msg_iov = &iov;
smsg.msg_iovlen = 1;
@@ -76,17 +76,16 @@ int avahi_netlink_work(AvahiNetlink *nl, int block) {
}
cmsg = CMSG_FIRSTHDR(&smsg);
- cred = (struct ucred *) CMSG_DATA (cmsg);
- if (cmsg == NULL || cmsg->cmsg_type != SCM_CREDENTIALS) {
- avahi_log_error("No sender credentials received, ignoring data.");
+ if (!cmsg || cmsg->cmsg_type != SCM_CREDENTIALS) {
+ avahi_log_warn("No sender credentials received, ignoring data.");
return -1;
}
- if (cred->uid != 0) {
- avahi_log_warn("Netlink message received from cred->uid != 0 (%d)", cred->uid);
+ cred = (struct ucred*) CMSG_DATA(cmsg);
+
+ if (cred->uid != 0)
return -1;
- }
p = (struct nlmsghdr *) nl->buffer;
@@ -139,7 +138,7 @@ AvahiNetlink *avahi_netlink_new(const AvahiPoll *poll_api, uint32_t groups, void
}
if (setsockopt(fd, SOL_SOCKET, SO_PASSCRED, &on, sizeof(on)) < 0) {
- avahi_log_error(__FILE__": bind(): %s", strerror(errno));
+ avahi_log_error(__FILE__": SO_PASSCRED: %s", strerror(errno));
goto fail;
}