mirror of https://github.com/CISOfy/lynis.git
[FILE-6398] Only perform test if we know if Linux kernel is monolithic/modular
This commit is contained in:
parent
fb5b808944
commit
699ec384d2
|
@ -172,6 +172,7 @@ ETC_PATHS="/etc /usr/local/etc"
|
|||
MDATPBINARY=""
|
||||
MIN_PASSWORD_LENGTH=-1
|
||||
MONGODB_RUNNING=0
|
||||
MONOLITHIC_KERNEL_TESTED=0
|
||||
MOUNTBINARY=""
|
||||
MTREEBINARY=""
|
||||
MYSQLCLIENTBINARY=""
|
||||
|
|
|
@ -738,37 +738,42 @@
|
|||
if [ ${SKIPTEST} -eq 0 ]; then
|
||||
LogText "Test: Checking if JBD (Journal Block Device) driver is loaded"
|
||||
NOTINUSE=0
|
||||
# Cannot check if driver is loaded/present if kernel is monolithic
|
||||
if [ ${MONOLITHIC_KERNEL} -eq 0 ]; then
|
||||
JBD=$(${LSMODBINARY} | ${GREPBINARY} ^jbd)
|
||||
if [ -n "${JBD}" ]; then
|
||||
LogText "Result: JBD driver is loaded"
|
||||
INUSE=$(echo ${JBD} | ${AWKBINARY} '{if ($3 -ne 0) {print $4}}')
|
||||
if [ -n "${INUSE}" ]; then
|
||||
LogText "Result: JBD driver is in use by drivers: ${INUSE}"
|
||||
Report "JBD driver is in use by drivers: ${INUSE}"
|
||||
Display --indent 2 --text "- JBD driver loaded and in use" --result "${STATUS_OK}" --color GREEN
|
||||
# Only perform testing if we know that KRNL-5723 performed tests
|
||||
if [ ${MONOLITHIC_KERNEL_TESTED} -eq 1 ]; then
|
||||
# Cannot check if driver is loaded/present if kernel is monolithic
|
||||
if [ ${MONOLITHIC_KERNEL} -eq 0 ]; then
|
||||
JBD=$(${LSMODBINARY} | ${GREPBINARY} ^jbd)
|
||||
if [ -n "${JBD}" ]; then
|
||||
LogText "Result: JBD driver is loaded"
|
||||
INUSE=$(echo ${JBD} | ${AWKBINARY} '{if ($3 -ne 0) {print $4}}')
|
||||
if [ -n "${INUSE}" ]; then
|
||||
LogText "Result: JBD driver is in use by drivers: ${INUSE}"
|
||||
Report "JBD driver is in use by drivers: ${INUSE}"
|
||||
Display --indent 2 --text "- JBD driver loaded and in use" --result "${STATUS_OK}" --color GREEN
|
||||
else
|
||||
NOTINUSE=1
|
||||
LogText "Result: JBD driver loaded, but not in use"
|
||||
Report "JBD driver is loaded, but not in use."
|
||||
Display --indent 2 --text "- JBD driver loaded, but not in use" --result "${STATUS_SUGGESTION}" --color YELLOW
|
||||
fi
|
||||
else
|
||||
NOTINUSE=1
|
||||
LogText "Result: JBD driver loaded, but not in use"
|
||||
Report "JBD driver is loaded, but not in use."
|
||||
Display --indent 2 --text "- JBD driver loaded, but not in use" --result "${STATUS_SUGGESTION}" --color YELLOW
|
||||
NOTINUSE=2
|
||||
LogText "Result: JBD driver not loaded"
|
||||
Report "JBD driver not loaded."
|
||||
Display --indent 2 --text "- JBD driver is not loaded" --result "${STATUS_CHECK_NEEDED}" --color YELLOW
|
||||
fi
|
||||
if [ ${NOTINUSE} -eq 1 ]; then
|
||||
ReportSuggestion "${TEST_NO}" "The JBD (Journal Block Device) driver is loaded but not in use." "You are currently not using any filesystems with journaling, i.e. you have greater risk of data corruption in case of system crash."
|
||||
elif [ ${NOTINUSE} -eq 2 ]; then
|
||||
ReportSuggestion "${TEST_NO}" "The JBD (Journal Block Device) driver is not loaded." "Since boot-time, you have not been using any filesystems with journaling. Alternatively, reason could be driver is blacklisted."
|
||||
fi
|
||||
else
|
||||
NOTINUSE=2
|
||||
LogText "Result: JBD driver not loaded"
|
||||
Report "JBD driver not loaded."
|
||||
Display --indent 2 --text "- JBD driver is not loaded" --result "${STATUS_CHECK_NEEDED}" --color YELLOW
|
||||
fi
|
||||
if [ ${NOTINUSE} -eq 1 ]; then
|
||||
ReportSuggestion "${TEST_NO}" "The JBD (Journal Block Device) driver is loaded but not in use." "You are currently not using any filesystems with journaling, i.e. you have greater risk of data corruption in case of system crash."
|
||||
elif [ ${NOTINUSE} -eq 2 ]; then
|
||||
ReportSuggestion "${TEST_NO}" "The JBD (Journal Block Device) driver is not loaded." "Since boot-time, you have not been using any filesystems with journaling. Alternatively, reason could be driver is blacklisted."
|
||||
Display --indent 2 --text "- JBD driver: unable to check" --result "${STATUS_UNKNOWN}" --color YELLOW
|
||||
LogText "Kernel is monolithic - cannot check if JBD driver is part of compiled kernel."
|
||||
fi
|
||||
else
|
||||
LogText "Kernel is monolithic - cannot check if JBD driver is part of compiled kernel."
|
||||
Report "Kernel is monolithic - cannot check if JBD driver is part of compiled kernel."
|
||||
Display --indent 2 --text "- JBD driver: unable to check" --result "${STATUS_UNKNOWN}" --color RED
|
||||
Display --indent 2 --text "- JBD driver: test skipped" --result "${STATUS_UNKNOWN}" --color YELLOW
|
||||
LogText "Test skipped as the kernel type (monolithic/modular) is unknown"
|
||||
fi
|
||||
fi
|
||||
#
|
||||
|
|
|
@ -176,6 +176,7 @@
|
|||
# Checking if any modules are loaded
|
||||
FIND=$(${LSMODBINARY} | ${GREPBINARY} -v "^Module" | wc -l | ${TRBINARY} -s ' ' | ${TRBINARY} -d ' ')
|
||||
Display --indent 2 --text "- Checking kernel type" --result "${STATUS_DONE}" --color GREEN
|
||||
MONOLITHIC_KERNEL_TESTED=1
|
||||
if [ "${FIND}" = "0" ]; then
|
||||
LogText "Result: Found monolithic kernel"
|
||||
Report "linux_kernel_type=monolithic"
|
||||
|
|
Loading…
Reference in New Issue