configure: disallow spaces and colons in source path and build path
v3 cover configure: disallow spaces and colons in source path and build path
Hi,
Here is a v3 set to address
https://bugs.launchpad.net/qemu/+bug/1817345
CCing Laurent Vivier as the patch is going through the trivial-patches branch.
The series follows up to:
https://lists.gnu.org/archive/html/qemu-devel/2019-05/msg00562.html
Changes since v2:
- Shorten 'if' check as suggested by Eric Blake in
https://lists.gnu.org/archive/html/qemu-devel/2019-05/msg01190.html
- Added Reviewed-by tags by Eric Blake.
Changes since v1:
- Add a preparatory patch to set source_path only once and in a more robust way.
- Move the checks in configure after the source_path definition to avoid using realpath which is not available everywhere.
- Cover also the build path in Makefile. An extensive explanation of why I think this is needed is here:
https://lists.gnu.org/archive/html/qemu-devel/2019-03/msg05398.html
Thank you,
Antonio
Antonio Ospite (2):
configure: set source_path only once and make its definition more
robust
configure: disallow spaces and colons in source path and build path
Makefile | 4 ++++ configure | 11 ++++++++--- 2 files changed, 12 insertions(+), 3 deletions(-)
Signature · 7 lines
Antonio Ospite https://ao2.it https://twitter.com/ao2it A: Because it messes up the order in which people normally read text. See http://en.wikipedia.org/wiki/Posting_style Q: Why is top-posting such a bad thing?
PATCH v3 1/2 configure: set source_path only once and make its definition more robust
From: Antonio Ospite <[email protected]>
Since commit 79d77bcd36 (configure: Remove --source-path option, 2019-04-29) source_path cannot be overridden anymore, move it out of the "default parameters" block since the word "default" may suggest that the value can change, while in fact it does not.
While at it, only set source_path once and separate the positional argument of basename with "--" to more robustly cover the case of path names starting with a dash.
--- configure | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
configure +3 -3
@@ -276,10 +276,10 @@ ld_has() { $ld --help 2>/dev/null | grep ".$1" >/dev/null 2>&1 } -# default parameters -source_path=$(dirname "$0") # make source path absolute -source_path=$(cd "$source_path"; pwd) +source_path=$(cd "$(dirname -- "$0")"; pwd) + +# default parameters cpu="" iasl="iasl" interp_prefix="/usr/gnemul/qemu-%M"
Signature · 1 line
2.20.1
Laurent Vivier
AppliedRe: [Qemu-devel] [PATCH v3 1/2] configure: set source_path only once and make its definition more robust
Le 26/05/2019 à 16:47, Antonio Ospite a écrit :
Quoted 26 lines
From: Antonio Ospite <[email protected]>
Since commit
79d77bcd36(configure: Remove --source-path option, 2019-04-29)source_pathcannot be overridden anymore, move it out of the "default parameters" block since the word "default" may suggest that the value can change, while in fact it does not.While at it, only set
source_pathonce and separate the positional argument of basename with "--" to more robustly cover the case of path names starting with a dash.Reviewed-by Eric Blake <[email protected]>Signed-off-by Antonio Ospite <[email protected]>--- configure | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)configure +0
-0@@ -276,10 +276,10 @@ ld_has() { $ld --help 2>/dev/null | grep ".$1" >/dev/null 2>&1 }
configure ld_has() { · line 285
Quoted 10 lines
configure +3
-3-# default parameters -source_path=$(dirname "$0") # make source path absolute -source_path=$(cd "$source_path"; pwd) +source_path=$(cd "$(dirname -- "$0")"; pwd) + +# default parameters cpu="" iasl="iasl" interp_prefix="/usr/gnemul/qemu-%M"
Applied to my trivial-patches branch.
Thanks,
Laurent
PATCH v3 2/2 configure: disallow spaces and colons in source path and build path
In reply to Antonio OspiteFrom: Antonio Ospite <[email protected]>
The configure script breaks when the qemu source directory is in a path containing white spaces, in particular the list of targets is not correctly generated when calling "./configure --help" because of how the default_target_list variable is built.
In addition to that, *building* qemu from a directory with spaces breaks some assumptions in the Makefiles, even if the original source path does not contain spaces like in the case of an out-of-tree build, or when symlinks are involved.
To avoid these issues, refuse to run the configure script and the Makefile if there are spaces or colons in the source path or the build path, taking as inspiration what the kbuild system in linux does.
--- Makefile | 4 ++++ configure | 5 +++++ 2 files changed, 9 insertions(+)
Makefile +4 -0
@@ -1,5 +1,9 @@ # Makefile for QEMU. +ifneq ($(words $(subst :, ,$(CURDIR))), 1) + $(error main directory cannot contain spaces nor colons) +endif + # Always point to the root of the build tree (needs GNU make). BUILD_DIR=$(CURDIR)
configure +5 -0
@@ -279,6 +279,11 @@ ld_has() { # make source path absolute source_path=$(cd "$(dirname -- "$0")"; pwd) +if printf %s\\n "$source_path" "$PWD" | grep -q "[[:space:]:]"; +then + error_exit "main directory cannot contain spaces nor colons" +fi + # default parameters cpu="" iasl="iasl"
Signature · 1 line
2.20.1
Laurent Vivier
AppliedLe 26/05/2019 à 16:47, Antonio Ospite a écrit :
Quoted 46 lines
From: Antonio Ospite <[email protected]>
The configure script breaks when the qemu source directory is in a path containing white spaces, in particular the list of targets is not correctly generated when calling "./configure --help" because of how the
default_target_listvariable is built.In addition to that, *building* qemu from a directory with spaces breaks some assumptions in the Makefiles, even if the original source path does not contain spaces like in the case of an out-of-tree build, or when symlinks are involved.
To avoid these issues, refuse to run the configure script and the
Makefileif there are spaces or colons in the source path or the build path, taking as inspiration what the kbuild system in linux does.Reviewed-by Eric Blake <[email protected]>Signed-off-by Antonio Ospite <[email protected]>--- Makefile | 4 ++++ configure | 5 +++++ 2 files changed, 9 insertions(+)Makefile +4
-0@@ -1,5 +1,9 @@ # Makefile for QEMU. +ifneq ($(words $(subst :, ,$(CURDIR))), 1) + $(error main directory cannot contain spaces nor colons) +endif + # Always point to the root of the build tree (needs GNU make). BUILD_DIR=$(CURDIR)configure +0
-0@@ -279,6 +279,11 @@ ld_has() { # make source path absolute
configure ld_has() { · line 289
Quoted 10 lines
configure +5
-0source_path=$(cd "$(dirname -- "$0")"; pwd) +if printf %s\\n "$source_path" "$PWD" | grep -q "[[:space:]:]"; +then + error_exit "main directory cannot contain spaces nor colons" +fi + # default parameters cpu="" iasl="iasl"
Applied to my trivial-patches branch.
Thanks,
Laurent
Quoted 8 lines · Antonio Ospite
Hi,
Here is a v3 set to address
https://bugs.launchpad.net/qemu/+bug/1817345CCing Laurent Vivier as the patch is going through the trivial-patches branch.
Ping.
I cannot see this in the trivial-patches repository nor in mainline qemu.
Thanks,
Antonio
Quoted 34 lines
The series follows up to:
https://lists.gnu.org/archive/html/qemu-devel/2019-05/msg00562.htmlChanges since v2:
- Shorten 'if' check as suggested by Eric Blake inhttps://lists.gnu.org/archive/html/qemu-devel/2019-05/msg01190.html- Added Reviewed-by tags by Eric Blake.
Changes since v1:
- Add a preparatory patch to setsource_pathonly once and in a more robust way.- Move the checks in configure after the
source_pathdefinition to avoid using realpath which is not available everywhere.- Cover also the build path in
Makefile. An extensive explanation of why I think this is needed is here:
https://lists.gnu.org/archive/html/qemu-devel/2019-03/msg05398.htmlThank you,
AntonioAntonio Ospite (2):
configure: setsource_pathonly once and make its definition more
robust
configure: disallow spaces and colons in source path and build pathMakefile | 4 ++++ configure | 11 ++++++++--- 2 files changed, 12 insertions(+), 3 deletions(-)
Le 26/06/2019 à 17:16, Antonio Ospite a écrit :
Quoted 6 lines · Antonio Ospite
Quoted 5 lines
Hi,
Here is a v3 set to address
https://bugs.launchpad.net/qemu/+bug/1817345
Quoted 8 lines
Quoted 3 lines
CCing Laurent Vivier as the patch is going through the trivial-patches branch.
Ping.
I cannot see this in the trivial-patches repository nor in mainline qemu.
I missed it because you didn't cc: qemu-trivial ML (I use this list to pick up the patches).
I'm going to add them to the next pull request.
Thanks,
Laurent
Quoted 11 lines · Laurent Vivier
Le 26/06/2019 à 17:16, Antonio Ospite a écrit :
Quoted 10 lines · Antonio Ospite
Quoted 8 lines
Hi,
Here is a v3 set to address
https://bugs.launchpad.net/qemu/+bug/1817345CCing Laurent Vivier as the patch is going through the trivial-patches branch.
Quoted 8 lines
Quoted 4 lines
Ping.
I cannot see this in the trivial-patches repository nor in mainline qemu.
I missed it because you didn't cc: qemu-trivial ML (I use this list to pick up the patches).
Ah yes, I had read that on
https://wiki.qemu.org/Contribute/TrivialPatches
but then forgot about it.
Quoted 5 lines
I'm going to add them to the next pull request.
Thanks,
Laurent
Thank you,
Antonio
Quoted 6 lines · Antonio Ospite
Quoted 5 lines · Antonio Ospite
Hi,
Here is a v3 set to address
https://bugs.launchpad.net/qemu/+bug/1817345
Quoted 8 lines
Quoted 3 lines
CCing Laurent Vivier as the patch is going through the trivial-patches branch.
Ping.
I cannot see this in the trivial-patches repository nor in mainline qemu.
Explicitly adding qemu-trivial in cc may help (done now).
Quoted 11 lines
Quoted 9 lines
Antonio Ospite (2):
configure: setsource_pathonly once and make its definition more robust
configure: disallow spaces and colons in source path and build pathMakefile | 4 ++++
configure | 11 ++++++++---2 files changed, 12 insertions(+), 3 deletions(-)
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3226 Virtualization: qemu.org | libvirt.org