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.9.1 with the ...



details:   https://anonhg.NetBSD.org/src/rev/6bef39fb830b
branches:  ROY
changeset: 455222:6bef39fb830b
user:      roy <roy%NetBSD.org@localhost>
date:      Wed Jul 17 18:24:23 2019 +0000

description:
Import openresolv-3.9.1 with the following changes:

  *  More strict POSIX shell support
  *  Interfaces have an implicit metric of 0 unless specified
  *  Inline comments are stripped from nameserver and domain entries

diffstat:

 external/bsd/openresolv/dist/LICENSE              |   23 ++
 external/bsd/openresolv/dist/README.md            |   64 ++++++
 external/bsd/openresolv/dist/dnsmasq.in           |    6 +-
 external/bsd/openresolv/dist/libc.in              |   24 +-
 external/bsd/openresolv/dist/named.in             |    8 +-
 external/bsd/openresolv/dist/pdns_recursor.in     |   78 +++++++
 external/bsd/openresolv/dist/pdnsd.in             |   12 +-
 external/bsd/openresolv/dist/resolvconf.conf      |    7 +
 external/bsd/openresolv/dist/resolvconf.conf.5.in |    2 +-
 external/bsd/openresolv/dist/resolvconf.in        |  223 ++++++++++++---------
 external/bsd/openresolv/dist/unbound.in           |    2 +-
 11 files changed, 328 insertions(+), 121 deletions(-)

diffs (truncated from 885 to 300 lines):

diff -r 096aaaf90fac -r 6bef39fb830b external/bsd/openresolv/dist/LICENSE
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/external/bsd/openresolv/dist/LICENSE      Wed Jul 17 18:24:23 2019 +0000
@@ -0,0 +1,23 @@
+Copyright (c) 2007-2017 Roy Marples <roy%marples.name@localhost>
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+1. Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGE.
diff -r 096aaaf90fac -r 6bef39fb830b external/bsd/openresolv/dist/README.md
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/external/bsd/openresolv/dist/README.md    Wed Jul 17 18:24:23 2019 +0000
@@ -0,0 +1,64 @@
+# openresolv
+
+openresolv is a [resolvconf](https://en.wikipedia.org/wiki/Resolvconf)
+implementation which manages `/etc/resolv.conf`.
+
+`/etc/resolv.conf` is a file that holds the configuration for the local
+resolution of domain names.
+Normally this file is either static or maintained by a local daemon,
+normally a DHCP daemon. But what happens if more than one thing wants to
+control the file?
+Say you have wired and wireless interfaces to different subnets and run a VPN
+or two on top of that, how do you say which one controls the file?
+It's also not as easy as just adding and removing the nameservers each client
+knows about as different clients could add the same nameservers.
+
+Enter resolvconf, the middleman between the network configuration services and
+`/etc/resolv.conf`.
+resolvconf itself is just a script that stores, removes and lists a full
+`resolv.conf` generated for the interface. It then calls all the helper scripts
+it knows about so it can configure the real `/etc/resolv.conf` and optionally
+any local nameservers other than libc.
+
+## Reasons for using openresolv
+
+Why openresolv over the
+[Debian implementation](http://qref.sourceforge.net/Debian/reference/ch-gateway.en.html#s-dns-resolvconf)?
+Here's some reasons:
+  *  Works with
+  [POSIX shell and userland](http://www.opengroup.org/onlinepubs/009695399)
+  *  Does not need awk, grep or sed which means we can work without `/usr`
+  mounted
+  *  Works with other init systems than Debians' out of the box
+  *  Available as a 2 clause
+  [BSD license](http://www.freebsd.org/copyright/freebsd-license.html)
+  *  Prefer configs via IF_METRIC for dynamic ordering
+  *  Configures zones for local resolvers other than libc
+
+The last point is quite important, especially when running VPN systems.
+Take the following resolv.conf files which have been generated by a
+[DHCP client](../dhcpcd) and sent to resolvconf:
+
+```
+# resolv.conf from bge0
+search foo.com
+nameserver 1.2.3.4
+
+# resolv.conf from tap0
+domain bar.org
+nameserver 5.6.7.8
+```
+
+In this instance, queries for foo.com will go to 1.2.3.4 and queries for
+bar.org will go to 5.6.7.8.
+This does require the resolvers to be configured to pickup the resolvconf
+generated configuration for them though.
+openresolv ships with helpers for:
+  *  [unbound](http://www.unbound.net/)
+  *  [dnsmasq](http://www.thekelleys.org.uk/dnsmasq/doc.html)
+  *  [ISC BIND](http://www.isc.org/software/bind)
+  *  [PowerDNS Recursor](http://wiki.powerdns.com/trac)
+
+See the
+[configuration section](https://roy.marples.name/projects/openresolv/config)
+for more details.
diff -r 096aaaf90fac -r 6bef39fb830b external/bsd/openresolv/dist/dnsmasq.in
--- a/external/bsd/openresolv/dist/dnsmasq.in   Wed Jun 26 17:46:09 2019 +0000
+++ b/external/bsd/openresolv/dist/dnsmasq.in   Wed Jul 17 18:24:23 2019 +0000
@@ -28,7 +28,7 @@
 
 [ -f "@SYSCONFDIR@"/resolvconf.conf ] || exit 0
 . "@SYSCONFDIR@/resolvconf.conf" || exit 1
-[ -z "$dnsmasq_conf" -a -z "$dnsmasq_resolv" ] && exit 0
+[ -z "${dnsmasq_conf}${dnsmasq_resolv}" ] && exit 0
 [ -z "$RESOLVCONF" ] && eval "$(@SBINDIR@/resolvconf -v)"
 NL="
 "
@@ -98,7 +98,7 @@
                                empty=false i=0
                                IFS=:
                                set -- $n
-                               while [ -n "$1" -o -n "$2" ]; do
+                               while [ -n "$1" ] || [ -n "$2" ]; do
                                        addr="$1"
                                        shift
                                        if [ -z "$addr" ]; then
@@ -184,7 +184,7 @@
                eval $dnsmasq_restart
        elif [ -n "$RESTARTCMD" ]; then
                set -- ${dnsmasq_service}
-               eval $RESTARTCMD
+               eval "$RESTARTCMD"
        else
                @SBINDIR@/resolvconf -r ${dnsmasq_service}
        fi
diff -r 096aaaf90fac -r 6bef39fb830b external/bsd/openresolv/dist/libc.in
--- a/external/bsd/openresolv/dist/libc.in      Wed Jun 26 17:46:09 2019 +0000
+++ b/external/bsd/openresolv/dist/libc.in      Wed Jul 17 18:24:23 2019 +0000
@@ -1,5 +1,5 @@
 #!/bin/sh
-# Copyright (c) 2007-2016 Roy Marples
+# Copyright (c) 2007-2019 Roy Marples
 # All rights reserved
 
 # libc subscriber for resolvconf
@@ -36,9 +36,9 @@
 # sed may not be available, and this is faster on small files
 key_get_value()
 {
-       local key="$1" x= line=
+       key="$1"
+       shift
 
-       shift
        if [ $# -eq 0 ]; then
                while read -r line; do
                        case "$line" in
@@ -58,8 +58,6 @@
 
 keys_remove()
 {
-       local key x line found
-
        while read -r line; do
                found=false
                for key do
@@ -79,7 +77,7 @@
 if [ -f "$SYSCONFDIR"/resolvconf.conf ]; then
        . "$SYSCONFDIR"/resolvconf.conf
 elif [ -d "$SYSCONFDIR"/resolvconf ]; then
-       SYSCONFDIR="$SYSCONFDIR/resolvconf/resolv.conf.d"
+       SYSCONFDIR="$SYSCONFDIR/resolvconf"
        base="$SYSCONFDIR/resolv.conf.d/base"
        if [ -f "$base" ]; then
                prepend_nameservers="$(key_get_value "nameserver " "$base")"
@@ -98,10 +96,12 @@
 : ${resolv_conf:=/etc/resolv.conf}
 : ${libc_service:=nscd}
 : ${list_resolv:=@SBINDIR@/resolvconf -l}
-if [ "${resolv_conf_head-x}" = x -a -f "$SYSCONFDIR"/resolv.conf.head ]; then
+if [ "${resolv_conf_head-x}" = x ] && [ -f "$SYSCONFDIR"/resolv.conf.head ]
+then
        resolv_conf_head="$(cat "${SYSCONFDIR}"/resolv.conf.head)"
 fi
-if [ "${resolv_conf_tail-x}" = x -a -f "$SYSCONFDIR"/resolv.conf.tail ]; then
+if [ "${resolv_conf_tail-x}" = x ] && [ -f "$SYSCONFDIR"/resolv.conf.tail ]
+then
        resolv_conf_tail="$(cat "$SYSCONFDIR"/resolv.conf.tail)"
 fi
 
@@ -110,7 +110,7 @@
  
 uniqify()
 {
-       local result=
+       result=
        while [ -n "$1" ]; do
                case " $result " in
                *" $1 "*);;
@@ -126,7 +126,7 @@
        backup=false
        newest=
        for conf in "$IFACEDIR"/*; do
-               if [ -z "$newest" -o "$conf" -nt "$newest" ]; then
+               if [ -z "$newest" ] || [ "$conf" -nt "$newest" ]; then
                        newest="$conf"
                fi
        done
@@ -178,7 +178,7 @@
        fi
 
        [ -n "$domain" ] && newconf="${newconf}domain $domain$NL"
-       if [ -n "$newsearch" -a "$newsearch" != "$domain" ]; then
+       if [ -n "$newsearch" ] && [ "$newsearch" != "$domain" ]; then
                newconf="${newconf}search $newsearch$NL"
        fi
        for n in $newns; do
@@ -232,7 +232,7 @@
        eval $libc_restart
 elif [ -n "$RESTARTCMD" ]; then
        set -- ${libc_service}
-       eval $RESTARTCMD
+       eval "$RESTARTCMD"
 else
        @SBINDIR@/resolvconf -r ${libc_service}
 fi
diff -r 096aaaf90fac -r 6bef39fb830b external/bsd/openresolv/dist/named.in
--- a/external/bsd/openresolv/dist/named.in     Wed Jun 26 17:46:09 2019 +0000
+++ b/external/bsd/openresolv/dist/named.in     Wed Jul 17 18:24:23 2019 +0000
@@ -28,14 +28,14 @@
 
 [ -f "@SYSCONFDIR@"/resolvconf.conf ] || exit 0
 . "@SYSCONFDIR@/resolvconf.conf" || exit 1
-[ -z "$named_zones" -a -z "$named_options" ] && exit 0
+[ -z "${named_zones}${named_options}" ] && exit 0
 [ -z "$RESOLVCONF" ] && eval "$(@SBINDIR@/resolvconf -v)"
 NL="
 "
 
 # Platform specific kludges
-if [ -z "$named_service" -a -z "$named_restart" -a \
-       -d "$RCDIR" -a ! -x "$RCDIR"/named ]
+if [ -z "${named_service}${named_restart}" ] &&
+   [ -d "$RCDIR" ] && ! [ -x "$RCDIR"/named ]
 then
        if [ -x "$RCDIR"/bind9 ]; then
                # Debian and derivatives
@@ -111,7 +111,7 @@
                eval $named_restart
        elif [ -n "$RESTARTCMD" ]; then
                set -- ${named_service}
-               eval $RESTARTCMD
+               eval "$RESTARTCMD"
        else
                @SBINDIR@/resolvconf -r ${named_service}
        fi
diff -r 096aaaf90fac -r 6bef39fb830b external/bsd/openresolv/dist/pdns_recursor.in
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/external/bsd/openresolv/dist/pdns_recursor.in     Wed Jul 17 18:24:23 2019 +0000
@@ -0,0 +1,78 @@
+#!/bin/sh
+# Copyright (c) 2009-2011 Roy Marples
+# All rights reserved
+
+# PowerDNS Recursor subscriber for resolvconf
+
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#     * Redistributions of source code must retain the above copyright
+#       notice, this list of conditions and the following disclaimer.
+#     * Redistributions in binary form must reproduce the above
+#       copyright notice, this list of conditions and the following
+#       disclaimer in the documentation and/or other materials provided
+#       with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+[ -f "@SYSCONFDIR@"/resolvconf.conf ] || exit 0
+. "@SYSCONFDIR@/resolvconf.conf" || exit 1
+[ -z "$pdns_zones" ] && exit 0
+[ -z "$RESOLVCONF" ] && eval "$(@SBINDIR@/resolvconf -v)"
+NL="
+"
+
+: ${pdns_service:=pdns_recursor}
+
+newzones=
+
+# pds_recursor does not present support global forward servers, which
+# does limit it's usefulness somewhat.
+# If it did, the below code can be enabled, or something like it.
+#for n in $NAMESERVERS; do
+#      newzones="$newzones${newzones:+,}$n"
+#done
+#[ -n "$newzones" ] && newzones=".=$newzones$NL"
+
+for d in $DOMAINS; do
+       newns=
+       ns="${d#*:}"



Home | Main Index | Thread Index | Old Index