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

[libvirt] [PATCH 3/4] Check for sys/ucred.h and adjust virnetsocket.c for OpenBSD compilation.



---
 configure.ac           |    2 +-
 src/rpc/virnetsocket.c |   10 ++++++++++
 2 files changed, 11 insertions(+), 1 deletions(-)

diff --git a/configure.ac b/configure.ac
index e0d00d5..7ba1e9c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -197,7 +197,7 @@ dnl Availability of various common headers (non-fatal if missing).
 AC_CHECK_HEADERS([pwd.h paths.h regex.h sys/un.h \
   sys/poll.h syslog.h mntent.h net/ethernet.h linux/magic.h \
   sys/un.h sys/syscall.h netinet/tcp.h ifaddrs.h libtasn1.h \
-  net/if.h execinfo.h])
+  net/if.h execinfo.h sys/ucred.h])
 
 dnl We need to decide at configure time if libvirt will use real atomic
 dnl operations ("lock free") or emulated ones with a mutex.
diff --git a/src/rpc/virnetsocket.c b/src/rpc/virnetsocket.c
index 5a48300..0457710 100644
--- a/src/rpc/virnetsocket.c
+++ b/src/rpc/virnetsocket.c
@@ -31,6 +31,10 @@
 #include <fcntl.h>
 #include <netdb.h>
 
+#ifdef HAVE_SYS_UCRED_H
+# include <sys/ucred.h>
+#endif
+
 #ifdef HAVE_NETINET_TCP_H
 # include <netinet/tcp.h>
 #endif
@@ -999,9 +1003,15 @@ int virNetSocketGetUNIXIdentity(virNetSocketPtr sock,
         return -1;
     }
 
+#if defined(__OpenBSD__)
+    *pid = getpid();
+    *uid = cr.cr_uid;
+    *gid = cr.cr_gid;
+#else
     *pid = cr.pid;
     *uid = cr.uid;
     *gid = cr.gid;
+#endif
 
     virMutexUnlock(&sock->lock);
     return 0;
-- 
1.7.6


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