[PATCH] rpc: Fix getsockopt on Snow Leopard and lower

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Since 5a468b38b6 we use SOL_LOCAL for the 2nd argument of getsockopt()
however Lion added the define SOL_LOCAL set to 0, which is the value to
the 2nd argument of getsockopt() for Unix sockets on Mac OS X. So
instead of using the define just pass 0 so we restore compatibility
with Snow Leopard and Leopard.

Reported at https://github.com/mxcl/homebrew/pull/23141
---
 src/rpc/virnetsocket.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/rpc/virnetsocket.c b/src/rpc/virnetsocket.c
index a2823ef..8651a8b 100644
--- a/src/rpc/virnetsocket.c
+++ b/src/rpc/virnetsocket.c
@@ -1160,7 +1160,13 @@ int virNetSocketGetUNIXIdentity(virNetSocketPtr sock,
     virObjectLock(sock);
 
 # if defined(__APPLE__)
-    if (getsockopt(sock->fd, SOL_LOCAL, LOCAL_PEERCRED, &cr, &cr_len) < 0) {
+    /* Lion (10.7) and higher define the value to be passed to getsockopt()
+     * as SOL_LOCAL for Unix sockets, it is defined to 0. However
+     * Snow Leopard and lower did not have this define so you had to
+     * pass 0. To support the most cases we just pass 0, this behavior
+     * matches PostgreSQL and CUPS source code.
+     */
+    if (getsockopt(sock->fd, 0, LOCAL_PEERCRED, &cr, &cr_len) < 0) {
 # else
     if (getsockopt(sock->fd, SOL_SOCKET, LOCAL_PEERCRED, &cr, &cr_len) < 0) {
 # endif
-- 
1.8.1.5

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]