Commit Graph

59 Commits

Author SHA1 Message Date
christos d653d57c19 PR/46786: Simon Burge: After conversion to 64 bit time_t, tar/pax/cpio
erroneously think that negative time_t's never fit in 32 bits. Rework
conversion code to always use uintmax_t, and detect negative values.
XXX[1]: Perhaps we should do the same (use a signed conversion) for all
fields not just for time_t
XXX[2]: pullup for 6
2012-08-09 08:09:21 +00:00
joerg 074c0c6e91 static + __dead 2011-08-29 14:47:47 +00:00
christos dbf8eeee06 add --xz 2011-06-18 23:07:04 +00:00
perry a992ea7967 Fixes from christos for pr-41167
XXX -X is still broken, but that wasn't part of this PR.
2009-04-07 19:52:35 +00:00
joerg 932c7ae27a Kill pre-4.4BSD compat code. 2008-02-24 20:42:46 +00:00
tls cfdef6ecba Teach set_ftime about symbolic links, because it has to know: on some
Linux systems, when we build as a tool we think we have lutimes but it
doesn't work on some filesystems at runtime.  A bit ugly but effective
and without use of AC_TRY_RUN in the tool build.  Tidier (than mine)
set_ftime reorganization from christos.
2008-01-10 04:24:51 +00:00
christos 206f418235 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.
2007-05-04 21:19:36 +00:00
christos 702d1ca548 PR/36194: Greg A. Woods: add a '-V' flag to pax for verbose summary without
listing (and other minor fixes)
2007-04-23 18:40:22 +00:00
christos c5d25686e0 PR/22995: Sergey Svishchev: If we are cd'ing around and we have directories
with relative paths, convert the directories to absolute paths, so that
restoring timestamps does not fail.
2006-04-16 16:20:21 +00:00
dsl b419a25464 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.)
2006-02-11 11:04:57 +00:00
christos b60b306ef2 Another missing mkdir() race pointed out by chuq. Factor out the mkdir code. 2005-09-16 16:48:18 +00:00
christos 15ea30eb09 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.
2005-04-24 01:45:03 +00:00
jmc 79308267d4 For HOSTTOOL builds, just exclude the chroot support as it's not needed and
avoids having to platform check for fchroot(). Fixes PR#27336
2004-10-22 21:00:18 +00:00
dsl 8317fe1276 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.
2004-10-17 18:49:55 +00:00
christos d980bf3418 Keep track of the length of the gnu long name/link hack, so that
we can append to it. Modify the code so that file_write is re-entrant,
even in the gnu long name/link hack.

The old code assumed that the buffer already contained the necessary
blocks to satisfy the read file request that contained the long
filename. This is not always the case, specially when we are dealing
with pipes which do shorter reads, thus having more probability
that a long file name will fall across a buffer boundary.

To reproduce, create a tar archive with a lot of gnu-long-names
(pkgsrc/devel/libsigc++2 is a good example), do a tar -tf to get
a list of filenames, compress it and do a tar -tzf to get another
list of the filenames. Notice that the two lists differ.
2004-09-22 15:03:18 +00:00
tron ed868bc7f4 Propery handle "cpio" archives where the last hardlink includes the
data of a file. This fixes PR bin/26514.
2004-08-22 16:46:18 +00:00
christos 08df9f4cb1 add -0 argument to handle nul separated file lists. 2004-06-19 02:27:00 +00:00
christos 5820cbfaf6 Welcome to WARNS=3 2004-05-11 17:12:26 +00:00
matt 8fbcc555cf When pax catches a signal and cleans up, make sure to remove any temporary
file that was being extracted to.  This will prevent pax from leaving
droppings when you hit ^C.
2004-02-13 23:10:14 +00:00
agc ed6ed8e698 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.
2003-10-13 07:41:22 +00:00
agc b5b2954259 Move UCB-licensed code from 4-clause to 3-clause licence.
Patches provided by Joel Baker in PR 22249, verified by myself.
2003-08-07 09:05:01 +00:00
simonb 1301238ab7 Add support for gnutar's -O "extract to stdout" option. 2003-07-08 06:00:48 +00:00
wiz e04df3a3d6 Add support for '-j' to create (and extract, but -z already did that)
bzip2 compressed tar files, for GNU tar compatibility.
Patch from Soren Jacobsen in PR 19467, okayed by christos.
Sync usage with options while here.
2003-02-25 13:36:59 +00:00
mrg c3510d1409 add --exclude support.
XXX:  --exclude & --exclude-from are still not 100% compatible, but since
rafal fixed --exclude-from's most annoying bug, they mostly work now.
2002-12-08 01:35:12 +00:00
christos 4472ef1520 Add proper longlink support. Previously we handled longname support, and
the longlink support was completely wrong.
2002-10-17 00:32:36 +00:00
christos f70dfaaf73 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.
2002-10-16 03:46:07 +00:00
christos ca541391bc PR/18663: Jeremy Reed: pax/tar/cpio allows ".." in names.
We now disallow it by default on both archive creation and extraction.
Add --insecure option to override.
2002-10-15 16:16:29 +00:00
mrg 20bac70304 make this build on LP64 2002-10-13 00:34:16 +00:00
christos 0c61202168 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.
2002-10-12 15:39:29 +00:00
tv 9fbd88883c Roll in fixes to permit cross-compiling from non-NetBSD hosts. This
round has been tested on Solaris/x86 and Linux hosts.

* Add host tools cap_mkdb, ctags, m4, uudecode.
* Protect __RCSID() and __COPYRIGHT() better.
* Reduce the number of places that need to include "config.h", to keep
  sources closer to their "vanilla" versions.
* Add more compat #defines and autoconf-checked functions.
2002-01-31 22:43:33 +00:00
tv a328e34106 Make almost all tools compile and run properly on non-NetBSD hosts. (In
particular, most tools now run correctly on Solaris 7.)
2002-01-29 10:20:28 +00:00
lukem 9ee82d317a s/u_longlong_t/unsigned long long/ to shut up the parc port 2001-10-28 13:06:43 +00:00
lukem 55026d5454 Implement -M flag: During a write or copy operation, treat the list of
files on standard input as an mtree(8) `specfile' specification, and
write or copy only those items in the specfile.

If the file exists in the underlying file system, its permissions and
modification time will be used unless specifically overridden by the
specfile. An error will be raised if the type of entry in the specfile
conflicts with that of an existing file.

Otherwise, it is necessary to specify at least the following parameters
in the specfile: type, mode, gname or gid, and uname or uid, device
(in the case of block or character devices), and link (in the case of
symbolic links). If time isn't provided, the current time will be used.
2001-10-25 08:51:50 +00:00
lukem c1bd745ccb - 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
2001-10-25 05:33:32 +00:00
kleink a8e69293b0 LC_TIME holds a locale name, which isn't a strftime() format string. 2000-10-22 15:41:31 +00:00
thorpej 4120b8a499 Add GNU tar-style long options for pax's tar front-end. Still many
GNU options not implemented, but there is an #if 0'd out canonical
list.
2000-07-04 17:17:49 +00:00
thorpej d0666190e1 Add a -O option: force one volume. This causes pax to not prompt for
a new volume upon premature end-of-volume (e.g. broken pipe).  This is
especially useful in automated environments where error recovery cannot
be performed by a human.
2000-03-30 17:53:04 +00:00
itohy f8adf56da0 Cleanup and fix typos.
Partially from FreeBSD.
2000-02-17 03:12:22 +00:00
itohy ba0ae447ef Fix SIGINFO botch (PR #8868).
Continue partial write(2) on signals (xwrite()).
Partial read(2) at a few places are also continued (xread()).

Add {read,write}_with_restart() hooks for porting on systems
which don't restart interrupted read()/write() calls.

Reviewed and discussed in tech-kern and tech-userlevel lists.
2000-02-17 03:06:12 +00:00
mrg b60cafe2fb add a new -p subflag: 'f' to preserve 4.4BSD fileflags. this only
really works for `pax -rw' but that's where it is most useful.
1999-11-01 01:35:58 +00:00
is e413a4ff50 Implement positional -C argument to tar. 1999-10-22 20:59:08 +00:00
mrg 78e294d1bc support ././@LongLink extraction, as created by GNU tar. 1999-10-22 10:43:11 +00:00
tron 1fbe6b7eae Strip leading slashes from filenames by default, add new "A" option to
disable this behaviour. Patches supplied by Peter Seebach in PR bin/8233.
1999-08-24 07:57:06 +00:00
christos 789b715904 Add SIGINFO support. 1999-03-03 18:06:52 +00:00
tron 7455a4498d Fix opt_add() prototype. 1999-02-07 15:08:50 +00:00
mrg ce6b187617 implement the gnutar -X flag in terms of pax -s. fix some bugs in pax -s handling while i am here... 1999-01-20 14:45:09 +00:00
tv af575980ab 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  ".)
1998-08-10 22:34:59 +00:00
mycroft d0e267dc7f Use the uid/gid caching moved into libc. Fixed a memory leak! 1998-07-28 17:44:23 +00:00
mycroft dbfa4f81b0 __AUDIT__ cleanup. 1998-07-27 16:43:25 +00:00
mycroft 778e6e0151 const poisoning. 1998-07-26 19:34:10 +00:00