Backport commits fixing the detection of GPT partition names during
preinit and sysupgrade, closing a shell-injection vulnerability.
da52dd0c83 ("base-files: quote values when evaluating uevent")
267873ac9b ("base-files: don't evaluate block-device uevent")
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
}
export_bootdevice() {
- local cmdline uuid disk uevent
+ local cmdline uuid disk uevent line
local MAJOR MINOR DEVNAME DEVTYPE
if read cmdline < /proc/cmdline; then
esac
if [ -e "$uevent" ]; then
- . "$uevent"
-
+ while read line; do
+ export -n "$line"
+ done < "$uevent"
export BOOTDEV_MAJOR=$MAJOR
export BOOTDEV_MINOR=$MINOR
return 0
export_partdevice() {
local var="$1" offset="$2"
- local uevent MAJOR MINOR DEVNAME DEVTYPE
+ local uevent line MAJOR MINOR DEVNAME DEVTYPE
for uevent in /sys/class/block/*/uevent; do
- . "$uevent"
+ while read line; do
+ export -n "$line"
+ done < "$uevent"
if [ $BOOTDEV_MAJOR = $MAJOR -a $(($BOOTDEV_MINOR + $offset)) = $MINOR -a -b "/dev/$DEVNAME" ]; then
export "$var=$DEVNAME"
return 0