|
|
8597553 |
commit e6b4e2de6dd91efdcac80b79149c596de8a26b70
|
|
|
8597553 |
Author: Florian Weimer <fweimer@redhat.com>
|
|
|
8597553 |
Date: Tue Jun 27 09:26:46 2017 +0200
|
|
|
8597553 |
|
|
|
8597553 |
resolv: Call _res_hconf_init from __res_vinit
|
|
|
8597553 |
|
|
|
8597553 |
Many callers of __res_maybe_init also call _res_hconf_init.
|
|
|
8597553 |
Additional calls to the latter do not hurt because the function
|
|
|
8597553 |
does its work only once. (/etc/hosts.conf is not reloaded or
|
|
|
8597553 |
even checked for changes.) This means that we can simplify the
|
|
|
8597553 |
code by calling _res_hconf_init directly from __res_vinit.
|
|
|
8597553 |
|
|
|
8597553 |
diff --git a/inet/gethstbyad_r.c b/inet/gethstbyad_r.c
|
|
|
8597553 |
index 88f428c1dbd3c177..6b5c13105059dd35 100644
|
|
|
8597553 |
--- a/inet/gethstbyad_r.c
|
|
|
8597553 |
+++ b/inet/gethstbyad_r.c
|
|
|
8597553 |
@@ -18,7 +18,7 @@
|
|
|
8597553 |
|
|
|
8597553 |
#include <netdb.h>
|
|
|
8597553 |
#include <string.h>
|
|
|
8597553 |
-
|
|
|
8597553 |
+#include <resolv/res_hconf.h>
|
|
|
8597553 |
|
|
|
8597553 |
#define LOOKUP_TYPE struct hostent
|
|
|
8597553 |
#define FUNCTION_NAME gethostbyaddr
|
|
|
8597553 |
@@ -27,7 +27,6 @@
|
|
|
8597553 |
#define ADD_VARIABLES addr, len, type
|
|
|
8597553 |
#define NEED_H_ERRNO 1
|
|
|
8597553 |
#define NEED__RES 1
|
|
|
8597553 |
-#define NEED__RES_HCONF 1
|
|
|
8597553 |
/* If the addr parameter is the IPv6 unspecified address no query must
|
|
|
8597553 |
be performed. */
|
|
|
8597553 |
#define PREPROCESS \
|
|
|
8597553 |
diff --git a/inet/gethstbynm2_r.c b/inet/gethstbynm2_r.c
|
|
|
8597553 |
index 57047979900accfc..580ba6d1cfbd63ec 100644
|
|
|
8597553 |
--- a/inet/gethstbynm2_r.c
|
|
|
8597553 |
+++ b/inet/gethstbynm2_r.c
|
|
|
8597553 |
@@ -22,7 +22,7 @@
|
|
|
8597553 |
#include <string.h>
|
|
|
8597553 |
#include <arpa/inet.h>
|
|
|
8597553 |
#include <netinet/in.h>
|
|
|
8597553 |
-
|
|
|
8597553 |
+#include <resolv/res_hconf.h>
|
|
|
8597553 |
|
|
|
8597553 |
#define LOOKUP_TYPE struct hostent
|
|
|
8597553 |
#define FUNCTION_NAME gethostbyname2
|
|
|
8597553 |
@@ -30,7 +30,7 @@
|
|
|
8597553 |
#define ADD_PARAMS const char *name, int af
|
|
|
8597553 |
#define ADD_VARIABLES name, af
|
|
|
8597553 |
#define NEED_H_ERRNO 1
|
|
|
8597553 |
-#define NEED__RES_HCONF 1
|
|
|
8597553 |
+#define NEED__RES 1
|
|
|
8597553 |
#define POSTPROCESS \
|
|
|
8597553 |
if (status == NSS_STATUS_SUCCESS) \
|
|
|
8597553 |
_res_hconf_reorder_addrs (resbuf);
|
|
|
8597553 |
diff --git a/inet/gethstbynm_r.c b/inet/gethstbynm_r.c
|
|
|
8597553 |
index 3758a9dde8e016f4..8f464b5ff1914b86 100644
|
|
|
8597553 |
--- a/inet/gethstbynm_r.c
|
|
|
8597553 |
+++ b/inet/gethstbynm_r.c
|
|
|
8597553 |
@@ -22,7 +22,7 @@
|
|
|
8597553 |
#include <string.h>
|
|
|
8597553 |
#include <arpa/inet.h>
|
|
|
8597553 |
#include <netinet/in.h>
|
|
|
8597553 |
-
|
|
|
8597553 |
+#include <resolv/res_hconf.h>
|
|
|
8597553 |
|
|
|
8597553 |
#define LOOKUP_TYPE struct hostent
|
|
|
8597553 |
#define FUNCTION_NAME gethostbyname
|
|
|
8597553 |
@@ -30,7 +30,7 @@
|
|
|
8597553 |
#define ADD_PARAMS const char *name
|
|
|
8597553 |
#define ADD_VARIABLES name
|
|
|
8597553 |
#define NEED_H_ERRNO 1
|
|
|
8597553 |
-#define NEED__RES_HCONF 1
|
|
|
8597553 |
+#define NEED__RES 1
|
|
|
8597553 |
#define POSTPROCESS \
|
|
|
8597553 |
if (status == NSS_STATUS_SUCCESS) \
|
|
|
8597553 |
_res_hconf_reorder_addrs (resbuf);
|
|
|
8597553 |
diff --git a/nscd/aicache.c b/nscd/aicache.c
|
|
|
8597553 |
index ea29b1c3d99bb530..358945140e04b2a9 100644
|
|
|
8597553 |
--- a/nscd/aicache.c
|
|
|
8597553 |
+++ b/nscd/aicache.c
|
|
|
8597553 |
@@ -26,7 +26,6 @@
|
|
|
8597553 |
#include <unistd.h>
|
|
|
8597553 |
#include <sys/mman.h>
|
|
|
8597553 |
#include <resolv/resolv-internal.h>
|
|
|
8597553 |
-#include <resolv/res_hconf.h>
|
|
|
8597553 |
#include <scratch_buffer.h>
|
|
|
8597553 |
|
|
|
8597553 |
#include "dbg_log.h"
|
|
|
8597553 |
@@ -103,7 +102,6 @@ addhstaiX (struct database_dyn *db, int fd, request_header *req,
|
|
|
8597553 |
nip = hosts_database;
|
|
|
8597553 |
|
|
|
8597553 |
/* Initialize configurations. */
|
|
|
8597553 |
- _res_hconf_init ();
|
|
|
8597553 |
if (__res_maybe_init (&_res, 0) == -1)
|
|
|
8597553 |
no_more = 1;
|
|
|
8597553 |
|
|
|
8597553 |
diff --git a/nscd/gethstbyad_r.c b/nscd/gethstbyad_r.c
|
|
|
8597553 |
index b17f0d2b5100c151..842ced2ec64048ea 100644
|
|
|
8597553 |
--- a/nscd/gethstbyad_r.c
|
|
|
8597553 |
+++ b/nscd/gethstbyad_r.c
|
|
|
8597553 |
@@ -28,7 +28,6 @@
|
|
|
8597553 |
#define EXTRA_VARIABLES , ttlp
|
|
|
8597553 |
#define NEED_H_ERRNO 1
|
|
|
8597553 |
#define NEED__RES 1
|
|
|
8597553 |
-#define NEED__RES_HCONF 1
|
|
|
8597553 |
|
|
|
8597553 |
/* We are nscd, so we don't want to be talking to ourselves. */
|
|
|
8597553 |
#undef USE_NSCD
|
|
|
8597553 |
diff --git a/nscd/gethstbynm3_r.c b/nscd/gethstbynm3_r.c
|
|
|
8597553 |
index 41bb26845d7b9592..2ab75e469eca1589 100644
|
|
|
8597553 |
--- a/nscd/gethstbynm3_r.c
|
|
|
8597553 |
+++ b/nscd/gethstbynm3_r.c
|
|
|
8597553 |
@@ -32,7 +32,7 @@
|
|
|
8597553 |
#define ADD_VARIABLES name, af
|
|
|
8597553 |
#define EXTRA_VARIABLES , ttlp, canonp
|
|
|
8597553 |
#define NEED_H_ERRNO 1
|
|
|
8597553 |
-#define NEED__RES_HCONF 1
|
|
|
8597553 |
+#define NEED__RES 1
|
|
|
8597553 |
|
|
|
8597553 |
#define HANDLE_DIGITS_DOTS 1
|
|
|
8597553 |
#define HAVE_LOOKUP_BUFFER 1
|
|
|
8597553 |
diff --git a/nss/getXXbyYY_r.c b/nss/getXXbyYY_r.c
|
|
|
8597553 |
index 5962475737dee6ba..7cab825cf05503f6 100644
|
|
|
8597553 |
--- a/nss/getXXbyYY_r.c
|
|
|
8597553 |
+++ b/nss/getXXbyYY_r.c
|
|
|
8597553 |
@@ -25,9 +25,6 @@
|
|
|
8597553 |
#ifdef USE_NSCD
|
|
|
8597553 |
# include <nscd/nscd_proto.h>
|
|
|
8597553 |
#endif
|
|
|
8597553 |
-#ifdef NEED__RES_HCONF
|
|
|
8597553 |
-# include <resolv/res_hconf.h>
|
|
|
8597553 |
-#endif
|
|
|
8597553 |
#ifdef NEED__RES
|
|
|
8597553 |
# include <resolv.h>
|
|
|
8597553 |
#endif
|
|
|
8597553 |
@@ -273,9 +270,6 @@ INTERNAL (REENTRANT_NAME) (ADD_PARAMS, LOOKUP_TYPE *resbuf, char *buffer,
|
|
|
8597553 |
return errno;
|
|
|
8597553 |
}
|
|
|
8597553 |
#endif /* need _res */
|
|
|
8597553 |
-#ifdef NEED__RES_HCONF
|
|
|
8597553 |
- _res_hconf_init ();
|
|
|
8597553 |
-#endif /* need _res_hconf */
|
|
|
8597553 |
|
|
|
8597553 |
void *tmp_ptr = fct.l;
|
|
|
8597553 |
#ifdef PTR_MANGLE
|
|
|
8597553 |
diff --git a/resolv/res_hconf.h b/resolv/res_hconf.h
|
|
|
8597553 |
index 6eaf4039f3451511..209f76a0d6ef8193 100644
|
|
|
8597553 |
--- a/resolv/res_hconf.h
|
|
|
8597553 |
+++ b/resolv/res_hconf.h
|
|
|
8597553 |
@@ -46,7 +46,7 @@ struct hconf
|
|
|
8597553 |
};
|
|
|
8597553 |
extern struct hconf _res_hconf;
|
|
|
8597553 |
|
|
|
8597553 |
-extern void _res_hconf_init (void);
|
|
|
8597553 |
+extern void _res_hconf_init (void) attribute_hidden;
|
|
|
8597553 |
extern void _res_hconf_trim_domain (char *domain);
|
|
|
8597553 |
extern void _res_hconf_trim_domains (struct hostent *hp);
|
|
|
8597553 |
extern void _res_hconf_reorder_addrs (struct hostent *hp);
|
|
|
8597553 |
diff --git a/resolv/res_init.c b/resolv/res_init.c
|
|
|
8597553 |
index 9aa907ee199f01a6..821f06061b4c3fb1 100644
|
|
|
8597553 |
--- a/resolv/res_init.c
|
|
|
8597553 |
+++ b/resolv/res_init.c
|
|
|
8597553 |
@@ -85,6 +85,7 @@
|
|
|
8597553 |
#include <ctype.h>
|
|
|
8597553 |
#include <netdb.h>
|
|
|
8597553 |
#include <resolv/resolv-internal.h>
|
|
|
8597553 |
+#include <res_hconf.h>
|
|
|
8597553 |
#include <stdio.h>
|
|
|
8597553 |
#include <stdio_ext.h>
|
|
|
8597553 |
#include <stdlib.h>
|
|
|
8597553 |
@@ -430,6 +431,9 @@ res_vinit_1 (res_state statp, bool preinit, FILE *fp, char **buffer)
|
|
|
8597553 |
int
|
|
|
8597553 |
__res_vinit (res_state statp, int preinit)
|
|
|
8597553 |
{
|
|
|
8597553 |
+ /* Ensure that /etc/hosts.conf has been loaded (once). */
|
|
|
8597553 |
+ _res_hconf_init ();
|
|
|
8597553 |
+
|
|
|
8597553 |
FILE *fp = fopen (_PATH_RESCONF, "rce");
|
|
|
8597553 |
if (fp == NULL)
|
|
|
8597553 |
switch (errno)
|
|
|
8597553 |
diff --git a/sysdeps/posix/getaddrinfo.c b/sysdeps/posix/getaddrinfo.c
|
|
|
8597553 |
index 91e0a76c5cfa027f..4fb1eaef79bc66a3 100644
|
|
|
8597553 |
--- a/sysdeps/posix/getaddrinfo.c
|
|
|
8597553 |
+++ b/sysdeps/posix/getaddrinfo.c
|
|
|
8597553 |
@@ -80,7 +80,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
8597553 |
#include <not-cancel.h>
|
|
|
8597553 |
#include <nscd/nscd-client.h>
|
|
|
8597553 |
#include <nscd/nscd_proto.h>
|
|
|
8597553 |
-#include <resolv/res_hconf.h>
|
|
|
8597553 |
#include <scratch_buffer.h>
|
|
|
8597553 |
#include <inet/net-internal.h>
|
|
|
8597553 |
|
|
|
8597553 |
@@ -767,7 +766,6 @@ gaih_inet (const char *name, const struct gaih_service *service,
|
|
|
8597553 |
nip = __nss_hosts_database;
|
|
|
8597553 |
|
|
|
8597553 |
/* Initialize configurations. */
|
|
|
8597553 |
- _res_hconf_init ();
|
|
|
8597553 |
if (__res_maybe_init (&_res, 0) == -1)
|
|
|
8597553 |
no_more = 1;
|
|
|
8597553 |
|