Commit graph

15897 commits

Author SHA1 Message Date
Olivier Certner
f9fa6cb391
cred: Hide internal flag CRED_FLAG_CAPMODE
This flag is used in field 'cr_flags', which is never directly visible
outside the kernel.  That field is however exported through 'struct
kinfo_proc' objects (field 'ki_cr_flags'), either from the kernel via
sysctls or from libkvm, and is supposed to contain exported flags
prefixed with KI_CRF_ (currently, KI_CRF_CAPABILITY_MODE and
KI_CRF_GRP_OVERFLOW, this second one being a purely userland one
signaling overflow of 'ki_groups').

Make sure that KI_CRF_CAPABILITY_MODE is the flag actually exported and
tested by userland programs, and hide the internal CRED_FLAG_CAPMODE.
As both flags are currently defined to the same value, this doesn't
change the KBI, but of course does change the KPI.  A code search via
GitHub and Google fortunately doesn't reveal any outside uses for
CRED_FLAG_CAPMODE.

While here, move assignment of 'ki_uid' to a more logical place in
kvm_proclist(), and definition of XU_NGROUPS as well in 'sys/ucred.h'
(no functional/interface changes intended).

Reviewed by:    mhorne
Approved by:    markj (mentor)
MFC after:      2 weeks
Sponsored by:   The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D46909

(cherry picked from commit 09290c3a0c82524138973b14f393379edf733753)

A ports exp-run (PR 283410) showed one port to be affected
(sysutils/procs), which has been fixed upstream and in the ports tree.
All additional indirect references to CRED_FLAG_CAPMODE we found after
the code search mentioned in the original commit message are
automatically generated from our headers by FFI mechanisms, so
automatically disappear at recompilation (and the KBI is not changed, as
explained above, so recompilation is not needed).
2025-04-08 15:38:14 +02:00
Konstantin Belousov
8476ab3558 gcore(1): dump NT_PROCSTAT_KQUEUES section
(cherry picked from commit 10626f7384f9e39a8c02dfd475b1fd14fd7395dd)
2025-04-07 04:28:22 +03:00
Konstantin Belousov
451fca2e9f procstat.1: document kqueues
(cherry picked from commit d76a31ca74cffda4aea63b1276f92c039ca76053)
2025-04-07 04:28:21 +03:00
Konstantin Belousov
a15cae4c74 procstat(1): dump kqueues
(cherry picked from commit 28f4cf9217c27edea42c5c024c9e71816890bb3c)
2025-04-07 04:28:21 +03:00
Christos Margiolis
1890f0b0df beep(1): Use AFMT_FLOAT
AFMT_FLOAT is supported by sound(4) as of FILLME, so use it here, since
the whole program works with floats already.

Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D47639

(cherry picked from commit 1166cfd96f3403edb082387fbc3a4d4aa249bce8)
2025-04-06 02:28:14 +02:00
Olivier Certner
68c46c41a7
mdo(1): Use setcred() to change credentials
As this is the only system call that MAC/do currently supports, and the
only one that really can be for transitions involving simultaneous
changes of user and group IDs.

Reviewed by:    bapt
Approved by:    markj (mentor)
Sponsored by:   The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D47621

(cherry picked from commit e395e354823b690ba19ecc8e3688bacec6f67ad3)
2025-04-03 21:31:05 +02:00
Ed Maste
e683e7e0f8 usr.bin/Makefile: always build ELF Tool Chain strings(1)
strings(1) is not conditional on WITH_/WITHOUT_TOOLCHAIN, as it is a
small utility that is also useful outside of the toolchain context.
As of commit 1cae7121c667 we switched to WITH_LLVM_BINUTILS by default.

After this change building world with default options but installing
WITHOUT_TOOLCHAIN failed, because we would build LLVM's strings but
attempt to install ELF Tool Chain's version, which did not exist.
Address this by always including ELF Tool Chain strings in non-install
make targets, so that it will be available if options are changed at
install time.

PR:		285556
Reported by:	Michael Butler
Reviewed by:	brooks
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D49425

(cherry picked from commit fdc4db57224ce19b867c60fce4c410068be40c27)
2025-04-01 08:52:53 -04:00
Dag-Erling Smørgrav
a4251e93f8 top: Make locale issues non-fatal.
If the `setlocale()` call fails, emit a warning and sleep briefly so the
user has a chance to see the warning before we redraw the screen.  Note
that we have no way of knowing exactly what is wrong, but at least we
can suggest that they check their environment.

MFC after:	1 week
Sponsored by:	Klara, Inc.
Reviewed by:	kevans
Differential Revision:	https://reviews.freebsd.org/D49230

(cherry picked from commit 180065eb09e699820a1e1c45d3d00156e0effe29)
2025-03-31 18:35:33 +00:00
Alexander Ziaee
c541138270
top: Sync usage and synopsis
Switching between io and cpu sorting uses a great example in the usage.
[-m io | cpu]. Use that everywhere.

MFC after:		3 days
Reviewed by:		mhorne
Approved by:		mhorne (mentor)
Differential Revision:	https://reviews.freebsd.org/D49515

(cherry picked from commit 187d954eab94fdcb33609d91966dbd727acfd720)
2025-03-31 13:26:26 -04:00
Alexander Ziaee
1fdca2a3a9
top: Polish key bindings in usage and manual
Organize key bindings by ascii(7) for consistency and maintainability,
mark them as Interactive Commands, wordsmith them, and sync their
organization between the manual and help screen.

MFC after:		3 days
PR:			282734
Fixes:			c8aa5e526 (move command mapping to commands.c)
Reviewed by:		imp, mhorne, Jim Brown <jpb@jimby.name>
Approved by:		mhorne (mentor)
Differential Revision:	https://reviews.freebsd.org/D49462

(cherry picked from commit 0a85254d5a33800600477ce57fbaab64591aa6ea)
2025-03-31 13:26:15 -04:00
Konstantin Belousov
04e4dda94f procstat.1: document local SOCK_SEQPACKET socket display
(cherry picked from commit 03dfb8d0211cf9d7405c4fd7d541dde28047001c)
2025-03-31 05:41:32 +03:00
Konstantin Belousov
a02f377d95 procstat.1: correct local socket types descriptions.
(cherry picked from commit 991329f507a893076a4119c90bb463de0ac15be9)
2025-03-31 05:41:32 +03:00
Konstantin Belousov
fb8c944d2b procstat: decode SOCK_SEQPACKET unix domain socket type
(cherry picked from commit 8011df62f57f021a1b4f62d9beea4c25d9b37a23)
2025-03-31 05:41:32 +03:00
Ahmad Khalifa
c0e07c93e8 install: print directory name instead of file name if mkstemp fails
Printing the file name doesn't make sense since mkstemp failing means
that the file wasn't created.

Also add a test case for this.

Co-authored-by: Jose Luis Duran <jlduran@gmail.com>
Reviewed by: imp,jhb
Pull Request: https://github.com/freebsd/freebsd-src/pull/1383

(cherry picked from commit e8d027be6b84ac976eacd46283c286b934dd6f1f)
2025-03-25 19:28:39 -06:00
Alexander Ziaee
4c02b6589e
etdump.1: Polish + xref cd9660(5)
+ correct misfile in section 8
+ rewrite the document descirption to include -9660
+ markup command modifiers as such instead of bold
+ markup variables as defined variables, enabling apropos
+ correct option syntax in description section
+ unwrap list offsets for legibility
+ fix line wrapping for standard BSD console
+ crossreference cd9660(5) and vis versa
+ tag SPDX for both manuals

MFC after:		3 days
Reviewed by:		mhorne
Approved by:		mhorne (mentor)
Differential Revision:	https://reviews.freebsd.org/D48513

(cherry picked from commit 283be95ea29abd7f867e4084bafe368c47f6c038)
2025-03-23 21:40:28 -04:00
Konstantin Belousov
8025c3957b procstat.1: document rlimitusage
(cherry picked from commit 82897058342e9bfe7193283421055e3f07ac9b8f)
2025-03-20 05:13:39 +02:00
Konstantin Belousov
d9b7d0a548 procstat.1: sort subcommands
(cherry picked from commit 0832381247d7e6e93ae9ba1639d07f33a6f07882)
2025-03-20 05:13:38 +02:00
Maxim Konovalov
6207ca7b76 truncate.1: improve the example section
Notably:
 * spell "Megabytes" as "megabytes" consistently;
 * remove a stray asterisk from the /boot/kernel/kernel listing
 * avoid using a shell prompt in the examples consistently
 * fixes the size parameter
 * add an example how to increase the file size

PR:		273997
MFC after:	1 week

(cherry picked from commit 5460bdda9d4cb3ce1d7431824b6f53c545888b53)
2025-03-14 01:55:55 +00:00
Mark Johnston
0599d2a1c5 limits tests: Try to fix spurious cputime test failures
I very occasionally see test failures caused by the total CPU time being
several milliseconds under 3s.  The test runs "limits -t 3 time <busy
loop>" and verifies that the reported time elapsed is at least 3s (and
not too much more).  In particular, any time spent executing time(1)
itself is counted against the limit but not recorded in the output.

I think it makes more sense to reverse the order, so that the CPU time
limit is not applied to time(1) itself.  This also resolves the test
failures I was seeing, which were reproducible only under load (i.e.,
running many tests in parallel).

MFC after:	2 weeks
Sponsored by:	Klara, Inc.

(cherry picked from commit 0f63c4af5e4761680550b0aa08cc96f52076c08c)
2025-03-07 22:51:48 +00:00
Alexander Ziaee
3cedc5a9f1
resizewin.1: Fix option list width typo + spdx
MFC after:		3 days
Accepted by:		mhorne (mentor)
Differential Revision:	https://reviews.freebsd.org/D48349

(cherry picked from commit 4a5d51e73e48b27d90b21ed26999b23208f603d8)
2025-02-26 19:52:19 -05:00
Cy Schubert
6a4a1a2385 shar: Make sure a sed failure in the generated archive results in failure
Obtained from:	NetBSD hg commit 365369:21b92f0055b4
MFC after:	1 week

(cherry picked from commit f0c8d2cd622a47e06c08620a10e13ad7519e9102)
2025-02-24 16:37:46 -08:00
Cy Schubert
b006133ca1 shar: Handle special characters or white space in file names fed to shar
Obtained from:	NetBSD hg commit 365370:124268924386
MFC after:	1 week

(cherry picked from commit 1080f5315427b382221651b342227b4923106f83)
2025-02-24 16:37:46 -08:00
Emmanuel Vadot
9197c04a25 Deprecate publickey(5) stuff
This uses DES and it's likely that nobody uses that in 2025.
If somebody uses this we help them by deprecating and removing this.

Reviewed by:	bapt, emaste
Differential Revision:	https://reviews.freebsd.org/D30682

(cherry picked from commit 723425f837270dd3b22098168ae9464a1ebe38c6)
2025-02-19 21:34:42 -05:00
Li-Wen Hsu
ef3ed0726f Canonicalize the name of the FreeBSD Foundation
Reviewed by:	emaste
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit dab59af3bcc7cb7ba01569d3044894b3e860ad56)
2025-02-19 09:58:47 -05:00
Dag-Erling Smørgrav
67cead936d unifdef: Fix collision check when adding symbols.
findsym() is intended for use while parsing input, so it should not be
called from addsym2() or indirectsym(), which are called before any
input is processed.

MFC after:	1 week
Sponsored by:	Klara, Inc.
Reviewed by:	kevans
Differential Revision:	https://reviews.freebsd.org/D48733

(cherry picked from commit c63af363c2458aebc30c01cd0b93b4b902580019)
2025-02-13 01:37:42 +01:00
Ed Maste
90702fb5de install: Fix METALOG ouptut for numeric -o and -g args
install's -o and -g flags both accept a name or a numeric argument.
In -U -M (non-root METALOG) mode it always emitted uname= and gname= in
the METALOG, but these are not appropriate for numeric IDs.

If the -o and/or -u arguments parse as an ID, emit uid= and/or gid=
respectively.

Note that if an argument is valid as both a name and numeric ID we will
prefer the name in normal (non -U -M) mode and the ID in -U -M mode.  We
don't want to require a passwd db in non-root mode, and entirely-numeric
user or group names are a terrible idea so just accept this discrepancy.

PR:		284119
Reviewed by:	jlduran
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D48504

(cherry picked from commit 4b04f5d7e8a2bb0488ad5804ecaf45cef5b1d46f)
2025-02-11 16:27:17 -05:00
Ed Maste
036ce9b76e vtfontcvt: Improve error message for unsupported DWIDTH
vtfontcvt requires that all glyphs are 1x or 2x a common width,
reporting for example "bitmap with unsupported DWIDTH 27 0 on line xxx"
if the font is expected to be 32 pixels wide.

Add the expected / permitted values to the error message to make the
issue more clear - for the same example,
"bitmap with unsupported DWIDTH 27 0 (not 32 or 64)".

Reviewed by:	ziaee
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 3433daae0d20d55503084c4d17b8a3e685657ad2)
2025-02-04 08:38:09 -05:00
Alexander Ziaee
b40f5ebc45
man.1: Improve search + spdx
People are often stunned by robust manual search functionality on
the community discord, so improve introductory doc regarding search by:

+ explain what search related flags do instead of using similies
+ consolidate and standardize search options in synopsis and usage
+ mention that a page or file can be specified in synopsis and example
+ call regular expressions `expression`, which searches to re_format(7)
+ crossreference the regular expression manual instead of egrep(1)
+ improve MANPATH xref flow and explanation, matching MAILPATH in sh(1)
+ mark up aditional semantics for their inclusion in apropos

While here:
+ use consistent spacing and form (Ql) for quoted literals
+ clean a few linter errors regarding self xref and nospace
+ reset a list width to indent for consistency with style.mdoc
+ tidy examples + align files + tag spdx

Outstanding:
- example 3 shows no results on a typical bsdinstall'd system

MFC after:	3 days
Reviewed by:	elliejs, emaste, imp, Jessica Hawkwell, jlduran
Approved by:	imp

(cherry picked from commit 46a9fb7287f41eedf321d81a68a826f231d11bfe)
2025-02-03 19:58:00 -05:00
Maxim Konovalov
9c72da8894 genl: typo fixes
PR:	284017
(cherry picked from commit 8b5058ec78a6fad972f48e6cd5613c2750f43ad6)
2025-01-29 18:33:13 +00:00
Faraz Vahedi
6f34788b4e colrm(1): Replace magic exit codes with standard macros
Signed-off-by: Faraz Vahedi <kfv@kfv.io>
Reviewed by:	markj, oshogbo
MFC after:	1 week
Pull Request:	https://github.com/freebsd/freebsd-src/pull/1496

(cherry picked from commit fc26f24b3ef276b2a9f73c9778aecff7377b1aeb)
2025-01-29 10:51:34 +01:00
Faraz Vahedi
6285abfcf3 nl(1): Capsicumise the utility
Signed-off-by: Faraz Vahedi <kfv@kfv.io>
Reviewed by:    markj, oshogbo
MFC after:      1 week
Pull Request:   https://github.com/freebsd/freebsd-src/pull/1465

(cherry picked from commit dfd52321b7beba716fa2bdd4f54e57e9ac806e96)
2025-01-29 10:51:31 +01:00
Faraz Vahedi
a6d0bc7065 perror(1): Replace magic exit codes with standard macros
Signed-off-by: Faraz Vahedi <kfv@kfv.io>
Reviewed by:    markj, oshogbo
MFC after:      1 week
Pull Request:   https://github.com/freebsd/freebsd-src/pull/1492

(cherry picked from commit 4dd6597a56f8c7ff03d4f451b612a9e45442c549)
2025-01-29 10:51:28 +01:00
Faraz Vahedi
8cf0915c19 perror(1): Reorder headers alphabetically to meet style(9) compliance
Signed-off-by: Faraz Vahedi <kfv@kfv.io>
Reviewed by:    markj, oshogbo
MFC after:      1 week
Pull Request:   https://github.com/freebsd/freebsd-src/pull/1492

(cherry picked from commit 82e9f8c2d19ba5d132438a764352eb3b4826fc58)
2025-01-29 10:51:24 +01:00
Mariusz Zaborski
75c8e113e6 leave: we should also cache time zone
MFC after:	1 week

(cherry picked from commit 08a38bb098e96f2ec77b26fab3b22bc4be89332a)
2025-01-29 10:51:22 +01:00
Faraz Vahedi
ef3914a561 leave(1): Replace magic exit codes with standard macros
Signed-off-by: Faraz Vahedi <kfv@kfv.io>
Reviewed by:	oshogbo
MFC after:	1 week
Pull Request:	https://github.com/freebsd/freebsd-src/pull/1499

(cherry picked from commit f7a6cf3a020600b77795729d1c01780dae8e6d2e)
2025-01-29 10:51:18 +01:00
Faraz Vahedi
15261be600 leave(1): Capsicumise
Signed-off-by: Faraz Vahedi <kfv@kfv.io>
Reviewed by:    oshogbo
MFC after:      1 week
Pull Request:   https://github.com/freebsd/freebsd-src/pull/1499

(cherry picked from commit 24a7303821ad2343b9239ab3d12a569a70a2b99a)
2025-01-29 10:51:15 +01:00
Faraz Vahedi
ac068edaa8 perror(1): Capsicumise
Signed-off-by: Faraz Vahedi <kfv@kfv.io>
Reviewed by:    markj, oshogbo
MFC after:      1 week
Pull Request:   https://github.com/freebsd/freebsd-src/pull/1492

(cherry picked from commit adc02d5e3cfad9c9d7e12f776cad651795d9ad78)
2025-01-29 10:51:10 +01:00
Faraz Vahedi
a7a1b23550 colrm(1): Capsicumise
Signed-off-by: Faraz Vahedi <kfv@kfv.io>
Reviewed by:	markj, oshogbo
MFC after:	1 week
Pull Request:	https://github.com/freebsd/freebsd-src/pull/1496

(cherry picked from commit 95498a5acc0888ed2e73237b82a1e90f109473f9)
2025-01-29 10:51:08 +01:00
Cy Schubert
6404a5a7fe genl.1: Improve grammar
Make the first sentence read more smoothly.

(cherry picked from commit 13d81ef632ec6ca5e6936ab77e8ac67a8c430033)
2025-01-19 17:59:16 -08:00
Mark Johnston
6d34cce606 sed tests: Add a regression test for the c function
Based on the test case from PR 271817 by Mohamed Akram.

PR:		271817
MFC after:	2 weeks

(cherry picked from commit 003818aca4cdda47adef808a56d48003aa514029)
2025-01-17 18:48:15 +00:00
Valeriy Ushakov
3e22772769 sed: The change ("c") command should start a new cycle.
The "c" command should start the next cycle as clarified in POSIX 2024.
This is also consistent with historical and gnu sed behavior.

This patch is from OpenBSD by way of NetBSD with a tweak to the man page
date by me.

Confirmed the test case in the bug now works.

PR:		271817
Obtained from:	NetBSD (1.39 uwe), OpenBSD (1.39 millert)
Sponsored by:	Netflix

(cherry picked from commit a2d78713171cf138b5ae50d61f82df1af7574c95)
2025-01-17 18:48:07 +00:00
Baptiste Daroussin
279d6c5173 bintrans(1): fix typo
Reported by:	Helge Oldach <freebsd@oldach.net>
2025-01-16 16:49:17 +01:00
Baptiste Daroussin
1795eae9a2 bintrans(1): RFC2047 variant of quoted print
MFC After:	1 week
Reviewed by:	pstref
Differential Revision:	https://reviews.freebsd.org/D48381

(cherry picked from commit beab8b1ddf86a88e0605562f2cc1d6a26c68604f)
2025-01-16 10:18:14 +01:00
Baptiste Daroussin
16dee1cc65 bintrans(1): qp switch to getopt_long
In preparation for more arguments, switch bintrans qp argument parsing
to getopt_long, while here make the decodign argument being -d|--decode
for compatibility with base64 encoding/decoding

MFC After:	1 week
Reviewed by:	pstef
Differential Revision:	https://reviews.freebsd.org/D48380

(cherry picked from commit a8d9bd3fa5855fe7583ed05946296ab6b9937d69)
2025-01-16 10:18:14 +01:00
Baptiste Daroussin
88f55c3150 nvi: import version 2.2.1-52c07e8
(cherry picked from commit 4087ffdbce725367566bc3fc60a959292daac99d)
2025-01-15 10:55:01 +01:00
Mark Johnston
0325afa639 ktrace: Make -t t trace struct arrays as well as structs
Otherwise there is no specific -t option which captures struct arrays.

MFC after:	1 week

(cherry picked from commit 596ee234ef4537e71f030e13598ecbe73ee697bb)
2025-01-14 14:15:00 +00:00
Mohamed Akram
2c1c6bd7d5 sed: Fix handling of an empty pattern space
Add a regression test.

PR:		271791
Obtained from:	OpenBSD (1.38 millert)
MFC after:	2 weeks

(cherry picked from commit 5982237f1e5a30b6b7d67b307b4d3685b00718bf)
2025-01-14 14:14:24 +00:00
Kyle Evans
4ce976c56f shar: add a deprecation notice
The shar(1) program is simple, but the fundamental idea of a sh archive
is risky at best and one that we probably shouldn't be promoting as
prominently as a program in $PATH and a manpage.  Let's deprecate and
remove it, since the same functionality can easily be found in
tar(1) instead.

Reviewed by:	emaste, philip
Reviewed by:	allanjude, brooks, delphij, des, imp, rpokala (previous)

(cherry picked from commit f68ee0e7a1e8732f725cad4ac708ec49093782d4)
(cherry picked from commit 2832af7b4ea256b18ef4dbf2ff97a50765f0609a)
2025-01-10 20:48:26 -06:00
Alexander Ziaee
267717c5db cu.1: describe better + tag spdx
Preserve over 40 years of "call UNIX" BSD heritage
while answering "one line about what it does" e.g.

"how do I get a serial console?"
"% apropos serial"

MFC after:	3 days
Reported by:	imp

Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/1423

(cherry picked from commit 4d12c7b9df660b15580ff3b07ef5570d1cab958a)
2024-12-28 11:17:27 -07:00
Yoshiaki Kasahara
000823559a find: Re-enable the -acl primary on FreeBSD
This was made conditional to support cross-builds, but the relevant
header wasn't included so it was never enabled for native builds.

PR:		278124
Fixes:		c3a6ea5ba6 Allow compiling usr.bin/find on Linux and Mac
(cherry picked from commit 984add354edef8a6b4983a33f89ff62532a1556b)
2024-12-27 10:49:45 -05:00