Commit graph

15848 commits

Author SHA1 Message Date
Martin Tournoij 9744821765 diff: use getline() instead of fgetln()
This replaces fgetln() with getline(). The main reason for this is
portability, making things easier for people who want to compile these
tools on non-FreeBSD systems.

I appreciate that's probably not the top concern for FreeBSD base tools,
but fgetln() is impossible to port to most platforms, as concurrent
access is essentially impossible to implement fully correct without the
line buffer on the FILE struct. Other than this, many generic FreeBSD
tools compile fairly cleanly on Linux with a few small changes.

Most uses of fgetln() pre-date getline() support (added in 2009 with
69099ba2ec), and there's been some previous patches (ee3ca711a8
8c98e6b1a7 1a2a4fc8ce) for other tools.

Obtained from:	https://github.com/dcantrell/bsdutils and
              	https://github.com/chimera-linux/chimerautils
Signed-off-by: Martin Tournoij <martin@arp242.net>
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/893
2024-04-19 15:52:21 -06:00
Martin Tournoij b05785953e cut: use getline() instead of fgetln()
This replaces fgetln() with getline(). The main reason for this is
portability, making things easier for people who want to compile these
tools on non-FreeBSD systems.

I appreciate that's probably not the top concern for FreeBSD base tools,
but fgetln() is impossible to port to most platforms, as concurrent
access is essentially impossible to implement fully correct without the
line buffer on the FILE struct. Other than this, many generic FreeBSD
tools compile fairly cleanly on Linux with a few small changes.

Most uses of fgetln() pre-date getline() support (added in 2009 with
69099ba2ec), and there's been some previous patches (ee3ca711a8
8c98e6b1a7 1a2a4fc8ce) for other tools.

Obtained from:	https://github.com/dcantrell/bsdutils and
              	https://github.com/chimera-linux/chimerautils
Signed-off-by: Martin Tournoij <martin@arp242.net>
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/893
2024-04-19 15:52:21 -06:00
Collin Funk 87b0195ace ctags: Use C99 bool instead of defining our own
Use stdbool.h definitions instead of defining non-standard ones.

Signed-off-by: Collin Funk <collin.funk1@gmail.com>

Reviewed by:	markj
MFC after:	2 weeks
Pull Request:	https://github.com/freebsd/freebsd-src/pull/1107
2024-04-19 14:48:37 -04:00
Mark Johnston 2f44f86575 install: Fix a compiler warning when bootstrapping
Fixes:		4336161cc9 ("install: Don't skip syncing in the common case.")
Reviewed by:	imp, des
Differential Revision:	https://reviews.freebsd.org/D44866
2024-04-19 14:48:37 -04:00
Gordon Bergling 8993d785a2 expand.1: Fix markup for the '-t' option
When viewing the manpage the '-t' option is shown as follows

    -t -Sm tab1, tab2, ..., tabn Sm

with the markup '\&Sm' included within '.It Fl t', which doesn't
makes any sense.

So just remove it.

PR:	274897
MFC after:	3 days
2024-04-19 17:39:37 +02:00
Dag-Erling Smørgrav 000a533e6d install: Assorted nitpickery.
* Use `errc()` instead of manually setting `errno` before calling `err()`.
* Change one warning into a fatal error.
* Drop some unnecessary casts.
* `strlcat()` bounds checks were off-by-one.  This does not matter in
  practice because the subsequent code renders an overrun harmless.
* We were passing `SSIZE_MAX` to `copy_file_range()` instead of the
  requested size.  This only matters if we're asked to install a file
  which is still being written to while we are copying it.

MFC after:	1 week
Sponsored by:	Klara, Inc.
Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D44810
2024-04-17 04:03:31 +02:00
Dag-Erling Smørgrav a0439a1b82 install: Remove the mmap(2) option.
We already removed it from cp(1) over a year ago but never followed up
here.  Do so now, for the same reasons: significant complexity for
little to no benefit.

MFC after:	1 week
Sponsored by:	Klara, Inc.
Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D44809
2024-04-17 04:03:31 +02:00
Martin Matuska b9128a37fa libarchive: merge from vendor branch
Libarchive 3.7.3

New features:
  #1941 uudecode filter: support file name and file mode in raw mode
  #1943 7-zip reader: translate Windows permissions into UNIX
        permissions
  #1962 zstd filter now supports the "long" write option
  #2012 add trailing letter b to bsdtar(1) substitute pattern
  #2031 PCRE2 support
  #2054 add support for long options "--group" and "--owner" to tar(1)

Security fixes:
  #2101 Fix possible vulnerability in tar error reporting introduced
        in f27c173

Important bugfixes:
  #1974 ISO9660: preserve the natural order of links
  #2105 rar5: fix infinite loop if during rar5 decompression the last
        block produced no data
  #2027 xz filter: fix incorrect eof at the end of an lzip member
  #2043 zip: fix end-of-data marker processing when decompressing zip
        archives

PR:		278315 (exp-run)
MFC after:	1 week
2024-04-16 23:39:31 +02:00
Dag-Erling Smørgrav 4336161cc9 install: Don't skip syncing in the common case.
In `copy()`, if no digest was requested (which is the common case), we
use `copy_file_range()` to avoid needlessly copying the contents of the
file into user space and back.  When `copy_file_range()` returns
successfully (which, again, is the common case), we simply return, and
therefore never get to the point where we call `fsync()` if the `-S`
option was specified.  Fix this.

MFC after:	1 week
Sponsored by:	Klara, Inc.
Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D44756
2024-04-12 19:31:35 +02:00
Dag-Erling Smørgrav 17dc7017d7 install: Simplify path construction.
There's no need to copy the path twice to split it into base and dir.
We simply call `basename()` first, then handle the two trivial cases in
which it isn't safe to call `dirname()`.

While here, add an early check that the destination is not an empty
string.  This would always fail eventually, so it may as well fail
right away.  Also add a test case for this shortcut.

MFC after:	1 week
Sponsored by:	Klara, Inc.
Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D44743
2024-04-12 19:31:35 +02:00
Dag-Erling Smørgrav e5035d0857 install: Always use a temporary file.
Previously, we would only use a temporary file if explicitly asked to
with the `-S` option, and even then, only if the target file already
existed.  This meant that an outside observer looking for the target
file might see a partial file, and might see the file disappear and
then reappear.

With this patch, we always use a temporary file, ensuring atomicity.
The downside is slightly increased disk usage.  The upside is never
having to worry about, for instance, cron jobs randomly failing if
they happen to run simultaneously with `make installworld`.

The `-S` option is retained, partly for compatibility, and partly
to control the use of `fsync(2)`, which has a non-negligible cost
(approximately 10% increase in wall time for `make installworld`).

MFC after:	1 week
Sponsored by:	Klara, Inc.
Reviewed by:	0mp, brooks, imp, markj
Differential Revision:	https://reviews.freebsd.org/D44742
2024-04-12 19:31:35 +02:00
Jake Freeland 9bec841312 ktrace: Record detailed ECAPMODE violations
When a Capsicum violation occurs in the kernel, ktrace will now record
detailed information pertaining to the violation.

For example:
- When a namei lookup violation occurs, ktrace will record the path.
- When a signal violation occurs, ktrace will record the signal number.
- When a sendto(2) violation occurs, ktrace will record the recipient
  sockaddr.

For all violations, the syscall and ABI is recorded.

kdump is also modified to display this new information to the user.

Reviewed by:	oshogbo, markj
Approved by:	markj (mentor)
MFC after:	1 month
Differential Revision:	https://reviews.freebsd.org/D40676
2024-04-07 18:52:51 -05:00
Dimitry Andric 74626c16ff Merge llvm-project release/18.x llvmorg-18.1.0-rc2-53-gc7b0a6ecd442
This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvm-project release/18.x llvmorg-18.1.0-rc2-53-gc7b0a6ecd442.

PR:		276104
MFC after:	1 month
2024-04-06 22:14:13 +02:00
Dimitry Andric b3edf44679 Merge llvm-project release/18.x llvmorg-18.1.0-rc2-0-gc6c86965d967
This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvm-project release/18.x llvmorg-18.1.0-rc2-0-gc6c86965d967.

PR:		276104
MFC after:	1 month
2024-04-06 22:14:07 +02:00
Dimitry Andric 7a6dacaca1 Merge llvm-project main llvmorg-18-init-18359-g93248729cfae
This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvm-project main llvmorg-18-init-18359-g93248729cfae, the
last commit before the upstream release/18.x branch was created.

PR:		276104
MFC after:	1 month
2024-04-06 22:13:49 +02:00
Dimitry Andric 1db9f3b21e Merge llvm-project main llvmorg-18-init-16595-g7c00a5be5cde
This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvm-project main llvmorg-18-init-16595-g7c00a5be5cde.

PR:		276104
MFC after:	1 month
2024-04-06 22:13:28 +02:00
Dimitry Andric 5f757f3ff9 Merge llvm-project main llvmorg-18-init-15088-gd14ee76181fb
This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvm-project main llvmorg-18-init-15088-gd14ee76181fb.

PR:		276104
MFC after:	1 month
2024-04-06 22:11:55 +02:00
Collin Funk 8268a31bcc which: Use size_t instead of ssize_t for pathlen
The "pathlen" variable is the return value of strlen(3) and is then
passed as an argument to malloc(3) and memcpy(3). The size_t type
matches the prototype for these functions. The size_t type is unsigned
so it can fit larger $PATH values than ssize_t. However, in practice
ssize_t should be larger enough so this change is just for clarity.

Signed-off-by: Collin Funk <collin.funk1@gmail.com>

MFC after:	1 week
Pull Request:	https://github.com/freebsd/freebsd-src/pull/1113
2024-04-05 14:30:31 -04:00
Xin LI 2f9cd13d6c Revert "MFV: xz 5.6.0"
This commit reverts 8db56defa7,
rolling back the vendor import of xz 5.6.0 and restoring the
package to version 5.4.5.

The revert was not directly due to the attack (CVE-2024-3094):
our import process have removed the test cases and build scripts
that would have enabled the attack. However, reverting would
help to reduce potential confusion and false positives from
security scanners that assess risk based solely on version
numbers.

Another commit will follow to restore binary compatibility with
the liblzma 5.6.0 library by making the previously private
symbol (lzma_mt_block_size) public.

PR:		278127
MFC after:	3 days
2024-04-04 23:39:23 -07:00
Dag-Erling Smørgrav 125c4560bc usr.bin: Make lorder conditional on MK_TOOLCHAIN.
MFC after:	1 week
Reviewed by:	allanjude, markj
Differential Revision:	https://reviews.freebsd.org/D44558
2024-04-01 15:18:35 +02:00
Gleb Smirnoff 1a8d176432 inpcb: fully retire inp_ppcb pointer
Before a protocol specific control block started to embed inpcb in self
(see 0aa120d52f, e68b379244, 483fe96511) this pointer used to point
at it.

Retain kf_sock_inpcb field in the struct kinfo_file in <sys/user.h>.  The
exp-run detected a minimal use of the field in ports:
  * sysutils/lsof - patched upstream
  * net-mgmt/netdata  - patch accepted upstream
  * emulators/qemu-user-static - upstream master branch seems not using
    the field anymore
We can keep the field around for some time, but eventually it may be
reused for something else.

PR:			277659 (exp-run)
Reviewed by:		tuexen
Differential Revision:	https://reviews.freebsd.org/D44491
2024-03-29 12:18:32 -07:00
Dag-Erling Smørgrav 2cab4be46b install: Prefer strsnvis() to strsvis().
MFC after:	1 week
Sponsored by:	Klara, Inc.
Reviewed by:	allanjude
Differential Revision:	https://reviews.freebsd.org/D44514
2024-03-27 11:03:59 +01:00
Dag-Erling Smørgrav 74a4aa9b15 touch: Add unit tests.
MFC after:	1 week
Reviewed by:	bapt
Differential Revision:	https://reviews.freebsd.org/D44505
2024-03-27 11:03:45 +01:00
Dag-Erling Smørgrav aa69e0f212 touch: Allow setting the timestamp to -1.
Note that VFS internally interprets a timestamp of -1 as “do not set”,
so this has no effect, but at least touch won't incorrectly reject the
given date / time (1969-12-31 23:59:59 UTC) as invalid.

While here, fix some style issues.

MFC after:	1 week
Reviewed by:	allanjude
Differential Revision:	https://reviews.freebsd.org/D44504
2024-03-27 11:03:40 +01:00
Dag-Erling Smørgrav d9a9f23d0b diff: Integrate libdiff from OpenBSD GoT.
This adds support for two new diff algorithms, Myers diff and Patience
diff.

These algorithms perform a different form of search compared to the
classic Stone algorithm and support escapes when worst case scenarios
are encountered.

Add the -A flag to allow selection of the algorithm, but default to
using the new Myers diff implementation.

The libdiff implementation currently only supports a subset of input and
output options supported by diff.  When these options are used, but the
algorithm is not selected, automatically fallback to the classic Stone
algorithm until support for these modes can be added.

Based on work originally done by thj@ with contributions from kevans@.

Sponsored by:	Klara, Inc.
Reviewed by:	thj
Differential Revision:	https://reviews.freebsd.org/D44302
2024-03-27 11:03:33 +01:00
Rainer Hurling eb1ca6736a usr.bin/calendar/calendars: Add myself as a committer 2024-03-24 19:57:27 +01:00
John F. Carr 55e2187a09 Translate linux_newlstat name argument
PR:	277847
MFC after:	1 week
2024-03-21 00:45:55 +02:00
Nuno Teixeira e37471440e Add myself (eduardo) to the calendar.
Reminded by:	mckusick
2024-03-19 21:21:04 +00:00
Dag-Erling Smørgrav 6561c0eceb diff: Improve history section.
Reviewed by:	gbe
Differential Revision:	https://reviews.freebsd.org/D44409
2024-03-19 03:59:00 +01:00
Oskar Holmlund d4135972ae add myself(oh) to the calendar
Reported by: McKusick
Approved by: Manu (mentor)
Differential Revision: https://reviews.freebsd.org/D44408
2024-03-18 22:33:03 +01:00
R. Christian McDonald 576fbcbf2d Add myself (rcm) to the calendar.
Reminded by:	mckusick
2024-03-18 16:26:59 -04:00
Hartmut Brandt c85d75a9fc Add myself (harti) to the calendar.
Reminded by:    mckusick
2024-03-18 17:58:03 +01:00
Gabriel M. Dutra f56e9a65cf calendars: Add myself to the FreeBSD calendar
Reported by:	mckusick
Approved by:	dbaio (mentor)
Differential Revision:	https://reviews.freebsd.org/D44396
2024-03-18 11:14:00 -03:00
Michael Osipov c547f17816 Add myself (michaelo) to the calendar
Reminded by:	mckusick
2024-03-18 10:46:02 +01:00
Jake Freeland 04473cfc4d Add myself (jfree) to calendar.freebsd
Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D44400
2024-03-17 18:10:42 -05:00
Neel Chauhan f526590a78 Add myself (nc) to the calendar
Reminded by:	mckusick
2024-03-17 15:34:59 -07:00
Vladimir Druzenko 228fc43bcf Add myself (vvd) to the calendar
Reported by:	mckusick
Approved by:	mckusick
2024-03-17 18:53:07 +03:00
Zhenlei Huang 4319ccae87 Add myself (zlei) to the calendar
Reminded by:	mckusick
2024-03-17 23:07:53 +08:00
Dmitry Salychev 65eb09f9d5
Add myself (dsl) to the calendar.freebsd 2024-03-17 11:09:52 +01:00
David E. O'Brien 87740ff2ac diff(1) add FreeBSD HISTORY 2024-03-15 15:26:12 -07:00
Simon J. Gerraty 3ff501040b bmake Makefile.config 2024-03-13 22:08:29 -07:00
Simon J. Gerraty 51ca8a7a7d bmake updated config.h 2024-03-13 22:03:50 -07:00
Eugene Grosbein 7f0dc6e2cd mkimg(1): process non-seekable output gracefully
mkimg may make severe load only to fail in the end
if output is non-seekable pipe, socket or FIFO
unless output format is raw disk image.

Check it out and fail early. Make it clear in the manual.

MFC after:	1 week
2024-03-12 23:00:21 +07:00
Warner Losh ba7b7f94c2 awk: Fix the tests
I'd forgotten that we have to adjust the stderr tests from
upstream. Remove the OK files. Also remove system-status.*.  These
restore the fixes I made in 517e52b6c2 which were lost when I imported
the last version of awk.

Also, force LANG to be C.UTF-8 when testing to ensure that stray lang
settings don't fail tests.

Sponsored by:		Netflix
2024-03-07 22:52:56 -07:00
Kyle Evans 02c57f7b48 kdump: decode pollfd struct arrays coming from poll(2)
We'll handle these just as we do kevents, one per line with subsequent
lines indented sufficiently to distinguish them from the upcoming
return value.

Sample, with indentation stripped and revents changed to '...' in the
first one to keep the line length down:

CALL  poll(0x820610560,0x3,0)
STRU  struct pollfd[] = { { fd=0, events=0x1<POLLIN>, revents=0x11<...>
 { fd=1, events=0x4<POLLOUT>, revents=0x4<POLLOUT>}
 { fd=-1, events=0x4<POLLOUT>, revents=0} }
RET   poll 2

Reviewed by:	bapt, jhb
Differential Revision:	https://reviews.freebsd.org/D44160
2024-03-04 23:44:09 -06:00
Dag-Erling Smørgrav aa80cfadff lorder: Tweak invalid file test.
Different implementations of `nm` have different ways of telling you
that your file is not a valid object or library, but they all seem to
have “not recognized” as a common substring.

MFC after:	1 week
Sponsored by:	Klara, Inc.
Reviewed by:	allanjude
Differential Revision:	https://reviews.freebsd.org/D44154
2024-02-29 14:59:25 +01:00
Dag-Erling Smørgrav aedb37dc49 lorder: Don't rely on legacy syntax.
MFC after:	1 week
Sponsored by:	Klara, Inc.
Reviewed by:	allanjude
Differential Revision:	https://reviews.freebsd.org/D44155
2024-02-29 14:59:21 +01:00
Dag-Erling Smørgrav cf4d9bf8b3 lorder: Undeprecate.
While lorder is not required by our current toolchain (or any toolchain
we've used in the past decade or two), it still occasionally shows up
in build systems of third party software, including The Open Group's
UNIX conformance test suite, and the maintenance cost is negligible.

MFC after:	1 week
Sponsored by:	Klara, Inc.
Reviewed by:	imp, allanjude, emaste
Differential Revision:	https://reviews.freebsd.org/D44135
2024-02-28 16:37:44 +01:00
Dag-Erling Smørgrav 96da41b6db lorder: Add unit tests.
MFC after:	1 week
Sponsored by:	Klara, Inc.
Reviewed by:	allanjude
Differential Revision:	https://reviews.freebsd.org/D44134
2024-02-28 16:37:41 +01:00
Dag-Erling Smørgrav 5c7b986c21 lorder: Clean up and improve robustness.
* Properly parse (no) command-line options.

* Ensure that errors go to stderr and result in a non-zero exit.

* Drop the special-case code for a single argument, as it will produce
  the wrong outcome if the file does not exist or is corrupted.

* Don't print anything until after we've collected all the data.

* Always create all temporary files before setting the trap.  This
  ensures that the trap can safely fire at any moment, regardless of any
  previous definition of `T`.

* Use a temporary file rather than a pipe between `nm` and `sed` to
  ensure proper termination if `nm` fails due to a missing or invalid
  input.

* The check for self-referential entries was conditional on testing our
  argument list against a regex looking for archives.  This was a
  needless and unreliable optimization; make the check unconditional.

* Document that lorder will not work properly if any of its inputs have
  spaces in their name.

MFC after:	1 week
Sponsored by:	Klara, Inc.
Reviewed by:	allanjude
Differential Revision:	https://reviews.freebsd.org/D44133
2024-02-28 16:37:36 +01:00