gnutls 3.7.7 ships with a <gnutls/socket.h> that fails to compile on
mingw: https://gitlab.com/gnutls/gnutls/-/issues/1382.  But it also
provides a stub function gnutls_transport_is_ktls_enabled that always
returns false (since ktls is a Linux-only thing for now).  As such, we
are hitting compilation errors such as:

In file included from ../../server/crypto.c:59:
/usr/x86_64-w64-mingw32/sys-root/mingw/include/gnutls/socket.h:32:10: fatal 
error: sys/socket.h: No such file or directory
   32 | #include <sys/socket.h>
      |          ^~~~~~~~~~~~~~
compilation terminated.

unless we also probe for whether the header works.  Noticed ever since
commit c4bc6d07 moved to newer lcitool that upgraded our CI mingw
environments into using the newer broken version of gnutls.
---
 configure.ac    |  1 +
 server/crypto.c | 12 +++++++++---
 2 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/configure.ac b/configure.ac
index dc9ff94f..d506fb51 100644
--- a/configure.ac
+++ b/configure.ac
@@ -646,6 +646,7 @@ AS_IF([test "x$GNUTLS_LIBS" != "x"],[
         gnutls_srp_server_get_username \
         gnutls_transport_is_ktls_enabled \
     ])
+    AC_CHECK_HEADERS([gnutls/socket.h])
     LIBS="$old_LIBS"

     dnl macOS has its own program called certtool and packages the
diff --git a/server/crypto.c b/server/crypto.c
index 070fcc55..1f605083 100644
--- a/server/crypto.c
+++ b/server/crypto.c
@@ -55,7 +55,13 @@
 #include <gnutls/gnutls.h>
 #include <gnutls/x509.h>

-#ifdef HAVE_GNUTLS_TRANSPORT_IS_KTLS_ENABLED
+#if defined HAVE_GNUTLS_TRANSPORT_IS_KTLS_ENABLED && \
+  defined HAVE_GNUTLS_SOCKET_H
+#define TRY_KTLS 1
+#else
+#define TRY_KTLS 0
+#endif
+#if TRY_KTLS
 #include <gnutls/socket.h>
 #endif

@@ -542,7 +548,7 @@ debug_session (gnutls_session_t session)
   bool dhe = false, ecdh = false;
   int grp;
   const char *desc, *username, *hint;
-#ifdef HAVE_GNUTLS_TRANSPORT_IS_KTLS_ENABLED
+#if TRY_KTLS
   gnutls_transport_ktls_enable_flags_t ktls_enabled;
 #endif

@@ -552,7 +558,7 @@ debug_session (gnutls_session_t session)
   desc = gnutls_session_get_desc (session);
   if (desc) nbdkit_debug ("TLS session: %s", desc);

-#ifdef HAVE_GNUTLS_TRANSPORT_IS_KTLS_ENABLED
+#if TRY_KTLS
   ktls_enabled = gnutls_transport_is_ktls_enabled (session);
   switch (ktls_enabled) {
   case GNUTLS_KTLS_RECV:
-- 
2.37.3

_______________________________________________
Libguestfs mailing list
Libguestfs@redhat.com
https://listman.redhat.com/mailman/listinfo/libguestfs

Reply via email to