[PATCH v2 2/3] Use struct sockpeercred when available

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

 



From: Jasper Lievisse Adriaanse <jasper@xxxxxxxxxxx>

OpenBSD uses 'struct sockpeercred' instead of 'struct ucred'. Add a
configure check that detects its presence and use if in the code that
could be compiled on OpenBSD.

Signed-off-by: Roman Bogorodskiy <bogorodskiy@xxxxxxxxx>
---
 configure.ac           | 6 ++++++
 src/rpc/virnetsocket.c | 4 ++++
 2 files changed, 10 insertions(+)

diff --git a/configure.ac b/configure.ac
index a46f9b3..2acc0f2 100644
--- a/configure.ac
+++ b/configure.ac
@@ -393,6 +393,12 @@ AC_CHECK_TYPE([struct ifreq],
         #include <net/if.h>
   ]])
 
+AC_CHECK_TYPE([struct sockpeercred],
+  [AC_DEFINE([HAVE_STRUCT_SOCKPEERCRED], [1],
+    [Defined if struct sockpeercred is available])],
+  [], [[#include <sys/socket.h>
+  ]])
+
 AC_CHECK_DECLS([ETH_FLAG_TXVLAN, ETH_FLAG_NTUPLE, ETH_FLAG_RXHASH, ETH_FLAG_LRO,
                 ETHTOOL_GGSO, ETHTOOL_GGRO, ETHTOOL_GFLAGS, ETHTOOL_GFEATURES],
   [], [], [[#include <linux/ethtool.h>
diff --git a/src/rpc/virnetsocket.c b/src/rpc/virnetsocket.c
index 526d291..4f67c8f 100644
--- a/src/rpc/virnetsocket.c
+++ b/src/rpc/virnetsocket.c
@@ -1259,7 +1259,11 @@ int virNetSocketGetUNIXIdentity(virNetSocketPtr sock,
                                 pid_t *pid,
                                 unsigned long long *timestamp)
 {
+# if defined(HAVE_STRUCT_SOCKPEERCRED)
+    struct sockpeercred cr;
+# else
     struct ucred cr;
+# endif
     socklen_t cr_len = sizeof(cr);
     int ret = -1;
 
-- 
2.4.6

--
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]