Bug #2730

tar misbehaves if compress utility missing

Added by Garrett D'Amore almost 9 years ago. Updated over 8 years ago.

cmd - userland programs
Start date:
Due date:
% Done:


Estimated time:
2.00 h
Gerrit CR:


tar doesn't deal well with the situation where bzip2 or gzip (and in the future xz) are missing.

IMO, we should deal with that exec failing better, but that might be hard to do. The most likely failure mode is the utility is absent or doesn't have the right mode bits, so if we just stat() before we fork() and exec(), that would go very far in covering the most likely error cases.

This is important as these utilities cross consolidation and packaging boundaries, and some distros might elect not to install them.

More detail from Milan:

$ LC_ALL=C tar tf t.tar.xz
tar: Could not exec /usr/bin/xzcat: No such file or directory
tar: blocksize = 0

$ LC_ALL=C tar cvJf t.tar.xz nscd
Compressing 't.tar.xz' with '/usr/bin/xz'...
tar: Could not exec /usr/bin/xz: No such file or directory
a nscd 0K
a nscd/getprinter.c 2K
a nscd/gethost.c 3K
a nscd/cache.o 31K

This ends in empty file, ending in the middle of work.

Returns error 141.

The same as in case of gzip/bzip2 missing. No change in behavior.
Probably it could be improved but nobody cared yet.


verify_tar.diff (1.74 KB) verify_tar.diff Milan Jurik, 2012-05-31 05:03 PM

Updated by Milan Jurik almost 9 years ago

  • Status changed from New to In Progress
  • Assignee set to Milan Jurik

stat() is the necessary first step. The other would be better monitoring of return values from compress tools. The third is better error reporting.


Updated by Milan Jurik over 8 years ago

Basics implemented. More precise detection of return values and handling of temporary tarfiles during update need some additional steps and small redesign.


Updated by Garrett D'Amore over 8 years ago

  • Status changed from Pending RTI to Resolved

Resolved in:

changeset: 13710:3cee4ba952f0
tag: tip
user: Milan Jurik <>
date: Tue Jun 05 10:09:55 2012 -0700
2730 tar misbehaves if compress utility missing
2731 add -a --auto feature to tar for gtar comptability
Reviewed by: Josef 'Jeff' Sipek <>
Reviewed by: Richard Lowe <>
Approved by: Garrett D'Amore <>

Also available in: Atom PDF