Import openresolv-3.5.0 with the following changes:

* Added resolv_conf_local_only which defaults to true.
  This means that if you configure a local nameserver we don't add
  any other nameservers to resolv.conf to avoid duplicate queries.
* Add domain_blacklist and name_server_blacklist variables.
  We default name_server_blacklist to 0.0.0.0 to handle some faulty
  routers.
* Add .Lk macro to URLs.
* Fix IPv6 parsing on domains which include an IPv4 server for dnsmasq.
This commit is contained in:
roy 2012-03-26 14:41:33 +00:00
parent 5adcf9c629
commit 45de6d39f8
5 changed files with 81 additions and 20 deletions

View File

@ -71,12 +71,13 @@ conf=
for d in $DOMAINS; do
dn="${d%%:*}"
ns="${d#*:}"
n="${ns%%,*}"
while [ -n "$ns" ]; do
case "$ns" in
case "$n" in
*.*.*.*)
SIFS=${IFS-y} OIFS=$IFS
IFS=.
set -- ${ns%%,*}
set -- $n
num="0x$(printf %02x $1 $2 $3 $4)"
if [ "$SIFS" = y ]; then
unset IFS
@ -89,7 +90,7 @@ for d in $DOMAINS; do
*:*:*:*:*:*:*:*)
SIFS=${IFS-y} OIFS=$IFS bytes=
IFS=:
set -- ${ns%%,*}
set -- $n
while [ -n "$1" ]; do
addr="$1"
shift
@ -111,11 +112,12 @@ for d in $DOMAINS; do
dbus=false
;;
esac
conf="${conf}server=/$dn/${ns%%,*}$NL"
conf="${conf}server=/$dn/$n$NL"
[ "$ns" = "${ns#*,}" ] && break
ns="${ns#*,}"
done
done
if $dbus; then
newconf="$newconf$NL# Domain specific servers will"
newconf="$newconf be sent over dbus${NL}enable-dbus$NL"

View File

@ -1,5 +1,5 @@
#!/bin/sh
# Copyright (c) 2007-2011 Roy Marples
# Copyright (c) 2007-2012 Roy Marples
# All rights reserved
# libc subscriber for resolvconf
@ -132,7 +132,11 @@ case "${resolv_conf_passthrough:-NO}" in
*)
[ -z "$RESOLVCONF" ] && eval "$(@PREFIX@/sbin/resolvconf -v)"
newsearch="$(uniqify $search_domains $SEARCH $search_domains_append)"
NS="$LOCALNAMESERVERS $NAMESERVERS"
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)"
# Hold our new resolv.conf in a variable to save on temporary files

View File

@ -1,4 +1,4 @@
.\" Copyright (c) 2007-2011 Roy Marples
.\" Copyright (c) 2007-2012 Roy Marples
.\" All rights reserved
.\"
.\" Redistribution and use in source and binary forms, with or without
@ -22,7 +22,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.Dd May 13, 2011
.Dd March 19, 2012
.Dt RESOLVCONF 8 SMM
.Os
.Sh NAME
@ -226,7 +226,8 @@ resolvconf, as written by Thomas Hood.
.Sh AUTHORS
.An Roy Marples Aq roy@marples.name
.Sh BUGS
Please report them to http://roy.marples.name/projects/openresolv
Please report them to
.Lk http://roy.marples.name/projects/openresolv
.Pp
.Nm
does not validate any of the files given to it.

View File

@ -1,4 +1,4 @@
.\" Copyright (c) 2009-2011 Roy Marples
.\" Copyright (c) 2009-2012 Roy Marples
.\" All rights reserved
.\"
.\" Redistribution and use in source and binary forms, with or without
@ -22,7 +22,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.Dd August 11, 2011
.Dd March 19, 2012
.Dt RESOLVCONF.CONF 5 SMM
.Os
.Sh NAME
@ -60,12 +60,20 @@ If unset, defaults to the following:-
Prepend search domains to the dynamically generated list.
.It Sy search_domains_append
Append search domains to the dynamically generated list.
.It Sy domain_blacklist
A list of domains to be removed from consideration.
To remove a domain, you can use foo.*
To remove a sub domain, you can use *.bar
.It Sy name_servers
Prepend name servers to the dynamically generated list.
You should set this to 127.0.0.1 if you use a local name server other than
libc.
.It Sy name_servers_append
Append name servers to the dynamically generated list.
.It Sy name_server_blacklist
A list of name servers to be removed from consideration.
The default is 0.0.0.0 as some faulty routers send it via DHCP.
To remove a block, you can use 192.168.*
.It Sy private_interfaces
These interfaces name servers will only be queried for the domains listed
in their resolv.conf.
@ -99,6 +107,12 @@ without any alteration.
.It Sy resolv_conf_sortlist
A libc resolver sortlist, as specified in
.Xr resolv.conf 5 .
.It Sy resolv_conf_local_only
If a local nameserver is configured then the default is just to specify that
and ignore all other entries as they will be configured for the local
nameserver.
Set this to YES to list them instead, if you need working DNS and the local
nameserver stops functioning at the expense of duplicated server queries.
.El
.Sh SUBSCRIBER OPTIONS
openresolv ships with subscribers for the name servers
@ -187,4 +201,5 @@ and
.Sh AUTHORS
.An Roy Marples Aq roy@marples.name
.Sh BUGS
Please report them to http://roy.marples.name/projects/openresolv
Please report them to
.Lk http://roy.marples.name/projects/openresolv

View File

@ -1,5 +1,5 @@
#!/bin/sh
# Copyright (c) 2007-2011 Roy Marples
# Copyright (c) 2007-2012 Roy Marples
# All rights reserved
# Redistribution and use in source and binary forms, with or without
@ -45,6 +45,7 @@ PRIVATEDIR="$VARDIR/private"
: ${dynamic_order:=tap[0-9]* tun[0-9]* vpn vpn[0-9]* ppp[0-9]* ippp[0-9]*}
: ${interface_order:=lo lo[0-9]*}
: ${name_server_blacklist:=0.0.0.0}
error_exit()
{
@ -289,18 +290,45 @@ list_resolv()
return $retval
}
list_remove() {
local list= e= l= result= found= retval=0
[ -z "$2" ] && return 0
eval list=\"\$$1\"
shift
set -f
for e; do
found=false
for l in $list; do
case "$e" in
$l) found=true;;
esac
$found && break
done
if $found; then
retval=$(($retval + 1))
else
result="$result $e"
fi
done
set +f
echo "${result# *}"
return $retval
}
make_vars()
{
local newdomains= d= dn= newns= ns=
eval "$(list_resolv -l "$@" | parse_resolv)"
# Ensure that we only list each domain once
newdomains=
for d in $DOMAINS; do
dn="${d%%:*}"
list_remove domain_blacklist "$dn" >/dev/null || continue
case " $newdomains" in
*" ${dn}:"*) continue;;
esac
newdomains="$newdomains${newdomains:+ }$dn:"
newns=
for nd in $DOMAINS; do
if [ "$dn" = "${nd%%:*}" ]; then
@ -308,19 +336,30 @@ make_vars()
while [ -n "$ns" ]; do
case ",$newns," in
*,${ns%%,*},*) ;;
*) newns="$newns${newns:+,}${ns%%,*}";;
*) list_remove name_server_blacklist \
"$ns" >/dev/null \
&& newns="$newns${newns:+,}${ns%%,*}";;
esac
[ "$ns" = "${ns#*,}" ] && break
ns="${ns#*,}"
done
fi
done
newdomains="$newdomains$newns"
if [ -n "$newns" ]; then
newdomains="$newdomains${newdomains:+ }$dn:$newns"
fi
done
DOMAIN="$(list_remove domain_blacklist $DOMAIN)"
SEARCH="$(uniqify $SEARCH)"
SEARCH="$(list_remove domain_blacklist $SEARCH)"
NAMESERVERS="$(uniqify $NAMESERVERS)"
NAMESERVERS="$(list_remove name_server_blacklist $NAMESERVERS)"
LOCALNAMESERVERS="$(uniqify $LOCALNAMESERVERS)"
LOCALNAMESERVERS="$(list_remove name_server_blacklist $LOCALNAMESERVERS)"
echo "DOMAIN='$DOMAIN'"
echo "SEARCH='$(uniqify $SEARCH)'"
echo "NAMESERVERS='$(uniqify $NAMESERVERS)'"
echo "LOCALNAMESERVERS='$(uniqify $LOCALNAMESERVERS)'"
echo "SEARCH='$SEARCH'"
echo "NAMESERVERS='$NAMESERVERS'"
echo "LOCALNAMESERVERS='$LOCALNAMESERVERS'"
echo "DOMAINS='$newdomains'"
}