mirror of https://github.com/CISOfy/lynis.git
Improve function to search for kernels on disk and checking results
This commit is contained in:
parent
f5399981c2
commit
4fa5139bfa
|
@ -490,21 +490,24 @@
|
|||
logtext "Result: /boot/vmlinuz not on disk, trying to find /boot/vmlinuz*"
|
||||
# Extra current kernel version and replace dashes to allow numeric sort later on
|
||||
MYKERNEL=`uname -r | sed 's/\.[a-z].*.//g' | sed 's/-[a-z].*.//g' | sed 's/-/./g'`
|
||||
logtext "Result: using ${MYKERNEL} as my kernel version (stripped)"
|
||||
FIND=`ls /boot/vmlinuz* 2> /dev/null`
|
||||
if [ ! "${FIND}" = "" ]; then
|
||||
# Display kernels, extract version numbers and sort them numeric per column (up to 6 numbers)
|
||||
KERNELS=`ls /boot/vmlinuz* | sed 's/vmlinuz-//' | sed 's/\.[a-z].*.//g' | sed 's/-[a-z].*.//g' | sed 's./boot/..' | sed 's/-/./g' | sort -n -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 -k6,6 -t \.`
|
||||
|
||||
elif [ ! `ls /boot/kernel* 2> /dev/null` = "" ]; then
|
||||
|
||||
# Display kernels, extract version numbers and sort them numeric per column (up to 6 numbers)
|
||||
# Examples:
|
||||
# /boot/kernel-genkernel-x86_64-3.14.14-gentoo
|
||||
KERNELS=`ls /boot/kernel* | awk -F- '{ if ($2=="genkernel") { print $4 }}' | grep "^[0-9]" | sort -n -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 -k6,6 -t \.`
|
||||
logtext "Result: using ${MYKERNEL} as my kernel version (stripped)"
|
||||
else
|
||||
ReportException "${TEST_NO}:2" "Can not find any vmlinuz or kernel files in /boot, which is unexpected"
|
||||
fi
|
||||
if [ ! "${KERNELS}" = "" ]; then
|
||||
FOUND_KERNEL=0
|
||||
for I in ${KERNELS}; do
|
||||
if [ ${FOUND_KERNEL} -eq 1 ]; then
|
||||
# Check if we already found a kernel and it is not equal to what we run (e.g. double versions may exist)
|
||||
if [ ${FOUND_KERNEL} -eq 1 -a ! "${MYKERNEL}" = "${I}" ]; then
|
||||
logtext "Result: found a kernel (${I}) later than running one (${MYKERNEL})"
|
||||
REBOOT_NEEDED=1
|
||||
fi
|
||||
|
@ -525,9 +528,7 @@
|
|||
REBOOT_NEEDED=0
|
||||
fi
|
||||
fi
|
||||
else
|
||||
ReportException "${TEST_NO}:2" "Can not find any vmlinuz or kernel files in /boot, which is unexpected"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
# No files in /boot
|
||||
else
|
||||
|
|
Loading…
Reference in New Issue