Import openresolv-3.3.4

Changes from openresolv-3.3.3 include:
 * private_interfaces is now shell expandable (ie, fxp*)
 * dnsmasq resolver restarting with DBus is now fixed
 * unbound resolver is sent SIGHUP for reload instead of forced restart
 * subscribers with the execute bit are executed, otherwise sourced into
   a subshell for speed
This commit is contained in:
roy 2009-12-04 14:11:49 +00:00
parent 25d47bcec5
commit 5bcbb70c4f
6 changed files with 86 additions and 52 deletions

View File

@ -28,7 +28,7 @@
[ -f "@SYSCONFDIR@"/resolvconf.conf ] || exit 0
. "@SYSCONFDIR@/resolvconf.conf" || exit 1
[ -z "$dnsmasq_conf" -o -z "$dnsmasq_resolv" ] && exit 0
[ -z "$dnsmasq_conf" -a -z "$dnsmasq_resolv" ] && exit 0
[ -z "$RESOLVCONF" ] && eval "$(@PREFIX@/sbin/resolvconf -v)"
: ${dnsmasq_pid:=/var/run/dnsmasq.pid}
@ -90,27 +90,32 @@ for d in $DOMAINS; do
done
changed=false
if [ ! -f "$dnsmasq_conf" ] || \
[ "$(cat "$dnsmasq_conf")" != "$(printf "$newconf")" ]
then
changed=true
printf "$newconf" >"$dnsmasq_conf"
fi
if [ -f "$dnsmasq_resolv" ]; then
if [ "$(cat "$dnsmasq_resolv")" != "$(printf "$newresolv")" ]; then
if [ -n "$dnsmasq_conf" ]; then
if [ ! -f "$dnsmasq_conf" ] || \
[ "$(cat "$dnsmasq_conf")" != "$(printf "$newconf")" ]
then
changed=true
printf "$newconf" >"$dnsmasq_conf"
fi
fi
if [ -n "$dnsmasq_resolv" ]; then
if [ -f "$dnsmasq_resolv" ]; then
if [ "$(cat "$dnsmasq_resolv")" != "$(printf "$newresolv")" ]
then
changed=true
printf "$newresolv" >"$dnsmasq_resolv"
fi
else
# dnsmasq polls this file so no need to set changed=true
printf "$newresolv" >"$dnsmasq_resolv"
fi
else
# dnsmasq polls this file so no need to set changed=true
printf "$newresolv" >"$dnsmasq_resolv"
fi
if $changed; then
eval $dnsmasq_restart
fi
if $dbus; then
$restart || kill -HUP $(cat "$dnsmasq_pid")
$changed || kill -HUP $(cat "$dnsmasq_pid")
# Send even if empty so old servers are cleared
dbus-send --system --dest=uk.org.thekelleys.dnsmasq \
/uk/org/thekelleys/dnsmasq uk.org.thekelleys.SetServers \

View File

@ -154,8 +154,12 @@ eval $libc_restart
retval=0
# Notify users of the resolver
for script in "$LIBEXECDIR"/libc.d/*; do
if [ -f "$script" -a -x "$script" ]; then
"$script" "$@"
if [ -f "$script" ]; then
if [ -x "$script" ]; then
"$script" "$@"
else
(. "$script" "$@")
fi
retval=$(($retval + $?))
fi
done

View File

@ -28,7 +28,7 @@
[ -f "@SYSCONFDIR@"/resolvconf.conf ] || exit 0
. "@SYSCONFDIR@/resolvconf.conf" || exit 1
[ -z "$named_zones" -o -z "$named_options" ] && exit 0
[ -z "$named_zones" -a -z "$named_options" ] && exit 0
[ -z "$RESOLVCONF" ] && eval "$(@PREFIX@/sbin/resolvconf -v)"
: ${named_restart:=@RESTARTCMD named@}
@ -62,17 +62,21 @@ done
# No point in changing files or reloading bind if the end result has not
# changed
changed=false
if [ ! -f "$named_options" ] || \
[ "$(cat "$named_options")" != "$(printf "$newoptions")" ]
then
printf "$newoptions" >"$named_options"
changed=true
if [ -n "$named_options" ]; then
if [ ! -f "$named_options" ] || \
[ "$(cat "$named_options")" != "$(printf "$newoptions")" ]
then
printf "$newoptions" >"$named_options"
changed=true
fi
fi
if [ ! -f "$named_zones" ] || \
[ "$(cat "$named_zones")" != "$(printf "$newzones")" ]
then
printf "$newzones" >"$named_zones"
changed=true
if [ -n "$named_zones" ]; then
if [ ! -f "$named_zones" ] || \
[ "$(cat "$named_zones")" != "$(printf "$newzones")" ]
then
printf "$newzones" >"$named_zones"
changed=true
fi
fi
if $changed; then

View File

@ -22,7 +22,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.Dd November 22, 2009
.Dd December 3, 2009
.Dt RESOLVCONF 8 SMM
.Os
.Sh NAME
@ -170,6 +170,21 @@ the operating systems lexical order.
See
.Xr resolvconf.conf 5
for details on these lists.
.Sh IMPLEMENTATION NOTES
If a subscriber has the executable bit then it is executed otherwise it is
assumed to be a shell script and sourced into the current environment in a
subshell.
This is done so that subscribers can remain fast, but are also not limited
to the shell language.
.Pp
Portable subscribers should not use anything outside of
.Pa /bin
and
.Pa /sbin
because
.Pa /usr
and others may not be available when booting.
Also, it would be unwise to assume any shell specific features.
.Sh ENVIRONMENT
.Bl -ohang
.It Va IF_METRIC
@ -215,8 +230,6 @@ You should consult
.Xr resolvconf.conf 5
for instructions on how to configure your resolver.
.Sh SEE ALSO
.Xr dnsmasq 8 ,
.Xr named 8 ,
.Xr resolv.conf 5 ,
.Xr resolvconf.conf 5 ,
.Xr resolver 3 ,

View File

@ -101,7 +101,7 @@ echo_resolv()
parse_resolv()
{
local line= ns= ds= search= d= n= newns=
local new=true iface= private=false
local new=true iface= private=false p=
echo "DOMAINS="
echo "SEARCH="
@ -113,18 +113,19 @@ parse_resolv()
if ${new}; then
iface="${line#\# resolv.conf from *}"
new=false
case " $private_interfaces " in
*" $iface "*)
if [ -e "$PRIVATEDIR/$iface" ]; then
private=true
;;
*)
if [ -e "$PRIVATEDIR/$iface" ]; then
private=true
else
private=false
fi
;;
esac
else
# Allow expansion
cd "$IFACEDIR"
private=false
for p in $private_interfaces; do
if [ "$p" = "$iface" ]; then
private=true
break
fi
done
fi
fi
;;
"nameserver "*)
@ -391,11 +392,17 @@ if [ "$cmd" = a ]; then
fi
eval "$(make_vars)"
export RESOLVCONF DOMAINS SEARCH NAMESERVERS
: ${list_resolv:=list_resolv -l}
retval=0
for script in "$LIBEXECDIR"/*; do
[ -f "$script" ] || continue
( . "$script" "$cmd" "$iface" )
retval=$(($retval + $?))
if [ -f "$script" ]; then
if [ -x "$script" ]; then
"$script" "$cmd" "$iface"
else
(. "$script" "$cmd" "$fiace")
fi
retval=$(($retval + $?))
fi
done
exit $retval

View File

@ -38,7 +38,7 @@ newconf="# Generated by resolvconf\n"
for d in $DOMAINS; do
dn="${d%%:*}"
ns="${d#*:}"
newconf="\n${newconf}forward-zone:\n\tname: \"$dn\"\n"
newconf="${newconf}\nforward-zone:\n\tname: \"$dn\"\n"
while [ -n "$ns" ]; do
newconf="${newconf}\tforward-addr: ${ns%%,*}\n"
[ "$ns" = "${ns#*,}" ] && break
@ -47,7 +47,7 @@ for d in $DOMAINS; do
done
if [ -n "$NAMESERVERS" ]; then
newconf="\n${newconf}forward-zone:\n\tname: \".\"\n"
newconf="${newconf}\nforward-zone:\n\tname: \".\"\n"
for n in $NAMESERVERS; do
newconf="${newconf}\tforward-addr: $n\n"
done
@ -57,11 +57,12 @@ if [ ! -f "$unbound_conf" ] || \
[ "$(cat "$unbound_conf")" != "$(printf "$newconf")" ]
then
printf "$newconf" >"$unbound_conf"
#if [ -s "$unbound_pid" ] && \
# kill -0 $(cat "$unbound_pid") 2>/dev/null
#then
# unbound-control reload
#else
# If we can't sent a HUP then force a restart
if [ -s "$unbound_pid" ]; then
if ! kill -HUP $(cat "$unbound_pid") 2>/dev/null; then
eval $unbound_restart
fi
else
eval $unbound_restart
#fi
fi
fi