X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Fshared%2Fnss-util.h;h=230a98604013caefb6151fd42ce97c6df9cc5887;hp=2c897d8520a3456bd3577f99ea34047906e8a40c;hb=ea30eb86e5a370fb8cb94e352e075e24d940d159;hpb=c9fdc26e96493175668fbde61a04fc70abff300d diff --git a/src/shared/nss-util.h b/src/shared/nss-util.h index 2c897d852..230a98604 100644 --- a/src/shared/nss-util.h +++ b/src/shared/nss-util.h @@ -23,6 +23,7 @@ #include #include +#include #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) \