Add domain, if available, to resolv.conf.
authorRoy Marples <roy@marples.name>
Fri, 12 Aug 2011 13:19:25 +0000 (13:19 +0000)
committerRoy Marples <roy@marples.name>
Fri, 12 Aug 2011 13:19:25 +0000 (13:19 +0000)
Only add search if available and different from domain.
This allows us to more acurately represent the given data even if a little
superfluous.

libc.in

diff --git a/libc.in b/libc.in
index 801f342fecf1efcda5b4b036ae6058c0155adef0..5aea64174b59373f9b9aa81181ee0c81236d0339 100644 (file)
--- a/libc.in
+++ b/libc.in
@@ -81,10 +81,8 @@ elif [ -d "$SYSCONFDIR"/resolvconf ]; then
        base="$SYSCONFDIR/resolv.conf.d/base"
        if [ -f "$base" ]; then
                name_servers="$(key_get_value "nameserver " "$base")"
+               domain="$(key_get_value "domain " "$base")"
                search_domains="$(key_get_value "search " "$base")"
-               if [ -z "$search_domains" ]; then
-                       search_domains="$(key_get_value "domain " "$base")"
-               fi
                resolv_conf_options="$(key_get_value "options " "$base")"
                resolv_conf_sortlist="$(key_get_value "sortlist " "$base")"
        fi
@@ -95,6 +93,7 @@ elif [ -d "$SYSCONFDIR"/resolvconf ]; then
                resolv_conf_tail="$(cat "$SYSCONFDIR"/resolv.conf.d/tail)"
        fi
 fi
+: ${domain:=$DOMAIN}
 : ${resolv_conf:=/etc/resolv.conf}
 : ${libc_service:=nscd}
 : ${libc_restart:=@RESTARTCMD ${libc_service}@}
@@ -141,7 +140,11 @@ case "${resolv_conf_passthrough:-NO}" in
        if [ -n "$resolv_conf_head" ]; then
                newconf="$newconf$resolv_conf_head$NL"
        fi
-       [ -n "$newsearch" ] && newconf="${newconf}search $newsearch$NL"
+
+       [ -n "$domain" ] && newconf="${newconf}domain $domain$NL"
+       if [ -n "$newsearch" -a "$newsearch" != "$domain" ]; then
+               newconf="${newconf}search $newsearch$NL"
+       fi
        for n in $newns; do
                newconf="${newconf}nameserver $n$NL"
        done