1
0
mirror of https://git.FreeBSD.org/ports.git synced 2025-01-06 06:30:19 +00:00

net/qt5-network: Add patch from Qt upstream fixing QDnsLookup.

This should fix bug in net-im/psi, when connecting to some servers was failing.

Reviewed by:	tcberner (mentor)
This commit is contained in:
Gleb Popov 2019-05-18 16:23:55 +00:00
parent ebc2194366
commit d94f06a86e
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=501973
2 changed files with 110 additions and 0 deletions

View File

@ -2,6 +2,7 @@
PORTNAME= network
DISTVERSION= ${QT5_VERSION}
PORTREVISION= 1
CATEGORIES= net ipv6
PKGNAMEPREFIX= qt5-

View File

@ -0,0 +1,109 @@
QDnsLookup: fix "Resolver functions not found" error on FreeBSD
The current code only tries to load the required functions from
LIBRESOLV_SO (if defined) and resolv, but on FreeBSD they are in libc:
https://www.freebsd.org/cgi/man.cgi?query=res_query&sektion=3&apropos=0&manpath=freebsd
This commit changes the code so that, after failing to load the
non-existent libraries, it attempts to load the functions with dlsym()
using the special handle RTLD_DEFAULT, which searches for the specified
symbol in the loaded libraries.
Task-number: QTBUG-74844
diff --git a/src/network/kernel/kernel.pri b/src/network/kernel/kernel.pri
index 11b80d59d5e..d7a92a12ebe 100644
--- src/network/kernel/kernel.pri
+++ src/network/kernel/kernel.pri
@@ -38,7 +38,11 @@ qtConfig(dnslookup) {
}
unix {
- !integrity:qtConfig(dnslookup): SOURCES += kernel/qdnslookup_unix.cpp
+ !integrity:qtConfig(dnslookup) {
+ SOURCES += kernel/qdnslookup_unix.cpp
+ qtConfig(dlopen): QMAKE_USE_PRIVATE += libdl
+ }
+
SOURCES += kernel/qhostinfo_unix.cpp
qtConfig(linux-netlink): SOURCES += kernel/qnetworkinterface_linux.cpp
diff --git a/src/network/kernel/qdnslookup_unix.cpp b/src/network/kernel/qdnslookup_unix.cpp
index ce1ec6442a6..ee7484ab35f 100644
--- src/network/kernel/qdnslookup_unix.cpp
+++ src/network/kernel/qdnslookup_unix.cpp
@@ -59,6 +59,10 @@
# include <gnu/lib-names.h>
#endif
+#if defined(Q_OS_FREEBSD) || QT_CONFIG(dlopen)
+# include <dlfcn.h>
+#endif
+
#include <cstring>
QT_BEGIN_NAMESPACE
@@ -87,6 +91,18 @@ struct QDnsLookupStateDeleter
}
};
+static QFunctionPointer resolveSymbol(QLibrary &lib, const char *sym)
+{
+ if (lib.isLoaded())
+ return lib.resolve(sym);
+
+#if defined(RTLD_DEFAULT) && (defined(Q_OS_FREEBSD) || QT_CONFIG(dlopen))
+ return reinterpret_cast<QFunctionPointer>(dlsym(RTLD_DEFAULT, sym));
+#else
+ return nullptr;
+#endif
+}
+
static bool resolveLibraryInternal()
{
QLibrary lib;
@@ -96,31 +112,30 @@ static bool resolveLibraryInternal()
#endif
{
lib.setFileName(QLatin1String("resolv"));
- if (!lib.load())
- return false;
+ lib.load();
}
- local_dn_expand = dn_expand_proto(lib.resolve("__dn_expand"));
+ local_dn_expand = dn_expand_proto(resolveSymbol(lib, "__dn_expand"));
if (!local_dn_expand)
- local_dn_expand = dn_expand_proto(lib.resolve("dn_expand"));
+ local_dn_expand = dn_expand_proto(resolveSymbol(lib, "dn_expand"));
- local_res_nclose = res_nclose_proto(lib.resolve("__res_nclose"));
+ local_res_nclose = res_nclose_proto(resolveSymbol(lib, "__res_nclose"));
if (!local_res_nclose)
- local_res_nclose = res_nclose_proto(lib.resolve("res_9_nclose"));
+ local_res_nclose = res_nclose_proto(resolveSymbol(lib, "res_9_nclose"));
if (!local_res_nclose)
- local_res_nclose = res_nclose_proto(lib.resolve("res_nclose"));
+ local_res_nclose = res_nclose_proto(resolveSymbol(lib, "res_nclose"));
- local_res_ninit = res_ninit_proto(lib.resolve("__res_ninit"));
+ local_res_ninit = res_ninit_proto(resolveSymbol(lib, "__res_ninit"));
if (!local_res_ninit)
- local_res_ninit = res_ninit_proto(lib.resolve("res_9_ninit"));
+ local_res_ninit = res_ninit_proto(resolveSymbol(lib, "res_9_ninit"));
if (!local_res_ninit)
- local_res_ninit = res_ninit_proto(lib.resolve("res_ninit"));
+ local_res_ninit = res_ninit_proto(resolveSymbol(lib, "res_ninit"));
- local_res_nquery = res_nquery_proto(lib.resolve("__res_nquery"));
+ local_res_nquery = res_nquery_proto(resolveSymbol(lib, "__res_nquery"));
if (!local_res_nquery)
- local_res_nquery = res_nquery_proto(lib.resolve("res_9_nquery"));
+ local_res_nquery = res_nquery_proto(resolveSymbol(lib, "res_9_nquery"));
if (!local_res_nquery)
- local_res_nquery = res_nquery_proto(lib.resolve("res_nquery"));
+ local_res_nquery = res_nquery_proto(resolveSymbol(lib, "res_nquery"));
return true;
}