pax misbehavior

Andriy Gapon avg at icyb.net.ua
Thu Sep 20 16:44:10 PDT 2007


Preparation first:
$ mkdir xxxxx
$ cd xxxxx/
$ touch yyyyy
$ ln -s yyyyy yyyyy.0
$ ln -s yyyyy.0 yyyyy.0.0
$ cd ..

Demonstration of expected behavior:
$ pax -w -f xxxxx.tar -s "#xxxxx#zzzzz#" xxxxx
$ pax -vf xxxxx.tar
drwxr-xr-x  2 ...    0 20 Sep 18:51 zzzzz
-rw-r--r--  1 ...    0 20 Sep 18:51 zzzzz/yyyyy
lrwxr-xr-x  1 ...    0 20 Sep 18:51 zzzzz/yyyyy.0 => yyyyy
lrwxr-xr-x  1 ...    0 20 Sep 18:51 zzzzz/yyyyy.0.0 => yyyyy.0
pax: ustar vol 1, 4 files, 10240 bytes read, 0 bytes written.

Demonstration of misbehavior:
$ pax -w -f xxxxx.tar -s "#xxxxx#zzzzz#" -s "#.*##" xxxxx
$ pax -vf xxxxx.tar
drwxr-xr-x  2 ...    0 20 Sep 18:51 zzzzz
-rw-r--r--  1 ...    0 20 Sep 18:51 zzzzz/yyyyy
pax: ustar vol 1, 2 files, 10240 bytes read, 0 bytes written.


The only thing added in the second test is -s "#.*##" option _after_ the
first -s option. Mysteriously it caused all symlinks to not be included
into an archive. But this should not happen if the behavior in the first
test is correct and pax follows POSIX specification: if an entry is
handled by the first -s (which it was in the first test), then further
-s options should not be applied to it. Our man page also says it:

   Multiple -s expressions can be specified.  The
   expressions are applied in the order they are specified on the com-
   mand line, terminating with the first successful substitution.

Of course, this synthetic test is a simplification of something done for
a real task with a real purpose. -s "#.*##" is meant to exclude from an
archive all "other" files and the side-effect of excluding symlinks as
well is very unfortunate.

Should I file a PR ?

-- 
Andriy Gapon



More information about the freebsd-stable mailing list