Re: [libvirt] [PATCH 1/2] tools: Ignore newlines in libvirt-guests.sh guest list

2016-10-07 Thread Eric Blake
On 10/07/2016 02:56 AM, Stefan Bader wrote:
> The list file expects all guest UUIDs on the same line as the URI
> which the guests run on. This does not happen when the list is
> echo'ed in quotes. When stripping the quotes, newlines get transformed
> into spaces. Without this, only the first guest on the list is actually
> handled.
> 
> Based on a fix by Omar Siam 
> 
> Bug-Ubuntu: http://bugs.launchpad.net/bugs/1591695
> 
> Signed-off-by: Stefan Bader 
> ---
>  tools/libvirt-guests.sh.in | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

ACK.

> 
> diff --git a/tools/libvirt-guests.sh.in b/tools/libvirt-guests.sh.in
> index 7f74b85..7380b4b 100644
> --- a/tools/libvirt-guests.sh.in
> +++ b/tools/libvirt-guests.sh.in
> @@ -499,7 +499,7 @@ stop() {
>  fi
>  
>  if [ -n "$list" ]; then
> -echo "$uri" "$list" >>"$LISTFILE"
> +echo "$uri" $list >>"$LISTFILE"

This is one case where "" is harmful - we WANT the shell to perform
word-splitting, and the content of $list should be safe for splitting
(ie. since all elements of the list are UUIDs, none of them should
contain any other whitespace or shell metacharacters that would
misbehave by losing the "").


-- 
Eric Blake   eblake redhat com+1-919-301-3266
Libvirt virtualization library http://libvirt.org



signature.asc
Description: OpenPGP digital signature
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

[libvirt] [PATCH 1/2] tools: Ignore newlines in libvirt-guests.sh guest list

2016-10-07 Thread Stefan Bader
The list file expects all guest UUIDs on the same line as the URI
which the guests run on. This does not happen when the list is
echo'ed in quotes. When stripping the quotes, newlines get transformed
into spaces. Without this, only the first guest on the list is actually
handled.

Based on a fix by Omar Siam 

Bug-Ubuntu: http://bugs.launchpad.net/bugs/1591695

Signed-off-by: Stefan Bader 
---
 tools/libvirt-guests.sh.in | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/libvirt-guests.sh.in b/tools/libvirt-guests.sh.in
index 7f74b85..7380b4b 100644
--- a/tools/libvirt-guests.sh.in
+++ b/tools/libvirt-guests.sh.in
@@ -499,7 +499,7 @@ stop() {
 fi
 
 if [ -n "$list" ]; then
-echo "$uri" "$list" >>"$LISTFILE"
+echo "$uri" $list >>"$LISTFILE"
 fi
 done
 set +f
-- 
1.9.1

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list