* [U-Boot] [PATCH] scripts: setlocalversion: safely extract variables from auto.conf using awk
@ 2017-08-08 13:37 Philipp Tomsich
2017-08-10 1:42 ` Tom Rini
2017-08-10 10:29 ` [U-Boot] " Philipp Tomsich
0 siblings, 2 replies; 3+ messages in thread
From: Philipp Tomsich @ 2017-08-08 13:37 UTC (permalink / raw)
To: u-boot
Moving SPL_LDSCRIPT to Kconfig triggered an unfortunate attempt of
command substitution, as the sourced auto.conf may include $(ARCH)
which tries to execute a command 'ARCH'.
This showed up as a warning similar to the following:
include/config/auto.conf: line 209: ARCH: command not found
This change does no longer attempt to source auto.conf, but rather
passes it through awk to retrieve the values for CONFIG_LOCALVERSION
and CONFIG_LOCALVERSION_AUTO. This will also mitigate the risk of
unintended command substitution.
Signed-off-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
Reported-by: Andy Yan <andy.yan@rock-chips.com>
---
scripts/setlocalversion | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/scripts/setlocalversion b/scripts/setlocalversion
index 63d91e2..8564bed 100755
--- a/scripts/setlocalversion
+++ b/scripts/setlocalversion
@@ -141,7 +141,11 @@ if $scm_only; then
fi
if test -e include/config/auto.conf; then
- . include/config/auto.conf
+ # We are interested only in CONFIG_LOCALVERSION and
+ # CONFIG_LOCALVERSION_AUTO, so extract these in a safe
+ # way (i.e. w/o sourcing auto.conf)
+ CONFIG_LOCALVERSION=`cat include/config/auto.conf | awk -F '=' '/^CONFIG_LOCALVERSION=/ {print $2}'`
+ CONFIG_LOCALVERSION_AUTO=`cat include/config/auto.conf | awk -F '=' '/^CONFIG_LOCALVERSION_AUTO=/ {print $2}'`
else
echo "Error: kernelrelease not valid - run 'make prepare' to update it"
exit 1
--
2.1.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [U-Boot] [PATCH] scripts: setlocalversion: safely extract variables from auto.conf using awk
2017-08-08 13:37 [U-Boot] [PATCH] scripts: setlocalversion: safely extract variables from auto.conf using awk Philipp Tomsich
@ 2017-08-10 1:42 ` Tom Rini
2017-08-10 10:29 ` [U-Boot] " Philipp Tomsich
1 sibling, 0 replies; 3+ messages in thread
From: Tom Rini @ 2017-08-10 1:42 UTC (permalink / raw)
To: u-boot
On Tue, Aug 08, 2017 at 03:37:03PM +0200, Philipp Tomsich wrote:
> Moving SPL_LDSCRIPT to Kconfig triggered an unfortunate attempt of
> command substitution, as the sourced auto.conf may include $(ARCH)
> which tries to execute a command 'ARCH'.
> This showed up as a warning similar to the following:
> include/config/auto.conf: line 209: ARCH: command not found
>
> This change does no longer attempt to source auto.conf, but rather
> passes it through awk to retrieve the values for CONFIG_LOCALVERSION
> and CONFIG_LOCALVERSION_AUTO. This will also mitigate the risk of
> unintended command substitution.
>
> Signed-off-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
> Reported-by: Andy Yan <andy.yan@rock-chips.com>
>
Reviewed-by: Tom Rini <trini@konsulko.com>
I do wonder if we can get this into the kernel as well.
--
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170809/aadf262c/attachment.sig>
^ permalink raw reply [flat|nested] 3+ messages in thread
* [U-Boot] scripts: setlocalversion: safely extract variables from auto.conf using awk
2017-08-08 13:37 [U-Boot] [PATCH] scripts: setlocalversion: safely extract variables from auto.conf using awk Philipp Tomsich
2017-08-10 1:42 ` Tom Rini
@ 2017-08-10 10:29 ` Philipp Tomsich
1 sibling, 0 replies; 3+ messages in thread
From: Philipp Tomsich @ 2017-08-10 10:29 UTC (permalink / raw)
To: u-boot
> Moving SPL_LDSCRIPT to Kconfig triggered an unfortunate attempt of
> command substitution, as the sourced auto.conf may include $(ARCH)
> which tries to execute a command 'ARCH'.
> This showed up as a warning similar to the following:
> include/config/auto.conf: line 209: ARCH: command not found
>
> This change does no longer attempt to source auto.conf, but rather
> passes it through awk to retrieve the values for CONFIG_LOCALVERSION
> and CONFIG_LOCALVERSION_AUTO. This will also mitigate the risk of
> unintended command substitution.
>
> Signed-off-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
> Reported-by: Andy Yan <andy.yan@rock-chips.com>
> Reviewed-by: Tom Rini <trini@konsulko.com>
> ---
>
> scripts/setlocalversion | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
Applied to u-boot-rockchip, thanks!
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-08-10 10:29 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-08-08 13:37 [U-Boot] [PATCH] scripts: setlocalversion: safely extract variables from auto.conf using awk Philipp Tomsich
2017-08-10 1:42 ` Tom Rini
2017-08-10 10:29 ` [U-Boot] " Philipp Tomsich
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox