When an interface is marked private, we just discard the nameservers from the openresolv-2.0
authorRoy Marples <roy@marples.name>
Fri, 3 Oct 2008 09:21:33 +0000 (09:21 +0000)
committerRoy Marples <roy@marples.name>
Fri, 3 Oct 2008 09:21:33 +0000 (09:21 +0000)
global search.

libc.in
resolvconf.8.in
resolvconf.in

diff --git a/libc.in b/libc.in
index e25e84d1f9526145ed8e04d05b477ae99c198cca..a01d431c56ef1a0f3166a9686611420f5bf6f453 100644 (file)
--- a/libc.in
+++ b/libc.in
@@ -81,15 +81,6 @@ if [ -e "${BASE}" ]; then
                NEWSEARCH="$(key_get_value "domain " "${BASE}")"
        fi
 fi
-for D in ${DOMAINS}; do
-       NEWSEARCH="${NEWSEARCH} ${D%%:*}"
-       NS="${D#*:}"
-       while [ -n "${NS}" ]; do
-               NEWNS="${NEWNS} ${NS%%,*}"
-               [ "${NS}" = "${NS#*,}" ] && break
-               NS="${NS#*,}"
-       done
-done
 NEWSEARCH="$(uniqify ${NEWSEARCH} ${SEARCH})"
 NEWNS="$(uniqify ${NEWNS} ${NAMESERVERS})"
 
index b409c1de5f369bc67dd8e79dcbaf47f00c3ac50f..6ea701d519d0586ab5b211a58b976fd9b9f76339 100644 (file)
@@ -22,7 +22,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.Dd October 01, 2008
+.Dd October 03, 2008
 .Dt RESOLVCONF 8 SMM
 .Sh NAME
 .Nm resolvconf
@@ -78,13 +78,9 @@ will supply files that the resolver should be configured to include.
 can mark an interfaces
 .Pa resolv.conf
 as private.
-This means that any queries for a host in the private domain or search
-paths are only send to the nameservers in the same
-.Pa resolv.conf .
-If only private
+This means that the nameservers listed in that
 .Pa resolv.conf
-files exist then
-.Nm installs them as global ones too.
+are only used for queries against the domain/search listed in the same file.
 This only works when a local resolver other than libc is installed.
 Doing this, you would probably want
 .Nm
index d8f69085365be1aafbfb1ba3c7923657d8f33fdc..714c7bf582379d1722f21b96ca60b2c59dcd4500 100644 (file)
@@ -81,31 +81,12 @@ echo_resolv()
        echo
 }
 
-# Return 1 if an interface is private
-# ie, we only use the listed nameservers for the domain/search path
-is_private()
-{
-       [ -e "${PRIVATEDIR}/$1" ] && return 0
-       if [ -e "${SYSCONFDIR}/private-interfaces" ]; then
-               for IFACE in $(cat "${SYSCONFDIR}/private-interfaces"); do
-                       [ "${IFACE}" = "$1" ] && return 0
-               done
-       else
-               cd "${IFACEDIR}"
-               for IFACE in tap[0-9]* tun[0-9]* vpn vpn[0-9]*; do
-                       [ -e "${IFACE}" ] || continue
-                       [ "${IFACE}" = "$1" ] && return 0
-               done
-       fi
-       return 1
-}
-
 # Parse resolv.conf's and make variables
 # for domain name servers, search name servers and global nameservers
 parse_resolv()
 {
        local LINE= NS= DOMAINS= SEARCH= D= N= NEWNS=
-       local NEW=true PRIVATE=false
+       local NEW=true IFACE=
 
        echo "DOMAINS="
        echo "SEARCH="
@@ -115,11 +96,7 @@ parse_resolv()
                case "${LINE}" in
                "# resolv.conf from "*)
                        if ${NEW}; then
-                               if is_private "${LINE#\# resolv.conf from *}"; then
-                                       PRIVATE=true
-                               else
-                                       PRIVATE=false
-                               fi
+                               IFACE="${LINE#\# resolv.conf from *}"
                                NEW=false
                        fi
                        ;;
@@ -137,8 +114,8 @@ parse_resolv()
                        ;;
                *)
                        if [ -z "${LINE}" ]; then
-                               if [ -n "${NS}" -a -n "${SEARCH}" ] && ${PRIVATE}; then
-                                       unset NEWNS
+                               if [ -n "${NS}" -a -n "${SEARCH}" ]; then
+                                       NEWNS=
                                        for N in ${NS}; do
                                                NEWNS="${NEWNS}${NEWNS:+,}${N}"
                                        done
@@ -147,10 +124,11 @@ parse_resolv()
                                                DOMAINS="${DOMAINS}${DOMAINS:+ }${D}:${NEWNS}"
                                        done
                                        echo "DOMAINS=\"\${DOMAINS} ${DOMAINS}\""
-                               else
-                                       echo "NAMESERVERS=\"\${NAMESERVERS} ${NS}\""
                                fi
                                echo "SEARCH=\"\${SEARCH} ${SEARCH}\""
+                               if [ ! -e "${PRIVATEDIR}/${IFACE}" ]; then
+                                       echo "NAMESERVERS=\"\${NAMESERVERS} ${NS}\""
+                               fi
                                NS=
                                SEARCH=
                                PRIVATE=false
@@ -283,25 +261,31 @@ fi
 if [ "${CMD}" = "v" ]; then
        eval "$("${ARGV0}" -l "${IFACE}" | parse_resolv)"
 
-       DOMAINS="$(uniqify ${DOMAINS})"
-       SEARCH="$(uniqify ${SEARCH})"
-       # If we don't have any non private nameservers
-       # then make them all private ones public
-       if [ -z "${NAMESERVERS}" ]; then
-               NAMESERVERS=
-               for D in ${DOMAINS}; do
-                       NS="${D#*:}"
-                       while [ -n "${NS}" ]; do
-                               NAMESERVERS="${NAMESERVERS} ${NS%%,*}"
-                               [ "${NS}" = "${NS#*,}" ] && break
-                               NS="${NS#*,}"
-                       done
+       # Ensure that we only list each domain once
+       NEWDOMAINS=
+       for D in ${DOMAINS}; do
+               DN="${D%%:*}"
+               case " ${NEWDOMAINS}" in
+                       *" ${DN}:"*) continue;;
+               esac
+               DONE="${DONE} ${DN}"
+               NEWDOMAINS="${NEWDOMAINS}${NEWDOMAINS:+ }${DN}:"
+               NEWNS=
+               for ND in ${DOMAINS}; do
+                       if [ "${DN}" = "${ND%%:*}" ]; then
+                               NS="${ND#*:}"
+                               while [ -n "${NS}" ]; do
+                                       NEWNS="${NEWNS}${NEWNS:+,}${NS%%,*}"
+                                       [ "${NS}" = "${NS#*,}" ] && break
+                                       NS="${NS#*,}"
+                               done
+                       fi
                done
-       fi
-       NAMESERVERS="$(uniqify ${NAMESERVERS})"
-       echo "DOMAINS='${DOMAINS}'"
-       echo "SEARCH='${SEARCH}'"
-       echo "NAMESERVERS='${NAMESERVERS}'"
+               NEWDOMAINS="${NEWDOMAINS}${NEWNS}"
+       done
+       echo "DOMAINS='${NEWDOMAINS}'"
+       echo "SEARCH='$(uniqify ${SEARCH})'"
+       echo "NAMESERVERS='$(uniqify ${NAMESERVERS})'"
        exit 0
 fi