Source-Changes-HG archive

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

[src/trunk]: src/external/bsd/openresolv/dist Import openresolv-3.6.0 with th...



details:   https://anonhg.NetBSD.org/src/rev/60914385cd14
branches:  trunk
changeset: 803274:60914385cd14
user:      roy <roy%NetBSD.org@localhost>
date:      Mon Oct 20 09:09:53 2014 +0000

description:
Import openresolv-3.6.0 with the following changes:

  *  dnsmasq subscriber no longer moans if it hasn't written a pidfile
  *  Ensure that name_server_blacklist works for more than one option.
     Thanks to Frederic Barthelery.
  *  unbound_insecure can disable DNSSEC for all domains processed.
  *  local_nameservers now defaults to
     127.* 0.0.0.0 255.255.255.255 ::1
     and is used instead of a hard coded list.
  *  Allow the disabling of resolvconf or optionally an individual
     subscriber.
  *  Don't wait around trying to create a lock if we don't have
     permission.
  *  resolv_conf_passthrough=NULL will update resolv.conf to match
     only what is configured in resolvconf.conf and ignore any
     interface configuration.

diffstat:

 external/bsd/openresolv/dist/dnsmasq.in    |    5 +-
 external/bsd/openresolv/dist/libc.in       |   32 ++++-
 external/bsd/openresolv/dist/resolvconf.in |  160 +++++++++++++++++++++-------
 external/bsd/openresolv/dist/unbound.in    |    9 +-
 4 files changed, 159 insertions(+), 47 deletions(-)

diffs (truncated from 420 to 300 lines):

diff -r e9c6167e5ea9 -r 60914385cd14 external/bsd/openresolv/dist/dnsmasq.in
--- a/external/bsd/openresolv/dist/dnsmasq.in   Mon Oct 20 08:37:30 2014 +0000
+++ b/external/bsd/openresolv/dist/dnsmasq.in   Mon Oct 20 09:09:53 2014 +0000
@@ -35,6 +35,7 @@
 
 : ${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 @@
        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
diff -r e9c6167e5ea9 -r 60914385cd14 external/bsd/openresolv/dist/libc.in
--- a/external/bsd/openresolv/dist/libc.in      Mon Oct 20 08:37:30 2014 +0000
+++ b/external/bsd/openresolv/dist/libc.in      Mon Oct 20 09:09:53 2014 +0000
@@ -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 @@
        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 @@
                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}@}
@@ -129,22 +130,41 @@
        [ -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)"
+       ;;
+esac
+case "${resolv_conf_passthrough:-NO}" in
+[Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|[Oo][Nn]|1) ;;
+*)
+       : ${domain:=$DOMAIN}
        newsearch="$(uniqify $prepend_search $SEARCH)"
        NS="$LOCALNAMESERVERS $NAMESERVERS"
        newns=
        gotlocal=false
        for n in $(uniqify $prepend_nameservers $NS); 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
 
diff -r e9c6167e5ea9 -r 60914385cd14 external/bsd/openresolv/dist/resolvconf.in
--- a/external/bsd/openresolv/dist/resolvconf.in        Mon Oct 20 08:37:30 2014 +0000
+++ b/external/bsd/openresolv/dist/resolvconf.in        Mon Oct 20 09:09:53 2014 +0000
@@ -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 @@
 # 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 @@
                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 @@
 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 @@
                        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
@@ -354,7 +368,9 @@
        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 "$@" | parse_resolv)"
+       fi
        if [ -n "$name_servers_append" -o -n "$search_domains_append" ]; then
                eval "$(echo_append | parse_resolv)"
        fi
@@ -374,7 +390,7 @@
                                        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 +417,21 @@
 }
 
 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 +460,7 @@
 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 +474,7 @@
        [ -n "$cmd" -a "$cmd" != h ] && usage "Unknown option $cmd"
        usage
 fi
+
 if [ "$cmd" = a ]; then
        for x in '/' \\ ' ' '*'; do
                case "$iface" in
@@ -464,38 +490,45 @@
        [ "$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"
 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 +536,21 @@
        # Read resolv.conf from stdin



Home | Main Index | Thread Index | Old Index