summaryrefslogtreecommitdiff
path: root/src/shared/nss-util.h
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2014-07-17 19:27:48 +0200
committerLennart Poettering <lennart@poettering.net>2014-07-17 19:39:50 +0200
commitea30eb86e5a370fb8cb94e352e075e24d940d159 (patch)
treeb6bb3c99522e37ff8fa595dcc83b112860c016a9 /src/shared/nss-util.h
parenta71516dfd1858f37712ef52a288bf5fb274383e0 (diff)
nss-util: be a tiny bit more compatible with glibc's lookup behaviour regarding IPv6
Check for RES_USE_INET6 before we prefer IPv6 over IPv4, for all our NSS modules. (Not that the DNS resolver that is configured with this matters to us, but hey, let's try to be compatible).
Diffstat (limited to 'src/shared/nss-util.h')
-rw-r--r--src/shared/nss-util.h18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/shared/nss-util.h b/src/shared/nss-util.h
index 2c897d8520..230a986040 100644
--- a/src/shared/nss-util.h
+++ b/src/shared/nss-util.h
@@ -23,6 +23,7 @@
#include <nss.h>
#include <netdb.h>
+#include <resolv.h>
#define NSS_GETHOSTBYNAME_PROTOTYPES(module) \
enum nss_status _nss_##module##_gethostbyname4_r( \
@@ -87,14 +88,27 @@ enum nss_status _nss_##module##_gethostbyname_r( \
struct hostent *host, \
char *buffer, size_t buflen, \
int *errnop, int *h_errnop) { \
- return _nss_##module##_gethostbyname3_r( \
+ enum nss_status ret = NSS_STATUS_NOTFOUND; \
+ \
+ if (_res.options & RES_USE_INET6) \
+ ret = _nss_##module##_gethostbyname3_r( \
+ name, \
+ AF_INET6, \
+ host, \
+ buffer, buflen, \
+ errnop, h_errnop, \
+ NULL, \
+ NULL); \
+ if (ret == NSS_STATUS_NOTFOUND) \
+ ret = _nss_##module##_gethostbyname3_r( \
name, \
- AF_UNSPEC, \
+ AF_INET, \
host, \
buffer, buflen, \
errnop, h_errnop, \
NULL, \
NULL); \
+ return ret; \
}
#define NSS_GETHOSTBYADDR_FALLBACKS(module) \