d6fe1b4
From 125b1a8619eb27556e093fd9c9adf451e896f012 Mon Sep 17 00:00:00 2001
d6fe1b4
From: Jakub Hrozek <jhrozek@redhat.com>
d6fe1b4
Date: Mon, 31 May 2010 16:32:54 +0200
d6fe1b4
Subject: [PATCH] ares_init: Last, not first instance of domain or search should win
d6fe1b4
d6fe1b4
diff --git a/ares_init.3 b/ares_init.3
d6fe1b4
index 00ff36d..fb25306 100644
d6fe1b4
--- a/ares_init.3
d6fe1b4
+++ b/ares_init.3
d6fe1b4
@@ -109,7 +109,7 @@ or the domain derived from the kernel hostname variable.
d6fe1b4
 .B ARES_OPT_LOOKUPS
d6fe1b4
 .B char *\fIlookups\fP;
d6fe1b4
 .br
d6fe1b4
-The lookups to perform for host queries.  
d6fe1b4
+The lookups to perform for host queries.
d6fe1b4
 .I lookups
d6fe1b4
 should be set to a string of the characters "b" or "f", where "b"
d6fe1b4
 indicates a DNS lookup and "f" indicates a lookup in the hosts file.
d6fe1b4
@@ -189,6 +189,27 @@ The process's available memory was exhausted.
d6fe1b4
 .TP 14
d6fe1b4
 .B ARES_ENOTINITIALIZED
d6fe1b4
 c-ares library initialization not yet performed.
d6fe1b4
+.SH NOTES
d6fe1b4
+When initializing from
d6fe1b4
+.B /etc/resolv.conf,
d6fe1b4
+.BR ares_init (3)
d6fe1b4
+reads the
d6fe1b4
+.I domain
d6fe1b4
+and
d6fe1b4
+.I search
d6fe1b4
+directives to allow lookups of short names relative to the domains
d6fe1b4
+specified. The
d6fe1b4
+.I domain
d6fe1b4
+and
d6fe1b4
+.I search
d6fe1b4
+directives override one another. If more that one instance of either
d6fe1b4
+.I domain
d6fe1b4
+or
d6fe1b4
+.I search
d6fe1b4
+directives is specified, the last occurence wins. For more information,
d6fe1b4
+please see the
d6fe1b4
+.BR resolv.conf (5)
d6fe1b4
+manual page.
d6fe1b4
 .SH SEE ALSO
d6fe1b4
 .BR ares_destroy(3),
d6fe1b4
 .BR ares_dup(3),
d6fe1b4
diff --git a/ares_init.c b/ares_init.c
d6fe1b4
index 1f561aa..9d1e447 100644
d6fe1b4
--- a/ares_init.c
d6fe1b4
+++ b/ares_init.c
d6fe1b4
@@ -839,11 +839,11 @@ DhcpNameServer
d6fe1b4
     if (fp) {
d6fe1b4
       while ((status = ares__read_line(fp, &line, &linesize)) == ARES_SUCCESS)
d6fe1b4
       {
d6fe1b4
-        if ((p = try_config(line, "domain")) && channel->ndomains == -1)
d6fe1b4
+        if ((p = try_config(line, "domain")))
d6fe1b4
           status = config_domain(channel, p);
d6fe1b4
         else if ((p = try_config(line, "lookup")) && !channel->lookups)
d6fe1b4
           status = config_lookup(channel, p, "bind", "file");
d6fe1b4
-        else if ((p = try_config(line, "search")) && channel->ndomains == -1)
d6fe1b4
+        else if ((p = try_config(line, "search")))
d6fe1b4
           status = set_search(channel, p);
d6fe1b4
         else if ((p = try_config(line, "nameserver")) && channel->nservers == -1)
d6fe1b4
           status = config_nameserver(&servers, &nservers, p);
d6fe1b4
-- 
d6fe1b4
1.6.6.1
d6fe1b4