summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2018-11-13 14:53:18 +0000
committerRoy Marples <roy@marples.name>2018-11-13 14:53:18 +0000
commit75679ee66fb6187405120f7bf47ec030c4f27c0b (patch)
tree932ca09f03260c9e11fe9c392c4dfc8d571dbd3a
parentfe4e1ec4e2be2adfc1530ade94ebb30aa6f51540 (diff)
downloadopenresolv-75679ee66fb6187405120f7bf47ec030c4f27c0b.tar.xz
shell [ ] only supports 4 parameters
Using a fifth paramter or more is unspecified.
-rw-r--r--dnsmasq.in6
-rw-r--r--libc.in12
-rw-r--r--named.in8
-rw-r--r--pdnsd.in2
-rw-r--r--resolvconf.conf.5.in2
-rw-r--r--resolvconf.in138
-rw-r--r--unbound.in2
7 files changed, 97 insertions, 73 deletions
diff --git a/dnsmasq.in b/dnsmasq.in
index b1a2c74..e0a7f53 100644
--- a/dnsmasq.in
+++ b/dnsmasq.in
@@ -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 @@ for d in $DOMAINS; do
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 @@ if $changed; then
eval $dnsmasq_restart
elif [ -n "$RESTARTCMD" ]; then
set -- ${dnsmasq_service}
- eval $RESTARTCMD
+ eval "$RESTARTCMD"
else
@SBINDIR@/resolvconf -r ${dnsmasq_service}
fi
diff --git a/libc.in b/libc.in
index 36d8411..a1c3ed0 100644
--- a/libc.in
+++ b/libc.in
@@ -96,10 +96,12 @@ fi
: ${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
@@ -124,7 +126,7 @@ case "${resolv_conf_passthrough:-NO}" in
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
@@ -176,7 +178,7 @@ case "${resolv_conf_passthrough:-NO}" in
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
@@ -230,7 +232,7 @@ if [ -n "$libc_restart" ]; then
eval $libc_restart
elif [ -n "$RESTARTCMD" ]; then
set -- ${libc_service}
- eval $RESTARTCMD
+ eval "$RESTARTCMD"
else
@SBINDIR@/resolvconf -r ${libc_service}
fi
diff --git a/named.in b/named.in
index 2083ea5..e5b5a91 100644
--- a/named.in
+++ b/named.in
@@ -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 @@ if $changed; then
eval $named_restart
elif [ -n "$RESTARTCMD" ]; then
set -- ${named_service}
- eval $RESTARTCMD
+ eval "$RESTARTCMD"
else
@SBINDIR@/resolvconf -r ${named_service}
fi
diff --git a/pdnsd.in b/pdnsd.in
index 6a01843..971d90d 100644
--- a/pdnsd.in
+++ b/pdnsd.in
@@ -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 --git a/resolvconf.conf.5.in b/resolvconf.conf.5.in
index fcebd86..c138406 100644
--- a/resolvconf.conf.5.in
+++ b/resolvconf.conf.5.in
@@ -70,7 +70,7 @@ These interfaces will be processed next, unless they have a metric.
If unset, defaults to the following:-
.D1 tap[0-9]* tun[0-9]* vpn vpn[0-9]* ppp[0-9]* ippp[0-9]*
.It Sy inclusive_interfaces
-Ignore any exlcusive marking for these interfaces.
+Ignore any exclusive marking for these interfaces.
This is handy when 3rd party integrations force the
.Nm resolvconf -x
option and you want to disable it easily.
diff --git a/resolvconf.in b/resolvconf.in
index b81b7a5..dd8797e 100644
--- a/resolvconf.in
+++ b/resolvconf.in
@@ -210,7 +210,7 @@ parse_resolv()
;;
*)
[ -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"
@@ -296,64 +296,84 @@ detect_init()
# systems we try to detect them first.
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
@@ -367,7 +387,7 @@ echo_resolv()
{
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.
@@ -408,7 +428,7 @@ list_resolv()
fi
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 +451,12 @@ list_resolv()
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 +482,14 @@ list_resolv()
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
}
@@ -572,7 +593,7 @@ make_vars()
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
@@ -580,7 +601,7 @@ make_vars()
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
@@ -665,36 +686,37 @@ if [ "$cmd" = D ]; then
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"
exit $?
fi
# Restart a service or echo the command to restart a service
-if [ "$cmd" = r -o "$cmd" = R ]; then
+if [ "$cmd" = r ] || [ "$cmd" = R ]; then
detect_init || exit 1
if [ "$cmd" = r ]; then
set -- $args
- eval $RESTARTCMD
+ eval "$RESTARTCMD"
else
- echo "$RESTARTCMD"
+ echo "$RESTARTCMD" |
+ sed -e '/^$/d' -e 's/^ //g'
fi
exit $?
fi
# Not normally needed, but subscribers should be able to run independently
-if [ "$cmd" = v -o -n "$VFLAG" ]; then
+if [ "$cmd" = v ] || [ -n "$VFLAG" ]; then
make_vars "$iface"
exit $?
fi
# Test that we have valid options
-if [ "$cmd" = a -o "$cmd" = d ]; then
+if [ "$cmd" = a ] || [ "$cmd" = d ]; then
if [ -z "$iface" ]; then
usage "Interface not specified"
fi
elif [ "$cmd" != u ]; then
- [ -n "$cmd" -a "$cmd" != h ] && usage "Unknown option $cmd"
+ [ -n "$cmd" ] && [ "$cmd" != h ] && usage "Unknown option $cmd"
usage
fi
@@ -710,7 +732,7 @@ if [ "$cmd" = a ]; then
"$x not allowed at start of interface name";;
esac
done
- [ "$cmd" = a -a -t 0 ] && error_exit "No file given via stdin"
+ [ "$cmd" = a ] && [ -t 0 ] && error_exit "No file given via stdin"
fi
if [ ! -d "$VARDIR" ]; then
@@ -806,8 +828,8 @@ a)
newmetric="$METRICDIR/$IF_METRIC $iface"
fi
rm -f "$METRICDIR/"*" $iface"
- [ "$oldmetric" != "$newmetric" -a \
- "$oldmetric" != "$METRICDIR/* $iface" ] &&
+ [ "$oldmetric" != "$newmetric" ] &&
+ [ "$oldmetric" != "$METRICDIR/* $iface" ] &&
changed=true
[ -n "$newmetric" ] && echo " " >"$newmetric"
diff --git a/unbound.in b/unbound.in
index 46d4524..34cb401 100644
--- a/unbound.in
+++ b/unbound.in
@@ -76,7 +76,7 @@ restart_unbound()
eval $unbound_restart
elif [ -n "$RESTARTCMD" ]; then
set -- ${unbound_service}
- eval $RESTARTCMD
+ eval "$RESTARTCMD"
else
@SBINDIR@/resolvconf -r ${unbound_service}
fi