When an interface is marked private, we just discard the nameservers from the
[openresolv] / named.in
old mode 100755 (executable)
new mode 100644 (file)
index 1b3801b..0a3f8f1
--- a/named.in
+++ b/named.in
@@ -48,8 +48,7 @@
 #echo "nameserver 127.0.0.1" > /usr/local/etc/resolvconf/resolv.conf.d/base
 
 # Load our variables from resolvconf
-VARS="$(resolvconf -v)"
-eval "${VARS}"
+eval "$(resolvconf -v)"
 
 # If our dir doesn't exist then don't do anything
 NAMEDB=/etc/namedb
@@ -59,19 +58,10 @@ NAMEDB=/etc/namedb
 NAMEDOPTIONS="${NAMEDB}/resolvconf-options.conf"
 NAMEDZONES="${NAMEDB}/resolvconf-zones.conf"
 
-# If we only have domain information then put it in search too
-[ -z "${NEWSEARCH}" -a -z "${NEWNS}" ] && NEWSEARCH="${NEWDOMAIN}"
-
 NEWOPTIONS="# Generated by resolvconf\n"
 NEWZONES="${NEWOPTIONS}"
 FORWARD=
-for N in ${NEWSEARCH}; do
-       case "${FORWARD}" in
-               *"\n\t${N#*,};"*);;
-               *) FORWARD="${FORWARD}\n\t${N#*,};";;
-       esac
-done
-for N in ${NEWNS}; do
+for N in ${NAMESERVERS}; do
        case "${FORWARD}" in
                *"\n\t${N};"*);;
                *) FORWARD="${FORWARD}\n\t${N};";;
@@ -81,23 +71,17 @@ if [ -n "${FORWARD}" ]; then
        NEWOPTIONS="${NEWOPTIONS}forward first;\nforwarders {${FORWARD}\n};\n"
 fi
 
-LASTDN=
-ZONES=
-for DN in $(printf "%s\n" ${NEWDOMAIN} | sort -u); do
-       case "${LASTDN}" in
-               "${DN%,*}");;
-               *)
-               LASTDN="${DN%,*}"
-               [ -n "${ZONES}" ] && ZONES="${ZONES}\n\t};\n};\n"
-               ZONES="${ZONES}zone \"${LASTDN}\" {\n"
-               ZONES="${ZONES}\ttype forward;\n"
-               ZONES="${ZONES}\tforward first;\n"
-               ZONES="${ZONES}\tforwarders {"
-               ;;
-       esac
-       ZONES="${ZONES}\n\t\t${DN#*,};"
+for D in ${DOMAINS}; do
+       NEWZONES="${NEWZONES}zone \"${D%%:*}\" {\n"
+       NEWZONES="${NEWZONES}\ttype forward;\n\tforward first;\n\tforwarders {\n"
+       NS="${D#*:}"
+       while [ -n "${NS}" ]; do
+               NEWZONES="${NEWZONES}\t\t${NS%%,*};\n"
+               [ "${NS}" = "${NS#*,}" ] && break
+               NS="${NS#*,}"
+       done
+       NEWZONES="${NEWZONES}\t};\n};\n"
 done
-[ -n "${ZONES}" ] && NEWZONES="${NEWZONES}${ZONES}\n\t};\n};\n"
 
 # No point in changing files or reloading bind if the end result has not
 # changed