Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/ROY]: src/external/bsd/openresolv/dist Import openresolv-3.3.4



details:   https://anonhg.NetBSD.org/src/rev/70798dea792b
branches:  ROY
changeset: 454304:70798dea792b
user:      roy <roy%NetBSD.org@localhost>
date:      Fri Dec 04 14:11:49 2009 +0000

description:
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

diffstat:

 external/bsd/openresolv/dist/dnsmasq.in      |  31 +++++++++++++---------
 external/bsd/openresolv/dist/libc.in         |   8 ++++-
 external/bsd/openresolv/dist/named.in        |  26 +++++++++++--------
 external/bsd/openresolv/dist/resolvconf.8.in |  19 ++++++++++++--
 external/bsd/openresolv/dist/resolvconf.in   |  37 ++++++++++++++++-----------
 external/bsd/openresolv/dist/unbound.in      |  17 ++++++------
 6 files changed, 86 insertions(+), 52 deletions(-)

diffs (266 lines):

diff -r 8e6ce5834e49 -r 70798dea792b external/bsd/openresolv/dist/dnsmasq.in
--- a/external/bsd/openresolv/dist/dnsmasq.in   Sat Nov 21 02:40:55 2009 +0000
+++ b/external/bsd/openresolv/dist/dnsmasq.in   Fri Dec 04 14:11:49 2009 +0000
@@ -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 @@
 done
 
 changed=false
-if [ ! -f "$dnsmasq_conf" ] || \
-       [ "$(cat "$dnsmasq_conf")" != "$(printf "$newconf")" ]
-then
-       changed=true
-       printf "$newconf" >"$dnsmasq_conf"
+if [ -n "$dnsmasq_conf" ]; then
+       if [ ! -f "$dnsmasq_conf" ] || \
+               [ "$(cat "$dnsmasq_conf")" != "$(printf "$newconf")" ]
+       then
+               changed=true
+               printf "$newconf" >"$dnsmasq_conf"
+       fi
 fi
-if [ -f "$dnsmasq_resolv" ]; then
-       if [ "$(cat "$dnsmasq_resolv")" != "$(printf "$newresolv")" ]; then
-               changed=true
+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 \
diff -r 8e6ce5834e49 -r 70798dea792b external/bsd/openresolv/dist/libc.in
--- a/external/bsd/openresolv/dist/libc.in      Sat Nov 21 02:40:55 2009 +0000
+++ b/external/bsd/openresolv/dist/libc.in      Fri Dec 04 14:11:49 2009 +0000
@@ -154,8 +154,12 @@
 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
diff -r 8e6ce5834e49 -r 70798dea792b external/bsd/openresolv/dist/named.in
--- a/external/bsd/openresolv/dist/named.in     Sat Nov 21 02:40:55 2009 +0000
+++ b/external/bsd/openresolv/dist/named.in     Fri Dec 04 14:11:49 2009 +0000
@@ -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 @@
 # 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
diff -r 8e6ce5834e49 -r 70798dea792b external/bsd/openresolv/dist/resolvconf.8.in
--- a/external/bsd/openresolv/dist/resolvconf.8.in      Sat Nov 21 02:40:55 2009 +0000
+++ b/external/bsd/openresolv/dist/resolvconf.8.in      Fri Dec 04 14:11:49 2009 +0000
@@ -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 @@
 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 @@
 .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 ,
diff -r 8e6ce5834e49 -r 70798dea792b external/bsd/openresolv/dist/resolvconf.in
--- a/external/bsd/openresolv/dist/resolvconf.in        Sat Nov 21 02:40:55 2009 +0000
+++ b/external/bsd/openresolv/dist/resolvconf.in        Fri Dec 04 14:11:49 2009 +0000
@@ -101,7 +101,7 @@
 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 @@
                        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 @@
 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
diff -r 8e6ce5834e49 -r 70798dea792b external/bsd/openresolv/dist/unbound.in
--- a/external/bsd/openresolv/dist/unbound.in   Sat Nov 21 02:40:55 2009 +0000
+++ b/external/bsd/openresolv/dist/unbound.in   Fri Dec 04 14:11:49 2009 +0000
@@ -38,7 +38,7 @@
 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 @@
 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 @@
        [ "$(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



Home | Main Index | Thread Index | Old Index