mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-09 14:35:25 +00:00
rpc: fix getsockopt for LOCAL_PEERCRED on Mac OS X
This fixes the following error:
error : virGetUserEnt:703 : Failed to find user record for uid '32654'
'32654' (it's random and varies) comes from getsockopt with
LOCAL_PEERCRED option. getsockopt returns w/o error but seems
to not set any value to the buffer for uid.
For Mac OS X, LOCAL_PEERCRED has to be used with SOL_LOCAL level.
With SOL_LOCAL, getsockopt returns a correct uid.
Note that SOL_LOCAL can be found in
/System/Library/Frameworks/Kernel.framework/Versions/A/Headers/sys/un.h.
Signed-off-by: Ryota Ozaki <ozaki.ryota@gmail.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
(cherry picked from commit 5a468b38b6
)
This commit is contained in:
parent
5395f0b5ad
commit
e3fb8465ec
@ -1159,7 +1159,11 @@ int virNetSocketGetUNIXIdentity(virNetSocketPtr sock,
|
|||||||
socklen_t cr_len = sizeof(cr);
|
socklen_t cr_len = sizeof(cr);
|
||||||
virObjectLock(sock);
|
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) {
|
if (getsockopt(sock->fd, SOL_SOCKET, LOCAL_PEERCRED, &cr, &cr_len) < 0) {
|
||||||
|
# endif
|
||||||
virReportSystemError(errno, "%s",
|
virReportSystemError(errno, "%s",
|
||||||
_("Failed to get client socket identity"));
|
_("Failed to get client socket identity"));
|
||||||
virObjectUnlock(sock);
|
virObjectUnlock(sock);
|
||||||
|
Loading…
Reference in New Issue
Block a user