1
0
Fork 0
mirror of https://gitlab.alpinelinux.org/alpine/aports.git synced 2025-07-13 19:29:53 +03:00
aports/community/qt6-qtbase/dns-resolver.patch
ptrcnull e6bb9a7ea4 community/qt6-qtbase: fix picking up unix dns resolver
(dns) state? nah, we're anarchists in here
2025-04-26 20:32:33 +00:00

104 lines
3.5 KiB
Diff

musl resolver does not have res_state;
use the regular res_state-less functions rather than using dummy resolver
based on community/qt5-qtwebengine/qt-musl-resolve.patch
diff --git a/cmake/FindWrapResolv.cmake b/cmake/FindWrapResolv.cmake
index 1afd253..68563d5 100644
--- a/cmake/FindWrapResolv.cmake
+++ b/cmake/FindWrapResolv.cmake
@@ -31,9 +31,8 @@ check_cxx_source_compiles("
int main(int, char **argv)
{
- res_state statep = 0;
- int n = res_nmkquery(statep, 0, argv[1], 0, 0, NULL, 0, NULL, NULL, 0);
- n = res_nsend(statep, NULL, 0, NULL, 0);
+ int n = res_mkquery(0, argv[1], 0, 0, NULL, 0, NULL, NULL, 0);
+ n = res_send(NULL, 0, NULL, 0);
n = dn_expand(NULL, NULL, NULL, NULL, 0);
return n;
}
diff --git a/src/network/kernel/qdnslookup_unix.cpp b/src/network/kernel/qdnslookup_unix.cpp
index 4262ad5..47524f9 100644
--- a/src/network/kernel/qdnslookup_unix.cpp
+++ b/src/network/kernel/qdnslookup_unix.cpp
@@ -25,6 +25,10 @@ QT_REQUIRE_CONFIG(libresolv);
#include <array>
+#if !defined(__GLIBC__)
+# include "resolv_compat.h"
+#endif
+
#ifndef T_OPT
// the older arpa/nameser_compat.h wasn't updated between 1999 and 2016 in glibc
# define T_OPT ns_t_opt
@@ -133,7 +137,7 @@ static int
prepareQueryBuffer(res_state state, QueryBuffer &buffer, const char *label, ns_rcode type)
{
// Create header and our query
- int queryLength = res_nmkquery(state, QUERY, label, C_IN, type, nullptr, 0, nullptr,
+ int queryLength = res_mkquery(QUERY, label, C_IN, type, nullptr, 0, nullptr,
buffer.data(), buffer.size());
Q_ASSERT(queryLength < int(buffer.size()));
if (Q_UNLIKELY(queryLength < 0))
@@ -170,7 +174,7 @@ static int sendStandardDns(QDnsLookupReply *reply, res_state state, QSpan<unsign
auto attemptToSend = [&]() {
std::memset(buffer.data(), 0, HFIXEDSZ); // the header is enough
- int responseLength = res_nsend(state, qbuffer.data(), qbuffer.size(), buffer.data(), buffer.size());
+ int responseLength = res_send(qbuffer.data(), qbuffer.size(), buffer.data(), buffer.size());
if (responseLength >= 0)
return responseLength; // success
diff --git a/src/network/kernel/qhostinfo_unix.cpp b/src/network/kernel/qhostinfo_unix.cpp
index 80d386a..ae205be 100644
--- a/src/network/kernel/qhostinfo_unix.cpp
+++ b/src/network/kernel/qhostinfo_unix.cpp
@@ -18,6 +18,10 @@
# include <resolv.h>
#endif
+#if !defined(__GLIBC__)
+# include "resolv_compat.h"
+#endif
+
#ifndef _PATH_RESCONF
# define _PATH_RESCONF "/etc/resolv.conf"
#endif
diff --git a/src/network/kernel/resolv_compat.h b/src/network/kernel/resolv_compat.h
new file mode 100644
index 0000000..4f0e852
--- /dev/null
+++ b/src/network/kernel/resolv_compat.h
@@ -0,0 +1,29 @@
+#if !defined(__GLIBC__)
+/***************************************************************************
+ * resolv_compat.h
+ *
+ * Mimick GLIBC's res_ninit() and res_nclose() for musl libc
+ * Note: res_init() is actually deprecated according to
+ * http://docs.oracle.com/cd/E36784_01/html/E36875/res-nclose-3resolv.html
+ **************************************************************************/
+#include <string.h>
+
+static inline int res_ninit(res_state statp)
+{
+ int rc = res_init();
+ if (statp != &_res) {
+ memcpy(statp, &_res, sizeof(*statp));
+ }
+ return rc;
+}
+
+static inline int res_nclose(res_state statp)
+{
+ if (!statp)
+ return -1;
+ if (statp != &_res) {
+ memset(statp, 0, sizeof(*statp));
+ }
+ return 0;
+}
+#endif