base-files: quote values when evaluating uevent
authorDaniel Golle <daniel@makrotopia.org>
Fri, 2 Feb 2018 00:57:46 +0000 (01:57 +0100)
committerJohn Crispin <john@phrozen.org>
Sun, 11 Feb 2018 15:42:01 +0000 (16:42 +0100)
When sourcing /sys/class/block/*/uevent values have to be quoted as
they may contain spaces (e.g. in PARTNAME).
Fix this by pre-processing with sed before sourcing.

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
package/base-files/files/lib/upgrade/common.sh

index 71cffc8..616131c 100644 (file)
@@ -134,8 +134,7 @@ export_bootdevice() {
                esac
 
                if [ -e "$uevent" ]; then
-                       . "$uevent"
-
+                       eval "$(sed "s/=\(.*\)/=\'\1\'/" < "$uevent")"
                        export BOOTDEV_MAJOR=$MAJOR
                        export BOOTDEV_MINOR=$MINOR
                        return 0
@@ -150,7 +149,7 @@ export_partdevice() {
        local uevent MAJOR MINOR DEVNAME DEVTYPE
 
        for uevent in /sys/class/block/*/uevent; do
-               . "$uevent"
+               eval "$(sed "s/=\(.*\)/=\'\1\'/" < "$uevent")"
                if [ $BOOTDEV_MAJOR = $MAJOR -a $(($BOOTDEV_MINOR + $offset)) = $MINOR -a -b "/dev/$DEVNAME" ]; then
                        export "$var=$DEVNAME"
                        return 0