Skip to content

Commit

Permalink
input: -i ova: Handle OVAs which contain user/group names with spaces
Browse files Browse the repository at this point in the history
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
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
  • Loading branch information
rwmjones committed Apr 4, 2022
1 parent 3565743 commit db00a9a
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion input/OVA.ml
Expand Up @@ -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
Expand Down

0 comments on commit db00a9a

Please sign in to comment.