Module Name: src
Committed By: martin
Date: Wed Nov 12 13:36:41 UTC 2014
Modified Files:
src/external/bsd/openresolv/dist [netbsd-7]: dnsmasq.in libc.in
resolvconf.8.in resolvconf.conf.5.in resolvconf.in unbound.in
Log Message:
Pull up the import of version 3.6.1 of openresolv, via patch,
requested by roy in ticket #208.
To generate a diff of this commit:
cvs rdiff -u -r1.1.1.9 -r1.1.1.9.6.1 \
src/external/bsd/openresolv/dist/dnsmasq.in
cvs rdiff -u -r1.1.1.7 -r1.1.1.7.6.1 src/external/bsd/openresolv/dist/libc.in
cvs rdiff -u -r1.2 -r1.2.4.1 src/external/bsd/openresolv/dist/resolvconf.8.in
cvs rdiff -u -r1.9 -r1.9.4.1 \
src/external/bsd/openresolv/dist/resolvconf.conf.5.in
cvs rdiff -u -r1.1.1.8 -r1.1.1.8.6.1 \
src/external/bsd/openresolv/dist/resolvconf.in
cvs rdiff -u -r1.1.1.5 -r1.1.1.5.6.1 \
src/external/bsd/openresolv/dist/unbound.in
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/external/bsd/openresolv/dist/dnsmasq.in
diff -u src/external/bsd/openresolv/dist/dnsmasq.in:1.1.1.9 src/external/bsd/openresolv/dist/dnsmasq.in:1.1.1.9.6.1
--- src/external/bsd/openresolv/dist/dnsmasq.in:1.1.1.9 Fri Jul 12 16:50:27 2013
+++ src/external/bsd/openresolv/dist/dnsmasq.in Wed Nov 12 13:36:40 2014
@@ -35,6 +35,7 @@ NL="
: ${dnsmasq_pid:=/var/run/dnsmasq.pid}
[ -s "$dnsmasq_pid" ] || dnsmasq_pid=/var/run/dnsmasq/dnsmasq.pid
+[ -s "$dnsmasq_pid" ] || unset dnsmasq_pid
: ${dnsmasq_service:=dnsmasq}
: ${dnsmasq_restart:=@RESTARTCMD ${dnsmasq_service}@}
newconf="# Generated by resolvconf$NL"
@@ -182,7 +183,9 @@ if $changed; then
eval $dnsmasq_restart
fi
if $dbus; then
- $changed || kill -HUP $(cat "$dnsmasq_pid")
+ if [ -s "$dnsmasq_pid" ]; then
+ $changed || kill -HUP $(cat "$dnsmasq_pid")
+ fi
# Send even if empty so old servers are cleared
if $dbus_ex; then
method=SetDomainServers
Index: src/external/bsd/openresolv/dist/libc.in
diff -u src/external/bsd/openresolv/dist/libc.in:1.1.1.7 src/external/bsd/openresolv/dist/libc.in:1.1.1.7.6.1
--- src/external/bsd/openresolv/dist/libc.in:1.1.1.7 Fri Jul 12 16:50:27 2013
+++ src/external/bsd/openresolv/dist/libc.in Wed Nov 12 13:36:40 2014
@@ -1,5 +1,5 @@
#!/bin/sh
-# Copyright (c) 2007-2012 Roy Marples
+# Copyright (c) 2007-2014 Roy Marples
# All rights reserved
# libc subscriber for resolvconf
@@ -72,6 +72,8 @@ keys_remove()
done
}
+local_nameservers="127.* 0.0.0.0 255.255.255.255 ::1"
+
# Support original resolvconf configuration layout
# as well as the openresolv config file
if [ -f "$SYSCONFDIR"/resolvconf.conf ]; then
@@ -93,7 +95,6 @@ elif [ -d "$SYSCONFDIR"/resolvconf ]; th
resolv_conf_tail="$(cat "$SYSCONFDIR"/resolv.conf.d/tail)"
fi
fi
-: ${domain:=$DOMAIN}
: ${resolv_conf:=/etc/resolv.conf}
: ${libc_service:=nscd}
: ${libc_restart:=@RESTARTCMD ${libc_service}@}
@@ -105,6 +106,9 @@ if [ "${resolv_conf_tail-x}" = x -a -f "
resolv_conf_tail="$(cat "$SYSCONFDIR"/resolv.conf.tail)"
fi
+backup=true
+signature="# Generated by resolvconf"
+
uniqify()
{
local result=
@@ -120,6 +124,7 @@ uniqify()
case "${resolv_conf_passthrough:-NO}" in
[Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|[Oo][Nn]|1)
+ backup=false
newest=
for conf in "$IFACEDIR"/*; do
if [ -z "$newest" -o "$conf" -nt "$newest" ]; then
@@ -129,27 +134,46 @@ case "${resolv_conf_passthrough:-NO}" in
[ -z "$newest" ] && exit 0
newconf="$(cat "$newest")$NL"
;;
+/dev/null|[Nn][Uu][Ll][Ll])
+ : ${resolv_conf_local_only:=NO}
+ if [ "$local_nameservers" = "127.* 0.0.0.0 255.255.255.255 ::1" ]; then
+ local_nameservers=
+ fi
+ # Need to overwrite our variables.
+ eval "$(@SBINDIR@/resolvconf -V)"
+ ;;
+
*)
[ -z "$RESOLVCONF" ] && eval "$(@SBINDIR@/resolvconf -v)"
- newsearch="$(uniqify $prepend_search $SEARCH)"
+ ;;
+esac
+case "${resolv_conf_passthrough:-NO}" in
+[Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|[Oo][Nn]|1) ;;
+*)
+ : ${domain:=$DOMAIN}
+ newsearch="$(uniqify $prepend_search $SEARCH $append_search)"
NS="$LOCALNAMESERVERS $NAMESERVERS"
newns=
gotlocal=false
- for n in $(uniqify $prepend_nameservers $NS); do
+ for n in $(uniqify $prepend_nameservers $NS $append_nameservers); do
add=true
- case "$n" in
- 127.*|0.0.0.0|255.255.255.255|::1) gotlocal=true;;
- *)
+ islocal=false
+ for l in $local_nameservers; do
+ case "$n" in
+ $l) islocal=true; gotlocal=true; break;;
+ esac
+ done
+ if ! $islocal; then
case "${resolv_conf_local_only:-YES}" in
[Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|[Oo][Nn]|1)
$gotlocal && add=false;;
esac
- esac
+ fi
$add && newns="$newns $n"
done
# Hold our new resolv.conf in a variable to save on temporary files
- newconf="# Generated by resolvconf$NL"
+ newconf="$signature$NL"
if [ -n "$resolv_conf_head" ]; then
newconf="$newconf$resolv_conf_head$NL"
fi
@@ -187,6 +211,22 @@ if [ -e "$resolv_conf" ]; then
[ "$(cat "$resolv_conf")" = "$(printf %s "$newconf")" ] && exit 0
fi
+# Change is good.
+# If the old file does not have our signature, back it up.
+# If the new file just has our signature, restore the backup.
+if $backup; then
+ if [ "$newconf" = "$signature$NL" ]; then
+ if [ -e "$resolv_conf.bak" ]; then
+ newconf="$(cat "$resolv_conf.bak")"
+ fi
+ elif [ -e "$resolv_conf" ]; then
+ read line <"$resolv_conf"
+ if [ "$line" != "$signature" ]; then
+ cp "$resolv_conf" "$resolv_conf.bak"
+ fi
+ fi
+fi
+
# Create our resolv.conf now
(umask 022; printf %s "$newconf" >"$resolv_conf")
eval $libc_restart
Index: src/external/bsd/openresolv/dist/resolvconf.8.in
diff -u src/external/bsd/openresolv/dist/resolvconf.8.in:1.2 src/external/bsd/openresolv/dist/resolvconf.8.in:1.2.4.1
--- src/external/bsd/openresolv/dist/resolvconf.8.in:1.2 Sat Jul 20 21:40:04 2013
+++ src/external/bsd/openresolv/dist/resolvconf.8.in Wed Nov 12 13:36:40 2014
@@ -1,4 +1,4 @@
-.\" Copyright (c) 2007-2012 Roy Marples
+.\" Copyright (c) 2007-2014 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 March 19, 2012
+.Dd October 26, 2014
.Dt RESOLVCONF 8 SMM
.Os
.Sh NAME
@@ -78,6 +78,20 @@ then
will supply files that the resolver should be configured to include.
.Pp
.Nm
+assumes it has a job to do.
+In some situations
+.Nm
+needs to act as a deterrent to writing to
+.Pa /etc/resolv.conf .
+Where this file cannot be made immutable or you just need to toggle this
+behaviour,
+.Nm
+can be disabled by adding
+.Sy resolvconf Ns = Ns NO
+to
+.Xr resolvconf.conf 5 .
+.Pp
+.Nm
can mark an interfaces
.Pa resolv.conf
as private.
@@ -142,18 +156,24 @@ as private.
.It Fl u
Force
.Nm
-to update all it's subscribers.
+to update all its subscribers.
.Nm
does not update the subscribers when adding a resolv.conf that matches
what it already has for that interface.
.El
.Pp
.Nm
-also has some options designed to be used by it's subscribers:-
+also has some options designed to be used by its subscribers:-
.Bl -tag -width indent
.It Fl v
Echo variables DOMAINS, SEARCH and NAMESERVERS so that the subscriber can
configure the resolver easily.
+.It Fl V
+Same as
+.Fl v
+except that only the information configured in
+.Xr resolvconf.conf 5
+is set.
.El
.Sh INTERFACE ORDERING
For
@@ -200,6 +220,8 @@ as private.
.El
.Sh FILES
.Bl -ohang
+.It Pa /etc/resolv.conf.bak
+Backup file of the original resolv.conf.
.It Pa @SYSCONFDIR@/resolvconf.conf
Configuration file for
.Nm .
Index: src/external/bsd/openresolv/dist/resolvconf.conf.5.in
diff -u src/external/bsd/openresolv/dist/resolvconf.conf.5.in:1.9 src/external/bsd/openresolv/dist/resolvconf.conf.5.in:1.9.4.1
--- src/external/bsd/openresolv/dist/resolvconf.conf.5.in:1.9 Sat Jul 20 21:40:04 2013
+++ src/external/bsd/openresolv/dist/resolvconf.conf.5.in Wed Nov 12 13:36:40 2014
@@ -1,4 +1,4 @@
-.\" Copyright (c) 2009-2013 Roy Marples
+.\" Copyright (c) 2009-2014 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 April 27, 2013
+.Dd October 28, 2014
.Dt RESOLVCONF.CONF 5 SMM
.Os
.Sh NAME
@@ -42,12 +42,22 @@ must contain valid shell commands.
Listed below are the standard
.Nm
variables that may be set.
+If the values contain white space for special shell characters,
+ensure they are quoted and escaped correctly.
.Pp
After updating this file, you may wish to run
.Nm resolvconf -u
to apply the new configuration.
+.Pp
+When a dynmically generated list is appended or prepended to, the whole
+is made unique where left-most wins.
.Sh RESOLVCONF OPTIONS
.Bl -tag -width indent
+.It Sy resolvconf
+Set to NO to disable
+.Nm resolvconf
+from running any subscribers.
+Defaults to YES.
.It Sy interface_order
These interfaces will always be processed first.
If unset, defaults to the following:-
@@ -56,6 +66,9 @@ 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 local_nameservers
+If unset, defaults to the following:-
+.D1 127.* 0.0.0.0 255.255.255.255 ::1
.It Sy search_domains
Prepend search domains to the dynamically generated list.
.It Sy search_domains_append
@@ -81,6 +94,34 @@ Useful for VPN domains.
This is equivalent to the
.Nm resolvconf -p
option.
+.It Sy replace
+Is a space separated list of replacement keywords. The syntax is this:
+.Va $keyword Ns / Ns Va $match Ns / Ns Va $replacement
+.Pp
+Example, given this resolv.conf:
+.D1 domain foo.org
+.D1 search foo.org dead.beef
+.D1 nameserver 1.2.3.4
+.D1 nameserver 2.3.4.5
+and this configuaration:
+.D1 replace="search/foo*/bar.com nameserver/1.2.3.4/5.6.7.8 nameserver/2.3.4.5/"
+you would get this resolv.conf instead:
+.D1 domain foo.org
+.D1 search bar.com
+.D1 nameserver 5.6.7.8
+.It Sy replace_sub
+Works the same way as
+.Sy replace
+except it works on each space separated value rather than the whole line,
+so it's useful for the replacing a single domain within the search directive.
+Using the same example resolv.conf and changing
+.Sy replace
+to
+.Sy replace_sub ,
+you would get this resolv.conf instead:
+.D1 domain foo.org
+.D1 search bar.com dead.beef
+.D1 nameserver 5.6.7.8
.It Sy state_dir
Override the default state directory of
.Pa @VARDIR@ .
@@ -104,6 +145,14 @@ A list of libc resolver options, as spec
When set to YES the latest resolv.conf is written to
.Sy resolv_conf
without any alteration.
+When set to /dev/null or NULL,
+.Sy resolv_conf_local_only
+is defaulted to NO,
+.Sy local_nameservers
+is unset unless overriden and only the information set in
+.Nm
+is written to
+.Sy resolv_conf .
.It Sy resolv_conf_sortlist
A libc resolver sortlist, as specified in
.Xr resolv.conf 5 .
@@ -114,6 +163,14 @@ name server.
Set this to NO to also list non-local nameservers.
This will give you working DNS even if the local nameserver stops functioning
at the expense of duplicated server queries.
+.It Sy append_nameservers
+Append name servers to the dynamically generated list.
+.It Sy prepend_nameservers
+Prepend name servers to the dynamically generated list.
+.It Sy append_search
+Append search domains to the dynamically generated list.
+.It Sy prepend_search
+Prepend search domains to the dynamically generated list.
.El
.Sh SUBSCRIBER OPTIONS
openresolv ships with subscribers for the name servers
@@ -124,6 +181,10 @@ and
.Xr unbound 8 .
Each subscriber can create configuration files which should be included in
in the subscribers main configuration file.
+.Pp
+To disable a subscriber, simply set it's name to NO.
+For example, to disable the libc subscriber you would set:
+.D1 libc=NO
.Bl -tag -width indent
.It Sy dnsmasq_conf
This file tells dnsmasq which name servers to use for specific domains.
@@ -190,6 +251,8 @@ Example pdnsd.conf:
.D1 }
.It Sy unbound_conf
This file tells unbound about specific and global name servers.
+.It Sy unbound_insecure
+When set to YES, unbound marks the domains as insecure, thus ignoring DNSSEC.
.Pp
Example resolvconf.conf for unbound:
.D1 name_servers=127.0.0.1
@@ -236,9 +299,10 @@ Command to restart the unbound service.
Location of the unbound pidfile.
.El
.Sh SEE ALSO
-.Xr resolv.conf 5
+.Xr resolv.conf 5 ,
+.Xr resolvconf 8
and
-.Xr resolvconf 8 .
+.Xr sh 1 .
.Sh AUTHORS
.An Roy Marples Aq Mt [email protected]
.Sh BUGS
Index: src/external/bsd/openresolv/dist/resolvconf.in
diff -u src/external/bsd/openresolv/dist/resolvconf.in:1.1.1.8 src/external/bsd/openresolv/dist/resolvconf.in:1.1.1.8.6.1
--- src/external/bsd/openresolv/dist/resolvconf.in:1.1.1.8 Fri Jul 12 16:50:27 2013
+++ src/external/bsd/openresolv/dist/resolvconf.in Wed Nov 12 13:36:40 2014
@@ -1,5 +1,5 @@
#!/bin/sh
-# Copyright (c) 2007-2012 Roy Marples
+# Copyright (c) 2007-2014 Roy Marples
# All rights reserved
# Redistribution and use in source and binary forms, with or without
@@ -32,6 +32,13 @@ VARDIR=@VARDIR@
# Disregard dhcpcd setting
unset interface_order state_dir
+# If you change this, change the test in VFLAG and libc.in as well
+local_nameservers="127.* 0.0.0.0 255.255.255.255 ::1"
+
+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"
+
# Support original resolvconf configuration layout
# as well as the openresolv config file
if [ -f "$SYSCONFDIR"/resolvconf.conf ]; then
@@ -43,13 +50,16 @@ elif [ -d "$SYSCONFDIR/resolvconf" ]; th
interface_order="$(cat "$SYSCONFDIR"/interface-order)"
fi
fi
+TMPDIR="$VARDIR/tmp"
IFACEDIR="$VARDIR/interfaces"
METRICDIR="$VARDIR/metrics"
PRIVATEDIR="$VARDIR/private"
+LOCKDIR="$VARDIR/lock"
-: ${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}
+warn()
+{
+ echo "$*" >&2
+}
error_exit()
{
@@ -113,7 +123,7 @@ echo_resolv()
parse_resolv()
{
local line= ns= ds= search= d= n= newns=
- local new=true iface= private=false p= domain=
+ local new=true iface= private=false p= domain= l= islocal=
newns=
@@ -138,13 +148,17 @@ parse_resolv()
fi
;;
"nameserver "*)
- case "${line#* }" in
- 127.*|0.0.0.0|255.255.255.255|::1)
- echo "LOCALNAMESERVERS=\"\$LOCALNAMESERVERS ${line#* }\""
- continue
- ;;
- esac
- ns="$ns${line#* } "
+ islocal=false
+ for l in $local_nameservers; do
+ case "${line#* }" in
+ $l)
+ islocal=true
+ echo "LOCALNAMESERVERS=\"\$LOCALNAMESERVERS ${line#* }\""
+ break
+ ;;
+ esac
+ done
+ $islocal || ns="$ns${line#* } "
;;
"domain "*)
if [ -z "$domain" ]; then
@@ -340,6 +354,47 @@ echo_append()
echo
}
+replace()
+{
+ local r= k= f= v= val= sub=
+
+ while read -r keyword value; do
+ for r in $replace; do
+ k="${r%%/*}"
+ r="${r#*/}"
+ f="${r%%/*}"
+ r="${r#*/}"
+ v="${r%%/*}"
+ case "$keyword" in
+ $k)
+ case "$value" in
+ $f) value="$v";;
+ esac
+ ;;
+ esac
+ done
+ val=
+ for sub in $value; do
+ for r in $replace_sub; do
+ k="${r%%/*}"
+ r="${r#*/}"
+ f="${r%%/*}"
+ r="${r#*/}"
+ v="${r%%/*}"
+ case "$keyword" in
+ $k)
+ case "$sub" in
+ $f) sub="$v";;
+ esac
+ ;;
+ esac
+ done
+ val="$val${val:+ }$sub"
+ done
+ printf "%s %s\n" "$keyword" "$val"
+ done
+}
+
make_vars()
{
local newdomains= d= dn= newns= ns=
@@ -354,7 +409,9 @@ make_vars()
if [ -n "$name_servers" -o -n "$search_domains" ]; then
eval "$(echo_prepend | parse_resolv)"
fi
- eval "$(list_resolv -l "$@" | parse_resolv)"
+ if [ -z "$VFLAG" ]; then
+ eval "$(list_resolv -l "$@" | replace | parse_resolv)"
+ fi
if [ -n "$name_servers_append" -o -n "$search_domains_append" ]; then
eval "$(echo_append | parse_resolv)"
fi
@@ -374,7 +431,7 @@ make_vars()
case ",$newns," in
*,${ns%%,*},*) ;;
*) list_remove name_server_blacklist \
- "$ns" >/dev/null \
+ "${ns%%,*}" >/dev/null \
&& newns="$newns${newns:+,}${ns%%,*}";;
esac
[ "$ns" = "${ns#*,}" ] && break
@@ -401,12 +458,21 @@ make_vars()
}
force=false
-while getopts a:Dd:fhIilm:puv OPT; do
+VFLAG=
+while getopts a:Dd:fhIilm:puvV OPT; do
case "$OPT" in
f) force=true;;
h) usage;;
m) IF_METRIC="$OPTARG";;
p) IF_PRIVATE=1;;
+ V)
+ VFLAG=1
+ if [ "$local_nameservers" = \
+ "127.* 0.0.0.0 255.255.255.255 ::1" ]
+ then
+ local_nameservers=
+ fi
+ ;;
'?') ;;
*) cmd="$OPT"; iface="$OPTARG";;
esac
@@ -435,7 +501,7 @@ if [ "$cmd" = l -o "$cmd" = i ]; then
fi
# Not normally needed, but subscribers should be able to run independently
-if [ "$cmd" = v ]; then
+if [ "$cmd" = v -o -n "$VFLAG" ]; then
make_vars "$iface"
exit $?
fi
@@ -449,6 +515,7 @@ elif [ "$cmd" != u ]; then
[ -n "$cmd" -a "$cmd" != h ] && usage "Unknown option $cmd"
usage
fi
+
if [ "$cmd" = a ]; then
for x in '/' \\ ' ' '*'; do
case "$iface" in
@@ -464,38 +531,56 @@ if [ "$cmd" = a ]; then
[ "$cmd" = a -a -t 0 ] && error_exit "No file given via stdin"
fi
-if [ ! -d "$IFACEDIR" ]; then
- if [ ! -d "$VARDIR" ]; then
- if [ -L "$VARDIR" ]; then
- dir="$(readlink "$VARDIR")"
- # link maybe relative
- cd "${VARDIR%/*}"
- if ! mkdir -m 0755 -p "$dir"; then
- error_exit "Failed to create needed" \
- "directory $dir"
- fi
- else
- if ! mkdir -m 0755 -p "$VARDIR"; then
- error_exit "Failed to create needed" \
- "directory $VARDIR"
- fi
+if [ ! -d "$VARDIR" ]; then
+ if [ -L "$VARDIR" ]; then
+ dir="$(readlink "$VARDIR")"
+ # link maybe relative
+ cd "${VARDIR%/*}"
+ if ! mkdir -m 0755 -p "$dir"; then
+ error_exit "Failed to create needed" \
+ "directory $dir"
+ fi
+ else
+ if ! mkdir -m 0755 -p "$VARDIR"; then
+ error_exit "Failed to create needed" \
+ "directory $VARDIR"
fi
fi
+fi
+
+if [ ! -d "$IFACEDIR" ]; then
mkdir -m 0755 -p "$IFACEDIR" || \
error_exit "Failed to create needed directory $IFACEDIR"
+ if [ "$cmd" = d ]; then
+ # Provide the same error messages as below
+ if ! ${force}; then
+ cd "$IFACEDIR"
+ for i in $args; do
+ warn "No resolv.conf for interface $i"
+ done
+ fi
+ ${force}
+ exit $?
+ fi
else
# Delete any existing information about the interface
if [ "$cmd" = d ]; then
cd "$IFACEDIR"
+ changed=false
for i in $args; do
- if [ "$cmd" = d -a ! -e "$i" ]; then
- $force && continue
- error_exit "No resolv.conf for" \
- "interface $i"
+ if [ -e "$i" ]; then
+ changed=true
+ elif ! ${force}; then
+ warn "No resolv.conf for interface $i"
fi
rm -f "$i" "$METRICDIR/"*" $i" \
"$PRIVATEDIR/$i" || exit $?
done
+ if ! ${changed}; then
+ # Set the return code based on the forced flag
+ ${force}
+ exit $?
+ fi
fi
fi
@@ -503,20 +588,21 @@ if [ "$cmd" = a ]; then
# Read resolv.conf from stdin
resolv="$(cat)"
changed=false
+ changedfile=false
# If what we are given matches what we have, then do nothing
if [ -e "$IFACEDIR/$iface" ]; then
if [ "$(echo "$resolv")" != \
"$(cat "$IFACEDIR/$iface")" ]
then
- rm "$IFACEDIR/$iface"
changed=true
+ changedfile=true
fi
else
changed=true
+ changedfile=true
fi
- if $changed; then
- echo "$resolv" >"$IFACEDIR/$iface" || exit $?
- fi
+ # Set metric and private before creating the interface resolv.conf file
+ # to ensure that it will have the correct flags
[ ! -d "$METRICDIR" ] && mkdir "$METRICDIR"
oldmetric="$METRICDIR/"*" $iface"
newmetric=
@@ -548,16 +634,64 @@ if [ "$cmd" = a ]; then
fi
;;
esac
+ if $changedfile; then
+ # Ensure that creating the file is an atomic operation
+ if [ ! -d "$TMPDIR" ]; then
+ mkdir -m 0755 -p "$TMPDIR" || \
+ error_exit \
+ "Failed to create needed directory $TMPDIR"
+ fi
+ TMPFILE="$TMPDIR/$iface.$$"
+ cleanup() { [ -n "$TMPFILE" ] && rm -f "$TMPFILE"; }
+ trap cleanup EXIT
+ echo "$resolv" >"$TMPFILE" || exit $?
+ mv -f "$TMPFILE" "$IFACEDIR/$iface" || exit $?
+ TMPFILE=
+ fi
$changed || exit 0
unset changed oldmetric newmetric
fi
+case "${resolvconf:-YES}" in
+[Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|[Oo][Nn]|1) ;;
+*) exit 0;;
+esac
+
+# An interface was added, deleted or changed.
+# These above actions are atomic, however calling our subcribers is not.
+# Even if we do our very best, the action of restarting the subscriber daemon
+# is not guaranteed to be serialised due to our many flavours of OS we support.
+# As such we spinlock at this point as best we can.
+# We don't use flock(1) because it's not widely available and normally resides
+# in /usr which we do our very best to operate without.
+[ -w "$VARDIR" ] || error_exit "Cannot write to $LOCKDIR"
+: ${lock_timeout:=10}
+while true; do
+ if mkdir "$LOCKDIR" 2>/dev/null; then
+ trap 'rm -rf "$LOCKDIR";' EXIT
+ trap 'rm -rf "$LOCKDIR"; exit 1' INT QUIT ABRT SEGV ALRM TERM
+ echo $$ >"$LOCKDIR/pid"
+ break
+ fi
+ lock_timeout=$(($lock_timeout - 1))
+ if [ "$lock_timeout" -le 0 ]; then
+ pid=$(cat "$LOCKDIR/pid")
+ error_exit "timed out waiting for lock from pid $pid"
+ fi
+ sleep 1
+done
+
eval "$(make_vars)"
export RESOLVCONF DOMAINS SEARCH NAMESERVERS LOCALNAMESERVERS
: ${list_resolv:=list_resolv -l}
retval=0
for script in "$LIBEXECDIR"/*; do
if [ -f "$script" ]; then
+ eval script_enabled="\$${script##*/}"
+ case "${script_enabled:-YES}" in
+ [Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|[Oo][Nn]|1) ;;
+ *) continue;;
+ esac
if [ -x "$script" ]; then
"$script" "$cmd" "$iface"
else
Index: src/external/bsd/openresolv/dist/unbound.in
diff -u src/external/bsd/openresolv/dist/unbound.in:1.1.1.5 src/external/bsd/openresolv/dist/unbound.in:1.1.1.5.6.1
--- src/external/bsd/openresolv/dist/unbound.in:1.1.1.5 Fri Jul 12 16:50:27 2013
+++ src/external/bsd/openresolv/dist/unbound.in Wed Nov 12 13:36:40 2014
@@ -1,5 +1,5 @@
#!/bin/sh
-# Copyright (c) 2009-2011 Roy Marples
+# Copyright (c) 2009-2014 Roy Marples
# All rights reserved
# unbound subscriber for resolvconf
@@ -26,6 +26,8 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+unbound_insecure=
+
[ -f "@SYSCONFDIR@"/resolvconf.conf ] || exit 0
. "@SYSCONFDIR@/resolvconf.conf" || exit 1
[ -z "$unbound_conf" ] && exit 0
@@ -41,6 +43,11 @@ newconf="# Generated by resolvconf$NL"
for d in $DOMAINS; do
dn="${d%%:*}"
ns="${d#*:}"
+ case "$unbound_insecure" in
+ [Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|[Oo][Nn]|1)
+ newconf="$newconf${NL}domain-insecure: \"$dn\""
+ ;;
+ esac
newconf="$newconf${NL}forward-zone:$NL name: \"$dn\"$NL"
while [ -n "$ns" ]; do
newconf="$newconf forward-addr: ${ns%%,*}$NL"