Home | History | Annotate | Download | only in pax
History log of /src/bin/pax/ar_subs.c
RevisionDateAuthorComments
 1.59  05-Aug-2024  riastradh pax(1): Nix trailing whitespace.

No functional change intended.
 1.58  28-May-2023  lukem pax: don't overwrite destination if -r -w copy fails

Add more error handling to pax -r -w so that any failure
during the copy to the temporary file (including a failed flush)
prevents any existing destination file from being replaced
with the partial (including possibly empty) temporary file.
The partial temporary file is removed. pax still exists non-zero.

Thanks to Michael van Elst (mlelstv@) for the analysis
of the problem in the PR.

Should fix PR misc/33753.
 1.57  05-Dec-2021  msaitoh branches: 1.57.2;
s/exisit/exist/ in comment.
 1.56  31-Aug-2011  plunky branches: 1.56.44; 1.56.46;
NULL does not need a cast
 1.55  14-Feb-2009  lukem fix -Wsign-compare issues
 1.54  04-May-2007  christos branches: 1.54.20;
PR/36275: john at iastate dot edu: tar -s modifies symlink targets
- This is explained in a comment in pat_rep.c inside mod_name(). I did not
want to change the default behavior, so I added another modifier "s" which
when set, the pattern will not modify the symlink destination.
- While here I fixed another bug that was introduced before by the fix in
PR/35257 where the renaming was happening twice since we called rep_name
twice.
- Finally if we are renaming hard of soft-link targets print the renames for
those too.
 1.53  23-Apr-2007  christos PR/36194: Greg A. Woods: add a '-V' flag to pax for verbose summary without
listing (and other minor fixes)
 1.52  08-Mar-2007  rillig EROFS is not a critical error in a "mkdir -p".
 1.51  14-Dec-2006  christos PR/35257: Andreas Gustafsson: tar(1) opens excluded files
Apply the file modification function in the input files so that we can
de-select matched patterns.
 1.50  07-Oct-2006  elad PR/34265: dieter roelants: pax truncates archive when appending fails.

Patch applied, thanks!
 1.49  11-Feb-2006  dsl Ensure we exit with an error if we don't actually do anything.
There are a lot of tty_warn(0,...) and syswarn(0,...) which probably ought
to be tty_warn/syswarn(1,...) to force an error exit. However some are
used in interactive parts (eg opening a continuation archive) where there
is a separate retry loop.
So we just pass a failure code out to main() - how quaint!
This should now cause the NetBSD build to fail when gzip tries to write
to a non-existant directory.
(I suspect there are still many errors that don't get reported correctly.)
 1.48  11-Feb-2006  dsl Change all the 'return(x)' to 'return c'.
Makes some other searches I want to do a bit easier.
 1.47  31-Jan-2006  christos Solaris mkdir on an automounted component returns ENOSYS. Go figure.
Good choices whould have been EROFS, EEXIST, EACCES, EISDIR...
 1.46  06-Dec-2005  christos If we get EACCES from mkdir, try to stat() it, and if it is ok, we keep going.
Fixes problem with IRIX.
 1.45  01-Nov-2005  christos PR/31923: Sergey Svishchev: pax-as-tar ignores -k, overwrites existing files
Fix from Onno van der Linden
 1.44  17-Sep-2005  christos mkdir(2) can return EISDIR for /
 1.43  16-Sep-2005  christos Another missing mkdir() race pointed out by chuq. Factor out the mkdir code.
 1.42  22-May-2005  christos Don't even declare fdochroot() if we are in tool mode.
 1.41  14-May-2005  christos Allow writing symlinks that point outside our tree, but not traversing
them to write other files.
 1.40  06-May-2005  jmc Wrap call to fchroot in CONFIG tests so this doesn't blow up on cross-tools
 1.39  05-May-2005  christos PR/30132: Juan RP: tar --chroot refuses to extract files.
fchroot() changes the effective path, so we need to call updatepath().
 1.38  24-Apr-2005  christos If we cannot resolve a path, that probably means that we have not created
directories for that path yet. So, do the check for each component recursively
and succeed if none of the components fall outside our current working
directory.
 1.37  24-Apr-2005  christos PR/18759: FUKAUMI Naoki: pax/tar dot-dot handling broken
PR/18840: Frederick Bruckman: Fix for PR/18663 incomplete pax symlink handling

This patch makes ``--insecure'' do something. Now if ``--insecure''
is not set (the default) we do a realpath(3) in all the pathnames
that we are trying to create and if either realpath fails, or the
path is outside our working directory, we print a warning and die.
This maybe too strict and might fail on valid archives that create
symlinks and directories in the wrong order.
 1.36  24-Apr-2005  christos For clarity instead of using -1 and -2 use the negative of the archive type.
 1.35  23-Jan-2005  jmc Apply user supplied patterns first before applying actions for -A. This way pax
behavior WRT to patterns lines up with the example in the documentation
and how other implementations do it as well since -A is a non-standard
option/behavior. Fixes items noted in PR#23776
 1.34  22-Oct-2004  jmc For HOSTTOOL builds, just exclude the chroot support as it's not needed and
avoids having to platform check for fchroot(). Fixes PR#27336
 1.33  17-Oct-2004  dsl Add an option --chroot to tar. Causes it to chroot(".") before doing
an extract. With -h this will cause existing absolute symlinks to be treated
as relative to the current directory.
Helps sysinst handle existing symlinks in the target system.
Remove 'L' from the usage (got spilt into 'h' and 'H' many moons ago)
Add 'S' to usage, and put into correct place in options list.
 1.32  10-Oct-2004  christos PR/27213: Greg A. Woods: pax doesn't honour SIGPIPE when listing
But always exit, not just on SIGPIPE.
 1.31  22-Aug-2004  tron Propery handle "cpio" archives where the last hardlink includes the
data of a file. This fixes PR bin/26514.
 1.30  16-Apr-2004  christos remove misplaced semi-colons.
 1.29  27-Oct-2003  lukem branches: 1.29.2;
Overhaul how `build.sh tools' are used:

* Rename "config.h" to "nbtool_config.h" and
HAVE_CONFIG_H to HAVE_NBTOOL_CONFIG_H.
This makes in more obvious in the source when we're using
tools/compat/config.h versus "standard autoconf" config.h

* Consistently move the inclusion of nbtool_config.h to before
<sys/cdefs.h> so that the former can provide __RCSID() (et al),
and there's no need to protect those macros any more.

These changes should make it easier to "tool-ify" a program by adding:
#if HAVE_NBTOOL_CONFIG_H
#include "nbtool_config.h"
#endif
to the top of the source files (for the general case).
 1.28  13-Oct-2003  agc Move Keith Muller's code from a 4-clause to a 3-clause licence by removing
the advertising clause. Diffs provided in PR 22397 by Joel Baker, confirmed
to the board by Keith Muller.
 1.27  07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22249, verified by myself.
 1.26  08-Jul-2003  simonb Add support for gnutar's -O "extract to stdout" option.
 1.25  23-Jun-2003  grant consistently use "cannot" instead of "can not".
 1.24  31-Mar-2003  christos RP/8227: Peter Seeback: Emulate old gnu tar better.
 1.23  09-Feb-2003  grant cosmetic error condition improvements.
- sprinkle some fflush() to print filenames correctly.
- print a \n to stdout to fix formatting.
- English, consistently use "Cannot" in error messages.

some whitespace cleanup.
 1.22  02-Feb-2003  wiz Fix various spelling, grammar, and punctuation problems in comments, from Sergey Svishchev in PR 20164.
 1.21  10-Dec-2002  christos PR/19339: Martin Weber: Tar fails to append on empty files and exits with
0. Revert previous change for PR/18689. We always want to exit with
an error if we could not determine the archive format. Instead,
treat empty files specially. On list/extract we turn into no/op.
On append, we turn into archive.
 1.20  18-Oct-2002  itojun exit with 0 if the input is empty of not a tar file. matches GNU tar behavior.
solves PR 18689.
 1.19  17-Oct-2002  christos Add proper longlink support. Previously we handled longname support, and
the longlink support was completely wrong.
 1.18  16-Oct-2002  christos Support gnu long filename extensions by default for tar on create, list, and
extract. We now generate GNU tar archives by default ("ustar ^@" instead of
"ustar^@00"). GNU extensions can be disabled with --strict.

XXX: long symlinks untested.
 1.17  12-Oct-2002  christos merge OpenBSD changes:
- correct -C processing
- add ability to read filenames and flags from a file
- don't print dangerous escape sequences to the terminal
- use strlcpy/strncpy properly.
- handle tmpfile creation better.
- improve documentation of options.
- handle stdout/stderr list selection correctly.
- kill gzip when we get interrupted.
- simplify gzip setup.
- add more flags to programs.

additional changes:
- librmt processing.
- set POSIXLY_CORRECT in options parsing.
- prevent more string overruns.
- support -T

we don't turn the switch on to replace tar and cpio yet.
 1.16  31-Jan-2002  tv branches: 1.16.2;
Protect __RCSID and __COPYRIGHT from being invoked if not defined.
 1.15  25-Oct-2001  lukem - ansi KNF (just remove all the #ifndef __STDC__ prototype junk,
leaving the ansi stuff)
- use longlong_t instead of quad_t (etc), and rename *uqd*() -> *ull*()
- clean up the NET2_STAT stuff similar to ftpd; provide #defines and
macros which select which cast to use, etc
- clean up the NET2_FTS and NET2_REGEX #define use
 1.14  17-Feb-2000  itohy Cleanup and fix typos.
Partially from FreeBSD.
 1.13  22-Oct-1999  mrg support ././@LongLink extraction, as created by GNU tar.
 1.12  24-Aug-1999  tron branches: 1.12.2;
Strip leading slashes from filenames by default, add new "A" option to
disable this behaviour. Patches supplied by Peter Seebach in PR bin/8233.
 1.11  03-Mar-1999  christos Add SIGINFO support.
 1.10  10-Aug-1998  tv Transparently handle old-style GNU tar archives that may have garbage in
the trailing block and do not have an end-of-archive marker. (Does this
handling based on whether the ustar id is "ustar" or "ustar ".)
 1.9  28-Jul-1998  mycroft Use the uid/gid caching moved into libc. Fixed a memory leak!
 1.8  01-Apr-1998  kleink Need <time.h> for time() prototype.
 1.7  20-Jul-1997  christos - Rename local warn so tty_warn that we can include <err.h> since this program
uses err() and errx().
- Fix printf format strings.
- Added WARNS=1; note
- Added missing prototypes.
- Split overloaded trail function into trail() and subtrail().
 1.6  11-Jan-1997  tls kill 'register'
 1.5  21-Mar-1995  cgd convert to new RCS id conventions.
 1.4  23-Sep-1994  mycroft Eliminate uses of some obsolete functions.
 1.3  14-Jun-1994  mycroft Fix up RCS ids.
 1.2  13-Jun-1994  jtc Add RCS ID's
 1.1  13-Jun-1994  jtc branches: 1.1.1;
Initial revision
 1.1.1.1  13-Jun-1994  jtc From 4.4 lite
 1.12.2.1  27-Dec-1999  wrstuden Pull up to last week's -current.
 1.16.2.3  25-Aug-2004  he Pull up revision 1.30 (requested by cube in ticket #1732):
Remove misplaced semi-colons.
 1.16.2.2  16-Jun-2004  jmc fix botched pullup from ticket #1021 and make sure this compiles on
non-NetBSD hosts again. Also fixes PR#24481
 1.16.2.1  07-Apr-2004  jmc Pullup rev 1.17-1.29 (requested by rafal in ticket #1021)

Pullup pax to current version on trunk. Includes many fixes.
 1.29.2.2  25-Aug-2004  jmc branches: 1.29.2.2.2;
Pullup rev 1.31 (requested by tron in ticket #784)

Propery handle "cpio" archives where the last hardlink includes the
data of a file. PR#26514
 1.29.2.1  21-Apr-2004  jmc Pullup rev 1.30 (requested by christos in ticket #170)

Fixes for multiple pax pr's. PR#25200. PR#25207.
 1.29.2.2.2.1  23-Jul-2005  snj Apply patch (requested by riz in ticket #5512):
Sync pax with HEAD of 2005-07-22.
 1.54.20.1  13-May-2009  jym Sync with HEAD.

Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html
 1.56.46.1  07-Aug-2024  martin Pull up following revision(s) (requested by riastradh in ticket #1863):

bin/pax/buf_subs.c: revision 1.31
tests/bin/pax/t_pax.sh: revision 1.3
tests/bin/pax/t_pax.sh: revision 1.4
tests/bin/pax/t_pax.sh: revision 1.5
tests/bin/pax/t_pax.sh: revision 1.6
tests/bin/pax/t_pax.sh: revision 1.7
bin/pax/extern.h: revision 1.61
bin/pax/pax.c: revision 1.50
bin/pax/pax.c: revision 1.51
bin/pax/file_subs.c: revision 1.65
bin/pax/ftree.c: revision 1.43
bin/pax/ar_subs.c: revision 1.58

pax: exit 0 if stdin filelist is used and empty

If copying a list of files from stdin, exit zero instead of non-zero
if there are no files supplied.

AFAICT, POSIX doesn't require a non-zero an error in this situation,
since there are no files to not match.

Fix from PR bin/41736 by Lloyd Parkes.

pax: don't overwrite destination if -r -w copy fails

Add more error handling to pax -r -w so that any failure
during the copy to the temporary file (including a failed flush)
prevents any existing destination file from being replaced
with the partial (including possibly empty) temporary file.

The partial temporary file is removed. pax still exists non-zero.
Thanks to Michael van Elst (mlelstv@) for the analysis
of the problem in the PR.
Should fix PR misc/33753.

tests/bin/pax: Add test for pax list in an ungettable cwd.
The list operation has no need to touch the file system, so it should
have no need for open(".") or getcwd() to succeed.

PR bin/44498: tar(1) unnecessarily demands that getcwd() work
(The PR was filed about tar(1), which is now bsdtar by default, but
the issue applies to pax(1) too and would continue to apply to tar(1)
if you set MKBSDTAR=no.)
pax(1): Don't require open(".") or getcwd to work for list operation.

PR 44498: tar(1) unnecessarily demands that getcwd() work
tests/bin/pax: Test pax(1) succeeds with empty file list on stdin.

PR bin/41736: pax reports an error when copying zero files
tests/bin/pax: Add some more cwd-related test cases.

PR bin/44498: tar(1) unnecessarily demands that getcwd() work
pax(1): Only require getcwd if we're reading without --insecure.

No other paths use the result of getcwd.

PR bin/44498: tar(1) unnecessarily demands that getcwd() work
 1.56.44.2  21-Apr-2020  martin Ooops, restore accidently removed files from merge mishap
 1.56.44.1  21-Apr-2020  martin Sync with HEAD
 1.57.2.1  07-Aug-2024  martin Pull up following revision(s) (requested by riastradh in ticket #776):

bin/pax/buf_subs.c: revision 1.31
tests/bin/pax/t_pax.sh: revision 1.3
tests/bin/pax/t_pax.sh: revision 1.4
tests/bin/pax/t_pax.sh: revision 1.5
tests/bin/pax/t_pax.sh: revision 1.6
tests/bin/pax/t_pax.sh: revision 1.7
bin/pax/extern.h: revision 1.61
bin/pax/pax.c: revision 1.50
bin/pax/pax.c: revision 1.51
bin/pax/file_subs.c: revision 1.65
bin/pax/ftree.c: revision 1.43
bin/pax/ar_subs.c: revision 1.58

pax: exit 0 if stdin filelist is used and empty

If copying a list of files from stdin, exit zero instead of non-zero
if there are no files supplied.

AFAICT, POSIX doesn't require a non-zero an error in this situation,
since there are no files to not match.

Fix from PR bin/41736 by Lloyd Parkes.

pax: don't overwrite destination if -r -w copy fails

Add more error handling to pax -r -w so that any failure
during the copy to the temporary file (including a failed flush)
prevents any existing destination file from being replaced
with the partial (including possibly empty) temporary file.

The partial temporary file is removed. pax still exists non-zero.
Thanks to Michael van Elst (mlelstv@) for the analysis
of the problem in the PR.
Should fix PR misc/33753.

tests/bin/pax: Add test for pax list in an ungettable cwd.
The list operation has no need to touch the file system, so it should
have no need for open(".") or getcwd() to succeed.

PR bin/44498: tar(1) unnecessarily demands that getcwd() work
(The PR was filed about tar(1), which is now bsdtar by default, but
the issue applies to pax(1) too and would continue to apply to tar(1)
if you set MKBSDTAR=no.)
pax(1): Don't require open(".") or getcwd to work for list operation.

PR 44498: tar(1) unnecessarily demands that getcwd() work
tests/bin/pax: Test pax(1) succeeds with empty file list on stdin.

PR bin/41736: pax reports an error when copying zero files
tests/bin/pax: Add some more cwd-related test cases.

PR bin/44498: tar(1) unnecessarily demands that getcwd() work
pax(1): Only require getcwd if we're reading without --insecure.

No other paths use the result of getcwd.

PR bin/44498: tar(1) unnecessarily demands that getcwd() work

RSS XML Feed