From 7e3c9448df1bea8344597bcc4a1732c51430bf1a Mon Sep 17 00:00:00 2001 From: Michael Boelen Date: Wed, 1 Apr 2020 16:16:31 +0200 Subject: [PATCH] [TIME-3104] search for files using find and strip potential characters that may be unexpected --- include/tests_time | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/include/tests_time b/include/tests_time index 23fd0965..7c15d0a3 100644 --- a/include/tests_time +++ b/include/tests_time @@ -163,22 +163,28 @@ fi done - # Don't run check in cron job directory on Solaris - # /etc/cron.d/FIFO is a special file and test get stuck at this file + # Notes: only test for normal files. File /etc/cron.d/FIFO on solaris is a special file and test may hang + # Linux systems may have a .placeholder file FOUND_IN_CRON=0 # Check cron jobs for I in ${CRON_DIRS}; do if [ -d ${I} ]; then if FileIsReadable ${I}; then - FIND=$(${LSBINARY} ${I} | ${GREPBINARY} -v FIFO) + FIND=$(${FINDBINARY} ${I} -type f -a ! -name ".placeholder" -print 2> /dev/null | ${SEDBINARY} 's/ /__space__/g' | ${TRBINARY} '\n' '\0' | ${TRBINARY} -cd '[:print:]\0' | ${TRBINARY} '\0' ' ') if [ -n "${FIND}" ]; then for J in ${FIND}; do - LogText "Test: checking for ntpdate or rdate in ${I}/${J}" - FIND2=$(${EGREPBINARY} "rdate|ntpdate" ${I}/${J} | ${GREPBINARY} -v "^#") - if [ -n "${FIND2}" ]; then - LogText "Positive match found: ${FIND2}" - FOUND=1; FOUND_IN_CRON=1; NTP_CONFIG_TYPE_SCHEDULED=1 + # Place back spaces if needed + J=$(echo ${J} | ${SEDBINARY} 's/__space__/ /g') + LogText "Test: checking for ntpdate or rdate in ${J}" + if FileIsReadable ${J}; then + FIND2=$(${EGREPBINARY} "rdate|ntpdate" "${J}" | ${GREPBINARY} -v "^#") + if [ -n "${FIND2}" ]; then + LogText "Positive match found: ${FIND2}" + FOUND=1; FOUND_IN_CRON=1; NTP_CONFIG_TYPE_SCHEDULED=1 + fi + else + LogText "Result: could not test in file '${J}' as it is not readable" fi done else