From 652d19442722bb352dc3a9fdce81331f67336cff Mon Sep 17 00:00:00 2001 From: Matt Fischer Date: Mon, 4 Feb 2013 18:17:18 -0600 Subject: [PATCH 1/4] Fixed LOCAL_CREDS code in Unix backend The Unix port supports credential passing using either cmsgcred or sockcred, however in a couple of places, the latter accidentally included some cmsgcred references. This patch changes the code so that it works properly when only LOCAL_CREDS support is present. --- dbus/dbus-sysdeps-unix.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/dbus/dbus-sysdeps-unix.c b/dbus/dbus-sysdeps-unix.c index a031059..bd9e74d 100644 --- a/dbus/dbus-sysdeps-unix.c +++ b/dbus/dbus-sysdeps-unix.c @@ -1668,6 +1668,7 @@ _dbus_read_credentials_socket (int client_fd, dbus_uid_t uid_read; dbus_pid_t pid_read; int bytes_read; + int controllen; #ifdef HAVE_CMSGCRED union { @@ -1710,10 +1711,16 @@ _dbus_read_credentials_socket (int client_fd, msg.msg_iov = &iov; msg.msg_iovlen = 1; +#if defined(HAVE_CMSGCRED) + controllen = CMSG_SPACE (sizeof (struct cmsgcred)); +#elif defined(LOCAL_CREDS) + controllen = sizeof (struct sockcred); +#endif + #if defined(HAVE_CMSGCRED) || defined(LOCAL_CREDS) _DBUS_ZERO(cmsg); msg.msg_control = (caddr_t) &cmsg; - msg.msg_controllen = CMSG_SPACE (sizeof (struct cmsgcred)); + msg.msg_controllen = controllen; #endif again: @@ -1751,7 +1758,7 @@ _dbus_read_credentials_socket (int client_fd, } #if defined(HAVE_CMSGCRED) || defined(LOCAL_CREDS) - if (cmsg.hdr.cmsg_len < CMSG_LEN (sizeof (struct cmsgcred)) + if (cmsg.hdr.cmsg_len < controllen || cmsg.hdr.cmsg_type != SCM_CREDS) { dbus_set_error (error, DBUS_ERROR_FAILED, -- 1.8.0.msysgit.0