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



details:   https://anonhg.NetBSD.org/src/rev/cae8e4205483
branches:  ROY
changeset: 454306:cae8e4205483
user:      roy <roy%NetBSD.org@localhost>
date:      Thu Nov 24 00:36:05 2011 +0000

description:
Import openresolv-3.4.5 with the following changes since the last version:
* More printf portabitiy fixes.
* Use read -r to avoid backslash problems.
* If we have a valid domain, put that in resolv.conf as well as search.
  This does not fix a technical problem, just stops me getting bug reports.
* Update metric and privacy even if resolv.conf didn't change.
* sortlist is now supported.
* Ensure subscriber config directories exist before writing the configs
* Don't create pdnsd.conf if it doesn't exist or is not writeable.

diffstat:

 external/bsd/openresolv/dist/dnsmasq.in           |    7 +
 external/bsd/openresolv/dist/libc.in              |   59 ++++++++---
 external/bsd/openresolv/dist/named.in             |    7 +
 external/bsd/openresolv/dist/pdnsd.in             |   34 ++++--
 external/bsd/openresolv/dist/resolvconf.conf.5.in |    5 +-
 external/bsd/openresolv/dist/resolvconf.in        |  102 ++++++++++++++++++---
 external/bsd/openresolv/dist/unbound.in           |    7 +
 7 files changed, 175 insertions(+), 46 deletions(-)

diffs (truncated from 487 to 300 lines):

diff -r c982b7e2ea05 -r cae8e4205483 external/bsd/openresolv/dist/dnsmasq.in
--- a/external/bsd/openresolv/dist/dnsmasq.in   Mon Jun 13 11:05:19 2011 +0000
+++ b/external/bsd/openresolv/dist/dnsmasq.in   Thu Nov 24 00:36:05 2011 +0000
@@ -93,6 +93,13 @@
        done
 done
 
+# Try to ensure that config dirs exist
+if type config_mkdirs >/dev/null 2>&1; then
+       config_mkdirs "$dnsmasq_conf" "$dnsmasq_resolv"
+else
+       @PREFIX@/sbin/resolvconf -D "$dnsmasq_conf" "$dnsmasq_resolv"
+fi
+
 changed=false
 if [ -n "$dnsmasq_conf" ]; then
        if [ ! -f "$dnsmasq_conf" ] || \
diff -r c982b7e2ea05 -r cae8e4205483 external/bsd/openresolv/dist/libc.in
--- a/external/bsd/openresolv/dist/libc.in      Mon Jun 13 11:05:19 2011 +0000
+++ b/external/bsd/openresolv/dist/libc.in      Thu Nov 24 00:36:05 2011 +0000
@@ -36,18 +36,18 @@
 # sed may not be available, and this is faster on small files
 key_get_value()
 {
-       local key="$1" value= x= line=
+       local key="$1" x= line=
 
        shift
        if [ $# -eq 0 ]; then
-               while read line; do
+               while read -r line; do
                        case "$line" in
                        "$key"*) echo "${line##$key}";;
                        esac
                done
        else
-               for x; do
-                       while read line; do
+               for x do
+                       while read -r line; do
                                case "$line" in
                                "$key"*) echo "${line##$key}";;
                                esac
@@ -56,6 +56,22 @@
        fi
 }
 
+keys_remove()
+{
+       local key x line found
+
+       while read -r line; do
+               found=false
+               for key do
+                       case "$line" in
+                       "$key"*|"#"*|" "*|"     "*|"") found=true;;
+                       esac
+                       $found && break
+               done
+               $found || echo "$line"
+       done
+}
+
 # Support original resolvconf configuration layout
 # as well as the openresolv config file
 if [ -f "$SYSCONFDIR"/resolvconf.conf ]; then
@@ -65,11 +81,10 @@
        base="$SYSCONFDIR/resolv.conf.d/base"
        if [ -f "$base" ]; then
                name_servers="$(key_get_value "nameserver " "$base")"
+               domain="$(key_get_value "domain " "$base")"
                search_domains="$(key_get_value "search " "$base")"
-               if [ -z "$search_domains" ]; then
-                       search_domains="$(key_get_value "domain " "$base")"
-               fi
                resolv_conf_options="$(key_get_value "options " "$base")"
+               resolv_conf_sortlist="$(key_get_value "sortlist " "$base")"
        fi
        if [ -f "$SYSCONFDIR"/resolv.conf.d/head ]; then
                resolv_conf_head="$(cat "${SYSCONFDIR}"/resolv.conf.d/head)"
@@ -78,6 +93,7 @@
                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}@}
@@ -124,20 +140,27 @@
        if [ -n "$resolv_conf_head" ]; then
                newconf="$newconf$resolv_conf_head$NL"
        fi
-       [ -n "$newsearch" ] && newconf="${newconf}search $newsearch$NL"
+
+       [ -n "$domain" ] && newconf="${newconf}domain $domain$NL"
+       if [ -n "$newsearch" -a "$newsearch" != "$domain" ]; then
+               newconf="${newconf}search $newsearch$NL"
+       fi
        for n in $newns; do
                newconf="${newconf}nameserver $n$NL"
        done
 
-       # Now get any configured options
-       opts="$resolv_conf_options${resolv_conf_options:+ }"
-       opts="$opts$($list_resolv | key_get_value "options ")"
-       if [ -n "$opts" ]; then
-               newconf="${newconf}options"
-               for opt in $(uniqify $opts); do
-                       newconf="${newconf} $opt"
-               done
-               newconf="$newconf$NL"
+       # Now add anything we don't care about such as sortlist and options
+       stuff="$($list_resolv | keys_remove nameserver domain search)"
+       if [ -n "$stuff" ]; then
+               newconf="$newconf$stuff$NL"
+       fi
+
+       # Append any user defined ones
+       if [ -n "$resolv_conf_options" ]; then
+               newconf="${newconf}options $resolv_conf_options$NL"
+       fi
+       if [ -n "$resolv_conf_sortlist" ]; then
+               newconf="${newconf}sortlist $resolv_conf_sortlist$NL"
        fi
 
        if [ -n "$resolv_conf_tail" ]; then
@@ -152,7 +175,7 @@
 fi
 
 # Create our resolv.conf now
-(umask 022; echo "$newconf" >"$resolv_conf")
+(umask 022; printf %s "$newconf" >"$resolv_conf")
 eval $libc_restart
 
 retval=0
diff -r c982b7e2ea05 -r cae8e4205483 external/bsd/openresolv/dist/named.in
--- a/external/bsd/openresolv/dist/named.in     Mon Jun 13 11:05:19 2011 +0000
+++ b/external/bsd/openresolv/dist/named.in     Thu Nov 24 00:36:05 2011 +0000
@@ -71,6 +71,13 @@
        newzones="$newzones     };$NL};$NL"
 done
 
+# Try to ensure that config dirs exist
+if type config_mkdirs >/dev/null 2>&1; then
+       config_mkdirs "$named_options" "$named_zones"
+else
+       @PREFIX@/sbin/resolvconf -D "$named_options" "$named_zones"
+fi
+
 # No point in changing files or reloading bind if the end result has not
 # changed
 changed=false
diff -r c982b7e2ea05 -r cae8e4205483 external/bsd/openresolv/dist/pdnsd.in
--- a/external/bsd/openresolv/dist/pdnsd.in     Mon Jun 13 11:05:19 2011 +0000
+++ b/external/bsd/openresolv/dist/pdnsd.in     Thu Nov 24 00:36:05 2011 +0000
@@ -30,6 +30,8 @@
 . "@SYSCONFDIR@/resolvconf.conf" || exit 1
 [ -z "$pdnsd_conf" -a -z "$pdnsd_resolv" ] && exit 0
 [ -z "$RESOLVCONF" ] && eval "$(@PREFIX@/sbin/resolvconf -v)"
+NL="
+"
 
 : ${pdnsd_restart:=pdnsd-ctl config $pdnsd_conf}
 signature="# Generated by resolvconf"
@@ -46,7 +48,7 @@
                sed "/^$m1/,/^$m2/d" $@
        else
                for x; do
-                       while read line; do
+                       while read -r line; do
                                case "$line" in
                                "$m1"*) in_marker=1;;
                                "$m2"*) in_marker=0;;
@@ -83,21 +85,29 @@
 newresolv="# Generated by resolvconf\n"
 changed=false
 
+# Try to ensure that config dirs exist
+if type config_mkdirs >/dev/null 2>&1; then
+       config_mkdirs "$pdnsd_resolv" "$pdnsd_conf"
+else
+       @PREFIX@/sbin/resolvconf -D "$pdnsd_resolv" "$pdnsd_conf"
+fi
+
 if [ -n "$pdnsd_resolv" ]; then
        for n in $NAMESERVERS; do
                newresolv="${newresolv}nameserver $n\n"
        done
 fi
 
-if [ -n "$pdnsd_conf" ]; then
+# Only modify the configuration if it exists and we can write to it
+if [ -w "$pdnsd_conf" ]; then
        cf="$pdnsd_conf.new"
        newconf=
 
        if [ -z "$pdnsd_resolv" ]; then
-               newconf="${newconf}server {\n"
-               newconf="${newconf}\tlabel=resolvconf;\n"
+               newconf="${newconf}server {$NL"
+               newconf="${newconf}     label=resolvconf;$NL"
                if [ -n "$NAMESERVERS" ]; then
-                       newconf="${newconf}\tip="
+                       newconf="${newconf}     ip="
                        first=true
                        for n in $NAMESERVERS; do
                                if $first; then
@@ -107,16 +117,16 @@
                                fi
                                newconf="$newconf$n"
                        done
-                       newconf="${newconf};\n"
+                       newconf="${newconf};$NL"
                fi
-               newconf="${newconf}}\n"
+               newconf="${newconf}}$NL"
        fi
 
        for d in $DOMAINS; do
-               newconf="${newconf}server {\n"
-               newconf="${newconf}\tinclude=.${d%%:*}.;\n"
-               newconf="${newconf}\tpolicy=excluded;\n"
-               newconf="${newconf}\tip="
+               newconf="${newconf}server {$NL"
+               newconf="${newconf}     include=.${d%%:*}.;$NL"
+               newconf="${newconf}     policy=excluded;$NL"
+               newconf="${newconf}     ip="
                ns="${d#*:}"
                while [ -n "$ns" ]; do
                        newconf="${newconf}${ns%%,*}"
@@ -124,7 +134,7 @@
                        ns="${ns#*,}"
                        newconf="${newconf},"
                done
-               newconf="${newconf};\n}\n"
+               newconf="${newconf};$NL}$NL"
        done
 
        rm -f "$cf"
diff -r c982b7e2ea05 -r cae8e4205483 external/bsd/openresolv/dist/resolvconf.conf.5.in
--- a/external/bsd/openresolv/dist/resolvconf.conf.5.in Mon Jun 13 11:05:19 2011 +0000
+++ b/external/bsd/openresolv/dist/resolvconf.conf.5.in Thu Nov 24 00:36:05 2011 +0000
@@ -22,7 +22,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.Dd April 21, 2011
+.Dd August 11, 2011
 .Dt RESOLVCONF.CONF 5 SMM
 .Os
 .Sh NAME
@@ -96,6 +96,9 @@
 When set to YES the latest resolv.conf is written to
 .Sy resolv_conf
 without any alteration.
+.It Sy resolv_conf_sortlist
+A libc resolver sortlist, as specified in
+.Xr resolv.conf 5 .
 .El
 .Sh SUBSCRIBER OPTIONS
 openresolv ships with subscribers for the name servers
diff -r c982b7e2ea05 -r cae8e4205483 external/bsd/openresolv/dist/resolvconf.in
--- a/external/bsd/openresolv/dist/resolvconf.in        Mon Jun 13 11:05:19 2011 +0000
+++ b/external/bsd/openresolv/dist/resolvconf.in        Thu Nov 24 00:36:05 2011 +0000
@@ -84,16 +84,23 @@
 
 echo_resolv()
 {
-       local line=
+       local line= OIFS="$IFS"
+
        [ -n "$1" -a -e "$IFACEDIR/$1" ] || return 1
        echo "# resolv.conf from $1"
        # Our variable maker works of the fact each resolv.conf per interface
        # is separated by blank lines.
        # So we remove them when echoing them.
-       while read line; do
-               [ -n "$line" ] && echo "$line"
+       while read -r line; do
+               IFS="$OIFS"
+               if [ -n "$line" ]; then
+                       # We need to set IFS here to preserve any whitespace
+                       IFS=''
+                       printf "%s\n" "$line"
+               fi
        done < "$IFACEDIR/$1"
        echo
+       IFS="$OIFS"
 }
 
 # Parse resolv.conf's and make variables
@@ -101,8 +108,9 @@
 parse_resolv()
 {
        local line= ns= ds= search= d= n= newns=
-       local new=true iface= private=false p=
+       local new=true iface= private=false p= domain=
 
+       echo "DOMAIN="
        echo "DOMAINS="



Home | Main Index | Thread Index | Old Index