Source: grub-installer
Severity: minor

Hi,

While looking at the grub-installer script, shellcheck highlighted the fact that
we appear to be using the variable $device_map in grub-installer, without it
being defined.

A grep of the D-I source tree for 'device_map=' found nothing, so it seems it's
not being set in an included library either.

git history reveals that it used to be set[1], until f97462fcb which was
removing a load of device.map related code as a merge from Ubuntu, so I guess
this is just some detritus that got missed at that point and happend to cause no
problems since.

That's presumably because that code only gets executed if the boot device
matches ``[hf]d[0-9]*'', which I'm guessing is either never or rarely.

If it ever does match, this gets run[2,3]:

   bootdisk="$(grep -v '^#' $device_map | grep "^ *$bootdev_nopart" \
                                | sed 's/^ *(.*)[[:space:]]*\(.*\)/\1/')"

which I'd expect to hang, waiting on the first grep's STDIN (unless STDIN is
redirected from /dev/null, or some such, at the time).

If the condition regarding the boot device is ever likely to be true, then this
code ought to be fixed, or at least the two cases in question could be changed
to throw a meaningful error, so that people can report useful bugs about it.
Otherwise, the obsolete code should be removed.

I'm happy to create an MR once I know which option is required.

Cheers, Phil.

[1]  
https://salsa.debian.org/installer-team/grub-installer/-/commit/f97462fcbb4bbeb4a600c30ddc84a88#ae6e84c2dbfeefe14b039001e1b64254dada292b_81_78
[2]  
https://salsa.debian.org/installer-team/grub-installer/-/blob/master/grub-installer#L1066
[3]  
https://salsa.debian.org/installer-team/grub-installer/-/blob/master/grub-installer#L1077

Reply via email to