diff options
author | Michael Boelen <michael.boelen@cisofy.com> | 2020-04-01 17:16:31 +0300 |
---|---|---|
committer | Michael Boelen <michael.boelen@cisofy.com> | 2020-04-01 17:16:31 +0300 |
commit | 7e3c9448df1bea8344597bcc4a1732c51430bf1a (patch) | |
tree | 36f4550a5f8f0d9adbc653ac8e9ebb1a289400e0 /include/tests_time | |
parent | 8c501c7aa8d6c2f9ef739a118285f66e888e72f1 (diff) |
[TIME-3104] search for files using find and strip potential characters that may be unexpected
Diffstat (limited to 'include/tests_time')
-rw-r--r-- | include/tests_time | 22 |
1 files 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 |