From: Michal Nowak Date: Mon, 20 Jan 2020 17:06:16 +0000 (+0100) Subject: mkeys: Prevent failing grep invocations X-Git-Tag: v9.14.11~35^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=377e48e89711cbd8a5a58f1d59d659dfab8a520c;p=thirdparty%2Fbind9.git mkeys: Prevent failing grep invocations Some 'grep' invocations were not guarded from interrupting the test prematurely, e.g. when no text was matched. (cherry picked from commit 6c4a2b602042d83450f0af50c25225efa8698750) --- diff --git a/bin/tests/system/mkeys/tests.sh b/bin/tests/system/mkeys/tests.sh index e33fab0504f..812a32bdecf 100644 --- a/bin/tests/system/mkeys/tests.sh +++ b/bin/tests/system/mkeys/tests.sh @@ -186,7 +186,7 @@ n=$((n+1)) echo_i "remove untrusted standby key, check timer restarts ($n)" ret=0 mkeys_sync_on 2 || ret=1 -t1=$(grep "trust pending" ns2/managed-keys.bind) +t1=$(grep "trust pending" ns2/managed-keys.bind) || true $SETTIME -D now -K ns1 "$standby1" > /dev/null mkeys_loadkeys_on 1 || ret=1 # Less than a second may have passed since the last time ns2 received a @@ -196,7 +196,7 @@ mkeys_loadkeys_on 1 || ret=1 sleep 1 mkeys_refresh_on 2 || ret=1 mkeys_sync_on 2 || ret=1 -t2=$(grep "trust pending" ns2/managed-keys.bind) +t2=$(grep "trust pending" ns2/managed-keys.bind) || true # trust pending date must be different [ -n "$t2" ] || ret=1 [ "$t1" = "$t2" ] && ret=1 @@ -234,7 +234,7 @@ count=$(grep -c "remove at" rndc.out.$n) || true count=$(grep -c "trust pending" rndc.out.$n) || true [ "$count" -eq 1 ] || ret=1 # pending date moved forward for the standby key -t2=$(grep "trust pending" ns2/managed-keys.bind) +t2=$(grep "trust pending" ns2/managed-keys.bind) || true [ -n "$t2" ] || ret=1 [ "$t1" = "$t2" ] && ret=1 if [ $ret != 0 ]; then echo_i "failed"; fi @@ -268,7 +268,7 @@ count=$(grep -c "remove at" rndc.out.$n) || true count=$(grep -c "trust pending" rndc.out.$n) || true [ "$count" -eq 1 ] || ret=1 # pending date moved forward for the standby key -t2=$(grep "trust pending" ns2/managed-keys.bind) +t2=$(grep "trust pending" ns2/managed-keys.bind) || true [ -n "$t2" ] || ret=1 [ "$t1" = "$t2" ] && ret=1 if [ $ret != 0 ]; then echo_i "failed"; fi @@ -306,7 +306,7 @@ count=$(grep -c "remove at" rndc.out.$n) || true count=$(grep -c "trust pending" rndc.out.$n) || true [ "$count" -eq 1 ] || ret=1 # pending date moved forward for the standby key -t2=$(grep "trust pending" ns2/managed-keys.bind) +t2=$(grep "trust pending" ns2/managed-keys.bind) || true [ -n "$t2" ] || ret=1 [ "$t1" = "$t2" ] && ret=1 if [ $ret != 0 ]; then echo_i "failed"; fi @@ -585,7 +585,7 @@ ret=0 # set using -T mkeytimers). mkeys_refresh_on 2 || ret=1 mkeys_status_on 2 > rndc.out.1.$n 2>&1 || ret=1 -t1=$(grep 'next refresh:' rndc.out.1.$n) +t1=$(grep 'next refresh:' rndc.out.1.$n) || true $PERL $SYSTEMTESTTOP/stop.pl --use-rndc --port "${CONTROLPORT}" mkeys ns1 rm -f ns1/root.db.signed.jnl cp ns1/root.db ns1/root.db.signed @@ -608,7 +608,7 @@ count=$(grep -c "trust" rndc.out.2.$n) || true [ "$count" -eq 1 ] || ret=1 count=$(grep -c "trusted since" rndc.out.2.$n) || true [ "$count" -eq 1 ] || ret=1 -t2=$(grep 'next refresh:' rndc.out.2.$n) +t2=$(grep 'next refresh:' rndc.out.2.$n) || true [ "$t1" = "$t2" ] && ret=1 if [ $ret != 0 ]; then echo_i "failed"; fi status=$((status+ret)) @@ -619,7 +619,7 @@ ret=0 # Refresh keys first to prevent previous checks from influencing this one mkeys_refresh_on 2 || ret=1 mkeys_status_on 2 > rndc.out.1.$n 2>&1 || ret=1 -t1=$(grep 'next refresh:' rndc.out.1.$n) +t1=$(grep 'next refresh:' rndc.out.1.$n) || true $PERL $SYSTEMTESTTOP/stop.pl --use-rndc --port "${CONTROLPORT}" mkeys ns1 rm -f ns1/root.db.signed.jnl cat ns1/K*.key >> ns1/root.db.signed @@ -646,7 +646,7 @@ count=$(grep -c "trust" rndc.out.2.$n) || true [ "$count" -eq 1 ] || ret=1 count=$(grep -c "trusted since" rndc.out.2.$n) || true [ "$count" -eq 1 ] || ret=1 -t2=$(grep 'next refresh:' rndc.out.2.$n) +t2=$(grep 'next refresh:' rndc.out.2.$n) || true [ "$t1" = "$t2" ] && ret=1 if [ $ret != 0 ]; then echo_i "failed"; fi status=$((status+ret)) @@ -696,7 +696,7 @@ echo_i "check that trust-anchor-telemetry queries contain the correct key ($n)" ret=0 # convert the hexadecimal key from the TAT query into decimal and # compare against the known key. -tathex=$(grep "query '_ta-[0-9a-f][0-9a-f]*/NULL/IN' approved" ns1/named.run | awk '{print $6; exit 0}' | sed -e 's/(_ta-\([0-9a-f][0-9a-f]*\)):/\1/') +tathex=$(grep "query '_ta-[0-9a-f][0-9a-f]*/NULL/IN' approved" ns1/named.run | awk '{print $6; exit 0}' | sed -e 's/(_ta-\([0-9a-f][0-9a-f]*\)):/\1/') || true tatkey=$($PERL -e 'printf("%d\n", hex(@ARGV[0]));' "$tathex") realkey=$(rndccmd 10.53.0.2 secroots - | sed -n 's#.*SHA256/\([0-9][0-9]*\) ; .*managed.*#\1#p') [ "$tatkey" -eq "$realkey" ] || ret=1