802 Commits
Author SHA1 Message Date
Gleb Popov e8da57256d libutil: Make free_iovec() zero its arguments, like the manpage claims
Approved by: kib
Differential Revision: https://reviews.freebsd.org/D59929
2026-09-26 19:14:00 +03:00
Jesús Daniel Colmenares Oviedo 2c68ad49f1 nullfs: Allow VSOCK to be mounted on top of another VSOCK
In the world of containers, mounting a unix(4) socket is a common
practice to allow communication between processes within containers.
For example, both Podman and Docker can expose a unix(4) socket,
and that same unix(4) socket can be mounted as a file accessible
to a process inside a container, allowing that application to control
Podman or Docker. Another example is PHP-FPM with NGINX, where,
instead of using TCP/IP for communication between containers, a
unix(4) socket is sufficient.

However, nullfs(4) and all related components do not allow mounting
a VSOCK on top of another. The current workaround involves creating
the socket in a directory and mounting that directory. This is an
option, though it does not provide a good user experience compared
to directly mounting a VSOCK on top of another, since the application
that creates the socket may create other sockets in that directory,
and the user may not wish to share them, or, worse yet, applications
that create unix(4) sockets may not provide any authentication at
all, as they may assume that security at the file system level is
sufficient.

Reviewed by:		dfr@
Approved by:		dfr@
Relnotes:		yes
Differential Revision:  https://reviews.freebsd.org/D59158
2026-08-28 01:12:46 -04:00
Faraz Vahedi 8d29d24296 libc: Restore prior C23 include guards
To avoid any sort of POLA violation, this commit restores old
guards and defines the C23 feature test macros in addition to
them.  This is to close off whole class of possible breakage,
rather than patching it case by case.

Reported by:	dim
Reviewed by:	dim, dteske, fuz
Approved by:	dim, dteske (mentor), fuz (mentor)
MFC after:	1 month
Differential Revision: https://reviews.freebsd.org/D58911
2026-08-19 13:51:21 +03:30
Faraz Vahedi cd0727ec70 libc: Add <stdio.h> C23 feature test macro
Define the __STDC_VERSION_STDIO_H__ feature test macro now that
the header fully conforms to C23.

Reviewed by:	fuz
Approved by:	fuz (mentor)
MFC after:	1 month
Differential Revision: https://reviews.freebsd.org/D58842
2026-08-14 23:01:54 +03:30
Dag-Erling Smørgrav c93f3b55e6 libutil: Reimplement getlocalbase()
* Get rid of the pointless LOCALBASE_CTL_LEN mechanism

* Apply minimal normalization to the paths obtained from the environment
  or sysctl variable

* Turn the manual page into a manual page

* Add tests

MFC after:	1 week
Reviewed by:	se
Differential Revision:	https://reviews.freebsd.org/D58362
2026-07-21 08:31:49 +00:00
Dag-Erling Smørgrav 641e8e3956 Revert "libc: Constify the getcap API"
This broke cross-building on Linux and macOS.

This reverts commit 823d00b2d4.
2026-06-05 19:15:46 +02:00
Dag-Erling Smørgrav 823d00b2d4 libc: Constify the getcap API
MFC after:	1 week
Inspired by:	NetBSD
Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D57252
2026-06-05 00:41:22 +02:00
Dag-Erling Smørgrav b5dce0ae4f login_class: Fix kqueues, pipebuf resource types
* kqueues is a count but is listed as a size

* pipebuf is a size but is listed as a count

PR:		295623
MFC after:	1 week
Fixes:          a4c04958f5 ("libutil: support RLIMIT_PIPEBUF")
Fixes:          85a0ddfd0b ("Add a resource limit for the total...")
Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D57333
2026-05-30 00:06:44 +02:00
Dag-Erling Smørgrav e9346d1d13 login.conf(5): Add missing resource limits
While here, reorder the table.

PR:		295618
MFC after:	1 week
Reviewed by:	olce
Differential Revision:	https://reviews.freebsd.org/D57258
2026-05-27 15:10:35 +02:00
Dag-Erling Smørgrav 363ea40c76 limits: Further RLIMIT_VMM cleanup
Teach limits(1), sh(1), and setclassresources(3) about RLIMIT_VMM.

Fixes:		1092ec8b33 ("kern: Introduce RLIMIT_VMM")
Reviewed by:	bnovkov
Differential Revision:	https://reviews.freebsd.org/D57031
2026-05-17 18:23:50 +02:00
Mark Johnston 237900f17f libutil: Include param.h in quotafile.c
Required for MAXPATHLEN.

MFC after:	1 week
2026-05-12 20:05:19 +00:00
Kyle Evans f268f95955 libutil: avoid an out-of-bounds read in trimdomain(3)
memchr(3) will happily believe we've passed in a valid object, but
hostsize could easily exceed the bounds of fullhost.  Clamp it down to
the string size to be safe and avoid UB.  This plugs a potential
overread noted in the compat shim that was just added.

Reviewed by:	des
Sponsored by:	Klara, Inc.
Differential Revision:	https://reviews.freebsd.org/D54623
2026-03-03 16:51:02 -06:00
Kyle Evans 7e70589b1b libutil: take a size_t in trimdomain()
INT_MAX is already larger than a reasonable hostname might be, but
size_t makes some of this easier to reason about as we do arithmetic
with it.  This would maybe not be worth it if we had to bump the
soversion because of it, but libutil does symbol versioning now so we
can provide a compat shim.

While we're here, fix some inconsistencies in argument names in the
manpage.

Reviewed by:	des
Obtained from:	https://github.com/apple-oss-distributions/libutil
Sponsored by:	Klara, Inc.
Differential Revision:	https://reviews.freebsd.org/D54622
2026-03-03 16:51:01 -06:00
Alexander Ziaee 960719762f trimdomain.3: Explain DISPLAY a bit more
MFC after:		3 days
Reported by:		jrtc27
Reviewed by:		des
Differential Revision:	https://reviews.freebsd.org/D54629
2026-02-17 12:28:25 -05:00
Simon Wollwage 54ce6b2c4c login.conf.5: Remove mention of login copyright setting
PR: 291649
Fixes: 905571c031 ("Remove copyright strings printed at login time via login(1) or sshd(8).")
Signed-off-by: Simon Wollwage [email protected]
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/1926
2026-01-09 14:13:37 -07:00
Kyle Evans 98edcbcce0 libutil: defer setting the MAC label until after the login class
MAC policies, like mac_biba(4), may forbid changing the login class once
a label has been applied.  For setting up the initial login context,
this isn't really expected and in-fact may break some class-based
configuration.

Defer setting the MAC label until after the login class is set, and
remove the requirement that we have a pwd entry since the label is
pulled from the login class -- we only use pwd for syslog in this path.

Patch is largely by Kevin Barry, with some modifications and this commit
message by kevans@.

PR:		177698
Reviewed by:	des, olce
MFC after:	3 days
Co-authored-by:	Kevin Barry <ta0kira gmail com>
Differential Revision:	https://reviews.freebsd.org/D53362
2025-10-28 21:37:21 -05:00
Lexi Winter 031e711647 packages: Install development manpages in the -dev package
Add a new per-group SUBPACKAGE option to bsd.man.mk.  When MANSPLITPKG
is enabled, this is forced to "-man", otherwise it defaults to empty
but can be overridden by the caller.

Use this in bsd.lib.mk to install library manpages in the -dev package
instead of the base package.  This is nearly always preferable, since
library manpages are usually in section 2 or 3 and are only relevant
to people with development packages installed.

For manpages which should be installed in the base package even for
libraries, add a new MANNODEV group in bsd.lib.mk.  Update existing
Makefiles to use this where appropriate.

MFC after:	3 days
Discussed with:	olce
Reviewed by:	olce
Sponsored by:	https://www.patreon.com/bsdivy
Differential Revision:	https://reviews.freebsd.org/D52832
2025-10-26 02:26:06 +00:00
Kirk McKusick 99bf680a84 Fix getmntpoint(3) to operate as it is documented in its manual page.
The -libutil function getmntpoint(3) is documented as accepting a device
name “with or without /dev/ prepended to it” but did not attempt to
prepend /dev/. This patch corrects the problem by prepending /dev/ to
names that do not begin with a '/'.

Reported-by: Dag-Erling Smørgrav
Differential Revision: https://reviews.freebsd.org/D53185
MFC-after:    1 week
Sponsored-by: Netflix
2025-10-22 11:01:37 -07:00
Lexi Winter 614c8750ce Remove ftpd(8)
This was previously deprecated and is slated for removal in 15.0.
Users who still need ftpd(8) can install the ftp/freebsd-ftpd port.

Retain the ftp(d) PAM services since other FTP daemons use them.

Update /etc/inetd.conf to point to /usr/local.

Add ftpd to ObsoleteFiles, but do not list configuration files since
users may want to preserve these to use with the freebsd-ftpd port.

There is still some language in the manual referring to ftpd(8)
which is relevant to the port, which has been retained but updated
to reference the port.

MFC after:	3 days
Relnotes:	yes
Reviewed by:	cperciva
Differential Revision:	https://reviews.freebsd.org/D52739
2025-09-29 22:53:34 +01:00
Dag-Erling Smørgrav 8073a5137f getmntpoint: Don't compare st_rdev for non-devices
If the mntfromname of a mountpoint is not a device (e.g. nullfs, tarfs,
procfs) we shouldn't compare st_rdev, as any match will be spurious.

MFC after:	1 week
Sponsored by:	Klara, Inc.
Sponsored by:	NetApp, Inc.
Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D51945
2025-08-17 19:29:27 +02:00
Dag-Erling Smørgrav d0cc09fcdb libutil: Fix manlint failures
MFC after:	1 week
Reviewed by:	ziaee
Differential Revision:	https://reviews.freebsd.org/D51864
2025-08-12 14:55:01 +02:00
Dag-Erling Smørgrav 7400d04407 libutil: Remove manual link for nonexistent function
I believe quota_statfs() was the original name of the function now
called quota_check_path().  I must have forgotten to update the MLINK
when I renamed it.

MFC after:	1 week
Fixes:		5666aadb3d ("Further extend the quotafile API.")
Fixes:		22afc76786 ("libutil: Add missing MLINKs")
Reviewed by:	bcr
Differential Revision:	https://reviews.freebsd.org/D51863
2025-08-12 14:55:01 +02:00
Dag-Erling Smørgrav bd953a6026 libutil: Fix 32-bit build
In the expand_generic test case for expand_number(), leave out size_t
if it's not 64 bits wide.

Fixes:		ab1c6874e5
2025-08-07 11:34:13 +02:00
Dag-Erling Smørgrav cc5276aed0 libutil: Fix login_setcryptfmt()
Our dummy crypt_set_format() needs to be exported, otherwise it will
be resolved at link time instead of load time, preventing the real
crypt_set_format() in libcrypt from replacing it when present.

PR:		288677
Fixes:		0c381b7f05
Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D51746
2025-08-06 22:43:13 +02:00
Dag-Erling Smørgrav ab1c6874e5 libutil: Backward compatibility for expand_number()
Reimplement expand_number() in terms of expand_unsigned(), which takes
a pointer to uint64_t like expand_number() did before.  Provide a macro
that picks the correct version based on the type of the argument.

Fixes:		2e0caa7c7e
Reviewed by:	jhb
Differential Revision:	https://reviews.freebsd.org/D51723
2025-08-06 22:43:13 +02:00
Dag-Erling Smørgrav 22afc76786 libutil: Add missing MLINKs
MFC after:	1 week
Reviewed by:	olce, imp, emaste
Differential Revision:	https://reviews.freebsd.org/D51706
2025-08-03 19:31:28 +02:00
Dag-Erling Smørgrav 4e6a3e7e32 libutil: Document pidfile_signal()
Fixes:		287451fd01
MFC after:	1 week
Reviewed by:	pauamma_gundo.com, emaste
Differential Revision:	https://reviews.freebsd.org/D51705
2025-08-03 19:31:20 +02:00
Dag-Erling Smørgrav 8d8a745c45 libutil: Drop auth_getval()
This function has been an empty stub for years; now that we're bumping
the library version, we can finally get rid of it.

Fixes:		0c381b7f05
Reviewed by:	kib, emaste
Differential Revision:	https://reviews.freebsd.org/D51704
2025-08-02 19:56:35 +02:00
Dag-Erling Smørgrav 301dee770e libutil: Better tests for expand_number(3)
Replace the current tests with jhb's earlier, more extensive proposal,
updated to take into account the switch back to signed integers.

Reviewed by:	pstef
Differential Revision:	https://reviews.freebsd.org/D20796
2025-08-02 16:05:44 +02:00
Dag-Erling Smørgrav 2e0caa7c7e libutil: Really fix expand_number(3)
It is unclear whether this function was originally intended to support
negative numbers.  The original implementation used signed integers,
but actually giving it a negative number as input would have invoked
undefined behavior, and the comments (since removed) only mentioned
positive numbers.  Fifteen years ago, I “fixed” this by changing the
type from signed to unsigned.  However, it would still have accepted
an input with a leading minus sign (though it would have returned its
absolute value).  Fifteen years on, change the type back to signed and
fix the logic so it correctly handles both positive and negative
numbers without invoking undefined behavior.  This makes it a better
match for humanize_number(3), which it is supposed to complement.

Fixes:		bbb2703b4f
Reviewed by:	jhb
Differential Revision:	https://reviews.freebsd.org/D51542
2025-08-02 16:05:36 +02:00
Dag-Erling Smørgrav 0c381b7f05 libutil: Add symbol versioning
Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D51694
2025-08-02 16:05:31 +02:00
Bojan Novković aae23170c8 libutil: Move cpuset(1) domain policy parsing code into libutil
cpuset(1) implements a domainset(9) policy parser that is used to
translate a <policy>:<domain_list> string into a domainset_t mask
and a valid domainset policy. This change moves the domainset parsing
code into a new cpuset.c function - 'domainset_parselist'.

The existing cpuset.c code was refactored into a generalized list
parsing function which is now used to parse both CPU sets and domain
sets. This is the same approach used in cpuset(1).

Reviewed by:	markj, ziaee (manpages)
Differential Revision:	https://reviews.freebsd.org/D46607
2025-07-27 18:31:48 +02:00
Brooks Davis a123502ef7 Search for mntopts.h globally, not locally
Change the include directives to use <mntopts.h> instead of "mntopts.h"
now that it's installed by libutil (the latter option was dubious
regardless since a -I${SRCTOP}/sbin/mount was required anyway).

Reviewed by:	olce, imp, dim, emaste
Differential Revision:	https://reviews.freebsd.org/D49952
2025-04-22 22:51:42 +01:00
Brooks Davis cda23fc36d Move mntopts(3) suppport into libutil
Many programs use this functionality so it should be available centrally
rather than compiled into each program independently.  This has the
modest downside of adding libutil dependencies to some mount_<foo>
programs, but many (plus mount(8)) already have those depndencies so
this shouldn't be a major imposition.

In commit 906c312bbf, Kirk said this could be done once the change was
merged to FreeBSD 13.  That happened in commit 668dfa0166 in 2023.

While here perform related tidying including removing SRCS where the
only entry is ${PROG}.c rendering it unnecessary.

Reviewed by:	olce, dim, emaste
Differential Revision:	https://reviews.freebsd.org/D49951
2025-04-22 22:51:42 +01:00
Ed Maste 4b60fac3a5 kinfo_getfile: Add a comment explaining 4/3 ratio
We first get the expected size of the data from the kern.proc.filedesc
sysctl, allocate 4/3 of that size, and then fetch the data.  Add a
comment about the reason (the fd table may grow between the two calls).

Sponsored by:	The FreeBSD Foundation
2025-04-11 14:42:44 -04:00
Maxim Konovalov d6917af2b9 login.conf.5: remove a stray quote
PR:	282858
2024-12-11 18:23:22 +00:00
David Gilbert 169e23d41f hexdump.3: Add missing LIBRARY section
All the other libutil section 3 manpages document this, and although
it's heavily implied by the libutil.h header in the synopsis, we should
still be explicit and consistent.

PR:		280078
Reviewed by:	jrtc27
MFC after:	1 week
2024-11-21 20:23:16 +00:00
Keith White 167bfde705 ftime.3: fix typo in spelling of libutil
PR:	282171
MFC after:	3 days
2024-10-18 15:50:24 +03:00
Konstantin Belousov a4c04958f5 libutil: support RLIMIT_PIPEBUF
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D46619
2024-09-20 09:46:06 +03:00
Warner Losh e9ac41698b Remove residual blank line at start of Makefile
This is a residual of the $FreeBSD$ removal.

MFC After: 3 days (though I'll just run the command on the branches)
Sponsored by: Netflix
2024-07-15 16:43:39 -06:00
Kyle Evans cf8e5289a1 include: ssp: round out fortification of current set of headers
ssp/ssp.h needed some improvements:
 - `len` isn't always a size_t, it may need casted
 - In some cases we may want to use a len that isn't specified as a
    parameter (e.g., L_ctermid), so __ssp_redirect() should be more
    flexible.
 - In other cases we may want additional checking, so pull all of the
    declaration bits out of __ssp_redirect_raw() so that some functions
    can implement the body themselves.

strlcat/strlcpy should be the last of the fortified functions that get
their own __*_chk symbols, and these cases are only done to be
consistent with the rest of the str*() set.

Reviewed by:	markj
Sponsored by:	Klara, Inc.
Sponsored by:	Stormshield
Differential Revision:	https://reviews.freebsd.org/D45679
2024-07-13 00:16:24 -05:00
Pedro F. Giffuni fc3907ce00 fparseln: Update license
Remove 3rd and 4th clauses in christos' license. OK christos.

Obtained from:	NetBSD
2024-06-15 18:30:27 -05:00
Pedro F. Giffuni 9a39435c0b Revert "fparseln: Update NetBSD version strings"
This reverts commit 1a968da448.

I was mistakenly looking at the version strings in the CVS attic
but the function was moved to libc/stdio where it matches the
current string.
2024-06-15 17:46:56 -05:00
Pedro F. Giffuni 1a968da448 fparseln: Update NetBSD version strings
The correponding changes (mostly ANSIfication) were done long ago locally.
No functional change.

Obtained from:	NetBSD (libutil CVS Attic)
2024-06-15 15:32:06 -05:00
Mariusz Zaborski bb421be6c1 libutil: move ftime to libutil
It seems that there are still some applications that use ftime(3)
(for example, science/siconos and sysutils/lcdproc). The issue
is that we don't build libcompat as a shared library anymore.
The easiest solution is to move it to libutil, until we
deprecate it for good.

This solution was proposed by kib@ in
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=257789.

PR:		257789
MFC after:	1 month
Reviewed by:	kib (ages ago)
Differential Revision:	https://reviews.freebsd.org/D39994
2024-05-29 14:36:09 +02:00
Olivier Certner c7e645269f login_cap.h: Remove LOGIN_DEFPRI
This is an implementation detail which is likely to become irrelevant in
the future, as we move to not resetting the priority if the
corresponding capability is not present in the configuration file
('/etc/login.conf').

GitHub's code search and Google show no use of this public constant, and
it doesn't exist in OpenBSD and NetBSD.

So, remove this definition and its sole use in-tree.

PR:                     276570 (exp-run)
Reviewed by:            emaste
Approved by:            emaste (mentor)
MFC after:              3 days
Sponsored by:           The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D43609
2024-01-29 22:58:10 +01:00
Olivier Certner e3a396eb2a login_cap.h: Remove LOGIN_DEFUMASK
This public constant has not been used in-tree since 1997 (this was
noticed while working on previous commit "setusercontext(): umask: Set
it only once (in the common case)").

Since it was an implementation detail and GitHub's code search and
Google show no use of this symbol today, simply remove it.

PR:                     276570 (exp-run)
Reviewed by:            emaste, kib (earlier version, then part of D40344)
Approved by:            emaste (mentor)
MFC after:              3 days
Sponsored by:           The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D43608
2024-01-29 22:58:10 +01:00
Olivier Certner f2a0277d3e setusercontext(): Set priority from '~/.login_conf' as well
Setting the process priority is done only when the current process'
effective UID corresponds to that for which context is to be set.
Consequently, setting priority is done with appropriate credentials and
will fail if the target user tries to raise it unduly via his
'~/.login_conf'.

PR:                     271751
Reviewed by:            kib, Andrew Gierth <andrew_tao173.riddles.org.uk>
Approved by:            emaste (mentor)
MFC after:              3 days
Relnotes:               yes
Sponsored by:           Kumacom SAS
Differential Revision:  https://reviews.freebsd.org/D40352
2024-01-29 22:58:09 +01:00
Olivier Certner 33d4ce5496 login.conf(5): Document priority's special value 'inherit'
Reviewed by:            emaste, yuripv (older version)
Approved by:            emaste (mentor)
MFC after:              3 days
Sponsored by:           Kumacom SAS
Differential Revision:  https://reviews.freebsd.org/D40691
2024-01-29 22:58:09 +01:00
Olivier Certner d162d7e2ad setclasspriority(): New possible value 'inherit'
It indicates to the login.conf machinery (setusercontext() /
setclasscontext()) to leave priority alone, effectively inheriting it
from the parent process.

PR:                     271749
Reviewed by:            emaste, yuripv
Approved by:            emaste (mentor)
MFC after:              3 days
Relnotes:               yes
Sponsored by:           Kumacom SAS
Differential Revision:  https://reviews.freebsd.org/D40690
2024-01-29 22:58:09 +01:00