Add private_interfaces configuration option for the times the calling
authorRoy Marples <roy@marples.name>
Thu, 19 Mar 2009 23:24:24 +0000 (23:24 +0000)
committerRoy Marples <roy@marples.name>
Thu, 19 Mar 2009 23:24:24 +0000 (23:24 +0000)
program doesn't or can't know about openresolv -p flag.

resolvconf.conf.5.in
resolvconf.in

index a2b6bd9f5dab76ff8e2ddb59d15b8d84fa7d9192..fc4bde5295dedb5e12841cdfc185ea78df927104 100644 (file)
@@ -22,7 +22,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.Dd March 18, 2009
+.Dd March 19, 2009
 .Dt RESOLVCONF.CONF 5 SMM
 .Os
 .Sh NAME
@@ -46,6 +46,12 @@ If unset, defaults to the following:-
 These interfaces will be processed next, unless they have a metric.
 If unset, defaults to the following:-
 .D1 tap[0-9]* tun[0-9]* vpn vpn[0-9]* ppp[0-9]* ippp[0-9]*
+.It Sy private_interfaces
+These interfaces name servers will only be queried for the domains listed
+in their resolv.conf.
+This is equivalent to the
+.Nm resolvconf -p
+option.
 .El
 .Sh LIBC OPTIONS
 The following variables affect
index 69158866ea39444e55d654661673f8cdcef1dcd3..d2c1049ca21ee18340a699beb646e7d3d29916e8 100644 (file)
@@ -99,8 +99,8 @@ echo_resolv()
 # for domain name servers, search name servers and global nameservers
 parse_resolv()
 {
-       local line= ns= domains= search= d= n= newns=
-       local new=true iface=
+       local line= ns= ds= search= d= n= newns=
+       local new=true iface= private=false
 
        echo "DOMAINS="
        echo "SEARCH="
@@ -112,6 +112,18 @@ parse_resolv()
                        if ${new}; then
                                iface="${line#\# resolv.conf from *}"
                                new=false
+                               case " ${private_interfaces} " in
+                               *" ${iface} "*)
+                                       private=true
+                                       ;;
+                               *)
+                                       if [ -e "${PRIVATEDIR}/${iface}" ]; then
+                                               private=true
+                                       else
+                                               private=false
+                                       fi
+                                       ;;
+                               esac
                        fi
                        ;;
                "nameserver "*)
@@ -124,26 +136,25 @@ parse_resolv()
                        search="${line#* }"
                        ;;
                *)
-                       if [ -z "${line}" ]; then
-                               if [ -n "${ns}" -a -n "${search}" ]; then
-                                       newns=
-                                       for n in ${ns}; do
-                                               newns="${newns}${newns:+,}${n}"
-                                       done
-                                       domains=
-                                       for d in ${search}; do
-                                               domains="${domains}${domains:+ }${d}:${newns}"
-                                       done
-                                       echo "DOMAINS=\"\${DOMAINS} ${domains}\""
-                               fi
-                               echo "SEARCH=\"\${SEARCH} ${search}\""
-                               if [ ! -e "${PRIVATEDIR}/${iface}" ]; then
-                                       echo "NAMESERVERS=\"\${NAMESERVERS} ${ns}\""
-                               fi
-                               ns=
-                               search=
-                               new=true
+                       [ -n "${line}" ] && continue
+                       if [ -n "${ns}" -a -n "${search}" ]; then
+                               newns=
+                               for n in ${ns}; do
+                                       newns="${newns}${newns:+,}${n}"
+                               done
+                               ds=
+                               for d in ${search}; do
+                                       ds="${ds}${ds:+ }${d}:${newns}"
+                               done
+                               echo "DOMAINS=\"\${DOMAINS} ${ds}\""
+                       fi
+                       echo "SEARCH=\"\${SEARCH} ${search}\""
+                       if ! ${private}; then
+                               echo "NAMESERVERS=\"\${NAMESERVERS} ${ns}\""
                        fi
+                       ns=
+                       search=
+                       new=true
                        ;;
                esac
        done