Browse Source

unbound: replace obsolete test expressions

Expressions '-o', '-a', and '\( \)' within test or '[ ]' are obsolete.
POSIX allows few arguments to test, so long expressions are not
portable. '[ p -a q ]' can be replaced with '[ p ] && [ q ]' instead.

Signed-off-by: Eric Luehrsen <ericluehrsen@gmail.com>
lilik-openwrt-22.03
Eric Luehrsen 6 years ago
committed by Yousong Zhou
parent
commit
f1d1530f48
6 changed files with 49 additions and 50 deletions
  1. +9
    -8
      net/unbound/files/dnsmasq.sh
  2. +1
    -1
      net/unbound/files/iptools.sh
  3. +3
    -3
      net/unbound/files/odhcpd.sh
  4. +2
    -2
      net/unbound/files/stopping.sh
  5. +1
    -1
      net/unbound/files/unbound.init
  6. +33
    -35
      net/unbound/files/unbound.sh

+ 9
- 8
net/unbound/files/dnsmasq.sh View File

@ -75,13 +75,13 @@ create_host_record() {
config_get name "$cfg" name
if [ -n "$name" -a -n "$ip" ] ; then
if [ -n "$name" ] && [ -n "$ip" ] ; then
create_local_zone "$name"
case $ip in
fe[89ab][0-9a-f]:*|169.254.*)
debug_ip="$ip@$host"
debug_ip="$ip@$name"
;;
[1-9a-f]*:*[0-9a-f])
@ -109,7 +109,7 @@ create_mx_record() {
config_get pref "$cfg" pref 10
if [ -n "$domain" -a -n "$relay" ] ; then
if [ -n "$domain" ] && [ -n "$relay" ] ; then
create_local_zone "$domain"
record="$domain.@@300@@IN@@MX@@$pref@@$relay."
DM_LIST_LOCAL_DATA="$DM_LIST_LOCAL_DATA $record"
@ -130,7 +130,7 @@ create_srv_record() {
config_get weight "$cfg" weight 10
if [ -n "$srv" -a -n "$target" -a -n "$port" ] ; then
if [ -n "$srv" ] && [ -n "$target" ] && [ -n "$port" ] ; then
create_local_zone "$srv"
record="$srv.@@300@@IN@@SRV@@$class@@$weight@@$port@@$target."
DM_LIST_LOCAL_DATA="$DM_LIST_LOCAL_DATA $record"
@ -148,7 +148,7 @@ create_cname_record() {
config_get target "$cfg" target
if [ -n "$cname" -a -n "$target" ] ; then
if [ -n "$cname" ] && [ -n "$target" ] ; then
create_local_zone "$cname"
record="$cname.@@300@@IN@@CNAME@@$target."
DM_LIST_LOCAL_DATA="$DM_LIST_LOCAL_DATA $record"
@ -172,7 +172,8 @@ dnsmasq_local_zone() {
fi
if [ -n "$fwd_domain" -a -n "$fwd_port" -a ! "${fwd_port:-53}" -eq 53 ] ; then
if [ -n "$fwd_domain" ] && [ -n "$fwd_port" ] \
&& [ ! "${fwd_port:-53}" -eq 53 ] ; then
# dnsmasq localhost listening ports (possible multiple instances)
DM_LIST_FWD_PORTS="$DM_LIST_FWD_PORTS $fwd_port"
DM_LIST_FWD_ZONES="$DM_LIST_FWD_ZONES $fwd_domain"
@ -193,7 +194,7 @@ dnsmasq_local_arpa() {
fi
if [ -n "$UB_LIST_NETW_WAN" -a "$DM_D_WAN_FQDN" -gt 0 ] ; then
if [ -n "$UB_LIST_NETW_WAN" ] && [ "$DM_D_WAN_FQDN" -gt 0 ] ; then
for ifsubnet in $UB_LIST_NETW_WAN ; do
ifarpa=$( domain_ptr_any "${ifsubnet#*@}" )
DM_LIST_FWD_ZONES="$DM_LIST_FWD_ZONES $ifarpa"
@ -260,7 +261,7 @@ dnsmasq_active() {
dnsmasq_local_arpa
if [ -n "$DM_LIST_FWD_PORTS" -a -n "$DM_LIST_FWD_ZONES" ] ; then
if [ -n "$DM_LIST_FWD_PORTS" ] && [ -n "$DM_LIST_FWD_ZONES" ] ; then
{
# Forward to dnsmasq on same host for DHCP lease hosts
echo "# $UB_SRVMASQ_CONF generated by UCI $( date -Is )"


+ 1
- 1
net/unbound/files/iptools.sh View File

@ -130,7 +130,7 @@ valid_subnet_any() {
local validip6=$( valid_subnet6 $subnet )
if [ "$validip4" = "ok" -o "$validip6" = "ok" ] ; then
if [ "$validip4" = "ok" ] || [ "$validip6" = "ok" ] ; then
echo "ok"
else
echo "not"


+ 3
- 3
net/unbound/files/odhcpd.sh View File

@ -35,8 +35,8 @@ odhcpd_zonedata() {
local dhcp_origin=$( uci_get dhcp.@odhcpd[0].leasefile )
if [ -f "$UB_TOTAL_CONF" -a -f "$dhcp_origin" \
-a "$dhcp_link" = "odhcpd" -a -n "$dhcp_domain" ] ; then
if [ -f "$UB_TOTAL_CONF" ] && [ -f "$dhcp_origin" ] \
&& [ "$dhcp_link" = "odhcpd" ] && [ -n "$dhcp_domain" ] ; then
local longconf dateconf
local dns_ls_add=$UB_VARDIR/dhcp_dns.add
local dns_ls_del=$UB_VARDIR/dhcp_dns.del
@ -48,7 +48,7 @@ odhcpd_zonedata() {
sort $dhcp_origin > $dhcp_ls_new
if [ ! -f $UB_DHCP_CONF -o ! -f $dns_ls_old ] ; then
if [ ! -f $UB_DHCP_CONF ] || [ ! -f $dns_ls_old ] ; then
# no old files laying around
longconf=freshstart


+ 2
- 2
net/unbound/files/stopping.sh View File

@ -43,11 +43,11 @@ rootkey_update() {
[ -z "$dnssec_age" ] && dnssec_age=9
if [ "$dnssec_age" -gt 90 -o "$dnssec" -lt 1 ] ; then
if [ "$dnssec_age" -gt 90 ] || [ "$dnssec" -lt 1 ] ; then
# Feature disabled
return 0
elif [ "$dnssec_ntp" -gt 0 -a ! -f "$UB_TIME_FILE" ] ; then
elif [ "$dnssec_ntp" -gt 0 ] && [ ! -f "$UB_TIME_FILE" ] ; then
# We don't have time yet
return 0
fi


+ 1
- 1
net/unbound/files/unbound.init View File

@ -61,7 +61,7 @@ service_triggers() {
. /usr/lib/unbound/defaults.sh
if [ ! -f "$UB_TOTAL_CONF" -o -n "$UB_BOOT" ] ; then
if [ ! -f "$UB_TOTAL_CONF" ] || [ -n "$UB_BOOT" ] ; then
# Unbound is can be a bit heavy, so wait some on first start but any
# interface coming up affects the trigger and delay so guarantee start
procd_add_raw_trigger "interface.*.up" 3000 /etc/init.d/unbound restart


+ 33
- 35
net/unbound/files/unbound.sh View File

@ -120,7 +120,8 @@ bundle_lan_networks() {
ifdashname="${ifname//./-}"
if [ "$ignore" -eq 0 -a -n "$ifdashname" -a -n "$UB_LIST_NETW_ALL" ] ; then
if [ "$ignore" -eq 0 ] && [ -n "$ifdashname" ] \
&& [ -n "$UB_LIST_NETW_ALL" ] ; then
for ifsubnet in $UB_LIST_NETW_ALL ; do
case $ifsubnet in
"${ifdashname}"@*)
@ -260,8 +261,8 @@ unbound_mkdir() {
chmod 644 $UB_VARDIR/*
if [ -f $UB_CTLKEY_FILE -o -f $UB_CTLPEM_FILE \
-o -f $UB_SRVKEY_FILE -o -f $UB_SRVPEM_FILE ] ; then
if [ -f $UB_CTLKEY_FILE ] || [ -f $UB_CTLPEM_FILE ] \
|| [ -f $UB_SRVKEY_FILE ] || [ -f $UB_SRVPEM_FILE ] ; then
# Keys (some) exist already; do not create new ones
chmod 640 $UB_CTLKEY_FILE $UB_CTLPEM_FILE \
$UB_SRVKEY_FILE $UB_SRVPEM_FILE
@ -312,8 +313,8 @@ unbound_control() {
if [ "$UB_D_CONTROL" -gt 1 ] ; then
if [ ! -f $UB_CTLKEY_FILE -o ! -f $UB_CTLPEM_FILE \
-o ! -f $UB_SRVKEY_FILE -o ! -f $UB_SRVPEM_FILE ] ; then
if [ ! -f $UB_CTLKEY_FILE ] || [ ! -f $UB_CTLPEM_FILE ] \
|| [ ! -f $UB_SRVKEY_FILE ] || [ ! -f $UB_SRVPEM_FILE ] ; then
# Key files need to be present; if unbound-control-setup was found, then
# they might have been made during unbound_makedir() above.
UB_D_CONTROL=0
@ -423,8 +424,8 @@ unbound_zone() {
case $zone_type in
auth_zone)
if [ "$UB_B_NTP_BOOT" -eq 0 -a -n "$UB_LIST_ZONE_NAMES" \
-a \( -n "$url_dir" -o -n "$UB_LIST_ZONE_SERVERS" \) ] ; then
if [ "$UB_B_NTP_BOOT" -eq 0 ] && [ -n "$UB_LIST_ZONE_NAMES" ] \
&& { [ -n "$url_dir" ] || [ -n "$UB_LIST_ZONE_SERVERS" ] ; } ; then
# Note AXFR may have large downloads. If NTP restart is configured,
# then this can cause procd to force a process kill.
for zone_name in $UB_LIST_ZONE_NAMES ; do
@ -460,13 +461,13 @@ unbound_zone() {
;;
forward_zone)
if [ ! -f $UB_TLS_FWD_FILE -a "$tls_upstream" = "yes" ] ; then
if [ ! -f $UB_TLS_FWD_FILE ] && [ "$tls_upstream" = "yes" ] ; then
logger -p 4 -t unbound -s \
"Forward-zone TLS benefits from authentication in package 'ca-bundle'"
fi
if [ -n "$UB_LIST_ZONE_NAMES" -a -n "$UB_LIST_ZONE_SERVERS" ] ; then
if [ -n "$UB_LIST_ZONE_NAMES" ] && [ -n "$UB_LIST_ZONE_SERVERS" ] ; then
for server in $UB_LIST_ZONE_SERVERS ; do
if [ "$( valid_subnet_any $server )" = "not" ] ; then
case $server in
@ -521,7 +522,7 @@ unbound_zone() {
;;
stub_zone)
if [ -n "$UB_LIST_ZONE_NAMES" -a -n "$UB_LIST_ZONE_SERVERS" ] ; then
if [ -n "$UB_LIST_ZONE_NAMES" ] && [ -n "$UB_LIST_ZONE_SERVERS" ] ; then
for zonename in $UB_LIST_ZONE_NAMES ; do
{
# generate a stub-zone: or ensure short cut to authority NS
@ -542,7 +543,7 @@ unbound_zone() {
##############################################################################
unbound_conf() {
local rt_mem rt_conn rt_buff modulestring domain ifsubnet nsubnet
local rt_mem rt_conn rt_buff modulestring domain ifsubnet
{
# server: for this whole function
@ -568,7 +569,7 @@ unbound_conf() {
fi
if [ "$UB_B_DNSSEC" -gt 0 -a -f "$UB_RKEY_FILE" ] ; then
if [ "$UB_B_DNSSEC" -gt 0 ] && [ -f "$UB_RKEY_FILE" ] ; then
{
echo " auto-trust-anchor-file: $UB_RKEY_FILE"
echo
@ -594,7 +595,7 @@ unbound_conf() {
} >> $UB_CORE_CONF
if [ "$UB_D_VERBOSE" -ge 0 -a "$UB_D_VERBOSE" -le 5 ] ; then
if [ "$UB_D_VERBOSE" -ge 0 ] && [ "$UB_D_VERBOSE" -le 5 ] ; then
echo " verbosity: $UB_D_VERBOSE" >> $UB_CORE_CONF
fi
@ -788,8 +789,7 @@ unbound_conf() {
passive)
{
# Some query privacy but "strict" will break some servers
if [ "$UB_B_QRY_MINST" -gt 0 \
-a "$UB_B_QUERY_MIN" -gt 0 ] ; then
if [ "$UB_B_QRY_MINST" -gt 0 ] && [ "$UB_B_QUERY_MIN" -gt 0 ] ; then
echo " qname-minimisation: yes"
echo " qname-minimisation-strict: yes"
elif [ "$UB_B_QUERY_MIN" -gt 0 ] ; then
@ -812,8 +812,7 @@ unbound_conf() {
aggressive)
{
# Some query privacy but "strict" will break some servers
if [ "$UB_B_QRY_MINST" -gt 0 \
-a "$UB_B_QUERY_MIN" -gt 0 ] ; then
if [ "$UB_B_QRY_MINST" -gt 0 ] && [ "$UB_B_QUERY_MIN" -gt 0 ] ; then
echo " qname-minimisation: yes"
echo " qname-minimisation-strict: yes"
elif [ "$UB_B_QUERY_MIN" -gt 0 ] ; then
@ -880,7 +879,7 @@ unbound_conf() {
fi
if [ -n "$UB_LIST_NETW_LAN" -a "$UB_D_PRIV_BLCK" -gt 1 ] ; then
if [ -n "$UB_LIST_NETW_LAN" ] && [ "$UB_D_PRIV_BLCK" -gt 1 ] ; then
{
for ifsubnet in $UB_LIST_NETW_LAN ; do
case $ifsubnet in
@ -917,7 +916,7 @@ unbound_conf() {
fi
if [ "$UB_B_LOCL_SERV" -gt 0 -a -n "$UB_LIST_NETW_ALL" ] ; then
if [ "$UB_B_LOCL_SERV" -gt 0 ] && [ -n "$UB_LIST_NETW_ALL" ] ; then
{
for ifsubnet in $UB_LIST_NETW_ALL ; do
# Only respond to queries from subnets which have an interface.
@ -955,8 +954,8 @@ unbound_hostname() {
echo
} >> $UB_HOST_CONF
elif [ -n "$UB_TXT_DOMAIN" \
-a \( "$UB_D_WAN_FQDN" -gt 0 -o "$UB_D_LAN_FQDN" -gt 0 \) ] ; then
elif [ -n "$UB_TXT_DOMAIN" ] \
&& { [ "$UB_D_WAN_FQDN" -gt 0 ] || [ "$UB_D_LAN_FQDN" -gt 0 ] ; } ; then
case "$UB_D_DOMAIN_TYPE" in
deny|inform_deny|refuse|static)
{
@ -1052,7 +1051,7 @@ unbound_hostname() {
echo
} >> $UB_HOST_CONF
elif [ "$zonetype" -eq 1 -a "$UB_D_PRIV_BLCK" -eq 0 ] ; then
elif [ "$zonetype" -eq 1 ] && [ "$UB_D_PRIV_BLCK" -eq 0 ] ; then
{
echo " local-zone: $ifarpa transparent"
echo
@ -1074,7 +1073,7 @@ unbound_hostname() {
fi
if [ "$UB_LIST_NETW_LAN" -a "$UB_D_LAN_FQDN" -gt 0 ] ; then
if [ "$UB_LIST_NETW_LAN" ] && [ "$UB_D_LAN_FQDN" -gt 0 ] ; then
for ifsubnet in $UB_LIST_NETW_LAN ; do
ifaddr=${ifsubnet#*@}
ifaddr=${ifaddr%/*}
@ -1126,7 +1125,7 @@ unbound_hostname() {
fi
if [ -n "$UB_LIST_NETW_WAN" -a "$UB_D_WAN_FQDN" -gt 0 ] ; then
if [ -n "$UB_LIST_NETW_WAN" ] && [ "$UB_D_WAN_FQDN" -gt 0 ] ; then
for ifsubnet in $UB_LIST_NETW_WAN ; do
ifaddr=${ifsubnet#*@}
ifaddr=${ifaddr%/*}
@ -1183,7 +1182,7 @@ unbound_hostname() {
unbound_uci() {
local cfg="$1"
local dnsmasqpath hostnm
local hostnm
hostnm=$( uci_get system.@system[0].hostname | awk '{print tolower($0)}' )
UB_TXT_HOSTNAME=${hostnm:-thisrouter}
@ -1241,42 +1240,41 @@ unbound_uci() {
if [ "$UB_D_DHCP_LINK" = "dnsmasq" ] ; then
if [ ! -x /usr/sbin/dnsmasq -o ! -x /etc/init.d/dnsmasq ] ; then
if [ ! -x /usr/sbin/dnsmasq ] || [ ! -x /etc/init.d/dnsmasq ] ; then
UB_D_DHCP_LINK=none
else
/etc/init.d/dnsmasq enabled || UB_D_DHCP_LINK=none
fi
if [ "$UB_B_READY" -eq 0 -a "$UB_D_DHCP_LINK" = "none" ] ; then
if [ "$UB_B_READY" -eq 0 ] && [ "$UB_D_DHCP_LINK" = "none" ] ; then
logger -t unbound -s "cannot forward to dnsmasq"
fi
fi
if [ "$UB_D_DHCP_LINK" = "odhcpd" ] ; then
if [ ! -x /usr/sbin/odhcpd -o ! -x /etc/init.d/odhcpd ] ; then
if [ ! -x /usr/sbin/odhcpd ] || [ ! -x /etc/init.d/odhcpd ] ; then
UB_D_DHCP_LINK=none
else
/etc/init.d/odhcpd enabled || UB_D_DHCP_LINK=none
fi
if [ "$UB_B_READY" -eq 0 -a "$UB_D_DHCP_LINK" = "none" ] ; then
if [ "$UB_B_READY" -eq 0 ] && [ "$UB_D_DHCP_LINK" = "none" ] ; then
logger -t unbound -s "cannot receive records from odhcpd"
fi
fi
if [ "$UB_N_EDNS_SIZE" -lt 512 \
-o 4096 -lt "$UB_N_EDNS_SIZE" ] ; then
if [ "$UB_N_EDNS_SIZE" -lt 512 ] || [ 4096 -lt "$UB_N_EDNS_SIZE" ] ; then
logger -t unbound -s "edns_size exceeds range, using default"
UB_N_EDNS_SIZE=1280
fi
if [ "$UB_N_RX_PORT" -ne 53 \
-a \( "$UB_N_RX_PORT" -lt 1024 -o 10240 -lt "$UB_N_RX_PORT" \) ] ; then
if [ "$UB_N_RX_PORT" -ne 53 ] \
&& { [ "$UB_N_RX_PORT" -lt 1024 ] || [ 10240 -lt "$UB_N_RX_PORT" ] ; } ; then
logger -t unbound -s "privileged port or in 5 digits, using default"
UB_N_RX_PORT=53
fi
@ -1329,8 +1327,8 @@ unbound_include() {
fi
if [ -z "$adb_files" \
-o ! -x /usr/bin/adblock.sh -o ! -x /etc/init.d/adblock ] ; then
if [ -z "$adb_files" ] || [ ! -x /usr/bin/adblock.sh ] \
|| [ ! -x /etc/init.d/adblock ] ; then
adb_enabled=0
elif /etc/init.d/adblock enabled ; then


Loading…
Cancel
Save