git.lirion.de

Of git, get, and gud

summaryrefslogtreecommitdiffstats
path: root/nagios-plugins-contrib-24.20190301~bpo9+1/debian/patches/dsa/check_running_kernel_jessie_centos_fix
blob: e850e2f981a9257f61f5e668cb10d2ab40d070db (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
--- a/dsa/checks/dsa-check-running-kernel
+++ b/dsa/checks/dsa-check-running-kernel
 _æ_  _æ_  -131,6 +131,11  _æ_  _æ_ 
 	filter="$3"
 	hdroff="$4"
 
+	if ! which $filter >/dev/null; then
+		echo "UNKNOWN: filter command '$filter' missing, perhaps install xz-utils?" >&2
+		exit $UNKNOWN
+	fi
+
 	get_offset "$image" $header | head -n 5 | while read off; do
 		(if [ "$off" != 0 ]; then
 		   dd ibs="$((off+hdroff))" skip=1 count=0
 _æ_  _æ_  -182,9 +187,8  _æ_  _æ_ 
 
 searched=""
 for on_disk in \
-	"/boot/vmlinuz-`uname -r`"\
-	"/boot/vmlinux-`uname -r`"\
-	"/boot/kfreebsd-`uname -r`.gz"; do
+	$([ -f "/boot/vmlinuz-$(uname -r)" ] && find /boot/ -name 'vmlinuz*' -and -name "vmlinuz-$(uname -r)" -or -name 'vmlinuz*' -and -newer "/boot/vmlinuz-$(uname -r)" | sort) \
+	$([ -f "/boot/kfreebsd-$(uname -r).gz" ] && find /boot/ -name 'kfreebsd*' -and -name "kfreebsd-$(uname -r).gz" -or -name 'kfreebsd*' -and -newer "/boot/kfreebsd-$(uname -r).gz" | sort); do
 
 	if [ -e "$on_disk" ]; then
 		if [ -z "$STRINGS" ]; then
 _æ_  _æ_  -196,12 +200,12  _æ_  _æ_ 
 			if [ -x /usr/bin/lsb_release ] ; then
 				vendor=$(lsb_release -i -s)
 				if [ -n "$vendor" ] && [ "xDebian" != "x$vendor" ] ; then
-					on_disk_version=$( echo $on_disk_version|sed -e "s/ ($vendor [[:alnum:]\.-]\+ [[:alnum:]\.]\+)//")
+					on_disk_version=$( echo $on_disk_version|sed -e "s/ ($vendor [[:alnum:]\.-]\+ [[:alnum:]\.-]\+)//")
 				fi
 			fi
-			[ -z "$on_disk_version" ] || break
+			[ -z "$on_disk_version" ] || continue
 			on_disk_version="`cat "$on_disk" | $STRINGS | grep 'Linux version' | head -n1`"
-			[ -z "$on_disk_version" ] || break
+			[ -z "$on_disk_version" ] || continue
 
 			echo "UNKNOWN: Failed to get a version string from image $on_disk"
 			exit $UNKNOWN