1
0
mirror of https://github.com/openbsd/src.git synced 2025-01-04 15:25:38 -08:00
Commit Graph

439 Commits

Author SHA1 Message Date
jmc
93da23dae1 use a more readable explanation of directory creation;
from evan silberman, tweaked by millert

ok sthen (pre-tweak)
2024-11-30 06:59:12 +00:00
guenther
b27f9b3934 'newercnt' no longer does anything that 'refcnt' doesn't; eliminate
the former in favor of the latter.

ok millert@
2024-08-15 00:47:44 +00:00
jca
c7d9714183 Zap trailing whitespace
Dummy commit to trigger the git exporter.
2024-07-14 14:32:02 +00:00
guenther
bb7daa6de6 When comparing mtimes for the -u and -Z options and the target is
'too old', use pathconfat(_PC_TIMESTAMP_RESOLUTION, AT_SYMLINK_NOFOLLOW)
to get the timestamp resolution to which the _source_ timestamp
should be truncated for a stable comparison.

Problem reported by Walter Alejandro Iglesias (wai(at)roquesor.com)
ok millert@
2024-05-18 05:21:38 +00:00
millert
8758bb5921 pax: make list file handle line-buffered unless it is stderr.
This fixes a problem where the file list output was fully-buffered
when used as part of a pipeline.  With this change, files are listed
as they are extracted in verbose mode.  OK deraadt@ guenther@
2024-05-10 20:28:31 +00:00
florian
55449a4bb3 gmtime(3) / locatime(3) can fail when timestamps are way off.
Add missing error checks to all calls under bin/

Input & OK millert
2024-04-28 16:43:15 +00:00
florian
9a584187e4 Use propper knf.
Spotted by kettenis.
2024-04-27 19:49:42 +00:00
florian
a782b597b2 localtime(3) can fail if time_t is very far in the future or past.
found using afl++

OK millert
2024-04-27 14:57:02 +00:00
jsg
e6c7c102cf correct indentation; no functional change
ok tb@
2024-04-23 13:34:50 +00:00
jca
8df7613330 Provide a pax format specific option handler
The existing tar_opt() implements support for -o write_opt=nodir for the
old tar and ustar formats. We don't really want to support it for the
pax format, and we want to be able to implement pax format specific
options (even if there are none right now).  ok millert@
2024-04-17 18:12:12 +00:00
jca
3e7fedf45e Fold long line 2024-04-17 15:48:44 +00:00
jca
4ce91cbef9 Fixup comment
Spotted by caspar@ earlier
2024-04-17 10:19:17 +00:00
jca
e313d3eb7c Switch tar(1) write default format to 'pax'
Lets us store longer file names, link names, finer grained timestamps,
larger archive member files, etc; at the expense of larger uncompressed
archives and less widespread support across the ecosystem.  If you're
unhappy with the new defaults, you can use -F ustar.  Or you can help
fix bugs / find a better middle ground.

Prodding from various including job@ and deraadt@
ok sthen@ caspar@ millert@
2024-04-16 23:09:35 +00:00
jca
fe4b30a064 Fix reading large pax extended records
512 bytes isn't enough if you want to store rather large but still
useful long file names or symbolic links destinations.  The best way to
size the buffer to read those records is based upon the largest paths
pax(1) can handle, and that is PAXPATHLEN.

Reported by caspar@, input and ok millert@
2024-04-16 22:58:10 +00:00
jca
cf0ae65b89 Fix pasto: broken storage of symbolic link long destinations in pax format 2024-04-16 20:51:11 +00:00
jca
489289b76a Revert wip patch, not intended for commit 2024-04-16 19:09:06 +00:00
jca
f30fa5528e Add tar(1) -F option to select write format
We want to move towards 'pax' as the default format for writing, this
option lets users downgrade to -F ustar where the 'pax' format isn't
convenient/usable (same as -x <format> in pax(1)).

-F <format> is more generic than -o/-O. -H (GNU tar) was already used
and we don't want long options so --format (NetBSD/FreeBSD) is excluded
too.

ok sthen@ caspar@ millert@
2024-04-16 19:04:11 +00:00
jca
ce1e26fb72 Correctly detect 'pax' format archives in append mode
We expect that existing pax archives start with a global or extended
header. If they don't, append operations will be done using ustar
format.

Fixes append mode on pax archives where pax(1) would bail out when
appending to pax archives, falsely detecting a mismatch.  Reading was
unaffected.  Reported by caspar@, ok caspar@ millert@
2024-04-16 18:52:43 +00:00
caspar
85d4a8a216 Amend previous: improve comment 2024-04-15 22:07:08 +00:00
jca
9dcb0c6dfd Switch pax(1) to write archives using the 'pax' format by default
ramdisk versions will keep using ustar for writing.

ok millert@
2024-04-15 17:33:10 +00:00
jca
b54e157770 Better formatting for pax extended header times
As specified, don't include the subsecond part if zero and drop trailing
zeros in the subsecond part.  ok millert@
2024-01-20 17:34:50 +00:00
jca
554c9a8f2b 'pax' format support for mtime and atime
Access time can't be represented by ustar, so always include it when
using the pax format.  Also include an extended header record for mtime
if the file modification time can't be fully represented by ustar (eg
subsecond resolution).

Input & ok millert@
2023-12-27 08:29:41 +00:00
jca
cd67bb408f Zap useless newline added in previous 2023-12-22 20:32:29 +00:00
jca
eafddf6efd 'pax' format support for files over 8GB
ok millert@
2023-12-22 20:29:27 +00:00
jca
ba5cb4516c Print the proper file name in case we fail to allocate a "path" extended header
Use name, not ln_name.  Pasto introduced in previous.
2023-12-21 01:20:54 +00:00
jca
013e174a37 Add basic write support for 'pax' format archives
Keep writing archives in ustar format by default.  People can test the
posix 'pax' format using pax(1) -w -x pax ... or cpio -o -H pax ...;
tar(1) can't exercise this code yet.  Only long names file and link
names are supported for now.

With input and tests from caspar@, ok millert@
2023-12-09 23:00:11 +00:00
espie
c01bd7436f mark functions as static when they're unused elsewhere, makes the
code slightly easier to understand.

okay and tweak kn@
2023-11-26 16:04:17 +00:00
kn
067bf70efe Tighten pledge in List and Append mode:
Drop "wpath cpath fattr dpath" in read-only:
-  cpio -i -t < test.tar
-  pax < test.tar
-  tar -t -f test.tar

Drop "cpath fattr dpath" in read-write:
-  echo foo | cpio -o -A -H ustar -O test.tar
-  tar -r -f test.tar foo
-  pax -w -a -f test.tar foo

Other modes remain unchanged and thus can create or modify files.

Feedback OK millert
2023-11-09 18:54:15 +00:00
kn
942b9b2914 Pledge once with or without "proc exec", not twice
Spotted while comparing ktraces between 'tar -z' and 'gzcat | tar -f-'.

Only the former runs, e.g. gzip(1), but the latter also pledges theses promises
just to pledge again immediately afterwards without them.

Make the calls mutually exclusive so 'tar -f-' et al. skip the first pledge
and thus never have "proc exec" to begin wth.

"looks good to me" mbuhl
OK millert
2023-10-15 09:49:57 +00:00
jca
9c4549c6e4 Zap #ifndef SMALL around pax format read support
-DSMALL has never been used to build the ramdisks, thus the support for
reading pax format archives has always been there.  This is misleading,
so just zap the ifdef since we want to keep read support.

Went through a make release Just In Case(tm).

Spotted by caspar@, ok millert@ sthen@ caspar@
2023-09-04 17:05:34 +00:00
guenther
e425abdca9 Copy entire st_*tim structs at once, rather than copying
the st_*time and (obsolete) st_*timensec members separately.

ok millert@
2023-08-19 04:21:05 +00:00
aisha
81f808e180 add extract example and reorder flags on other examples
comments sthen@ and Peter J. Philipp <pjp AT delphinusdns DOT org>
ok jmc@
2023-08-03 18:17:54 +00:00
jeremy
07ca5729a7 Don't open files that will be skipped
Previously, when creating an archive file with pax(1), pax will attempt
to open a file even if the file will be skipped due to an -s replacement
with the empty string. With this change, pax will not attempt to open
files that it knows will be skipped.

When doing direct copies to a directory (-rw), pax already skips
the file before attempting to open it. So this makes the behavior
more consistent.

This can measurably speed up pax when skipping a large number of files.

OK tb@
2023-07-10 16:28:33 +00:00
guenther
c0c9035167 It isn't portable to use stderr (or std{in,out}) in file-scope
initializers as they are not required to be compile-time constants.
So, intialize these global variables at the top of main().

ok miod@ deraadt@ yasuoka@ millert@
2023-07-05 18:45:14 +00:00
millert
2f186deaaa pax: truncate times to MAX_TIME_T, not INT_MAX
If the mtime in the file header is larger than MAX_TIME_T, trucate
it to MAX_TIME_T, not INT_MAX.  OK otto@
2023-06-26 18:00:59 +00:00
millert
375ccafb2e pax: use safe_print() to display messages which may include file names.
Reported by David Leadbeater.  OK op@
2023-06-26 16:58:50 +00:00
op
3921d3a361 fix grammar of the comment describing pat_chk(); ok millert@ 2023-06-26 07:10:17 +00:00
tb
366a2d3255 pax: Switch a function definition from K&R to ANSI. 2023-01-17 16:20:28 +00:00
cheloha
d7259957e8 userspace: remove vestigial '?' cases from top-level getopt(3) loops
getopt(3) returns '?' when it encounters a flag not present in the in
the optstring or if a flag is missing its option argument.  We can
handle this case with the "default" failure case with no loss of
legibility.  Hence, remove all the redundant "case '?':" lines.

Prompted by dlg@.  With help from dlg@ and millert@.

Link: https://marc.info/?l=openbsd-tech&m=167011979726449&w=2

ok naddy@ millert@ dlg@
2022-12-04 23:50:45 +00:00
naddy
41ce3b17e7 man pages: add missing commas between subordinate and main clauses
jmc@ dislikes a comma before "then" in a conditional, so leave those
untouched.

ok jmc@
2022-03-31 17:27:13 +00:00
sthen
3e1094ec64 Support mtime/atime/ctime extended headers in !SMALL builds.
These are becoming quite common in distributed software (including
tars produced by Python and Go) and often standard timestamps are
not set, resulting in extracted files dated as the epoch.

Lots of help from tb@, ok tb@ millert@
2022-03-01 21:19:11 +00:00
guenther
d51a20138d When it's the possessive of 'it', it's spelled "its", without the
apostrophe.
2022-01-28 05:15:05 +00:00
deraadt
b7041c0781 For open/openat, if the flags parameter does not contain O_CREAT, the
3rd (variadic) mode_t parameter is irrelevant.  Many developers in the past
have passed mode_t (0, 044, 0644, or such), which might lead future people
to copy this broken idiom, and perhaps even believe this parameter has some
meaning or implication or application. Delete them all.
This comes out of a conversation where tb@ noticed that a strange (but
intentional) pledge behaviour is to always knock-out high-bits from
mode_t on a number of system calls as a safety factor, and his bewilderment
that this appeared to be happening against valid modes (at least visually),
but no sorry, they are all irrelevant junk.  They could all be 0xdeafbeef.
ok millert
2021-10-24 21:24:15 +00:00
deraadt
8e4f2f54ea 32-bit systems incorrectly parse the (64-bit) length of ustar extended
headers (hd->size) using a 32-bit operation.
from Samanta Navarro
ok guenther
2021-06-14 00:36:13 +00:00
jmc
3a414a3889 -f - can respresent both stdin and stdout; rework the text a little
to make it read better;

reported by roderick
ok millert
2020-10-05 05:52:19 +00:00
espie
8cc78d4587 in case we can't create intermediate directories because of permissions,
show a less confusing track

okay millert@ (with a small tweak to the error message by millert@)
2020-03-23 20:04:19 +00:00
schwarze
2a110ee1f1 Usually, -width Fl (which is 10n) is too wide and hence ugly.
Change several instances, most of them to the usual -width Ds.
2020-01-16 16:46:46 +00:00
naddy
55d472e467 In cpio mode, when processing the -o switch, only set the archive format
if not already set.  This makes "cpio -Hustar -o" behave the same as
"cpio -o -Hustar".  ok guenther@
2019-11-15 20:34:17 +00:00
deraadt
3aaa63eb46 When system calls indicate an error they return -1, not some arbitrary
value < 0.  errno is only updated in this case.  Change all (most?)
callers of syscalls to follow this better, and let's see if this strictness
helps us in the future.
2019-06-28 13:34:58 +00:00
deraadt
c2d43eca3f mkstemp() returns -1 on failure 2019-06-28 05:35:34 +00:00