I mistakenly posted bad patches to bitbake-devel earlier today. These are 2 alternative patches (pick only one). They apply on master branch but should backport easily. I tested them and generated them on kirkstone (and then updated the path and checked application on master).
This is a full fix for a problem partially addressed by Jaeyoon Jung ( [email protected] Thu Sep 21 17:27:10 2023 +0200 https://lists.openembedded.org/g/openembedded-core/message/186885) That fix swapped " for ' which instead causes the failure to occur when KCONFIG_CONFIG_COMMAND contained ' (single quotes) whereas before it occurred when KCONFIG_CONFIG_COMMAND contained " (double quotes). The problem only arises because of the extra "sh -c" needed in cml1.bbclass to execute multiple shell statements, and because of the existence of a prepended "exec" by terminal.bbclass function emit_terminal_func. This means that the implicitly shell-ready KCONFIG_CONFIG_COMMAND needs escaping for insertion into the extra "sh -c". Although cml1.bbclass escaped the shell code in the source, the KCONFIG_CONFIG_COMMAND was not escaped, and so either " or ' was going to fall victim at some point. These two alternative patches directly address the need to escape KCONFIG_CONFIG_COMMAND. The first patch is the simplest, and causes KCONFIG_CONFIG_COMMAND to be passed as additional arguments to the inner "sh -c", entirely avoiding the need to shell escape, on this principle: -"sh -c 'make %s ...'" % ${KCONFIG_CONFIG_COMMAND}" +"sh -c 'make \"$@\" ...' dummy-arg0 %s" % ${KCONFIG_CONFIG_COMMAND} The second fix uses shlex.quote (suitable for python 3.3 or above) to quote the entire argument to "sh -c" including KCONFIG_CONFIG_COMMAND, avoiding also the need to manually escape any of the nested shell. I think that the first fix is more portable, but they both require scrutiny to ensure fixing the problem properly is worth the trouble. For application in kirkstone and some others, meta/classes-recipe/cml1.bbclass needs changing to meta/classes/cml1.bbclass I know that we have a good-enough-for-now fix from Jaeyoon Jung, so this isn't urgent, and maybe not even important. Sam
From a8e847c3073fb380a2e35fcea1994a17ba68faf1 Mon Sep 17 00:00:00 2001 From: Sam Liddicott <[email protected]> Date: Thu, 12 Sep 2024 17:18:37 +0100 Subject: avoid the need to escape KCONFIG_CONFIG_COMMAND for do_menuconfig Although KCONFIG_CONFIG_COMMAND is shell-ready, it needs escaping when composed as part of some shell which is then embedded into an outer "sh -c" in cml1.bbclass This patch avoids the need to escape KCONFIG_CONFIG_COMMAND by inserting it into the outer "sh -c" and passing it from there as optional args with a dummy arg0 Signed-off-by: Sam Liddicott <[email protected]> --- meta/classes-recipe/cml1.bbclass | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meta/classes-recipe/cml1.bbclass b/meta/classes-recipe/cml1.bbclass index d319d66ab2..0dbaf25b8e 100644 --- a/meta/classes-recipe/cml1.bbclass +++ b/meta/classes-recipe/cml1.bbclass @@ -48,5 +48,5 @@ python do_menuconfig() { # ensure that environment variables are overwritten with this tasks 'd' values d.appendVar("OE_TERMINAL_EXPORTS", " PKG_CONFIG_DIR PKG_CONFIG_PATH PKG_CONFIG_LIBDIR PKG_CONFIG_SYSROOT_DIR") - oe_terminal("sh -c 'make %s; if [ \\$? -ne 0 ]; then echo \"Command failed.\"; printf \"Press any key to continue... \"; read r; fi'" % d.getVar('KCONFIG_CONFIG_COMMAND'), + oe_terminal("sh -c 'make \"$@\" ; if [ $? -ne 0 ]; then echo \"Command failed.\"; printf \"Press any key to continue... \"; read r; fi' oe_terminal-cmd %s " % d.getVar('KCONFIG_CONFIG_COMMAND'), d.getVar('PN') + ' Configuration', d) -- 2.43.0
From a96f41f6d6f0d8308d74a74d736d5a35dc54f0fa Mon Sep 17 00:00:00 2001 From: Sam Liddicott <[email protected]> Date: Thu, 12 Sep 2024 17:18:37 +0100 Subject: use shlex.quote on KCONFIG_CONFIG_COMMAND for do_menuconfig Although KCONFIG_CONFIG_COMMAND is shell-ready, it needs escaping when composed as part of some shell which is then embedded into an outer "sh -c" in cml1.bbclass This patch uses shlex.quote to escape the entire shell fragment when it is composed in the inner "sh -c" Signed-off-by: Sam Liddicott <[email protected]> --- meta/classes-recipe/cml1.bbclass | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meta/classes-recipe/cml1.bbclass b/meta/classes-recipe/cml1.bbclass index d319d66ab2..f6727c5c33 100644 --- a/meta/classes-recipe/cml1.bbclass +++ b/meta/classes-recipe/cml1.bbclass @@ -36,4 +36,5 @@ KCONFIG_CONFIG_ENABLE_MENUCONFIG ??= "true" KCONFIG_CONFIG_ROOTDIR ??= "${B}" python do_menuconfig() { import shutil + import shlex @@ -48,5 +49,5 @@ python do_menuconfig() { # ensure that environment variables are overwritten with this tasks 'd' values d.appendVar("OE_TERMINAL_EXPORTS", " PKG_CONFIG_DIR PKG_CONFIG_PATH PKG_CONFIG_LIBDIR PKG_CONFIG_SYSROOT_DIR") - oe_terminal("sh -c 'make %s; if [ \\$? -ne 0 ]; then echo \"Command failed.\"; printf \"Press any key to continue... \"; read r; fi'" % d.getVar('KCONFIG_CONFIG_COMMAND'), + oe_terminal('sh -c %s' % shlex.quote("make %s; if [ $? -ne 0 ]; then echo 'Command failed.'; printf 'Press any key to continue... '; read r; fi" % d.getVar('KCONFIG_CONFIG_COMMAND')), d.getVar('PN') + ' Configuration', d) -- 2.43.0
-=-=-=-=-=-=-=-=-=-=-=- Links: You receive all messages sent to this group. View/Reply Online (#204448): https://lists.openembedded.org/g/openembedded-core/message/204448 Mute This Topic: https://lists.openembedded.org/mt/108416314/21656 Group Owner: [email protected] Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [[email protected]] -=-=-=-=-=-=-=-=-=-=-=-
