This file is indexed.

/usr/share/lupin-support/grub-mkimage is in lupin-support 0.55.

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
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
#! /bin/sh -e

# grub-install helper script for lupin. This script will upgrade
# the grub bootloader installed on the host (wubildr).
#
# Copyright (C) Agostino Russo
#
# Lupin is free software; you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as
# published by the Free Software Foundation; either version 2.1 of
# the License, or (at your option) any later version.
#
# Lupin is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

newns () {
    [ "$LUPIN_NEWNS" ] || exec /usr/lib/lupin-support/newns "$0" "$@"
}

# Look for wubildr on all partitions of BIOS-accessible disk devices.
# We can safely ignore the hibernation case here, because the Windows boot
# loader boots straight into Windows if Windows was hibernated.
find_wubildr () {
    local partitions=
    for disk in $(grub-mkdevicemap -m - | cut -f2); do
        disk="$(readlink -f "$disk")" || continue
        sysdisk="/sys$(udevadm info -q path -n "$disk" 2>/dev/null)" || continue
        for syspartition in "$sysdisk"/*[0-9]; do
            [ -d "$syspartition" ] || continue
            partition="/dev/$(udevadm info -q name -p "$syspartition" 2>/dev/null)" || continue
            fs="$(grub-probe -t fs -d "$partition" 2>/dev/null)" || continue
            [ "$fs" = fat ] || [ "$fs" = ntfs ] || continue
            if [ "$(grub-fstest "$partition" ls /wubildr 2>/dev/null)" ]; then
                partitions="${partitions:+$partitions }$partition"
            fi
        done
    done
    echo "$partitions"
}

parse_proc_mounts () {
    while read -r line; do
        set -- $line
        printf '%s %s %s\n' "$(readlink -f "$1")" "$2" "$3"
    done
}

unescape_mount () {
    printf %s "$1" | \
        sed 's/\\011/   /g; s/\\012/\n/g; s/\\040/ /g; s/\\134/\\/g'
}

newns "$@"

prefix=
test_only=false

for option in "$@"; do
    case "$option" in
    --prefix=*)
        prefix=`echo "$option" | sed 's/--prefix=//'` ;;
    --test)
	test_only=: ;;
    esac
done

GRUB_DEVICE_BOOT="`grub-probe --target=device /boot`"
case ${GRUB_DEVICE_BOOT} in
  /dev/loop/*|/dev/loop[0-9])
    loop_file=`losetup ${GRUB_DEVICE_BOOT} | sed -e "s/^[^(]*(\([^)]\+\)).*/\1/"`
  ;;
esac

# Is /boot loop-mounted from a file on another filesystem?
if [ "x${loop_file}" = x ] || [ ! -f "${loop_file}" ]; then
  exit 1
fi

mtpt="${loop_file%/*}"
while [ -n "$mtpt" ]; do
    while read DEV MTPT FSTYPE OPTS REST; do
        if [ "$MTPT" = "$mtpt" ]; then
            loop_file=${loop_file#$MTPT}
            host_mountpoint=$MTPT
            break
        fi
    done < /proc/mounts
    mtpt="${mtpt%/*}"
    [ -z "$host_mountpoint" ] || break
done

if [ "x${host_mountpoint}" = x ]; then
    exit 1
fi

target="${host_mountpoint}/wubildr"

if $test_only; then
    if [ -f "$target" ]; then
        # Found on this partition
        exit 0
    elif [ "$(find_wubildr)" ]; then
        # Found on some other partition
        exit 0
    else
        # Not found
        exit 1
    fi
fi

wubildr_partitions="$(find_wubildr)"

if [ ! -f "$target" ] && [ -z "$wubildr_partitions" ]; then
    exit 1
fi

# TODO You might want to have this as a proper file somewhere in /usr/share
tmp="$(mktemp -dt)"
echo 'normal (memdisk)/wubildr.cfg' > "$tmp/wubildr-bootstrap.cfg"
cat << EOF > "$tmp/wubildr.cfg"
set show_panic_message=true
if search -s -f -n $loop_file; then
    if loopback loop0 $loop_file; then
        set root=(loop0)
        if [ -e /boot/grub/grub.cfg ]; then
            set prefix=(loop0)/boot/grub
            if configfile /boot/grub/grub.cfg; then
                set show_panic_message=false
            fi
        elif [ -e /grub/grub.cfg ]; then
                set prefix=(loop0)/grub
                if configfile /grub/grub.cfg; then
                    set show_panic_message=false
                fi
	else
		if search -s -f -n /ubuntu/install/wubildr-disk.cfg; then
			if configfile /ubuntu/install/wubildr-disk.cfg; then
				set show_panic_message=false
			fi
		fi
        fi
    fi
fi
if [ \${show_panic_message} = true ]; then
    echo "It is not possible to boot from the Ubuntu image."
    echo "The Windows partition might be corrupted."
    echo "Please reboot into Windows and run: chkdsk /r"
    echo "Then try again."
fi
EOF
(cd "$tmp" && tar cf wubildr.tar wubildr.cfg)

# Watch the modules order!
modules=" \
    biosdisk part_msdos part_gpt fat ntfs ext2 ntfscomp iso9660 loopback \
    search linux boot echo test gzio normal memdisk tar probe configfile"

# Ensure errors pass through the pipeline.
s="$( ((grub-mkimage -O i386-pc ${prefix:+--prefix="$prefix"} -c "$tmp/wubildr-bootstrap.cfg" -m "$tmp/wubildr.tar" $modules; echo $? >&3) | cat /usr/lib/grub/i386-pc/lnxboot.img - > "$tmp/wubildr") 3>&1)"; [ "$s" = 0 ]

if [ -f "$target" ]; then
    cp -af "$tmp/wubildr" "$target.new"
    mv -f "$target.new" "$target"
fi

grep ^/dev/ /proc/mounts | parse_proc_mounts >"$tmp/mounted-map"
mkdir -p "$tmp/mnt"
for partition in $wubildr_partitions; do
    if grep -q "^$partition " "$tmp/mounted-map"; then
        mpoint="$(grep "^$partition " "$tmp/mounted-map" | head -n1 | cut -d' ' -f2)"
        mpoint="$(unescape_mount "$mpoint")"
        if [ "$mpoint" = /host ]; then
            continue
        fi
    else
        mount "$partition" "$tmp/mnt" 2>/dev/null || continue
        mpoint="$tmp/mnt"
    fi
    if [ -f "$mpoint/wubildr" ]; then
        cp -af "$tmp/wubildr" "$mpoint/wubildr.new"
        mv -f "$mpoint/wubildr.new" "$mpoint/wubildr"
    fi
    if ! grep -q "^$partition " "$tmp/mounted-map"; then
        umount "$tmp/mnt" || true
    fi
done

rm -rf --one-file-system "$tmp" || true