Brad Bishop | 08902b0 | 2019-08-20 09:16:51 -0400 | [diff] [blame] | 1 | From e41ddbd89a4bb042ac00469fa5880ba584c25c05 Mon Sep 17 00:00:00 2001 |
| 2 | From: Khem Raj <raj.khem@gmail.com> |
| 3 | Date: Thu, 25 Jul 2019 12:10:56 -0700 |
| 4 | Subject: [PATCH] nis-hosts: Remove use of RES_USE_INET6 |
| 5 | |
| 6 | Upstream glibc dropped it starting glibc 2.30 |
| 7 | see |
| 8 | https://sourceware.org/git/?p=glibc.git;a=commit;h=3f8b44be0a658266adff5ece1e4bc3ce097a5dbe |
| 9 | |
| 10 | Fixes issue #6 |
| 11 | |
| 12 | Upstream-Status: Submitted [https://github.com/thkukuk/libnss_nis/pull/7] |
| 13 | |
| 14 | Signed-off-by: Khem Raj <raj.khem@gmail.com> |
| 15 | --- |
| 16 | src/nis-hosts.c | 55 ++++++++++++------------------------------------- |
| 17 | 1 file changed, 13 insertions(+), 42 deletions(-) |
| 18 | |
| 19 | diff --git a/src/nis-hosts.c b/src/nis-hosts.c |
| 20 | index 307b46e..bd3c4ad 100644 |
| 21 | --- a/src/nis-hosts.c |
| 22 | +++ b/src/nis-hosts.c |
| 23 | @@ -35,15 +35,12 @@ |
| 24 | #include "libc-lock.h" |
| 25 | #include "nss-nis.h" |
| 26 | |
| 27 | -/* Get implementation for some internal functions. */ |
| 28 | -#include "mapv4v6addr.h" |
| 29 | - |
| 30 | #define ENTNAME hostent |
| 31 | #define DATABASE "hosts" |
| 32 | #define NEED_H_ERRNO |
| 33 | |
| 34 | -#define EXTRA_ARGS , af, flags |
| 35 | -#define EXTRA_ARGS_DECL , int af, int flags |
| 36 | +#define EXTRA_ARGS , af |
| 37 | +#define EXTRA_ARGS_DECL , int af |
| 38 | |
| 39 | #define ENTDATA hostent_data |
| 40 | struct hostent_data |
| 41 | @@ -67,19 +64,8 @@ LINE_PARSER |
| 42 | /* Parse address. */ |
| 43 | if (af != AF_INET6 && inet_pton (AF_INET, addr, entdata->host_addr) > 0) |
| 44 | { |
| 45 | - assert ((flags & AI_V4MAPPED) == 0 || af != AF_UNSPEC); |
| 46 | - if (flags & AI_V4MAPPED) |
| 47 | - { |
| 48 | - map_v4v6_address ((char *) entdata->host_addr, |
| 49 | - (char *) entdata->host_addr); |
| 50 | - result->h_addrtype = AF_INET6; |
| 51 | - result->h_length = IN6ADDRSZ; |
| 52 | - } |
| 53 | - else |
| 54 | - { |
| 55 | - result->h_addrtype = AF_INET; |
| 56 | - result->h_length = INADDRSZ; |
| 57 | - } |
| 58 | + result->h_addrtype = AF_INET; |
| 59 | + result->h_length = INADDRSZ; |
| 60 | } |
| 61 | else if (af != AF_INET |
| 62 | && inet_pton (AF_INET6, addr, entdata->host_addr) > 0) |
| 63 | @@ -134,7 +120,7 @@ strong_alias (_nss_nis_sethostent, _nss_nis_endhostent) |
| 64 | static enum nss_status |
| 65 | internal_nis_gethostent_r (struct hostent *host, char *buffer, |
| 66 | size_t buflen, int *errnop, int *h_errnop, |
| 67 | - int af, int flags) |
| 68 | + int af) |
| 69 | { |
| 70 | char *domain; |
| 71 | if (yp_get_default_domain (&domain)) |
| 72 | @@ -203,7 +189,7 @@ internal_nis_gethostent_r (struct hostent *host, char *buffer, |
| 73 | ++p; |
| 74 | free (result); |
| 75 | |
| 76 | - parse_res = parse_line (p, host, data, buflen, errnop, af, flags); |
| 77 | + parse_res = parse_line (p, host, data, buflen, errnop, af); |
| 78 | if (parse_res == -1) |
| 79 | { |
| 80 | free (outkey); |
| 81 | @@ -232,8 +218,7 @@ _nss_nis_gethostent_r (struct hostent *host, char *buffer, size_t buflen, |
| 82 | __libc_lock_lock (lock); |
| 83 | |
| 84 | status = internal_nis_gethostent_r (host, buffer, buflen, errnop, h_errnop, |
| 85 | - ((_res.options & RES_USE_INET6) ? AF_INET6 : AF_INET), |
| 86 | - ((_res.options & RES_USE_INET6) ? AI_V4MAPPED : 0 )); |
| 87 | + AF_INET); |
| 88 | |
| 89 | __libc_lock_unlock (lock); |
| 90 | |
| 91 | @@ -244,7 +229,7 @@ _nss_nis_gethostent_r (struct hostent *host, char *buffer, size_t buflen, |
| 92 | static enum nss_status |
| 93 | internal_gethostbyname2_r (const char *name, int af, struct hostent *host, |
| 94 | char *buffer, size_t buflen, int *errnop, |
| 95 | - int *h_errnop, int flags) |
| 96 | + int *h_errnop) |
| 97 | { |
| 98 | uintptr_t pad = -(uintptr_t) buffer % __alignof__ (struct parser_data); |
| 99 | buffer += pad; |
| 100 | @@ -318,7 +303,7 @@ internal_gethostbyname2_r (const char *name, int af, struct hostent *host, |
| 101 | ++p; |
| 102 | free (result); |
| 103 | |
| 104 | - int parse_res = parse_line (p, host, data, buflen, errnop, af, flags); |
| 105 | + int parse_res = parse_line (p, host, data, buflen, errnop, af); |
| 106 | |
| 107 | if (parse_res < 1 || host->h_addrtype != af) |
| 108 | { |
| 109 | @@ -351,8 +336,7 @@ _nss_nis_gethostbyname2_r (const char *name, int af, struct hostent *host, |
| 110 | } |
| 111 | |
| 112 | return internal_gethostbyname2_r (name, af, host, buffer, buflen, errnop, |
| 113 | - h_errnop, |
| 114 | - ((_res.options & RES_USE_INET6) ? AI_V4MAPPED : 0)); |
| 115 | + h_errnop); |
| 116 | } |
| 117 | |
| 118 | |
| 119 | @@ -360,18 +344,8 @@ enum nss_status |
| 120 | _nss_nis_gethostbyname_r (const char *name, struct hostent *host, char *buffer, |
| 121 | size_t buflen, int *errnop, int *h_errnop) |
| 122 | { |
| 123 | - if (_res.options & RES_USE_INET6) |
| 124 | - { |
| 125 | - enum nss_status status; |
| 126 | - |
| 127 | - status = internal_gethostbyname2_r (name, AF_INET6, host, buffer, buflen, |
| 128 | - errnop, h_errnop, AI_V4MAPPED); |
| 129 | - if (status == NSS_STATUS_SUCCESS) |
| 130 | - return status; |
| 131 | - } |
| 132 | - |
| 133 | return internal_gethostbyname2_r (name, AF_INET, host, buffer, buflen, |
| 134 | - errnop, h_errnop, 0); |
| 135 | + errnop, h_errnop); |
| 136 | } |
| 137 | |
| 138 | |
| 139 | @@ -433,9 +407,7 @@ _nss_nis_gethostbyaddr_r (const void *addr, socklen_t addrlen, int af, |
| 140 | ++p; |
| 141 | free (result); |
| 142 | |
| 143 | - int parse_res = parse_line (p, host, data, buflen, errnop, af, |
| 144 | - ((_res.options & RES_USE_INET6) |
| 145 | - ? AI_V4MAPPED : 0)); |
| 146 | + int parse_res = parse_line (p, host, data, buflen, errnop, af); |
| 147 | if (parse_res < 1) |
| 148 | { |
| 149 | if (parse_res == -1) |
| 150 | @@ -532,8 +504,7 @@ _nss_nis_gethostbyname4_r (const char *name, struct gaih_addrtuple **pat, |
| 151 | buflen -= pad; |
| 152 | |
| 153 | struct hostent host; |
| 154 | - int parse_res = parse_line (result, &host, data, buflen, errnop, AF_UNSPEC, |
| 155 | - 0); |
| 156 | + int parse_res = parse_line (result, &host, data, buflen, errnop, AF_UNSPEC); |
| 157 | if (parse_res < 1) |
| 158 | { |
| 159 | if (parse_res == -1) |
| 160 | -- |
| 161 | 2.22.0 |
| 162 | |