name_servers[_append] and search_domains[_append] now apply
authorRoy Marples <roy@marples.name>
Fri, 12 Jul 2013 12:59:56 +0000 (12:59 +0000)
committerRoy Marples <roy@marples.name>
Fri, 12 Jul 2013 12:59:56 +0000 (12:59 +0000)
to all subscribers instead of just libc.

libc.in
resolvconf.in

diff --git a/libc.in b/libc.in
index 945efc826889dde3485d4f1b82d1fe99870bbce2..2e29e4fdb0bcc5c90035c173d9fb9d20ca393bc7 100644 (file)
--- a/libc.in
+++ b/libc.in
@@ -80,9 +80,9 @@ elif [ -d "$SYSCONFDIR"/resolvconf ]; then
        SYSCONFDIR="$SYSCONFDIR/resolvconf/resolv.conf.d"
        base="$SYSCONFDIR/resolv.conf.d/base"
        if [ -f "$base" ]; then
-               name_servers="$(key_get_value "nameserver " "$base")"
+               prepend_nameservers="$(key_get_value "nameserver " "$base")"
                domain="$(key_get_value "domain " "$base")"
-               search_domains="$(key_get_value "search " "$base")"
+               prepend_search="$(key_get_value "search " "$base")"
                resolv_conf_options="$(key_get_value "options " "$base")"
                resolv_conf_sortlist="$(key_get_value "sortlist " "$base")"
        fi
@@ -131,11 +131,11 @@ case "${resolv_conf_passthrough:-NO}" in
        ;;
 *)
        [ -z "$RESOLVCONF" ] && eval "$(@SBINDIR@/resolvconf -v)"
-       newsearch="$(uniqify $search_domains $SEARCH $search_domains_append)"
+       newsearch="$(uniqify $prepend_search $SEARCH)"
        NS="$LOCALNAMESERVERS $NAMESERVERS"
        newns=
        gotlocal=false
-       for n in $(uniqify $name_servers $NS $name_servers_append); do
+       for n in $(uniqify $prepend_nameservers $NS); do
                add=true
                case "$n" in
                127.*|0.0.0.0|255.255.255.255|::1) gotlocal=true;;
index a27fba878d219ed0ba33b6b4d5329ebb89afb160..fcb1dcf7ec0d34aece2dc5127f47d856d28184eb 100644 (file)
@@ -30,7 +30,7 @@ LIBEXECDIR=@LIBEXECDIR@
 VARDIR=@VARDIR@
 
 # Disregard dhcpcd setting
-unset interface_order
+unset interface_order state_dir
 
 # Support original resolvconf configuration layout
 # as well as the openresolv config file
@@ -115,18 +115,6 @@ parse_resolv()
        local line= ns= ds= search= d= n= newns=
        local new=true iface= private=false p= domain=
 
-       echo "DOMAIN="
-       echo "DOMAINS="
-       echo "SEARCH=\"$search_domains\""
-       # let our subscribers know about global nameservers
-       for n in $name_servers; do
-               case "$n" in
-               127.*|0.0.0.0|255.255.255.255|::1) :;;
-               *) newns="$newns${newns:+ }$n";;
-               esac
-       done
-       echo "NAMESERVERS=\"$newns\""
-       echo "LOCALNAMESERVERS="
        newns=
 
        while read -r line; do
@@ -328,10 +316,48 @@ list_remove() {
        return $retval
 }
 
+echo_prepend()
+{
+       echo "# Generated by resolvconf"
+       if [ -n "$search_domains" ]; then
+               echo "search $search_domains"
+       fi
+       for n in $name_servers; do
+               echo "nameserver $n"
+       done
+       echo
+}
+
+echo_append()
+{
+       echo "# Generated by resolvconf"
+       if [ -n "$search_domains_append" ]; then
+               echo "search $search_domains_append"
+       fi
+       for n in $name_servers_append; do
+               echo "nameserver $n"
+       done
+       echo
+}
+
 make_vars()
 {
        local newdomains= d= dn= newns= ns=
+
+       # Clear variables
+       DOMAIN=
+       DOMAINS=
+       SEARCH=
+       NAMESERVERS=
+       LOCALNAMESERVERS=
+
+       if [ -n "$name_servers" -o -n "$search_domains" ]; then
+               eval "$(echo_prepend | parse_resolv)"
+       fi
        eval "$(list_resolv -l "$@" | parse_resolv)"
+       if [ -n "$name_servers_append" -o -n "$search_domains_append" ]; then
+               eval "$(echo_append | parse_resolv)"
+       fi
 
        # Ensure that we only list each domain once
        for d in $DOMAINS; do