From patchwork Fri Dec 30 19:15:57 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Weimer X-Patchwork-Id: 18730 Received: (qmail 16072 invoked by alias); 30 Dec 2016 19:16:03 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 16042 invoked by uid 89); 30 Dec 2016 19:16:01 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-5.1 required=5.0 tests=BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=__set_errno, 4211, octets, 7896 X-HELO: mx1.redhat.com Date: Fri, 30 Dec 2016 20:15:57 +0100 To: libc-alpha@sourceware.org Subject: [PATCH COMMITTED] resolv: Turn historic name lookup functions into compat symbols User-Agent: Heirloom mailx 12.5 7/5/10 MIME-Version: 1.0 Message-Id: <20161230191557.76657402C1F77@oldenburg.str.redhat.com> From: fweimer@redhat.com (Florian Weimer) This change also removes the preprocessor-based function renaming. It also applied to tests in resolv/, which ended up running against the historic functions. _endhtent was not part of the ABI because it is not listed in the resolv/Versions file. 2016-12-30 Florian Weimer * resolv/Makefile (libresolv-routines): Rename gethnamaddr to compat-gethnamaddr. (CPPFLAGS): Remove. * resolv/gethnamaddr.c: Rename ... * resolv/compat-gethnamaddr.c: ... to this file. (_endhtent): Make static. (res_gethostbyname): Renamed from gethostbyname. Turn into compat symbol. (res_gethostbyname2): Renamed from gethostbyname2. Turn into compat symbol. (res_gethostbyaddr): Renamed from gethostbyaddr. Turn into compat symbol. (_sethtent, _gethtent, _gethtbyname, gethtbyname2, _gethtbyaddr): Turn into compat symbol. * include/resolv.h (_endhtent): Remove declaration. +++ b/resolv/compat-gethnamaddr.c @@ -54,23 +54,26 @@ it exports symbols in the libresolv ABI. The file is not maintained any more, nor are these functions. */ -#include -#include -#include -#include -#include -#include +#include +#if SHLIB_COMPAT (libresolv, GLIBC_2_0, GLIBC_2_25) -#include -#include -#include -#include -#include -#include -#include +# include +# include +# include +# include +# include +# include -#define MAXALIASES 35 -#define MAXADDRS 35 +# include +# include +# include +# include +# include +# include +# include + +# define MAXALIASES 35 +# define MAXADDRS 35 static char *h_addr_ptrs[MAXADDRS + 1]; @@ -86,17 +89,17 @@ static void map_v4v6_hostent (struct hostent *hp, char **bp, int *len) __THROW; extern void addrsort (char **, int) __THROW; -#if PACKETSZ > 65536 -#define MAXPACKET PACKETSZ -#else -#define MAXPACKET 65536 -#endif +# if PACKETSZ > 65536 +# define MAXPACKET PACKETSZ +# else +# define MAXPACKET 65536 +# endif /* As per RFC 1034 and 1035 a host name cannot exceed 255 octets in length. */ -#ifdef MAXHOSTNAMELEN -# undef MAXHOSTNAMELEN -#endif -#define MAXHOSTNAMELEN 256 +# ifdef MAXHOSTNAMELEN +# undef MAXHOSTNAMELEN +# endif +# define MAXHOSTNAMELEN 256 typedef union { HEADER hdr; @@ -108,11 +111,11 @@ typedef union { char ac; } align; -#ifndef h_errno +# ifndef h_errno extern int h_errno; -#endif +# endif -#ifdef DEBUG +# ifdef DEBUG static void Dprintf (char *msg, int num) { @@ -123,11 +126,11 @@ Dprintf (char *msg, int num) __set_errno (save); } } -#else -# define Dprintf(msg, num) /*nada*/ -#endif +# else +# define Dprintf(msg, num) /*nada*/ +# endif -#define BOUNDED_INCR(x) \ +# define BOUNDED_INCR(x) \ do { \ cp += x; \ if (cp > eom) { \ @@ -136,7 +139,7 @@ Dprintf (char *msg, int num) } \ } while (0) -#define BOUNDS_CHECK(ptr, count) \ +# define BOUNDS_CHECK(ptr, count) \ do { \ if ((ptr) + (count) > eom) { \ __set_h_errno (NO_RECOVERY); \ @@ -419,11 +422,11 @@ getanswer (const querybuf *answer, int anslen, const char *qname, int qtype) return (NULL); } -extern struct hostent *gethostbyname2(const char *name, int af); -libresolv_hidden_proto (gethostbyname2) +extern struct hostent *res_gethostbyname2(const char *name, int af); +libresolv_hidden_proto (res_gethostbyname2) struct hostent * -gethostbyname (const char *name) +res_gethostbyname (const char *name) { struct hostent *hp; @@ -432,15 +435,16 @@ gethostbyname (const char *name) return (NULL); } if (_res.options & RES_USE_INET6) { - hp = gethostbyname2(name, AF_INET6); + hp = res_gethostbyname2(name, AF_INET6); if (hp) return (hp); } - return (gethostbyname2(name, AF_INET)); + return (res_gethostbyname2(name, AF_INET)); } +compat_symbol (libresolv, res_gethostbyname, res_gethostbyname, GLIBC_2_0); struct hostent * -gethostbyname2 (const char *name, int af) +res_gethostbyname2 (const char *name, int af) { union { @@ -568,10 +572,11 @@ gethostbyname2 (const char *name, int af) free (buf.buf); return ret; } -libresolv_hidden_def (gethostbyname2) +libresolv_hidden_def (res_gethostbyname2) +compat_symbol (libresolv, res_gethostbyname2, res_gethostbyname2, GLIBC_2_0); struct hostent * -gethostbyaddr (const void *addr, socklen_t len, int af) +res_gethostbyaddr (const void *addr, socklen_t len, int af) { const u_char *uaddr = (const u_char *)addr; static const u_char mapped[] = { 0,0, 0,0, 0,0, 0,0, 0,0, 0xff,0xff }; @@ -668,6 +673,7 @@ gethostbyaddr (const void *addr, socklen_t len, int af) __set_h_errno (NETDB_SUCCESS); return (hp); } +compat_symbol (libresolv, res_gethostbyaddr, res_gethostbyaddr, GLIBC_2_0); void _sethtent (int f) @@ -679,8 +685,9 @@ _sethtent (int f) stayopen = f; } libresolv_hidden_def (_sethtent) +compat_symbol (libresolv, _sethtent, _sethtent, GLIBC_2_0); -void +static void _endhtent (void) { if (hostf && !stayopen) { @@ -754,6 +761,7 @@ _gethtent (void) return (&host); } libresolv_hidden_def (_gethtent) +compat_symbol (libresolv, _gethtent, _gethtent, GLIBC_2_0); struct hostent * _gethtbyname (const char *name) @@ -767,6 +775,7 @@ _gethtbyname (const char *name) } return (_gethtbyname2(name, AF_INET)); } +compat_symbol (libresolv, _gethtbyname, _gethtbyname, GLIBC_2_0); struct hostent * _gethtbyname2 (const char *name, int af) @@ -789,6 +798,7 @@ _gethtbyname2 (const char *name, int af) return (p); } libresolv_hidden_def (_gethtbyname2) +compat_symbol (libresolv, _gethtbyname2, _gethtbyname2, GLIBC_2_0); struct hostent * _gethtbyaddr (const char *addr, size_t len, int af) @@ -803,6 +813,7 @@ _gethtbyaddr (const char *addr, size_t len, int af) return (p); } libresolv_hidden_def (_gethtbyaddr) +compat_symbol (libresolv, _gethtbyaddr, _gethtbyaddr, GLIBC_2_0); static void map_v4v6_address (const char *src, char *dst) @@ -888,3 +899,5 @@ addrsort (char **ap, int num) needsort++; } } + +#endif /* SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_25) */ diff --git a/include/resolv.h b/include/resolv.h index 699cc81..95dcd3c 100644 --- a/include/resolv.h +++ b/include/resolv.h @@ -26,7 +26,6 @@ extern __thread struct __res_state *__resp attribute_tls_model_ie; extern int __res_vinit (res_state, int); extern int __res_maybe_init (res_state, int); extern void _sethtent (int); -extern void _endhtent (void); extern struct hostent *_gethtent (void); extern struct hostent *_gethtbyname (const char *__name); extern struct hostent *_gethtbyname2 (const char *__name, int __af); diff --git a/resolv/Makefile b/resolv/Makefile index 06329e1..bd086e0 100644 --- a/resolv/Makefile +++ b/resolv/Makefile @@ -42,11 +42,12 @@ routines += gai_sigqueue tests += tst-res_hconf_reorder endif extra-libs-others = $(extra-libs) -libresolv-routines := gethnamaddr res_comp res_debug \ +libresolv-routines := res_comp res_debug \ res_data res_mkquery res_query res_send \ inet_net_ntop inet_net_pton inet_neta base64 \ ns_parse ns_name ns_netint ns_ttl ns_print \ - ns_samedomain ns_date compat-hooks + ns_samedomain ns_date \ + compat-hooks compat-gethnamaddr libanl-routines := gai_cancel gai_error gai_misc gai_notify gai_suspend \ getaddrinfo_a @@ -84,12 +85,6 @@ generated += mtrace-tst-leaks.out tst-leaks.mtrace \ include ../Rules -CPPFLAGS += -Dgethostbyname=res_gethostbyname \ - -Dgethostbyname2=res_gethostbyname2 \ - -Dgethostbyaddr=res_gethostbyaddr \ - -Dgetnetbyname=res_getnetbyname \ - -Dgetnetbyaddr=res_getnetbyaddr - CFLAGS-res_hconf.c = -fexceptions # The DNS NSS modules needs the resolver. diff --git a/resolv/gethnamaddr.c b/resolv/compat-gethnamaddr.c similarity index 91% rename from resolv/gethnamaddr.c rename to resolv/compat-gethnamaddr.c