Commit graph

15897 commits

Author SHA1 Message Date
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
Eugene Grosbein d1797fb5bb mkimg.1: add new PARTITION SPECIFICATION section
The specification follows a commentary to the function parse_part()
in the source code and the code itself.

MFC after:	3 days
2024-02-28 02:56:26 +07:00
Dag-Erling Smørgrav 312b1076c6 diff: Bump manual page date.
Sponsored by:	Klara, Inc.
2024-02-26 19:21:40 +01:00
Dag-Erling Smørgrav 53de23f4d1 diff: Fix --expand-tabs and --side-by-side.
* Overhaul column width and padding calculation.
* Rewrite print_space() so it is now a) correct and b) understandable.
* Rewrite tab expansion in fetch() for the same reason.

This brings us in line with GNU diff for all cases I could think of.

Sponsored by:	Klara, Inc.
Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D44014
2024-02-26 19:08:06 +01:00
Xin LI 8db56defa7 MFV: xz 5.6.0.
MFC after:	2 weeks
2024-02-25 15:46:22 -08:00
Rick Parrish 0112f8c4a8 posixmqcontrol(1): manage posix message queues
Reviewed by:	kib, paumma
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D43845
2024-02-24 01:08:48 +02:00
Bryan Drewery d0bf8b5aac wc: Fix SIGINFO race with casper init.
If a file is specified then fileargs_init(3) may return [EINTR]. With
the SIGINFO handler not being SA_RESTART this causes an early exit
if a SIGINFO comes in. Rather than checking for [EINTR] or changing the
handler just move it later which resolves the problem.
2024-02-18 10:57:42 -08:00
Dag-Erling Smørgrav ad7bef8b89 sdiff: Fix binary case.
MFC after:	1 week
Sponsored by:	Klara, Inc.
Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D43942
2024-02-18 18:39:50 +01:00
Dag-Erling Smørgrav a834edfccd sdiff: Fix --expand-tabs and --tabsize.
MFC after:	1 week
Sponsored by:	Klara, Inc.
Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D43941
2024-02-18 18:39:50 +01:00
Dag-Erling Smørgrav 3cc86989bf sdiff: Misc cleanup.
MFC after:	1 week
Sponsored by:	Klara, Inc.
Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D43943
2024-02-18 18:39:50 +01:00
Dimitry Andric 73ff7384e0 Optionally create full debuginfo for llvm-related executables
Commit de6feefdb7 limited the amount of debuginfo generated for clang
and other llvm-related executables. This was done to save disk space and
memory during building, but it makes debugging any of these executables
much harder.

Add a new src.conf(5) setting, WITH_LLVM_FULL_DEBUGINFO, to generate
full debuginfo instead. This is off by default, but could for example be
enabled for release builds or snapshots, so llvm executables are easier
to debug.

Reviewed by:	emaste
MFC after:	1 week
Differential Revision: https://reviews.freebsd.org/D43839
2024-02-17 00:15:32 +01:00
LO WEN-CHIEN 49eeca743b
stat(1): Fix grammar error in stat.c
Event:		Advanced UNIX Programming Course (Fall’23) at NTHU
Pull Request:	https://github.com/freebsd/freebsd-src/pull/1014
2024-02-13 15:33:16 +08:00
LO WEN-CHIEN b1d0cf28ff
ar(1): Fix grammar error in write.c
Event:		Advanced UNIX Programming Course (Fall’23) at NTHU
Pull Request:	https://github.com/freebsd/freebsd-src/pull/1013
2024-02-13 15:31:59 +08:00
LO WEN-CHIEN 1d83ae9d3d
install(1): Fix typo in usr.bin/xinstall/xinstall.c
Event:		Advanced UNIX Programming Course (Fall’23) at NTHU
Pull Request:	https://github.com/freebsd/freebsd-src/pull/1012
2024-02-13 15:21:45 +08:00
Dag-Erling Smørgrav 851a9da38f patch: Support long context lines.
MFC after:	1 week
Sponsored by:	Klara, Inc.
Reviewed by:	allanjude
Differential Revision:	https://reviews.freebsd.org/D43850
2024-02-12 19:26:13 +01:00
Dimitry Andric d9c0e2e166 Revert "Build clang and other llvm executables as PIE"
This reverts commit 470f9f13de.

I need more time to figure out how to make this work correctly with
incremental builds, which it currently miserably fails on.
2024-02-12 10:27:00 +01:00
Dimitry Andric 470f9f13de Build clang and other llvm executables as PIE
There is no reason anymore to not build these as PIE. Unfortunately
bsd.lib.mk does not allow for building _only_ PIE static libraries, so
lib/clang/Makefile.inc needs a kludge to work around that issue.

MFC after:	1 week
2024-02-11 19:01:56 +01:00
Dimitry Andric 4015c06420 Remove usr.bin/clang/llvm-ar/llvm-cxxfilt-driver.cpp file
I accidentally copied this to the wrong place, or by accident to two
places, during the merge of llvmorg-17-init-19304-gd0b54bb50e51.

Fixes:		06c3fb2749
MFC after:	3 days
2024-02-10 22:02:45 +01:00
Hiroki Sato 4594eb4548
systat(1): Plug memory leak
The procstat_getprocs() function call in procgetinfo() allocated
a buffer but it was not freed properly.
2024-02-08 15:45:04 +09:00
Collin Funk 912b52a62c msgs: 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>
Pull-request: https://github.com/freebsd/freebsd-src/pull/1105
2024-02-06 08:37:50 -05:00
Ricardo Branco 8e05c2373e wc: Do not use st_size if it equals zero
Pseudo-filesystems often cannot compute the size of the file correctly
and report 0 for the size. Ignore the size when it's zero and fallback
to the size unknown code.

PR: 276093
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/985
2024-02-02 18:34:59 -07:00
Mohamed Akram e85a6f8dff man: fix redirect for locales and file arguments
Use the locale-specific path for localized pages and the appropriate parent
directory for file arguments when handling redirects.

Signed-off-by: Mohamed Akram <mohd.akram@outlook.com>
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/1019
2024-02-02 18:34:59 -07:00
Graham Perrin 7edb49a115 freebsd-tips: freebsd-update fetch, then install
In end of life (EOL) warning cases: freebsd-update fetch install (the
two commands, combined) may fetch and patch, but not install.

Instead: run the two consecutively. Consistent with installation
information in /releases/ areas and with accepted
https://reviews.freebsd.org/D42722

Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/1096
2024-02-02 08:25:44 -07:00
Dag-Erling Smørgrav bc2913d173 bintrans: Remove unused variable.
MFC after:	1 week
Sponsored by:	Klara, Inc.
Reviewed by:	allanjude
Differential Revision:	https://reviews.freebsd.org/D43559
2024-02-01 14:10:45 +01:00
Dag-Erling Smørgrav 64028ac3ba bintrans: Add base64 to name list in manual page.
MFC after:	1 week
Sponsored by:	Klara, Inc.
Reviewed by:	0mp, pstef
Differential Revision:	https://reviews.freebsd.org/D43558
2024-02-01 14:10:41 +01:00
Dag-Erling Smørgrav bce34cba07 bintrans: Fix uninitialized variable.
`prev` may be used uninitialized if `body` starts with a newline.

MFC after:	1 week
Sponsored by:	Klara, Inc.
Reviewed by:	bapt, emaste
Differential Revision:	https://reviews.freebsd.org/D43534
2024-02-01 14:10:37 +01:00
Dag-Erling Smørgrav 5cb28f7979 bintrans: Error out if writing to the output failed.
- Cover all code paths.
- When decoding, check all output files, not just the last one.
- A simple `ferror()` check is not enough as an error may later occur
  while flushing whatever remains in the output buffer.

MFC after:	1 week
Sponsored by:	Klara, Inc.
Reviewed by:	allanjude
Differential Revision:	https://reviews.freebsd.org/D43532
2024-02-01 14:10:31 +01:00
Wolfram Schneider b8a484ec34 man: support special characters in filenames
man.sh needs to handle double quotes and sub shell character
as '`' '$' etc.

PR:		275967
Reviewed by:	bapt

MFC after:	1 week
Differential Revision: https://reviews.freebsd.org/D43453
2024-01-25 07:14:06 +00:00
Tijl Coosemans 95bf75895d join(1): Fix ordering in case of missing fields
The comparison function had the ordering reversed causing join(1) to
miss some matching lines.

PR:		232405
Submitted by:	Martijn van Duren <martijn@openbsd.org>
MFC after:	1 week
2024-01-24 10:58:00 +01:00
Ricardo Branco e4b646ce16 find: Add -readable, -writable & -executable options
Reviewed by:	jhb, Mina Galić
Pull Request:	https://github.com/freebsd/freebsd-src/pull/1080
2024-01-21 17:33:46 -08:00
Fernando Apesteguía 70445a8061 cksum(1): Add EXAMPLES to manual page
Approved by:	bcr@
2024-01-18 14:04:25 +01:00
Kristof Provost 5dea523bd2 pflow: netstat statistics
Expose pflow counters via netstat.

Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D43107
2024-01-16 09:45:53 +01:00
Ricardo Branco 2a121b97e9 find: Allow '/' to be used with -perm for GNU compatibility
In 2005, Gnu find deprecated '+' as the leading character for the -perm
argument, instead preferring '/' with the same meaning. Implement that
behavior here, and document it in the man page.

Reviewed by: imp, emaste
Pull Request: https://github.com/freebsd/freebsd-src/pull/1060
2024-01-15 11:47:24 -07:00
Mohamed Akram ec13a838e6 man: avoid unportable use of utilities
echo -e is not portable. It can be replaced by printf %b (it works
only with the /bin/sh built-in echo, not /bin/echo anyway).
head -# is not portable, but head -n # is.

Replace these two things in three places total.

Signed-off-by: Mohamed Akram <mohd.akram@outlook.com>
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/1062
2024-01-15 11:30:37 -07:00
Simon J. Gerraty d5e0a182cf Update to bmake-20240108 2024-01-13 17:31:01 -08:00
Wolfram Schneider e3c7b76fa8 man(1): support spaces in filenames
The globbing function in exists() needs to handle white spaces.

PR:          275978
Reviewed by: kevans, bapt, emaste
MFC after:   1 week
2024-01-13 16:16:55 +00:00
Dag-Erling Smørgrav 1e25eb287f login: Missed an instance of getpwnam().
Fixes:		a3d80dd8aa
MFC after:	1 week
Sponsored by:	Klara, Inc.
Reviewed by:	allanjude
Differential Revision:	https://reviews.freebsd.org/D43423
2024-01-12 17:40:55 +01:00
Dag-Erling Smørgrav 899837e8f5 uniq: Error out if writing to the output failed.
MFC after:	1 week
Sponsored by:	Klara, Inc.
Reviewed by:	kevans
Differential Revision:	https://reviews.freebsd.org/D43407
2024-01-12 16:44:06 +01:00
Dag-Erling Smørgrav e2ec8ee02a uniq: Clean up and test obsolete options.
MFC after:	1 week
Sponsored by:	Klara, Inc.
Reviewed by:	kevans
Differential Revision:	https://reviews.freebsd.org/D43402
2024-01-12 16:44:00 +01:00
Dag-Erling Smørgrav 11715600e6 uniq: Fix interactive use.
Output a line as soon as it is possible to determine that it will have
to be output.  For the basic case, this means output each line as it is
read unless it is identical to the previous one.  For the -d case, it
means output the first instance as soon as the second is read, unless
the -c option was also given.  The -D and -u cases were already fine.

Add test cases for interactive use with no options and with -d.

Explicitly ignore -d when -D is also specified.

MFC after:	1 week
Sponsored by:	Klara, Inc.
Reviewed by:	rew, kevans
Differential Revision:	https://reviews.freebsd.org/D43382
2024-01-12 16:43:55 +01:00
Dag-Erling Smørgrav e762fd81e2 uniq: Replace NetBSD's unit tests with our own.
These new tests cover more functionality and are easier to extend.

MFC after:	1 week
Sponsored by:	Klara, Inc.
Reviewed by:	emaste
Differential Revision:	https://reviews.freebsd.org/D43381
2024-01-12 16:43:49 +01:00
Dag-Erling Smørgrav a3d80dd8aa login: Use getpwnam_r() instead of getpwnam().
Since we expect the entry to still be valid after calling into PAM,
which may call getpwnam() itself, we need to use getpwnam_r().

MFC after:	1 week
Sponsored by:	Klara, Inc.
Reviewed by:	kevans, imp, allanjude, markj
Differential Revision:	https://reviews.freebsd.org/D43376
2024-01-12 16:43:42 +01:00
Baptiste Daroussin 91dc237466 find: fix build on 32bits 2024-01-12 07:34:28 +01:00
Goran Mekić d06a00963b find: add SIGINFO handler
Print number of files processed and path currently being processed on
SIGINFO.

Reviewed by:	des, asomers
Sponsored by:	Axcient
MFC after:	2 weeks
Differential Revision: https://reviews.freebsd.org/D43380
2024-01-11 16:37:14 -07:00
Mark Johnston 1f62718d8b top: Avoid printing a blank line when the ZFS ARC is empty
PR:		275994
MFC after:	2 weeks
2024-01-11 10:01:37 -05:00
Dag-Erling Smørgrav c2356a440d asa: Rewrite to fix line termination issue.
The standard is somewhat unclear, but on the balance, I believe that the
phrase “the rest of the input line” should be interpreted to mean the
rest of the input line including the terminating newline if and only if
there is one.  This means the current implementation is incorrect on two
points:

- First, it suppresses the previous line's newline in the '1' case.

- Second, it unconditionally emits a newline at the end of the output
  for non-empty input, even if the input did not end with a newline.

Resolve this by rewriting the main loop.  Instead of special-casing the
first line and then assuming that every line ends with a newline, we
remember how each line ends and emit that either at the beginning of
the next line or at the end of the file except in the one case ('+')
where the standard explicitly says not to.

While here, try to reduce diff to upstream a little and update their
RCS tag to reflect the fact that while we've diverged significantly
from them, we've incorporated all their changes.  Remove the useless
second RCS tag.

We also update the tests to account for the change in interpretation
of the '1' case and add a test case for unterminated input.

MFC after:	1 week
Sponsored by:	Klara, Inc.
Reviewed by:	kevans
Differential Revision:	https://reviews.freebsd.org/D43326
2024-01-09 17:27:15 +01:00
Wolfram Schneider 1e82d882ed fix using man(1) with multiple pages
PR: 275978
Reported by: Mohamed Akram
Fixes: 789480702e
MFC after: 1 week
2024-01-08 16:05:50 +00:00
Lexi Winter 6c951b3717 mail: add volatile in grabh()
setjmp() requires that any stack variables modified between the setjmp
call and the longjmp() must be volatile.  This means that 'saveint' in
grabh() must be volatile, since it's modified after the setjmp().
Otherwise, the signal handler is not properly restored, resulting in a
crash (SIGBUS) if ^C is typed twice while composing.

PR:		276119
Reported by:	Christopher Davidson <christopher.davidson@gmail.com>
MFC after:	2 weeks
Pull Request:	https://github.com/freebsd/freebsd-src/pull/993
2024-01-04 21:40:53 -05:00
Ricardo Branco 1fb3caee72 tail: Do not trust st_size if it equals zero.
PR:		bin/276107
MFC after:	1 week
2024-01-04 01:00:23 -08:00
Ricardo Branco e23954bd42 hexdump: Do not trust st_size if it equals zero.
Fix for hexdump -s not being able to skip files residing in
pseudo-filesystems that advertise a zero size value.

Historically, many pseudofs-based filesystems (e.g., procfs) report
a va_size of 0 for numerous files classified as regular files.
Typically, the contents of these files are generated on demand
from kernel data as sbuf(9) strings at the time they are read.
Accurately reporting the size of these files is challenging, as it
often involves generating their contents. These pseudofs implementations
frequently report the size as 0. This is a historical behavior and also
aligns with Linux behavior. To maintain compatibility, we have chosen
to preserve the existing behavior and address it in the userland
application, rather than modifying it in the kernel (by updating the
correct value for va_size).

PR:		bin/276106
MFC after:	1 week
2024-01-04 00:16:50 -08:00
Wolfram Schneider 9035bfffed indent: make the URL of the manpage two characters longer so that the test is successful 2023-12-29 09:37:43 +00:00
Lexi Winter f79b200b6a nfsstat: make -q work without -e/-E
MFC after:	2 weeks
Pull Request:	https://github.com/freebsd/freebsd-src/pull/961
2023-12-28 13:27:07 -07:00