mirror of
https://github.com/CISOfy/lynis.git
synced 2025-07-28 16:24:13 +02:00
[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
|
if [ ${SKIPTEST} -eq 0 ]; then
|
||||||
Display --indent 2 --text "- Starting file permissions check"
|
Display --indent 2 --text "- Starting file permissions check"
|
||||||
LogText "Test: Checking file permissions"
|
LogText "Test: Checking file permissions"
|
||||||
|
FOUND=0
|
||||||
for PROFILE in ${PROFILES}; do
|
for PROFILE in ${PROFILES}; do
|
||||||
LogText "Using profile ${PROFILE} for baseline."
|
LogText "Using profile ${PROFILE} for baseline."
|
||||||
FIND=$(${EGREPBINARY} '^permfile=|^permdir=' ${PROFILE} | ${CUTBINARY} -d= -f2 | ${CUTBINARY} -d: -f1)
|
FILES=$(${EGREPBINARY} '^permfile=|^permdir=' ${PROFILE} | ${CUTBINARY} -d= -f2 | ${CUTBINARY} -d: -f1)
|
||||||
for I in ${FIND}; do
|
for F in ${FILES}; do
|
||||||
LogText "Checking ${I}"
|
LogText "Test: checking file/directory ${F}"
|
||||||
CheckFilePermissions "${I}"
|
if [ -f "${F}" ]; then
|
||||||
LogText " Expected permissions: ${PROFILEVALUE}"
|
PERMS=$(${GREPBINARY} '^permfile=' ${PROFILE} | ${GREPBINARY} "=${F}:" | ${CUTBINARY} -d: -f2)
|
||||||
LogText " Actual permissions: ${FILEVALUE}"
|
if HasCorrectFilePermissions "${F}" "${PERMS}"; then
|
||||||
LogText " Result: $PERMS"
|
Display --indent 4 --text "File: ${F}" --result "${STATUS_OK}" --color GREEN
|
||||||
if [ "${PERMS}" = "FILE_NOT_FOUND" ]; then
|
else
|
||||||
if IsVerbose; then Display --indent 4 --text "${I}" --result "${STATUS_NOT_FOUND}" --color WHITE; fi
|
Display --indent 4 --text "File: ${F}" --result "${STATUS_SUGGESTION}" --color YELLOW
|
||||||
elif [ "${PERMS}" = "OK" ]; then
|
FOUND=1
|
||||||
Display --indent 4 --text "${I}" --result "${STATUS_OK}" --color GREEN
|
fi
|
||||||
elif [ "${PERMS}" = "BAD" ]; then
|
elif [ -d "${F}" ]; then
|
||||||
Display --indent 4 --text "${I}" --result "${STATUS_WARNING}" --color RED
|
PERMS=$(${GREPBINARY} '^permdir=' ${PROFILE} | ${GREPBINARY} "=${F}:" | ${CUTBINARY} -d: -f2)
|
||||||
ReportWarning ${TEST_NO} "Incorrect permissions for file ${I}"
|
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
|
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
|
fi
|
||||||
done
|
done
|
||||||
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
|
fi
|
||||||
#
|
#
|
||||||
#################################################################################
|
#################################################################################
|
||||||
|
Loading…
x
Reference in New Issue
Block a user