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 Resolvconf is (can be) used as ...



details:   https://anonhg.NetBSD.org/src/rev/1fd8e0d64bbe
branches:  trunk
changeset: 836067:1fd8e0d64bbe
user:      kre <kre%NetBSD.org@localhost>
date:      Mon Sep 24 21:58:11 2018 +0000

description:
Resolvconf is (can be) used as part of network config during
system installation, so also must confine itself to POSIX specified
test ('[') usage.     Pointed out by roy@ - thanks.

diffstat:

 external/bsd/openresolv/dist/dnsmasq.in    |    4 +-
 external/bsd/openresolv/dist/libc.in       |   10 +-
 external/bsd/openresolv/dist/named.in      |    6 +-
 external/bsd/openresolv/dist/pdnsd.in      |    2 +-
 external/bsd/openresolv/dist/resolvconf.in |  132 ++++++++++++++++------------
 5 files changed, 88 insertions(+), 66 deletions(-)

diffs (truncated from 351 to 300 lines):

diff -r 9113f17fc2bc -r 1fd8e0d64bbe external/bsd/openresolv/dist/dnsmasq.in
--- a/external/bsd/openresolv/dist/dnsmasq.in   Mon Sep 24 21:15:39 2018 +0000
+++ b/external/bsd/openresolv/dist/dnsmasq.in   Mon Sep 24 21:58:11 2018 +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
diff -r 9113f17fc2bc -r 1fd8e0d64bbe external/bsd/openresolv/dist/libc.in
--- a/external/bsd/openresolv/dist/libc.in      Mon Sep 24 21:15:39 2018 +0000
+++ b/external/bsd/openresolv/dist/libc.in      Mon Sep 24 21:58:11 2018 +0000
@@ -98,10 +98,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
 
@@ -126,7 +128,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 +180,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
diff -r 9113f17fc2bc -r 1fd8e0d64bbe external/bsd/openresolv/dist/named.in
--- a/external/bsd/openresolv/dist/named.in     Mon Sep 24 21:15:39 2018 +0000
+++ b/external/bsd/openresolv/dist/named.in     Mon Sep 24 21:58:11 2018 +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
diff -r 9113f17fc2bc -r 1fd8e0d64bbe external/bsd/openresolv/dist/pdnsd.in
--- a/external/bsd/openresolv/dist/pdnsd.in     Mon Sep 24 21:15:39 2018 +0000
+++ b/external/bsd/openresolv/dist/pdnsd.in     Mon Sep 24 21:58:11 2018 +0000
@@ -28,7 +28,7 @@
 
 [ -f "@SYSCONFDIR@"/resolvconf.conf ] || exit 0
 . "@SYSCONFDIR@/resolvconf.conf" || exit 1
-[ -z "$pdnsd_conf" -a -z "$pdnsd_resolv" ] && exit 0
+[ -z "${pdnsd_conf}${pdnsd_resolv}" ] && exit 0
 [ -z "$RESOLVCONF" ] && eval "$(@SBINDIR@/resolvconf -v)"
 NL="
 "
diff -r 9113f17fc2bc -r 1fd8e0d64bbe external/bsd/openresolv/dist/resolvconf.in
--- a/external/bsd/openresolv/dist/resolvconf.in        Mon Sep 24 21:15:39 2018 +0000
+++ b/external/bsd/openresolv/dist/resolvconf.in        Mon Sep 24 21:58:11 2018 +0000
@@ -211,7 +211,7 @@
                        ;;
                *)
                        [ -n "$line" ] && continue
-                       if [ -n "$ns" -a -n "$search" ]; then
+                       if [ -n "$ns" ] && [ -n "$search" ]; then
                                newns=
                                for n in $ns; do
                                        newns="$newns${newns:+,}$n"
@@ -297,64 +297,83 @@
        # systems we try to detect them first.
        local status="@STATUSARG@"
        : ${status:=status}
-       if [ -x /bin/systemctl -a -S /run/systemd/private ]; then
-               RESTARTCMD="if /bin/systemctl --quiet is-active \$1.service; then
-       /bin/systemctl restart \$1.service;
-fi"
-       elif [ -x /usr/bin/systemctl -a -S /run/systemd/private ]; then
-               RESTARTCMD="if /usr/bin/systemctl --quiet is-active \$1.service; then
-       /usr/bin/systemctl restart \$1.service;
-fi"
-       elif [ -x /sbin/rc-service -a \
-           -s /libexec/rc/init.d/softlevel -o -s /run/openrc/softlevel ]
+       if [ -x /bin/systemctl ] && [ -S /run/systemd/private ]; then
+               RESTARTCMD='
+                       if /bin/systemctl --quiet is-active $1.service
+                       then
+                               /bin/systemctl restart $1.service
+                       fi'
+       elif [ -x /usr/bin/systemctl ] && [ -S /run/systemd/private ]; then
+               RESTARTCMD='
+                       if /usr/bin/systemctl --quiet is-active $1.service
+                       then
+                               /usr/bin/systemctl restart $1.service
+                       fi'
+       elif [ -x /sbin/rc-service ] && [ -s /libexec/rc/init.d/softlevel ] ||
+            [ -s /run/openrc/softlevel ]
        then
-               RESTARTCMD="/sbin/rc-service -i \$1 -- -Ds restart"
+               RESTARTCMD='/sbin/rc-service -i $1 -- -Ds restart'
        elif [ -x /usr/sbin/invoke-rc.d ]; then
                RCDIR=/etc/init.d
-               RESTARTCMD="if /usr/sbin/invoke-rc.d --quiet \$1 status 1>/dev/null 2>&1; then
-       /usr/sbin/invoke-rc.d \$1 restart;
-fi"
+               RESTARTCMD='
+                  if /usr/sbin/invoke-rc.d --quiet $1 status >/dev/null 2>&1
+                  then
+                       /usr/sbin/invoke-rc.d $1 restart
+                  fi'
        elif [ -x /sbin/service ]; then
                # Old RedHat
                RCDIR=/etc/init.d
-               RESTARTCMD="if /sbin/service \$1; then
-       /sbin/service \$1 restart;
-fi"
+               RESTARTCMD='
+                       if /sbin/service $1; then
+                               /sbin/service $1 restart
+                       fi'
        elif [ -x /usr/sbin/service ]; then
                # Could be FreeBSD
-               RESTARTCMD="if /usr/sbin/service \$1 $status 1>/dev/null 2>&1; then
-       /usr/sbin/service \$1 restart;
-fi"
+               RESTARTCMD='
+                       if /usr/sbin/service $1 $status >/dev/null 2>&1
+                       then
+                               /usr/sbin/service $1 restart
+                       fi'
        elif [ -x /bin/sv ]; then
-               RESTARTCMD="/bin/sv status \$1 >/dev/null 2>&1 && /bin/sv try-restart \$1"
+               RESTARTCMD='/bin/sv status $1 >/dev/null 2>&1 &&
+                           /bin/sv try-restart $1'
        elif [ -x /usr/bin/sv ]; then
-               RESTARTCMD="/usr/bin/sv status \$1 >/dev/null 2>&1 && /usr/bin/sv try-restart \$1"
-       elif [ -e /etc/arch-release -a -d /etc/rc.d ]; then
+               RESTARTCMD='/usr/bin/sv status $1 >/dev/null 2>&1 &&
+                           /usr/bin/sv try-restart $1'
+       elif [ -e /etc/arch-release ] && [ -d /etc/rc.d ]; then
                RCDIR=/etc/rc.d
-               RESTARTCMD="if [ -e /var/run/daemons/\$1 ]; then
-       /etc/rc.d/\$1 restart;
-fi"
-       elif [ -e /etc/slackware-version -a -d /etc/rc.d ]; then
-               RESTARTCMD="if /etc/rc.d/rc.\$1 status 1>/dev/null 2>&1; then
-       /etc/rc.d/rc.\$1 restart;
-fi"
-       elif [ -e /etc/rc.d/rc.subr -a -d /etc/rc.d ]; then
+               RESTARTCMD='
+                       if [ -e /var/run/daemons/$1 ]
+                       then
+                               /etc/rc.d/$1 restart
+                       fi'
+       elif [ -e /etc/slackware-version ] && [ -d /etc/rc.d ]; then
+               RESTARTCMD='
+                       if /etc/rc.d/rc.$1 status >/dev/null 2>&1
+                       then
+                               /etc/rc.d/rc.$1 restart
+                       fi'
+       elif [ -e /etc/rc.d/rc.subr ] && [ -d /etc/rc.d ]; then
                # OpenBSD
-               RESTARTCMD="if /etc/rc.d/\$1 check 1>/dev/null 2>&1; then
-       /etc/rc.d/\$1 restart;
-fi"
+               RESTARTCMD='
+                       if /etc/rc.d/$1 check >/dev/null 2>&1
+                       then
+                               /etc/rc.d/$1 restart
+                       fi'
        else
                for x in /etc/init.d/rc.d /etc/rc.d /etc/init.d; do
                        [ -d $x ] || continue
-                       RESTARTCMD="if $x/\$1 $status 1>/dev/null 2>&1; then
-       $x/\$1 restart;
-fi"
+                       RESTARTCMD="
+                               if $x/\$1 $status >/dev/null 2>&1
+                               then
+                                       $x/\$1 restart
+                               fi"
                        break
                done
        fi
 
        if [ -z "$RESTARTCMD" ]; then
-               if [ "$NOINIT_WARNED" != true ]; then
+               if [ "$_NOINIT_WARNED" != true ]; then
                        warn "could not detect a useable init system"
                        _NOINIT_WARNED=true
                fi
@@ -368,7 +387,7 @@
 {
        local line= OIFS="$IFS"
 
-       [ -n "$1" -a -f "$IFACEDIR/$1" ] || return 1
+       [ -n "$1" ] && [ -f "$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.
@@ -405,7 +424,7 @@
                excl=true
                cd "$IFACEDIR"
                for i in $inclusive_interfaces; do
-                       if [ -f "$i" -a "$list" = "$i" ]; then
+                       if [ -f "$i" ] && [ "$list" = "$i" ]; then
                                list=
                                excl=false
                                break
@@ -431,11 +450,12 @@
                        done
                done
                for i in $dynamic_order; do
-                       if [ -e "$i" -a ! -e "$METRICDIR/"*" $i" ]; then
+                       if [ -e "$i" ] && ! [ -e "$METRICDIR/"*" $i" ]; then
                                list="$list $i"
                        fi
                        for ii in "$i":* "$i".*; do
-                               if [ -f "$ii" -a ! -e "$METRICDIR/"*" $ii" ]; then
+                               if [ -f "$ii" ] && ! [ -e "$METRICDIR/"*" $ii" ]
+                               then
                                        list="$list $ii"
                                fi
                        done
@@ -461,14 +481,14 @@
                        continue
                fi
                
-               if [ "$cmd" = i -o "$cmd" = "-i" ]; then
+               if [ "$cmd" = i ] || [ "$cmd" = "-i" ]; then
                        printf %s "$i "
                else
                        echo_resolv "$i" && echo
                fi
-               [ $? = 0 -a "$retval" = 1 ] && retval=0
+               [ $? = 0 ] && [ "$retval" = 1 ] && retval=0
        done
-       [ "$cmd" = i -o "$cmd" = "-i" ] && echo
+       [ "$cmd" = i ] || [ "$cmd" = "-i" ] && echo
        return $retval
 }
 
@@ -575,7 +595,7 @@
        NAMESERVERS=
        LOCALNAMESERVERS=
        
-       if [ -n "$name_servers" -o -n "$search_domains" ]; then
+       if [ -n "${name_servers}${search_domains}" ]; then
                eval "$(echo_prepend | parse_resolv)"
        fi
        if [ -z "$VFLAG" ]; then
@@ -583,7 +603,7 @@
                list_resolv -i "$@" >/dev/null || IF_EXCLUSIVE=0
                eval "$(list_resolv -l "$@" | replace | parse_resolv)"
        fi
-       if [ -n "$name_servers_append" -o -n "$search_domains_append" ]; then
+       if [ -n "${name_servers_append}${search_domains_append} ]; then
                eval "$(echo_append | parse_resolv)"
        fi
 
@@ -667,13 +687,13 @@
 fi
 
 # -l lists our resolv files, optionally for a specific interface
-if [ "$cmd" = l -o "$cmd" = i ]; then
+if [ "$cmd" = l ] || [ "$cmd" = i ]; then
        list_resolv "$cmd" "$args"



Home | Main Index | Thread Index | Old Index