This file is indexed.

/usr/sbin/kernel-helper is in grub 0.97-29ubuntu68.

This file is owned by root:root, with mode 0o755.

The actual contents of the file can be viewed below.

 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#!/bin/bash -e

# -i : Only create symlinks for the running kernel if a last-good-boot doesn't
#      already exist.
# -c : Create symlinks for a newly booted kernel. Usually called from an
#      init script at the very start of the boot process.

kver=$(uname -r)
mdir="/lib/modules/$kver"
lastkdir="/boot/last-good-boot"
lastmdir="/lib/modules/last-good-boot"
fail_exit_val=1

if test -e /etc/default/kernel-helper-rc; then
	. /etc/default/kernel-helper-rc

	if [ -n "$DISABLE_LAST_GOOD" ]; then
		# Just quit silently
		exit
	fi
fi

usage() {
	echo "Usage: $(basename $0) -i|-u" 1>&2
	echo "  -i Create initial last-good-boot" 1>&2
	echo "  -u Update last-good-boot" 1>&2
	echo 1>&2
	exit 1
}

[ "$#" -ne 1 ] && usage
case "$1" in
-i)
	# Create initial last-good-boot.
	if [ -d "$lastkdir" ] && [ -d "$lastmdir" ]; then
		# Quit silently, a last-good-boot already exists.
		exit 0
	fi
	# No fail here
	fail_exit_val=0
	;;
-u)
	# Update last-good-boot.
	;;
*)
	usage
	;;
esac

if [ "$(id -u)" -ne 0 ]; then
	echo "$(basename $0): Need to be root to run this command" 2>&1
	exit 1
fi

if grep -q last-good-boot /proc/cmdline; then
	# Quit silently. Don't update when booting the last good kernel
	exit 0
fi

if [ ! -e "/boot/vmlinuz-$kver" -a ! -e "/boot/$kver/vmlinuz" ]; then
	# Fail, since we cannot do anything here
	exit $fail_exit_val
fi

rm -rf "${lastkdir}.tmp" "${lastmdir}.tmp"

install -d "${lastkdir}.tmp" "${lastmdir}.tmp"

if [ -e "/boot/$kver/vmlinuz" ]; then
	ln -t "${lastkdir}.tmp" /boot/$kver/{vmlinuz,initrd.img,System.map}
else
	ln /boot/vmlinuz-$kver "${lastkdir}.tmp/vmlinuz"
	ln /boot/initrd.img-$kver "${lastkdir}.tmp/initrd.img"
	ln /boot/System.map-$kver "${lastkdir}.tmp/System.map"
fi

cat /proc/cmdline > "${lastkdir}.tmp/cmdline"
echo $kver > ${lastkdir}.tmp/version

if [ -e /proc/version_signature ]; then
	cat /proc/version_signature > ${lastkdir}.tmp/version_signature
fi

(cd $mdir && find . -print | cpio --pass-through -d --link \
	"${lastmdir}.tmp") > /dev/null 2>&1

# Munge modules.dep
rm -f "${lastmdir}.tmp/modules.dep"
cat $mdir/modules.dep | sed -e \
	"s#/lib/modules/$kver/#/lib/modules/last-good-boot/#g" > \
	"${lastmdir}.tmp/modules.dep"

rm -rf "${lastkdir}" "${lastmdir}"
mv "${lastkdir}.tmp" "${lastkdir}"
mv "${lastmdir}.tmp" "${lastmdir}"

# We must now run update-grub to get the right cmdline in place
[ ! -e /boot/grub ] ||  update-grub 2>/dev/null