[Toybox] tar xf doesn't work on compressed files if the *cat tools aren't available
enh
enh at google.com
Fri Aug 26 16:34:04 PDT 2022
On Thu, Aug 25, 2022 at 5:49 PM enh <enh at google.com> wrote:
> the kernel folks build in an even more restricted environment than AOSP.
> so although they have bzip2 and gzip, they don't have bzcat and gzcat.
>
> from a bad run (with no bzcat/gzcat):
>
> ~/aosp-master-with-phones$ /usr/bin/strace -f -e execve
> ./prebuilts/build-tools/linux-x86/bin/toybox tar tvf x.tar.gz
> execve("./prebuilts/build-tools/linux-x86/bin/toybox",
> ["./prebuilts/build-tools/linux-x8"..., "tar", "tvf", "x.tar.gz"],
> 0x7ffe8acad930 /* 36 vars */) = 0
> /usr/bin/strace: Process 640688 attached
> [pid 640688]
> execve("/usr/local/google/home/enh/aosp-master-with-phones/prebuilts/build-tools/path/linux-x86/bzip2",
> ["bzip2", "-d"], 0x7ffd675c2a80 /* 36 vars */) = 0
> bzip2: (stdin) is not a bzip2 file.
> [pid 640688] +++ exited with 2 +++
> --- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=640688,
> si_uid=73769, si_status=2, si_utime=0, si_stime=0} ---
> +++ exited with 0 +++
>
> from a successful run (with all the tools):
>
> ~/aosp-master-with-phones$ strace -f -e execve
> ./prebuilts/build-tools/linux-x86/bin/toybox tar tvf x.tar.gz
> execve("./prebuilts/build-tools/linux-x86/bin/toybox",
> ["./prebuilts/build-tools/linux-x8"..., "tar", "tvf", "x.tar.gz"],
> 0x7ffea9535030 /* 36 vars */) = 0
> strace: Process 640431 attached
> [pid 640431] execve("/usr/bin/zcat", ["/usr/bin/zcat"], 0x7fffe0fd7580 /*
> 36 vars */) = 0
> [pid 640431] execve("/usr/bin/gzip", ["gzip", "-cd"], 0x55f91049b290 /* 34
> vars */) = 0
> [pid 640431] +++ exited with 0 +++
> --- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=640431,
> si_uid=73769, si_status=0, si_utime=0, si_stime=0} ---
> -rw-r----- enh/primarygroup 0 2022-08-25 20:53 foo
> +++ exited with 0 +++
>
> there is code to try to use $TOOL -d if the *cat tool doesn't exist
> (that's why we're running bzip2 at all), but it's obviously not working
> here :-(
>
> it also works fine if you explicitly say 'z'.
>
> so here's the setup:
>
> $ touch foo
> $ tar czf x.tar.gz foo
>
> here's the failure:
>
> $ tar tf x.tar.gz
> bzip2: (stdin) is not a bzip2 file.
>
> here's the success:
>
> $ tar tzf /tmp/x.tar.gz
> foo
>
> i didn't get time today to look at this in more detail, but i do notice
> that there appears to be an inconsistency between the two ways we choose
> the appropriate tool:
>
> *archiver = FLAG(I) ? TT.I : (FLAG(z) ? "gzip" : (FLAG(J) ?
> "xz":"bzip2"));
>
> struct string_list *zcat = FLAG(I) ? 0 : find_in_path(getenv("PATH"),
> FLAG(j) ? "bzcat" : FLAG(J) ? "xzcat" : "zcat");
>
> is that intentional or a bug?
>
> (i'll try to have another look tomorrow, but since you seem to be
> nocturnal atm i thought i'd send this out now anyway :-) )
>
ran out of time to investigate further today, but i did at least send you a
patch to fix the build, and another to fix the tar tests on macOS again...
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.landley.net/pipermail/toybox-landley.net/attachments/20220826/caab53cb/attachment.htm>
More information about the Toybox
mailing list