mirror of https://github.com/CISOfy/lynis.git
[SCHD-7704] permission checks and minor code cleanups
This commit is contained in:
parent
320a397772
commit
6083f6d9ff
|
@ -36,7 +36,7 @@
|
|||
Register --test-no SCHD-7702 --weight L --network NO --category security --description "Check status of cron daemon"
|
||||
if [ ${SKIPTEST} -eq 0 ]; then
|
||||
FIND=$(${PSBINARY} aux | ${EGREPBINARY} "( cron$|/cron(d)? )")
|
||||
if [ "${FIND}" = "" ]; then
|
||||
if [ -z "${FIND}" ]; then
|
||||
LogText "Result: no cron daemon found"
|
||||
else
|
||||
LogText "Result: cron daemon running"
|
||||
|
@ -73,8 +73,7 @@
|
|||
for I in ${CRON_DIRS}; do
|
||||
LogText "Test: checking directory ${I}"
|
||||
if [ -d ${I} ]; then
|
||||
FileIsReadable ${I}
|
||||
if [ ${CANREAD} -eq 1 ]; then
|
||||
if FileIsReadable ${I}; then
|
||||
LogText "Result: found directory ${I}"
|
||||
LogText "Test: searching files in ${I}"
|
||||
FIND=$(find ${I} -type f -print | ${GREPBINARY} -v ".placeholder")
|
||||
|
@ -108,8 +107,9 @@
|
|||
LogText "Test: checking directory ${I}"
|
||||
if [ -d ${I} ]; then
|
||||
LogText "Result: found directory ${I}"
|
||||
if FileIsReadable ${I}; then
|
||||
LogText "Test: searching files in ${I}"
|
||||
FIND=$(find ${I} -type f -print | ${GREPBINARY} -v ".placeholder")
|
||||
FIND=$(find ${I} -type f -print 2> /dev/null | ${GREPBINARY} -v ".placeholder")
|
||||
if [ "${FIND}" = "" ]; then
|
||||
LogText "Result: no files found in ${I}"
|
||||
else
|
||||
|
@ -122,6 +122,9 @@
|
|||
done
|
||||
LogText "Result: done with analyzing files in ${I}"
|
||||
fi
|
||||
else
|
||||
LogText "Result: directory permissions are too strict to enter it (which might be good)"
|
||||
fi
|
||||
else
|
||||
LogText "Result: directory ${I} does not exist"
|
||||
fi
|
||||
|
@ -130,23 +133,27 @@
|
|||
# /var/spool/cron/* and /var/spool/cron/crontabs/*
|
||||
# Search only in one tree, to avoid searching the tree twice
|
||||
if [ -d /var/spool/cron/crontabs ]; then
|
||||
FIND=$(find /var/spool/cron/crontabs -type f -print)
|
||||
FIND=$(${FINDBINARY} /var/spool/cron/crontabs -xdev -type f -print 2> /dev/null)
|
||||
for I in ${FIND}; do
|
||||
if FileIsReadable ${I}; then
|
||||
FindCronJob ${I}
|
||||
for J in ${sCRONJOBS}; do
|
||||
LogText "Found cronjob (/var/spool/cron/crontabs): ${I} (${J})"
|
||||
Report "cronjob[]=${I}"
|
||||
done
|
||||
fi
|
||||
done
|
||||
else
|
||||
if [ -d /var/spool/cron ]; then
|
||||
FIND=$(find /var/spool/cron -type f -print)
|
||||
for I in ${FIND}; do
|
||||
if FileIsReadable ${I}; then
|
||||
FindCronJob ${I}
|
||||
for J in ${sCRONJOBS}; do
|
||||
LogText "Found cronjob (/var/spool/cron): ${I} (${J})"
|
||||
LogText "cronjob[]=${I}"
|
||||
done
|
||||
fi
|
||||
done
|
||||
fi
|
||||
fi
|
||||
|
@ -156,11 +163,11 @@
|
|||
if [ -f /etc/anacrontab ]; then
|
||||
LogText "Test: checking anacrontab"
|
||||
sANACRONJOBS=$(${EGREPBINARY} '^([0-9@])' /etc/anacrontab | ${TRBINARY} '\t' ' ' | ${TRBINARY} -s ' ' | ${TRBINARY} ' ' ',')
|
||||
if [ ! "${sANACRONJOBS}" = "" ]; then
|
||||
if [ ! -z "${sANACRONJOBS}" ]; then
|
||||
Report "scheduler[]=anacron"
|
||||
for J in ${sANACRONJOBS}; do
|
||||
LogText "Found anacron job (/etc/anacrontab): ${J}"
|
||||
Report "cronjob[]=${J}"
|
||||
for I in ${sANACRONJOBS}; do
|
||||
LogText "Found anacron job (/etc/anacrontab): ${I}"
|
||||
Report "cronjob[]=${I}"
|
||||
done
|
||||
fi
|
||||
fi
|
||||
|
@ -187,7 +194,7 @@
|
|||
if [ ${SKIPTEST} -eq 0 ]; then
|
||||
LogText "Test: Checking atd status"
|
||||
FIND=$(${PSBINARY} ax | ${GREPBINARY} "/atd" | ${GREPBINARY} -v "grep")
|
||||
if [ ! "${FIND}" = "" ]; then
|
||||
if [ ! -z "${FIND}" ]; then
|
||||
LogText "Result: at daemon active"
|
||||
Display --indent 2 --text "- Checking atd status" --result "${STATUS_RUNNING}" --color GREEN
|
||||
ATD_RUNNING=1
|
||||
|
|
Loading…
Reference in New Issue