mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-09-02 07:35:26 +00:00
Handle non-zero return codes in rpz test
This commit is contained in:
@@ -89,15 +89,15 @@ digcmd () {
|
|||||||
-e '/-b/!s/@\([^ ]*\)/@\1 -b\1/' \
|
-e '/-b/!s/@\([^ ]*\)/@\1 -b\1/' \
|
||||||
-e '/+n?o?auth/!s/.*/+noauth &/'`
|
-e '/+n?o?auth/!s/.*/+noauth &/'`
|
||||||
#echo_i "dig $digcmd_args 1>&2
|
#echo_i "dig $digcmd_args 1>&2
|
||||||
$DIG $digcmd_args
|
$DIG $digcmd_args || return
|
||||||
}
|
}
|
||||||
|
|
||||||
# set DIGNM=file name for dig output
|
# set DIGNM=file name for dig output
|
||||||
GROUP_NM=
|
GROUP_NM=
|
||||||
TEST_NUM=0
|
TEST_NUM=0
|
||||||
make_dignm () {
|
make_dignm () {
|
||||||
TEST_NUM=`expr $TEST_NUM : '\([0-9]*\).*'` # trim '+' characters
|
TEST_NUM=$(expr $TEST_NUM : '\([0-9]*\).*' || true) # trim '+' characters
|
||||||
TEST_NUM=`expr $TEST_NUM + 1`
|
TEST_NUM=$((TEST_NUM + 1))
|
||||||
DIGNM=dig.out$GROUP_NM-$TEST_NUM
|
DIGNM=dig.out$GROUP_NM-$TEST_NUM
|
||||||
while test -f $DIGNM; do
|
while test -f $DIGNM; do
|
||||||
TEST_NUM="$TEST_NUM+"
|
TEST_NUM="$TEST_NUM+"
|
||||||
@@ -116,7 +116,7 @@ setret () {
|
|||||||
# $2=DNS server and client IP address
|
# $2=DNS server and client IP address
|
||||||
get_sn() {
|
get_sn() {
|
||||||
SOA=`$DIG -p ${PORT} +short +norecurse soa "$1" "@$2" "-b$2"`
|
SOA=`$DIG -p ${PORT} +short +norecurse soa "$1" "@$2" "-b$2"`
|
||||||
SN=`expr "$SOA" : '[^ ]* [^ ]* \([^ ]*\) .*'`
|
SN=$(expr "$SOA" : '[^ ]* [^ ]* \([^ ]*\) .*' || true)
|
||||||
test "$SN" != "" && return
|
test "$SN" != "" && return
|
||||||
echo_i "no serial number from \`dig -p ${PORT} soa $1 @$2\` in \"$SOA\""
|
echo_i "no serial number from \`dig -p ${PORT} soa $1 @$2\` in \"$SOA\""
|
||||||
exit 1
|
exit 1
|
||||||
@@ -136,7 +136,7 @@ get_sn_fast () {
|
|||||||
# $2=DNS server IP address
|
# $2=DNS server IP address
|
||||||
FZONES=`sed -n -e 's/^zone "\(.*\)".*\(10.53.0..\).*/Z=\1;M=\2/p' dnsrps.zones`
|
FZONES=`sed -n -e 's/^zone "\(.*\)".*\(10.53.0..\).*/Z=\1;M=\2/p' dnsrps.zones`
|
||||||
dnsrps_loaded() {
|
dnsrps_loaded() {
|
||||||
test "$mode" = dnsrps || return
|
test "$mode" = dnsrps || return 0
|
||||||
n=0
|
n=0
|
||||||
for V in $FZONES; do
|
for V in $FZONES; do
|
||||||
eval "$V"
|
eval "$V"
|
||||||
@@ -238,7 +238,7 @@ restart () {
|
|||||||
# $1=server and irrelevant args
|
# $1=server and irrelevant args
|
||||||
# $2=error message
|
# $2=error message
|
||||||
ckalive () {
|
ckalive () {
|
||||||
CKALIVE_NS=`expr "$1" : '.*@ns\([1-9]\).*'`
|
CKALIVE_NS=$(expr "$1" : '.*@ns\([1-9]\).*' || true)
|
||||||
if test -z "$CKALIVE_NS"; then
|
if test -z "$CKALIVE_NS"; then
|
||||||
CKALIVE_NS=3
|
CKALIVE_NS=3
|
||||||
fi
|
fi
|
||||||
@@ -248,7 +248,7 @@ ckalive () {
|
|||||||
setret "$2"
|
setret "$2"
|
||||||
# restart the server to avoid stalling waiting for it to stop
|
# restart the server to avoid stalling waiting for it to stop
|
||||||
restart $CKALIVE_NS "rebuild-bl-rpz"
|
restart $CKALIVE_NS "rebuild-bl-rpz"
|
||||||
return 1
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
resetstats () {
|
resetstats () {
|
||||||
@@ -447,7 +447,7 @@ here () {
|
|||||||
DROPPED='^;; no servers could be reached'
|
DROPPED='^;; no servers could be reached'
|
||||||
drop () {
|
drop () {
|
||||||
make_dignm
|
make_dignm
|
||||||
digcmd $* >$DIGNM
|
digcmd $* >$DIGNM || true
|
||||||
if grep "$DROPPED" $DIGNM >/dev/null; then
|
if grep "$DROPPED" $DIGNM >/dev/null; then
|
||||||
clean_result ${DIGNM}*
|
clean_result ${DIGNM}*
|
||||||
return 0
|
return 0
|
||||||
@@ -488,6 +488,8 @@ make_proto_nodata() {
|
|||||||
# ensure that the fast-expire zone is populated before we begin testing
|
# ensure that the fast-expire zone is populated before we begin testing
|
||||||
$RNDCCMD $ns3 retransfer fast-expire
|
$RNDCCMD $ns3 retransfer fast-expire
|
||||||
|
|
||||||
|
native=0
|
||||||
|
dnsrps=0
|
||||||
for mode in native dnsrps; do
|
for mode in native dnsrps; do
|
||||||
status=0
|
status=0
|
||||||
case ${mode} in
|
case ${mode} in
|
||||||
@@ -823,7 +825,7 @@ EOF
|
|||||||
|
|
||||||
# look for complaints from lib/dns/rpz.c and bin/name/query.c
|
# look for complaints from lib/dns/rpz.c and bin/name/query.c
|
||||||
for runfile in ns*/named.run; do
|
for runfile in ns*/named.run; do
|
||||||
EMSGS=`nextpart $runfile | grep -E -l 'invalid rpz|rpz.*failed'`
|
EMSGS=$(nextpart $runfile | grep -E -l 'invalid rpz|rpz.*failed' || true)
|
||||||
if test -n "$EMSGS"; then
|
if test -n "$EMSGS"; then
|
||||||
setret "error messages in $runfile starting with:"
|
setret "error messages in $runfile starting with:"
|
||||||
grep -E 'invalid rpz|rpz.*failed' ns*/named.run | \
|
grep -E 'invalid rpz|rpz.*failed' ns*/named.run | \
|
||||||
@@ -1021,6 +1023,6 @@ EOF
|
|||||||
*) echo_i "invalid test mode";;
|
*) echo_i "invalid test mode";;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
status=`expr ${native:-0} + ${dnsrps:-0}`
|
status=$((native + dnsrps))
|
||||||
|
|
||||||
[ $status -eq 0 ] || exit 1
|
[ $status -eq 0 ] || exit 1
|
||||||
|
Reference in New Issue
Block a user