diff mbox series

[OpenWrt-Devel] base-files: quote values when evaluating uevent

Message ID 20180202005740.GA4414@makrotopia.org
State Accepted
Delegated to: John Crispin
Headers show
Series [OpenWrt-Devel] base-files: quote values when evaluating uevent | expand

Commit Message

Daniel Golle Feb. 2, 2018, 12:57 a.m. UTC
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 | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

Comments

Philip Prindeville Feb. 9, 2018, 8:43 p.m. UTC | #1
LGTM

Been using it here for a few days.


> On Feb 1, 2018, at 5:57 PM, Daniel Golle <daniel@makrotopia.org> wrote:
> 
> 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 | 5 ++---
> 1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/package/base-files/files/lib/upgrade/common.sh b/package/base-files/files/lib/upgrade/common.sh
> index 71cffc8587..616131c89c 100644
> --- a/package/base-files/files/lib/upgrade/common.sh
> +++ b/package/base-files/files/lib/upgrade/common.sh
> @@ -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
> -- 
> 2.16.1
> 
> 
> _______________________________________________
> Lede-dev mailing list
> Lede-dev@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/lede-dev
diff mbox series

Patch

diff --git a/package/base-files/files/lib/upgrade/common.sh b/package/base-files/files/lib/upgrade/common.sh
index 71cffc8587..616131c89c 100644
--- a/package/base-files/files/lib/upgrade/common.sh
+++ b/package/base-files/files/lib/upgrade/common.sh
@@ -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