Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/CISOfy/lynis.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Boelen <michael.boelen@cisofy.com>2021-07-21 16:26:48 +0300
committerMichael Boelen <michael.boelen@cisofy.com>2021-07-21 16:26:48 +0300
commitb0bee6584389dec8fbfe95176246b22904e861a6 (patch)
tree4242c124dd8320d7d6202ab34c0f195522468bdc /include/tests_kernel
parent9f430d0870c6ad1e181eee3ef4bf7201c954e162 (diff)
KRNL-5830: sort kernels by version (ls -v) instead of date on disk (ls -t)
Diffstat (limited to 'include/tests_kernel')
-rw-r--r--include/tests_kernel5
1 files changed, 3 insertions, 2 deletions
diff --git a/include/tests_kernel b/include/tests_kernel
index 19ed4dae..610fd325 100644
--- a/include/tests_kernel
+++ b/include/tests_kernel
@@ -673,9 +673,9 @@
LogText "Result: found ${ROOTDIR}boot/vmlinuz-lts"
FOUND_VMLINUZ=${ROOTDIR}boot/vmlinuz-lts
else
- # Match on items like /boot/vm5.3.7 or /boot/vmlinuz-5.3.7-1-default. Get newest file (ls -t and pipe into head)
+ # Match on items like /boot/vm5.3.7 or /boot/vmlinuz-5.3.7-1-default. Sort based on versions (-v) and then find the last item
# Note: ignore a rescue kernel (e.g. CentOS)
- FOUND_VMLINUZ=$(${LSBINARY} -t ${ROOTDIR}boot/vm[l0-9]* 2> /dev/null | ${GREPBINARY} -v '\-rescue\-' | ${HEADBINARY} -1)
+ FOUND_VMLINUZ=$(${LSBINARY} -v ${ROOTDIR}boot/vm[l0-9]* 2> /dev/null | ${GREPBINARY} -v '\-rescue\-' | ${TAILBINARY} -1)
LogText "Result: found ${FOUND_VMLINUZ}"
fi
@@ -749,6 +749,7 @@
done
# Display kernels, extract version numbers and ${SORTBINARY} them numeric per column (up to 6 numbers)
# Ignore rescue images. Remove generic. and huge. for Slackware machines
+ # TODO: see if this can be simplified using ls -v sorting
LogText "Action: checking relevant kernels"
KERNELS=$(${LSBINARY} /boot/vmlinuz* | ${GREPBINARY} -v rescue | ${SEDBINARY} 's/vmlinuz-//' | ${SEDBINARY} 's/generic.//' | ${SEDBINARY} 's/huge.//' | ${SEDBINARY} 's/\.[a-z].*.//g' | ${SEDBINARY} 's/-[a-z].*.//g' | ${SEDBINARY} 's./boot/..' | ${SEDBINARY} 's/-/./g' | ${SORTBINARY} -n -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 -k6,6 -t \.)
KERNELS_ONE_LINE=$(${ECHOCMD} ${KERNELS} | ${TRBINARY} '\n' ' ')