From df7c6257a56d54a001859c209b92f7e74589cd13 Mon Sep 17 00:00:00 2001 From: Simon Biewald Date: Thu, 9 Jul 2020 18:41:09 +0200 Subject: compare correct stuff in openntpd tests I accidentially compared rubbish in the openntpd tests, thus they were not executed at all. Additionally, == was used instead of =. --- include/tests_time | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/tests_time b/include/tests_time index 7c15d0a3..79e7aa2e 100644 --- a/include/tests_time +++ b/include/tests_time @@ -532,7 +532,7 @@ # # Test : TIME-3180 # Description : Report if ntpctl cannot communicate with OpenNTPD - if [ "${NTPD_RUNNING}" -eq 1 ] && [ -n "${NTPCTLBINARY}" ] && [ "${NTP_DAEMON}" == "openntpd" ]; then + if [ "${NTP_DAEMON_RUNNING}" -eq 1 ] && [ -n "${NTPCTLBINARY}" ] && [ "${NTP_DAEMON}" = "openntpd" ]; then PREQS_MET="YES" else PREQS_MET="NO" @@ -548,7 +548,7 @@ # # Test : TIME-3181 # Description : Check status of OpenNTPD time synchronisation - if [ "${NTPD_RUNNING}" -eq 1 ] && [ -n "${NTPCTLBINARY}" ] && [ "${NTP_DAEMON}" == "openntpd" ] && [ "${OPENNTPD_COMMUNICATION}" -eq 1 ]; then + if [ "${NTP_DAEMON_RUNNING}" -eq 1 ] && [ -n "${NTPCTLBINARY}" ] && [ "${NTP_DAEMON}" = "openntpd" ] && [ "${OPENNTPD_COMMUNICATION}" -eq 1 ]; then PREQS_MET="YES" else PREQS_MET="NO" @@ -567,7 +567,7 @@ # Test : TIME-3182 # Description : Check OpenNTPD has working peers - if [ "${NTPD_RUNNING}" -eq 1 ] && [ -n "${NTPCTLBINARY}" ] && [ "${NTP_DAEMON}" == "openntpd" ] && [ "${OPENNTPD_COMMUNICATION}" -eq 1 ]; then + if [ "${NTP_DAEMON_RUNNING}" -eq 1 ] && [ -n "${NTPCTLBINARY}" ] && [ "${NTP_DAEMON}" = "openntpd" ] && [ "${OPENNTPD_COMMUNICATION}" -eq 1 ]; then PREQS_MET="YES" else PREQS_MET="NO" -- cgit v1.2.3 From 9107867fa1307a7ec65f250efbc2440665078fb0 Mon Sep 17 00:00:00 2001 From: Simon Biewald Date: Thu, 9 Jul 2020 18:57:01 +0200 Subject: use correct regex and comparison to match peers --- include/tests_time | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/tests_time b/include/tests_time index 79e7aa2e..eee5cbfc 100644 --- a/include/tests_time +++ b/include/tests_time @@ -576,8 +576,8 @@ Register --test-no TIME-3182 --preqs-met "${PREQS_MET}" --weight L --network NO --category security --description "Check OpenNTPD has working peers" if [ ${SKIPTEST} -eq 0 ]; then # Format is "xx/yy peers valid, ..." - FIND=$(${NTPCTLBINARY} -s status | ${EGREPBINARY} -o "[0-9]{1,4}/" | ${EGREPBINARY} -o "[0-9]{1,4}" ) - if [ -n "${FIND}" ] || [ "${FIND}" -eq 0 ]; then + FIND=$(${NTPCTLBINARY} -s status | ${EGREPBINARY} -o '[0-9]+/[0-9]+' | ${CUTBINARY} -d '/' -f 1) + if [ -z "${FIND}" ] || [ "${FIND}" -eq 0 ]; then ReportWarning "${TEST_NO}" "OpenNTPD has no peers" "${NTPCTLBINARY} -s status" fi fi -- cgit v1.2.3 From 092fe08c400a0b7eb4f6ace7ac4ebaf6c4c9bec6 Mon Sep 17 00:00:00 2001 From: Simon Biewald Date: Fri, 10 Jul 2020 00:40:36 +0200 Subject: shellcheck: check exit code directly --- include/tests_time | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/include/tests_time b/include/tests_time index eee5cbfc..c85e2876 100644 --- a/include/tests_time +++ b/include/tests_time @@ -86,9 +86,8 @@ # Reason: openntpd syncs only if large time corrections are not required or -s is passed. # This might be not intended by the administrator (-s is NOT the default!) FIND=$(${PSBINARY} ax | ${GREPBINARY} "ntpd: ntp engine" | ${GREPBINARY} -v "grep") - ${NTPCTLBINARY} -s status > /dev/null 2> /dev/null # Status code 0 is when communication over the socket is successfull - if [ "$?" -eq 0 ]; then + if ${NTPCTLBINARY} -s status > /dev/null 2> /dev/null; then FOUND=1; NTP_DAEMON_RUNNING=1; NTP_CONFIG_TYPE_DAEMON=1; NTP_DAEMON="openntpd" LogText "result: found openntpd (method: ntpctl)" OPENNTPD_COMMUNICATION=1 -- cgit v1.2.3 From 7ba220811f309ae69751821858e5b39bbc5c3cb7 Mon Sep 17 00:00:00 2001 From: Simon Biewald Date: Fri, 10 Jul 2020 00:41:45 +0200 Subject: use = instead of == --- include/tests_time | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/tests_time b/include/tests_time index c85e2876..153397e2 100644 --- a/include/tests_time +++ b/include/tests_time @@ -100,7 +100,7 @@ LogText "result: running openntpd not found, but ntpctl is instaalled" fi - if [ "${NTP_DAEMON}" == "openntpd" ]; then + if [ "${NTP_DAEMON}" = "openntpd" ]; then Display --indent 2 --text "- NTP daemon found: OpenNTPD" --result "${STATUS_FOUND}" --color GREEN fi fi -- cgit v1.2.3