mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
rpc: Fix getsockopt on Snow Leopard and lower
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
This commit is contained in:
parent
fa23f9fcbb
commit
2f776d4979
@ -1149,6 +1149,23 @@ cleanup:
|
||||
}
|
||||
#elif defined(LOCAL_PEERCRED)
|
||||
|
||||
/* VIR_SOL_PEERCRED - the value needed to let getsockopt() work with
|
||||
* LOCAL_PEERCRED
|
||||
*/
|
||||
# ifdef __APPLE__
|
||||
# ifdef SOL_LOCAL
|
||||
# define VIR_SOL_PEERCRED SOL_LOCAL
|
||||
# else
|
||||
/* Prior to Mac OS X 10.7, SOL_LOCAL was not defined and users were
|
||||
* expected to supply 0 as the second value for getsockopt() when using
|
||||
* LOCAL_PEERCRED
|
||||
*/
|
||||
# define VIR_SOL_PEERCRED 0
|
||||
# endif
|
||||
# else
|
||||
# define VIR_SOL_PEERCRED SOL_SOCKET
|
||||
# endif
|
||||
|
||||
int virNetSocketGetUNIXIdentity(virNetSocketPtr sock,
|
||||
uid_t *uid,
|
||||
gid_t *gid,
|
||||
@ -1159,11 +1176,7 @@ int virNetSocketGetUNIXIdentity(virNetSocketPtr sock,
|
||||
socklen_t cr_len = sizeof(cr);
|
||||
virObjectLock(sock);
|
||||
|
||||
# if defined(__APPLE__)
|
||||
if (getsockopt(sock->fd, SOL_LOCAL, LOCAL_PEERCRED, &cr, &cr_len) < 0) {
|
||||
# else
|
||||
if (getsockopt(sock->fd, SOL_SOCKET, LOCAL_PEERCRED, &cr, &cr_len) < 0) {
|
||||
# endif
|
||||
if (getsockopt(sock->fd, VIR_SOL_PEERCRED, LOCAL_PEERCRED, &cr, &cr_len) < 0) {
|
||||
virReportSystemError(errno, "%s",
|
||||
_("Failed to get client socket identity"));
|
||||
virObjectUnlock(sock);
|
||||
|
Loading…
x
Reference in New Issue
Block a user