mirror of https://github.com/CISOfy/lynis.git
[FILE-7524] optimized test with new function and changed warning to suggestion
This commit is contained in:
parent
0a3f42afbc
commit
3407a1dbe6
|
@ -32,27 +32,37 @@
|
|||
if [ ${SKIPTEST} -eq 0 ]; then
|
||||
Display --indent 2 --text "- Starting file permissions check"
|
||||
LogText "Test: Checking file permissions"
|
||||
FOUND=0
|
||||
for PROFILE in ${PROFILES}; do
|
||||
LogText "Using profile ${PROFILE} for baseline."
|
||||
FIND=$(${EGREPBINARY} '^permfile=|^permdir=' ${PROFILE} | ${CUTBINARY} -d= -f2 | ${CUTBINARY} -d: -f1)
|
||||
for I in ${FIND}; do
|
||||
LogText "Checking ${I}"
|
||||
CheckFilePermissions "${I}"
|
||||
LogText " Expected permissions: ${PROFILEVALUE}"
|
||||
LogText " Actual permissions: ${FILEVALUE}"
|
||||
LogText " Result: $PERMS"
|
||||
if [ "${PERMS}" = "FILE_NOT_FOUND" ]; then
|
||||
if IsVerbose; then Display --indent 4 --text "${I}" --result "${STATUS_NOT_FOUND}" --color WHITE; fi
|
||||
elif [ "${PERMS}" = "OK" ]; then
|
||||
Display --indent 4 --text "${I}" --result "${STATUS_OK}" --color GREEN
|
||||
elif [ "${PERMS}" = "BAD" ]; then
|
||||
Display --indent 4 --text "${I}" --result "${STATUS_WARNING}" --color RED
|
||||
ReportWarning ${TEST_NO} "Incorrect permissions for file ${I}"
|
||||
FILES=$(${EGREPBINARY} '^permfile=|^permdir=' ${PROFILE} | ${CUTBINARY} -d= -f2 | ${CUTBINARY} -d: -f1)
|
||||
for F in ${FILES}; do
|
||||
LogText "Test: checking file/directory ${F}"
|
||||
if [ -f "${F}" ]; then
|
||||
PERMS=$(${GREPBINARY} '^permfile=' ${PROFILE} | ${GREPBINARY} "=${F}:" | ${CUTBINARY} -d: -f2)
|
||||
if HasCorrectFilePermissions "${F}" "${PERMS}"; then
|
||||
Display --indent 4 --text "File: ${F}" --result "${STATUS_OK}" --color GREEN
|
||||
else
|
||||
Display --indent 4 --text "File: ${F}" --result "${STATUS_SUGGESTION}" --color YELLOW
|
||||
FOUND=1
|
||||
fi
|
||||
elif [ -d "${F}" ]; then
|
||||
PERMS=$(${GREPBINARY} '^permdir=' ${PROFILE} | ${GREPBINARY} "=${F}:" | ${CUTBINARY} -d: -f2)
|
||||
if HasCorrectFilePermissions "${F}" "${PERMS}"; then
|
||||
Display --indent 4 --text "Directory: ${F}" --result "${STATUS_OK}" --color GREEN
|
||||
else
|
||||
Display --indent 4 --text "Directory: ${F}" --result "${STATUS_SUGGESTION}" --color YELLOW
|
||||
FOUND=1
|
||||
fi
|
||||
else
|
||||
LogText "UNKNOWN status for file"
|
||||
if IsVerbose; then Display --indent 4 --text "${F}" --result "${STATUS_NOT_FOUND}" --color WHITE; fi
|
||||
LogText "Skipping file/directory ${F} as it does not exist on this system"
|
||||
fi
|
||||
done
|
||||
done
|
||||
if [ ${FOUND} -eq 1 ]; then
|
||||
ReportSuggestion "${TEST_NO}" "Consider restricting file permissions" "See screen output or log file" "text:Use chmod to change file permissions"
|
||||
fi
|
||||
fi
|
||||
#
|
||||
#################################################################################
|
||||
|
|
Loading…
Reference in New Issue