about summary refs log tree commit diff
diff options
context:
space:
mode:
authorPetr Baudis <pasky@ucw.cz>2010-08-22 16:15:17 +0200
committerPetr Baudis <pasky@suse.cz>2010-11-16 02:50:21 +0100
commitb321e863ac162595250446a3b107384dc7aecd89 (patch)
tree434804a50634ccc72c0af4d16e78bea63306a912
parentb9be604a7bcffd1fa5fc0141c0dfd2ddcbf09451 (diff)
downloadglibc-b321e863ac162595250446a3b107384dc7aecd89.tar.gz
glibc-b321e863ac162595250446a3b107384dc7aecd89.tar.xz
glibc-b321e863ac162595250446a3b107384dc7aecd89.zip
Make nscd load /etc/host.conf options in aicache
This patch makes sure _res_hconf is initialized before resolving is being done.

However, this would not be enough since nscd has its own _res_hconf due to
nscd/res_hconf.c; _res_hconf_init() would work on different _res_hconf instance
than the NSS routines. We just need to make sure nscd and glibc share the same
_res_hconf instance - this should not be a problem since users should run
matching versions of glibc and nscd anyway.
-rw-r--r--ChangeLog6
-rw-r--r--nscd/aicache.c3
-rw-r--r--resolv/res_hconf.c2
3 files changed, 11 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 3d87811dc3..8f7372ba62 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2010-08-19  Petr Baudis <pasky@suse.cz>
+
+	[BZ #11928]
+        * nscd/aicache.c (addhstaiX): Ensure _res_hconf has been initialized.
+        * resolv/res_hconf.c (_res_hconf): Do not redefine outside of libc.
+
 2010-05-31  Petr Baudis <pasky@suse.cz>
 
 	[BZ #10085]
diff --git a/nscd/aicache.c b/nscd/aicache.c
index 3cb2208035..2e92929a65 100644
--- a/nscd/aicache.c
+++ b/nscd/aicache.c
@@ -26,6 +26,7 @@
 #include <time.h>
 #include <unistd.h>
 #include <sys/mman.h>
+#include <resolv/res_hconf.h>
 
 #include "dbg_log.h"
 #include "nscd.h"
@@ -103,6 +104,8 @@ addhstaiX (struct database_dyn *db, int fd, request_header *req,
 
   if (__res_maybe_init (&_res, 0) == -1)
 	    no_more = 1;
+  if (!_res_hconf.initialized)
+    _res_hconf_init ();
 
   /* If we are looking for both IPv4 and IPv6 address we don't want
      the lookup functions to automatically promote IPv4 addresses to
diff --git a/resolv/res_hconf.c b/resolv/res_hconf.c
index ed55bec296..c79b85ab43 100644
--- a/resolv/res_hconf.c
+++ b/resolv/res_hconf.c
@@ -84,7 +84,9 @@ static const struct cmd
 };
 
 /* Structure containing the state.  */
+#ifndef NOT_IN_libc
 struct hconf _res_hconf;
+#endif
 
 /* Skip white space.  */
 static const char *