Fix resolv_conf_local_only.
authorRoy Marples <roy@marples.name>
Tue, 27 Mar 2012 21:16:28 +0000 (21:16 +0000)
committerRoy Marples <roy@marples.name>
Tue, 27 Mar 2012 21:16:28 +0000 (21:16 +0000)
libc.in

diff --git a/libc.in b/libc.in
index 4988c18cf429a084a68c93b16e7342926e4cd368..c4233d5cdbea480ccfe0f8a1ee2442c053b496ed 100644 (file)
--- a/libc.in
+++ b/libc.in
@@ -132,12 +132,21 @@ case "${resolv_conf_passthrough:-NO}" in
 *)
        [ -z "$RESOLVCONF" ] && eval "$(@PREFIX@/sbin/resolvconf -v)"
        newsearch="$(uniqify $search_domains $SEARCH $search_domains_append)"
-       NS="$LOCALNAMESERVERS"
-       case "${resolv_conf_local_only:-1}" in
-       [Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|[Oo][Nn]|1) ;;
-       *) NS="$NS $NAMESERVERS";;
-       esac
-       newns="$(uniqify $name_servers $NS $name_servers_append)"
+       NS="$LOCALNAMESERVERS $NAMESERVERS"
+       newns=
+       gotlocal=false
+       for n in $(uniqify $name_servers $NS $name_servers_append); do
+               add=true
+               case "$n" in
+               127.*|0.0.0.0|255.255.255.255|::1) gotlocal=true;;
+               *)
+                       case "${resolv_conf_local_only:-YES}" in
+                       [Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|[Oo][Nn]|1)
+                               $gotlocal && add=false;;
+                       esac
+               esac
+               $add && newns="$newns $n"
+       done
 
        # Hold our new resolv.conf in a variable to save on temporary files
        newconf="# Generated by resolvconf$NL"