Commit Graph

371 Commits

Author SHA1 Message Date
Paul Eggert
d2f18d9ecb (decode_options): Check that volume label is not too long to overflow
name in tar header block.
2000-10-25 05:21:06 +00:00
Paul Eggert
29c1020f91 (check_label_pattern): Make sure header name is a string before
passing it to fnmatch.
(init_volume_number): Check for global_volno overflow.
(new_volume): Check for global_volno overflow.
2000-10-25 05:21:06 +00:00
Paul Eggert
22596ef599 Include <time.h>, since we invoke "time". 2000-10-24 06:37:55 +00:00
Paul Eggert
f326d78fda Include localedir.h.
(main): Update copyright date to 2000.
2000-10-24 06:18:37 +00:00
Paul Eggert
caf6047e1e Include localedir.h, prepargs.h.
(long_options): Now static.
(long_options, usage, decode_options): -j is now short for --bzip2,
and -I is now an alias for -T.
(decode_options, main): argv is not const pointer now.
(decode_options): Invoke prepend_default_options to support TAR_OPTIONS.
In diagnostic, mention the string that was the invalid blocking factor,
tape length, group, owner, or record size.
--delete is no longer incompatible with -f -, undoing 2000-01-07 change.
(main): Invoke extract_finish at end of extraction.
2000-10-24 06:18:37 +00:00
Paul Eggert
8111f9d34d Include hash.h.
(gnu_list_name): Remove decl.
(struct link): Remove "next" member.
(linklist): Remove.
(start_header): Say "leading `FOO'" rather than "`FOO' prefix" for consistency
with other diagnostics.
(deal_with_sparse): Check for I/O error when closing the file.
(create_archive):
Do not allocate an array of size PATH_MAX, as PATH_MAX might be (size_t) -1.
Instead, allocate an array with the size that's needed.
(hash_link, compare_links): New functions.
(dump_file): Do not exhaust open file descriptors when descending deeply
into a directory, by using savedir rather than opendir/readdir.
Do not zero-fill the name buffer unnecessarily.
Hash the set of links already created, instead of using a linked list.
Fix some bugs in outputting sparse files which caused the sparse tables
to be incorrect.
When a file unexpectedly shrinks, output zeros rather than garbage.
Do not allocate an array of size PATH_MAX, as PATH_MAX might be (size_t) -1.
Instead, allocate an array with the size that's needed.
2000-10-24 06:18:37 +00:00
Paul Eggert
e0fe240d7c Fix comments. 2000-10-24 06:18:37 +00:00
Paul Eggert
e89bcb7fb3 (we_are_root): Now global.
(struct delayed_symlink): New type.
(delayed_symlink_head): New var.
(extr_init, fatal_exit):
Invoke extract_finish on fatal errors, not apply_delayed_set_stat.
(set_mode, set_stat): Pointer args are now const pointers.
(check_time): New function.
(set_stat): Warn if setting a file's timestamp to be the future.
(make_directories): Do not save and restore errno.
(maybe_recoverable): Set errno to ENOENT if we cannot make missing
intermediate directories.
(extract_archive):
Invoke apply_nonancestor_delayed_set_stat here, not in caller.
Extract potentially dangerous symbolic links more carefully, deferring their
creation until the end, and using a regular file placeholder in the meantime.
Do not remove trailing / and /. from file names.
Do not bother checking for ".." when checking whether a directory
loops back on itself, as loopbacks can occur with symlinks too.
Also, in that case, do not bother saving and restoring errno; just
set it to EEXIST.
(apply_nonancestor_delayed_set_stat): A prefix is a potential ancestor if
it ends in slash too (as well as ending in a char just before slash).
(apply_delayed_set_stat): Remove.
(apply_delayed_symlinks, extract_finish): New functions.
2000-10-24 06:18:37 +00:00
Paul Eggert
2f04b655d8 (update_archive): Use skip_member. 2000-10-24 06:18:37 +00:00
Paul Eggert
bc8d000b64 (read_and):
Do not invoke apply_nonancestor_delayed_set_stat;
DO_SOMETHING is now responsible for that.
Do not invoke apply_delayed_set_stat; our caller is now responsible for that.
(read_header): Use signed char instead of signed_char.
Prevent later references to current_header from
mistakenly treating it as an old GNU header.
(from_header): Quote invalid base-64 strings in diagnostics.
(time_from_header): Do not warn about future timestamps in archive;
check_time now does that.
(tartime): Fix off-by-one error when copying year if OLD_CTIME.
(print_header): Quote unknown file types.
(skip_member): New function, replacing skip_extended_headers and
now skipping the whole member instead of just the extended headers.
All callers changed.  This makes the code handle extended headers
uniformly, and fixes some bugs.
2000-10-24 06:18:37 +00:00
Paul Eggert
8a098729c0 (extract_mangle): Fix diagnostic with wrong number of %s'es. 2000-10-24 06:18:37 +00:00
Paul Eggert
257a4160e4 (base_name): Do not include basename.h; declare base_name
instead.
(rexec): Don't declare unless using it.
(do_command): Simplify signal-handling code slightly.
2000-10-24 06:18:37 +00:00
Paul Eggert
4dcebd9655 (_GNU_SOURCE): Remove; autoconf now does this.
(child_open_for_compress, child_open_for_uncompress, close_archive):
Propagate any failure of the compression process back to "tar".
(open_archive, flush_write, flush_read, close_archive):
Do not allocate an array of size PATH_MAX, as PATH_MAX might be (size_t) -1.
Instead, allocate an array with the size that's needed.
(open_archive): Don't bother checking S_ISCHR of /dev/null.
(backspace_output): Don't try to backspace past start of archive.
(close_archive): Remove special case for DELETE_SUBCOMMAND.
2000-10-24 06:18:37 +00:00
Paul Eggert
85e724550f (_GNU_SOURCE): Remove; autoconf now does this.
Include <hash.h>.
(getpwuid, getgrgid): Declare only if system headers don't.
(gid_to_gname): Don't invoke setgrent.
(namelist): Now static, not global.
(nametail): New var.  All uses of namelast changed to use nametail,
with one extra level of indirection.
(name_gather): Use memcpy instead of strncpy + assignment of NUL.
(name_match): Set nametail too, when setting namelist to null.
(add_hierarchy_to_namelist): Change type of dir arg from char * to
struct name *, so that we don't have to look up the name again here.
Get change_dir from dir rather than as a separate arg.  Add dirsize arg,
and pass it along to get_directory_contents.  Remove unnecessary check
of directory type.
(new_name): Do not append a slash if PATH already ends in one.
(avoided_names, struct avoided_name): Remove.
(avoided_name_table): New var, replacing avoided_names.
(hash_avoided_name, compare_avoided_names): New function.
(add_avoided_name, is_avoided_name): Use hash table rather than linked list.
2000-10-24 06:18:37 +00:00
Paul Eggert
ba2ef4d075 Update copyright year. 2000-01-07 23:02:32 +00:00
Paul Eggert
c18999bad5 (read_and): Invoke apply_nonancestor_delayed_set_stat on file names
after handling them.
(list_archive): Use consistent message for unexpected EOF.
Use error message functions to report errors consistently.
(read_header): Use xalloc_die to report memory exhaustion.
Use consistent message for unexpected EOF.
(decode_mode): Remove; moved to misc.c.
(skip_file): Use consistent message for unexpected EOF.
(skip_extended_headers): Likewise.
2000-01-07 19:25:23 +00:00
Paul Eggert
f74454cb37 (find_new_file_size): Return size instead of storing through pointer.
All callers changed.
(deal_with_sparse): Don't keep reading after read errors.
(finish_sparse_file): Just abort if there is an internal error.
Use error message functions to report errors consistently.
(dump_file): Fix typo: stat_warn and stat_error were interchanged.
Quote file names with colons if possible.
Don't restore access times on directories during incremental dumps
until after dealing with the directory.
If ignoring failed reads, count closedir errors as warnings, not errors.
Fix buffer overrun problem when dumping sparse files.
If ignoring failed reads, count read errors as warnings, not errors.
Use error message functions to report errors consistently.
If ignoring failed reads, count unknown files as warnings, not errors.
2000-01-07 19:25:23 +00:00
Paul Eggert
f2b8b4a42d (extract_mangle): Use xalloc_die to report memory exhaustion.
Quote file names with colons if possible.
2000-01-07 19:25:23 +00:00
Paul Eggert
53f16a5971 (extr_init): If we run out of memory, invoke apply_delayed_set_stat.
(set_mode): Use Use error message functions to report errors consistently.
(set_stat): Likewise.
(repair_delayed_set_stat): Quote file names with colons if possible.
(prepare_to_extract): Don't complain if we can't remove ".".
(extract_sparse_file): Use consistent message for unexpected EOF.
Use error message functions to report errors consistently.
(extract_archive): Use consistent message for unexpected EOF.
Use error message functions to report errors consistently.
Quote file names with colons if possible.
(apply_delayed_set_stat): New function.
(apply_nonancestor_delayed_set_stat): Renamed from apply_delayed_set_stat.
Don't remove head if it doesn't apply.
(fatal_exit): Invoke apply_delayed_set_stat with no args.
2000-01-07 19:25:23 +00:00
Paul Eggert
c598438dd2 (decode_options): Use xalloc_die to report memory exhaustion.
--delete and -f - are now incompatible, since we didn't have time
to fix their bugs.
2000-01-07 19:25:23 +00:00
Paul Eggert
cae3ad0d8e (archive_write_error): Add noreturn attribute to decl.
(xclose): Use close_error.
(xdup2): Regularize messages with rest of tar.
(archive_write_error): Use write_fatal_details.
(flush_read): Don't read past EOF.
(flush_archive, close_archive, new_volume): Use close_warn.
2000-01-07 19:25:23 +00:00
Paul Eggert
db3693939d (append_file): Use error message functions to report errors consistently. 2000-01-07 19:25:23 +00:00
Paul Eggert
a78ab36e1e (<quotearg.h>): New include.
(append_file):
Don't assume that gettext preserves errno.
Quote arbitrary strings in diagnostics.
Check for close error.
1999-12-13 05:11:05 +00:00
Paul Eggert
c6720c5a8b ("quotearg.h"): New include.
(usage): Now has __attribute__ ((noreturn)).
(confirm): Report errno if we can't open tty.
(confirm, decode_options):
Quote arbitrary strings in diagnostics.
(OVERWRITE_OPTION): New constant.
(long_options, usage, decode_options): New --overwrite option.
(decode_options): --keep-old-files, --overwrite, and --unlink-first
are now mutually exclusive.
Don't assume that gettext preserves errno.
(main): Set default quoting style to escape_quoting_style.
1999-12-13 05:11:05 +00:00
Paul Eggert
df2ff9e4e4 (read_and, list_archive):
Quote arbitrary strings in diagnostics.
(from_header): Use locale_quoting_style to quote diagnostics.
(print_header, print_for_mkdir): Quote with quotearg, not quote_copy_string.
1999-12-13 04:52:26 +00:00
Paul Eggert
aef747068b (decode_oflag): O_APPEND might not be defined. 1999-12-13 04:52:26 +00:00
Paul Eggert
a3f819a9d7 (REM_BIAS): Increase from 128 to (1 << 30). 1999-12-13 04:52:26 +00:00
Paul Eggert
f0429c4a22 (<quotearg.h>): New include.
(name_init, name_next, name_close, names_notfound, collect_and_sort_names):
Don't assume that gettext preserves errno.
Quote arbitrary strings in diagnostics.
(excluded_name): Fix typo that caused empty patterns to be mishandled.
1999-12-13 04:52:26 +00:00
Paul Eggert
6e9d1539b6 (<quotearg.h>): New include.
(enum permstatus): New enum.
(struct delayed_set_stat): file_name is now at end of buffer, to avoid
two mallocs.  New members file_name_len, invert_permissions, permstatus.
(extr_init): Remove hack that silently adjusted newdir_umask.
(set_mode, set_stat): New args invert_permissions, permstatus, typeflag.
Use these args to decide whether and how to set modes.
(set_mode, set_stat, prepare_to_extract, extract_sparse_file, extract_archive):
Don't assume that gettext preserves errno.
(set_stat): Remove arg symlink_flag; subsumed by typeflag.
(delay_set_stat, repair_delayed_set_stat): New functions.
(make_directories): Avoid mkdir where last part of path is "..".
Create a struct delayed_set_stat for each directory made.
(prepare_to_extract): Renamed from unlink_destination, and
return 0 immediately if to_stdout_option; all callers changed.
(maybe_recoverable): New parameter interdir_made.
Add support for --overwrite.
(extract_sparse_file, extract_archive):
Quote arbitrary strings in diagnostics.
(extract_archive): By default, warn about ".." in member names, and skip them.
Don't open files with O_NONBLOCK or O_APPEND.
Open with O_TRUNC only if --overwrite; otherwise, use O_EXCL to avoid
overwriting them.  Pass only rwxrwxrwx permissions to `open' and `mkdir',
minus the current umask.  Keep track of intermediate directories made,
to avoid looping when making x/../x when x doesn't exist; the
earlier code solved this in a different way that didn't fit well
into the new scheme.  Don't extract permissions onto existing
directories unless --overwrite is given.  Do not add -wx------
permissions to new directories permanently; just do it temporarily.
Remove no-longer-needed hack with MSDOS and directory time stamps.
(apply_delayed_set_stat): New argument specifies which directories to
fix statuses of.  Do not wait until the end of extraction to fix
statuses; instead, fix a directory's status once we exit that directory.
This requires less memory and does the right thing in some cases
where the old method didn't.
(fatal_exit): New function.
1999-12-13 03:26:04 +00:00
Paul Eggert
ed7e2ec8a3 (<quotearg.h>): New include.
(start_header): Use `member names' to refer to archive member names, not
`archive names'.  Warn about `..' in member names.
(finish_sparse_file, dump_file):
Quote arbitrary strings in diagnostics.
(finish_sparse_file, dump_file):
Don't assume that gettext preserves errno.
(dump_file): Don't use `access' to determine whether a directory is readable;
this isn't reliable if tar is setuid.  Use `opendir' instead.
Check for readdir and closedir failures.
Don't dump sockets as if they were fifos; just warn and skip.
1999-12-13 03:07:14 +00:00
Paul Eggert
196caec187 (xclose, xdup2, child_open_for_compress, child_open_for_uncompress,
archive_write_error, archive_read_error, flush_archive, close_archive,
init_volume_number, new_volume):
Don't assume that gettext preserves errno.

(xdup2): Don't report errno if dup returns an unexpected nonnegative value.
(open_archive): Reject multivolume verify attempts a bit earlier.
Rename local variable `access', in case it's defined by system header.

(open_archive, backspace_output): Use `Cannot' uniformly, instead of
`Could not' sometimes and `Cannot' others.

(open_archive, flush_read, flush_archive, close_archive, new_volume):
Quote arbitrary strings in diagnostics.

(read_error): Set archive to STDOUT_FILENO temporarily when writing
archive buffer.

(init_volume_number): Check for input and output errors in volno_file.

(new_volume): Use new fatal_exit function to exit, and new xfork
function to fork.
1999-12-13 02:51:14 +00:00
Paul Eggert
86b765527a (dump_file): Undo previous change about diagnosing unexpectely missing
files.  Instead, diagnose them a bit better.

Report that a file changed if its ctime changes; this is more
sensitive than mtime+size, and more accurate.
1999-12-03 13:46:09 +00:00
Paul Eggert
c9f5ead8de Remove bogus errno FIXMEs. 1999-12-03 13:04:17 +00:00
Paul Eggert
bc9dc01ec3 (name_next): If file names are given both in the
command line (e.g. via -C) and in a file (via -T), do not
ignore the command-line names.
1999-12-03 13:04:17 +00:00
Paul Eggert
3495d84e27 (dump_file): Do not diagnose a file that the parent directory
said should be there, but is absent.  It was
probably removed between then and now.
Do not pass meaningless errno to ERROR when reporting that the
file changed as we read it.
1999-12-03 13:04:17 +00:00
Paul Eggert
04f1deefad (finish_header): Report block numbers with origin 0, not origin 1. 1999-11-07 22:01:27 +00:00
Paul Eggert
859a4ec01f (usage): Add examples. 1999-11-07 21:15:15 +00:00
Paul Eggert
02519e5575 Include getopt.h.
(long_opts): New constant.
(usage): New function.
(main): Implement --help and --version.
Output usage message if arguments are bad.
1999-11-07 21:06:38 +00:00
Paul Eggert
f87e585c51 (to_chars): Remove trailing newline from warning.
(dump_file): Ignore doors.
1999-11-07 21:06:38 +00:00
Paul Eggert
7be178a4d4 (set_stat): Remove duplicate code. 1999-11-07 21:06:38 +00:00
Paul Eggert
26505948d9 (from_header): Handle 32-bit two's complement negative time stamps
even if the leading octal digit is 2 or 3.
1999-11-07 21:06:38 +00:00
Paul Eggert
a46a204436 (update_archive): Fix typo: last two args to dump_file were interchanged. 1999-10-11 06:56:17 +00:00
Paul Eggert
51f0c7c364 (tartime): Now extern.
(read_and): Invalid headers cause errors, not warnings.
1999-10-11 06:56:17 +00:00
Paul Eggert
3f3860fd6a (dump_file): Fix typo: last two args to dump_file were interchanged. 1999-10-11 06:56:17 +00:00
Paul Eggert
cf4065dfe9 (decode_options): Invalid dates are now treated as (time_t) -1.
Redo version message to conform to GNU standards.
1999-10-11 06:56:17 +00:00
Paul Eggert
29929863e8 (write_error): Read error is an error, not just a warning. 1999-09-25 05:47:17 +00:00
Paul Eggert
559eeb2b52 (to_chars): Fix base-256 output. 1999-09-25 05:47:17 +00:00
Paul Eggert
10f585ea2f (print_total_written): Use a format compatible with
Amanda 2.4.1p1.
1999-09-25 00:25:36 +00:00
Paul Eggert
e6d8e9279f (update_archive): Remove call to name_expand; had no effect.
Use chdir_do to change into directory.
Use deref_stat instead of stat.
Use add_avoided_name to mark names to be avoided; the old method of
setting a bit with the name caused all descendants of that name to
be avoided, in some circumstances.
1999-09-24 23:44:52 +00:00
Paul Eggert
825b72c52b (<time.h>): Include.
(time): Declare if not defined.
(confirm): Don't read past EOF.
(long_options, usage): Add --no-same-owner, --no-same-permissions.
(main): Use clock_gettime if available.
1999-09-24 23:44:52 +00:00