[Libguestfs] [PATCH v2v] input: -i ova: Handle OVAs which contain user/group names with spaces

Laszlo Ersek lersek at redhat.com
Mon Apr 4 11:49:05 UTC 2022


On 04/04/22 12:14, Richard W.M. Jones wrote:
> If importing an OVA that has user/group names with spaces then the
> plain tar -tRvf command would print them without any quoting.  Our
> simple strategy of splitting on spaces resulted in an "extra field"
> being parsed.  This is an example from a real OVA (note "Domain Users"
> is the group name):
> 
> $ tar --quoting-style=literal -tRvf protect_appliance.ova
> block 0: -rw-r--r-- eraautobuilds/Domain Users 33508 2021-11-04 17:48 PROTECT_Appliance.ovf
> 
> Luckily this is fairly simple to fix.  We don't care about the
> original user/group name, and using --numeric-owner causes tar to
> print the UID/GID instead:
> 
> $ tar --quoting-style=literal --numeric-owner -tRvf protect_appliance.ova
> block 0: -rw-r--r-- 1074101/1049089 33508 2021-11-04 17:48 PROTECT_Appliance.ovf
> 
> I also added --quoting-style=literal to deal with possible future
> cases where the filename contains spaces.  Because we use
> nsplit ~max:8 these should now be handled correctly too, although I
> didn't test this.
> 
> Reported-by: Jiří Sléžka
> Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=2069768
> ---
>  input/OVA.ml | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/input/OVA.ml b/input/OVA.ml
> index 36bb4fd043..9e9c371285 100644
> --- a/input/OVA.ml
> +++ b/input/OVA.ml
> @@ -394,7 +394,10 @@ let re_tar_message = PCRE.compile "\\*\\* [^*]+ \\*\\*$"
>  
>  let get_tar_offet_and_size tar filename =
>    let cmd =
> -    sprintf "LANG=C tar --no-auto-compress -tRvf %s" (Filename.quote tar) in
> +    sprintf "LANG=C tar \
> +             --no-auto-compress --quoting-style=literal --numeric-owner \
> +             -tRvf %s"
> +      (Filename.quote tar) in
>    let lines = external_command cmd in
>    let rec loop lines =
>      match lines with
> 

Reviewed-by: Laszlo Ersek <lersek at redhat.com>


More information about the Libguestfs mailing list