Commit Graph

56 Commits

Author SHA1 Message Date
Sergey Poznyakoff
dd6094f6c0 Updated invocations of safer_name_suffix 2004-01-03 22:25:24 +00:00
Sergey Poznyakoff
5f32345fe6 Minor fix 2003-12-01 21:28:11 +00:00
Sergey Poznyakoff
47e73c7a44 (extract_archive): Check reported size vs.
archive file size to determine if we have to do with a
sparse file.
2003-12-01 21:19:37 +00:00
Sergey Poznyakoff
87fa28ed2a Use new sparse file interface. 2003-11-17 07:37:03 +00:00
Sergey Poznyakoff
89d2ad35e6 Added missing includes. 2003-10-08 11:17:36 +00:00
Sergey Poznyakoff
c1b9212b16 Moved system dependencies to system.c 2003-10-04 18:14:32 +00:00
Paul Eggert
07286647fb --strip strips file system prefix too, and it counts adjacent
slashes as if they were one slash.
2003-09-22 18:54:50 +00:00
Sergey Poznyakoff
ddab1f615e (extract_archive): Implemented --strip-path 2003-09-04 15:44:44 +00:00
Sergey Poznyakoff
d858a433c8 Use current_stat_info 2003-08-31 22:41:32 +00:00
Paul Eggert
675c5a2f24 (we_are_root): Now bool, not int.
(check_time): Warn about implausibly old time stamps.
(set_stat): Use utimbuf, not stat_info.
(preprare_to_extract): New arg DIRECTORY.
(fill_in_sparse_array): Moved here from compare.c.
(extract_sparse_file): Now returns off_t, giving size left.
Truncate file at end.
(extract_archive): Use safer_name_suffix rather than rolling our own.
Use fill_in_sparse_array rather than rolling our own.
Strip trailing slashes more effectively.
Check for unsafe names.
2003-07-05 06:53:31 +00:00
Paul Eggert
02a275c6ac (maybe_recoverable): Treat OVERWRITE_OLD_DIRS like DEFAULT_OLD_FILES. 2001-09-24 18:58:52 +00:00
Paul Eggert
6c9e824ce5 (extract_archive): When marking a directory to be updated after
symlinks, stat all directories after it in the delayed-set-stat
list too, since they will be checked after symlinks.
Add support for --overwrite-dir.
2001-09-22 00:47:09 +00:00
Paul Eggert
8267e6ed02 Fix bug: statement before decl. 2001-09-14 02:05:00 +00:00
Paul Eggert
95dda72cc6 (struct delayed_set_stat): New member 'after_symlinks'.
(delay_set_stat): Initialize it to 0.
(set_mode): New arg current_stat_info.  Use it (if nonnull) to avoid
taking an extra stat ourselves.  All callers changed.
(set_stat): Likewise.
(apply_nonancestor_delayed_set_stat): New arg 'after_symlinks'.
If false, stop when encountering a struct whose 'after_symlinks' member is
true.  Otherwise, go through all structures but check them more carefully.
All callers changed.
(extract_archive): When extracting a deferred symlink, if its parent
directory's status needs fixing, then mark the directory as needing
to be fixed after symlinks.
(extract_finish): Fix status of ordinary directories, then apply delayed
symlinks, then fix the status of directories that are ancestors
of delayed symlinks.
2001-09-12 06:46:23 +00:00
Paul Eggert
4bb7c67e04 (delay_set_stat): Fix off-by-one error in file
name size allocation that caused core dumps.
From Jan.Djarv@mbox200.swipnet.se.
(extract_archive): Use strcpy, not memcpy,
for consistency with other code that does similar things.
2001-08-29 21:37:27 +00:00
Paul Eggert
a7cd57a91d (struct delayed_symlinks, extract_archive, apply_delayed_symlinks):
Support hard links to symbolic links.

(struct delayed_symlink): Remove 'names' member, replacing it with
'sources' and 'target' member.  All uses changed.

(struct string_list): New type.

(delayed_set_stat, extract_archive): Use offsetof when computing sizes
for struct hack; this avoids wasted space in some cases.

(extract_archive): Fix test for absolute pathnames and/or "..".
Use link_error to report errors for links.
Remove redundant trailing '/' at "really_dir", for all uses, not
just before invoking mkdir.
If overwriting old files, do not worry so much about existing directories.
Fix mode computation in the case where the directory exists.

(apply_delayed_symlinks): If we can't make a hard link to a symbolic
link, make a copy of the symbolic link.
2001-08-27 14:27:54 +00:00
Paul Eggert
eca497ef34 (<time.h>): Do not include; system.h now does this.
(make_directories): Skip filesystem prefixes.
Don't assume '/' is the only separator.
(extract_sparse_file): Use new full_write semantics.
On write error, return instead of invoking skip_file.
Do not free sparsearray; caller does this now.
(apply_nonancestor_delayed_set_stat): Do not assume '/' is the only
separator.
(extract_archive): Don't assume file name lengths fit in int.
Report what got stripped from member name; it might be more than '/'.
Use new full_write semantics.
Do not pass redundant trailing "/" to mkdir, as POSIX does not allow
mkdir to ignore it.
Do not report mkdir error if old_files_option == KEEP_OLD_FILES.
2001-01-13 05:59:29 +00:00
Paul Eggert
22596ef599 Include <time.h>, since we invoke "time". 2000-10-24 06:37:55 +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
ba2ef4d075 Update copyright year. 2000-01-07 23:02:32 +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
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
c9f5ead8de Remove bogus errno FIXMEs. 1999-12-03 13:04:17 +00:00
Paul Eggert
7be178a4d4 (set_stat): Remove duplicate code. 1999-11-07 21:06:38 +00:00
Paul Eggert
5ae88d8a13 (<time.h>): No need to include.
(time): No need to declare.
(now): Remove variable.
(extr_init): Don't initialize `now'.
Increment same_permissions_option and same_owner_option if we_are_root
is nonzero; this supports the new --no-same-owner option.
(set_stat): Use start_time instead of `now'.
1999-09-21 15:13:33 +00:00
Paul Eggert
c270f6f1b2 Lint cleanup. 1999-08-23 09:55:55 +00:00
Paul Eggert
72290b64a6 (extract_sparse_file, extract_archive): Don't assume find_next_block yields nonnull.
(extract_archive): Fix sparse array bug: we did not find end of array
correctly.
1999-08-18 07:52:26 +00:00
Paul Eggert
5e0e027651 (make_directories): Do not chown intermediate directories, even
if we are root.
1999-08-16 08:13:20 +00:00
Paul Eggert
bda50f104b (time): Don't declare if defined.
(extr_init): Remove unneeded cast around 0 arg to time.
1999-08-14 07:10:19 +00:00
Paul Eggert
c402183f88 (extract_archive): Open files with O_NONBLOCK instead of O_NDELAY. 1999-08-11 12:47:01 +00:00
Paul Eggert
9cb6f5c466 this matches historical practice.
(unlink_destination): New function, which checks for unlink failures.
(maybe_recoverable): Stay quiet if -U.
(extract_archive): Use O_EXCL if unlink_first_option.
Report unlink failures.
Use HAVE_SYMLINK, not S_ISLNK, to determine whether symlink exists.
Use HAVE_MKFIFO || defined mkfifo, not S_ISFIFO, to determine whether
mkfifo exists.
1999-07-20 07:09:27 +00:00
Paul Eggert
6a8c91fef3 (extract_archive): Test whether S_IFCHR and S_IFBLK are nonzero,
not whether they are defined, for consistency with other tests.
1999-07-12 13:03:58 +00:00
Paul Eggert
0f32adce25 (extr_init, make_directories, extract_archive):
Do not assume mode bits have traditional Unix values.
(set_mode): Use %04 not %0.4 format.
(extract_sparse_file): Do not use data_block uninitialized.
Check for lseek failures; use portable lseek whence values.
1999-07-02 21:25:09 +00:00
Paul Eggert
6290150c47 Fix copyright notice. 1999-07-01 21:01:44 +00:00
Paul Eggert
1521a94b11 Handle EINTR correctly; use STDIN_FILENO instead of 0, etc. 1999-06-29 02:26:25 +00:00
Paul Eggert
7381ee26dd (extract_archive): Fix bug when extracting sparse files: they were
trashing the tar file header.
1999-02-01 07:51:19 +00:00
Paul Eggert
53a5ac41d2 (set_stat): chmod after chown even when not root; if we are using
--same-owner this is needed e.g. on Solaris 2.5.1.
1998-11-30 22:17:11 +00:00
Paul Eggert
49086e2770 (newdir_umask, current_umask): Now mode_t.
(extract_sparse_file): Args now use off_t.

(set_mode, set_stat, make_directories, extract_sparse_file,
extract_archive): Use off_t, size_t, ssize_t when appropriate.  Remove
now-useless casts.  Use unsigned long to print *_t types, except use
STRINGIFY_BIGINT for off_t.
1997-10-31 00:58:55 +00:00
Paul Eggert
818c240503 GNU tar 1.12 1997-04-23 00:05:57 +00:00
François Pinard
a295fffa66 *** empty log message *** 1994-11-16 02:46:28 +00:00
François Pinard
604e1433aa *** empty log message *** 1994-11-16 02:46:25 +00:00
François Pinard
32841f71ca *** empty log message *** 1994-11-16 02:46:22 +00:00
François Pinard
d61947f130 *** empty log message *** 1994-11-16 02:46:19 +00:00
François Pinard
9276277081 *** empty log message *** 1994-11-16 02:46:17 +00:00
François Pinard
0435e380a9 *** empty log message *** 1994-11-16 02:46:14 +00:00
François Pinard
2017294abd *** empty log message *** 1994-11-16 02:46:11 +00:00
François Pinard
84bff04c0d *** empty log message *** 1994-11-16 02:46:08 +00:00
François Pinard
7a8e060e78 *** empty log message *** 1994-11-16 02:46:06 +00:00
François Pinard
a7d353a9f0 *** empty log message *** 1994-11-16 02:46:03 +00:00
François Pinard
f420331fb4 *** empty log message *** 1994-11-16 02:46:00 +00:00