Commit Graph

2006 Commits

Author SHA1 Message Date
Robert Clausecker d518f64cef libc/resolv: get rid of MD5
MD5 is used by libc/resolv to generate a random sequence id from a
current time stamp.  Replace this convoluted mechanism with a call
to arc4random().  This permits us to entirely drop MD5 from libc,
simplifying the MD5 rework proposed in D45670.

Approved by:	markj
Reviewed by:	kevans, markj
See also:	D45670
Event:		EuroBSDcon 2025
Differential Revision:	https://reviews.freebsd.org/D52784
2025-10-04 10:50:02 +02:00
Robert Clausecker 4266461079 lib/libc: add recallocarray()
This function from OpenBSD is a hybrid of reallocarray() and calloc().
It reallocates an array, clearing any newly allocated items.
reallocarray() ultimately originates from OpenBSD.

The source is taken from lib/libopenbsd, which now no longer has the
function unless when bootstrapping (needed for mandoc).

Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D52863
2025-10-03 19:46:55 +02:00
Lexi Winter a053f948ad libbsm: Rename package to audit-lib
This is part of audit, so use the new LIB_PACKAGE feature to name the
package audit-lib, rather than libbsm.

MFC after:	1 day
Reviewed by:	bapt
Sponsored by:	https://www.patreon.com/bsdivy
Differential Revision:	https://reviews.freebsd.org/D52789
2025-09-30 09:14:58 +01:00
Dag-Erling Smørgrav 155290b23f tzcode: Expose and document offtime() and offtime_r()
Includes diff reduction to upstream version of this patch.

MFC after:	3 days
Sponsored by:	Klara, Inc.
Reviewed by:	philip
Differential Revision:	https://reviews.freebsd.org/D39715
2025-09-23 21:38:49 +02:00
Dag-Erling Smørgrav d20c825072 Revert "libc: Remove readdir_r(3)"
This reverts commit d549de7690.
2025-09-11 17:12:22 +02:00
Dag-Erling Smørgrav d549de7690 libc: Remove readdir_r(3)
This function was never safe to use.  We marked it deprecated in the
manual page in 2016, and it is marked obsolete in POSIX 2024.  We
previously added a linker warning and annotated the prototype; now that
stable/15 has been branched, we can remove it from main.

Relnotes:	yes
Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D52474
2025-09-10 18:58:06 +02:00
Lexi Winter dc5ba6b8b4 Remove MK_GSSAPI
For MIT Kerberos, MK_GSSAPI has no meaning: GSSAPI is a required part of
Kerberos and is always built if MK_KERBEROS is enabled.  Backport this
behaviour to Heimdal so it works the same way.

While here, change Heimdal's libcom_err and compile_et to be selected by
MK_KERBEROS, not MK_KERBEROS_SUPPORT, since these are part of Kerberos
and third-party users might need it even if Kerberos support is disabled
in the base system.  This means MK_KERBEROS_SUPPORT installs the same
files with both MIT and Heimdal.

Reviewed by:	cy
Differential Revision:	https://reviews.freebsd.org/D51859
2025-08-20 19:42:20 +01:00
Lexi Winter 837b13af68 Revert "Remove Secure RPC DES authentication"
This reverts commit 7ac276298b.

Requested by:	kib
2025-08-15 17:59:18 +01:00
Lexi Winter 7ac276298b Remove Secure RPC DES authentication
Following the earlier removal of keyserv, none of this functionality
works since it requires keyserv.

Remove the relevant symbols from libc's Symbol.map.  Leave compatibility
symbols for existing applications, but since the functions don't work
without keyserv, stub them out to return an error.

Remove some private symbols that were only used by keyserv; these don't
get compatibility symbols.

Remove the documentation for the old functions.

Remove rpc.ypupdated since it requires DES authentication.

Reviewed by:		manu, des, emaste
Differential Revision:	https://reviews.freebsd.org/D50442
2025-08-10 16:36:40 +01:00
Cy Schubert e26259f48a gssapi,krb5: Replace libgssapi with the MIT version
lib/libgssapi is based on Heimdal. As on Linux systems, the MIT
libgssapi_krb5 replaces it. With both gssapi libraries and header files
installed results in broken buildworld (gssd) and ports that will not
build without modifications to support the MIT gssapi in an alternate
location.

73ed0c7992 removed the MIT GSSAPI headers from /usr/include. Apps using
MIT KRB5 gssapi functions and structures will fail to build without this
patch.

This patch includes a temporary patch to usr.sbin/gssd to allow it
to build with this patch. rmacklem@ has a patch for this and for
kgssapi that uses this patch to resolve kgssapi issues for NFS with
Kerberos.

This patch is an updated version of D51661 to allow it to build following
additional patchs to the tree.

This should have been implmented with 7e35117eb0.

Fixes:			7e35117eb0, 73ed0c7992
Differential Revision:	https://reviews.freebsd.org/D51661
2025-08-07 10:17:00 -07:00
Dag-Erling Smørgrav 2bd157bc73 libc: Deprecate readdir_r()
This function was never safe to use.  We marked it deprecated in the
manual page in 2016, and it is marked obsolete in POSIX 2024.  Add a
linker warning and annotate the prototype.

Sponsored by:	Klara, Inc.
Reviewed by:	imp, markj
Differential Revision:	https://reviews.freebsd.org/D51681
2025-08-02 01:11:56 +02:00
Ed Maste c143ffbaf7 rpc.h: Remove reference to unimplemented DES ioctls
We won't be adding support for hardware DES.  Remove the #ifdef notdef
block.

Sponsored by:	The FreeBSD Foundation
2025-07-23 16:53:30 -04:00
Dag-Erling Smørgrav 0a5b763d98 libc: Rename fscandir{,_b}() to fdscandir{,_b}().
This seems to fit the pattern better (e.g. fdopendir()).

I've added weak references to ease the transition, but since it's only
been a few days, we can remove them (and the ObsoleteFiles entries for
the manual pages) before we branch stable/15.

Fixes:		deeebfdeca
Sponsored by:	Klara, Inc.
Reviewed by:	kevans
Differential Revision:	https://reviews.freebsd.org/D50980
2025-06-23 15:03:10 +02:00
Dag-Erling Smørgrav deeebfdeca libc: Add fscandir(), fscandir_b(), scandirat_b().
While here, clean up scandir() a bit and improve the documentation.

MFC after:	never
Sponsored by:	Klara, Inc.
Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D50935
2025-06-20 13:10:23 +02:00
Olivier Certner 63c9b01806 arm64: lib32: Don't try to install removed <machine/runq.h>
Reported by:    Herbert J. Skuhra (herbert gojira.at)
Fixes:          79d8a99ee583 ("runq: Deduce most parameters, remove machine headers")
MFC after:      1 month
Event:          Kitchener-Waterloo Hackathon 202506
Sponsored by:   The FreeBSD Foundation
2025-06-18 12:00:08 -04:00
Warner Losh d8b51259ca ssp: Protect sig2str with proper visibility markers
We only define SIG2STR_MAX with careful visibility, but define the
fortified version unconditionally. It needs to have the same visibility
both places.

Fixes:		3d12567133
Reviewed by:	jrtc27, kevans
Sponsored by:	Netflix
2025-06-11 21:19:05 -06:00
Ricardo Branco b0334450aa include: ssp: fortify <signal.h>
sig2str(3)

Reviewed by: imp, kib, des, jilles
Pull Request: https://github.com/freebsd/freebsd-src/pull/1696
Closes: https://github.com/freebsd/freebsd-src/pull/1696
2025-06-11 17:16:22 -06:00
Ricardo Branco 3d12567133 Add the POSIX sig2str(3) & str2sig(3) calls
Signed-off-by: Ricardo Branco <rbranco@suse.de>
Reviewed by: imp, kib, des, jilles
Pull Request: https://github.com/freebsd/freebsd-src/pull/1696
2025-06-11 17:16:22 -06:00
Ricardo Branco 86f06e612b Add POSIX NSIG_MAX & _SC_NSIG
Signed-off-by: Ricardo Branco <rbranco@suse.de>
Reviewed by: imp, kib
Pull Request: https://github.com/freebsd/freebsd-src/pull/1710
Closes: https://github.com/freebsd/freebsd-src/pull/1710
2025-06-11 17:16:20 -06:00
Brooks Davis 2d92a5abef Add sys/stdarg.h
While the type of va_list and implementation of va_*() psuedo functions
varies (sometimes greatly) by architecture, they will always be defined
by the compiler in a consistant way that does not require machine
dependent handling.

MFC after:	1 week

Reviewed by:	imp
Exp-run by:	antoine (PR 286274)
Pull Request:	https://github.com/freebsd/freebsd-src/pull/1595
2025-06-11 17:39:02 +01:00
Brooks Davis c190cd94b7 sys/_stdarg.h: drop cdefs.h and _types.h polution
Rely in sys/_visible for visibility macros and use __buitin_va_list
instead of __va_list everywere we declare va_list.

Reviewed by:	imp
Exp-run by:	antoine (PR 286274)
Pull Request:	https://github.com/freebsd/freebsd-src/pull/1595
2025-06-11 17:39:02 +01:00
Brooks Davis 2e783ea70a stddef.h: don't include sys/cdefs.h
Switch to sys/_visible.h for visibility macros.

Prefer __builtin_offsetof over __offset.  sys/cdefs.h always defines
__offsetof to __builtin_offsetof so just use the latter to remove a
dependency on sys/cdefs.h.  Realistically, we're never going to care
about a compiler that doesn't supply this builtin.

Add a somewhat questionable guard around the offsetof() definition
because the compiler no longer thinks it the same as a number of other
redundent definitions scattered around (e.g., in the openzfs codebase).
It is actually the same and those defintions likely shouldn't exist at
all, but it's easy to add a guard for now.

Reviewed by:	imp
Exp-run by:	antoine (PR 286274)
Pull Request:	https://github.com/freebsd/freebsd-src/pull/1595
2025-06-11 17:39:02 +01:00
Brooks Davis b01e971fd3 Don't rely on sys/_types.h including sys/cdefs.h
These headers relied in __BEGIN_DECS/__END_DECLS being defined when
sys/_types.h was included, but there's not a requirement that this be
the case.

Reviewed by:	imp
Exp-run by:	antoine (PR 286274)
Pull Request:	https://github.com/freebsd/freebsd-src/pull/1595
2025-06-11 17:39:01 +01:00
Bojan Novković 8bc0b97e19 glob.h: Limit glob_b prototype visibility
Hide glob_b behind __BSD_VISIBLE as it is not a POSIX function.

Reported by:	kib
Reviewed by:	kib
Fixes:	1e0743f54d ("glob: Add blocks support")
Differential Revision:	https://reviews.freebsd.org/D50670
2025-06-03 22:59:28 +02:00
Bojan Novković 1e0743f54d glob: Add blocks support
This change introduces the `glob_b` function which takes a block instead
of a function pointer.

Relnotes:	yes
Sponsored by:   Klara, Inc.
Inspired by:  https://github.com/apple-oss-distributions/Libc
Differential Revision:	https://reviews.freebsd.org/D50485
2025-06-02 11:32:50 +02:00
Konstantin Belousov a56fe703c2 Provide user interface to retrieve reported extended errors
Reviewed by:	brooks
Sponsored by:	The FreeBSD Foundation
MFC after:	2 weeks
Differential revision:	https://reviews.freebsd.org/D50483
2025-05-31 22:52:42 +03:00
Konstantin Belousov 98af94cae7 sysconf(3): add _SC_UEXTERR_LEN, the max length of the extended error string
Reviewed by:	brooks
Sponsored by:	The FreeBSD Foundation
MFC after:	2 weeks
Differential revision:	https://reviews.freebsd.org/D50483
2025-05-31 22:52:42 +03:00
Konstantin Belousov 31760ee65a libthr: add stable user interface for sigfastblock(2)
Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D50377
2025-05-19 09:07:43 +03:00
Konstantin Belousov c0fdd2bf94 pthread_switch_add_np(3): remove
The interface is not functional with libthr and returns not supported
error always.  There is no point in providing it to userspace or document.

The symbols are kept for ABI compatibility, of course.

Reviewed by:	emaste, markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D50376
2025-05-19 09:07:43 +03:00
Dag-Erling Smørgrav da2025a0e8 fts: Add FTS_COMFOLLOWDIR and FTS_NOSTAT_TYPE.
MFC after:	never
Relnotes:	yes
Sponsored by:	Klara, Inc.
Reviewed by:	kevans, imp
Differential Revision:	https://reviews.freebsd.org/D50233
2025-05-08 16:29:15 +02:00
Konstantin Belousov 5ab906195b include/paths.h: add _PATH_NOSHUTDOWN
Reviewed by:	bapt, kevans, olce
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D50166
2025-05-05 19:04:22 +03:00
Dag-Erling Smørgrav 873420ca1e libc: Add getenv_r() function.
This is a calque of the NetBSD function of the same name.

MFC after:	never
Relontes:	yes
Sponsored by:	Klara, Inc.
Reviewed by:	kevans
Differential Revision:	https://reviews.freebsd.org/D49979
2025-04-27 08:29:32 +02:00
Dag-Erling Smørgrav f0ac5e919f fts: Add blocks support.
This adds an `fts_open_b()` variant of `fts_open()` which takes a block
instead of a function pointer.

This was inspired by, and is intended to be compatible with, Apple's
implementation; however, although our FTS and theirs share a common
ancestor, they have diverged significantly.  That and the fact that
we still target compilers which don't support blocks means Apple's
implementation was not directly reusable.

This is the second use case for blocks in FreeBSD (the first being
`qsort_b()`, which we use here).  This suggest we might want to add
a `COMPILER_FEATURE` for blocks to avoid hardcoding any further
`COMPILER_TYPE` checks.

MFC after:	never
Relnotes:	yes
Sponsored by:	Klara, Inc.
Reviewed by:	kevans, theraven, imp
Differential Revision:	https://reviews.freebsd.org/D49877
2025-04-22 19:25:56 +02:00
Ricardo Branco 3b2f0bfc35 Add POSIX psiginfo(3) call
Signed-off-by: Ricardo Branco <rbranco@suse.de>
PR:	286133
MFC after:	 1 week
Github PR:	 https://github.com/freebsd/freebsd-src/pull/1666
2025-04-17 18:19:44 +03:00
Dag-Erling Smørgrav 80e06d621a fts: Move private flags away from public ones.
Renumber the private flags so there is a sizeable gap between them and
the public flags, making it easier to add public flags in the future.
These private flags are only ever set or read by FTS itself, so there
is no compatibility issue.

MFC after:	1 week
Sponsored by:	Klara, Inc.
Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D49711
2025-04-10 13:35:46 +02:00
Stephen Hurd 415a0ce02c Revert Make newly POSIX functions visible
Summary:
This reverts commit d7efac1be1.
This reverts commit 9d0eea9422.

Some ports (specifically Python) define __BSD_VISIBLE themselves, so
the change from __BSD_VISIBLE to __POSIX_VISIBLE >= 202405 makes them
fail.

Reported by:	jrtc27, cperciva
2025-03-20 03:41:27 -04:00
Stephen Hurd d7efac1be1 Add missing ||
Fixes:	9d0eea9422
2025-03-19 20:55:13 -04:00
Stephen Hurd 9d0eea9422 Make newly POSIX functions visible
Some of the POSIX 202405L functions are already in the system, make
them visible when appropriate.

Reviewed by:	imp
MFC after:	1 week
Differential Revision: https://reviews.freebsd.org/D47859
2025-03-19 19:45:06 -04:00
Gleb Smirnoff c62ae124cc rpc: limited multithread support for svc_nl
The rpc(3) itself was not designed with multithreading in mind, but we can
actually achieve some parallelism without modifying the library and the
framework.  This transport will allow to process RPCs in threads, with
some hacks on the application side (documented in code).  We make
reentrable only one method - SVC_REPLY().  Reading and parsing of incoming
calls is still done synchronously.  But the actual processing of the calls
can be offloaded to a thread, and once finished the thread can safely
execute svc_sendreply() and the reply would be sent with the correct xid.

Differential Revision:	https://reviews.freebsd.org/D48569
2025-02-01 01:00:28 -08:00
Gleb Smirnoff c5d671b711 libc/rpc: add userland side RPC server over netlink(4)
To be used by NFS related daemons that provide RPC services to the kernel.
Some implementation details inside the new svc_nl.c.

Reviewed by:		rmacklem
Differential Revision:	https://reviews.freebsd.org/D48550
2025-02-01 01:00:25 -08:00
Gleb Smirnoff fa1b961259 krpc: add kernel side client over netlink(4)
This shall be the official transport to connect kernel side RPC clients
to userland side RPC servers.  All current kernel side clients that
hijack unix(4) sockets will be converted to it.  Some implementation
details are available inside new clnt_nl.c.

The complementary RPC server over netlink(4) coming in next commit.

Reviewed by:		rmacklem
Differential Revision:	https://reviews.freebsd.org/D48549
2025-02-01 01:00:25 -08:00
Ed Maste 473681a1a5 libc: Fix getentropy POSIX 2024 conformance issues
GETENTROPY_MAX should be defined in limits.h.  EINVAL is the return
value for buflen > GETENTROPY_MAX.

PR:		282783
Reviewed by:	markj, asomers, jhb
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D47689
2025-01-17 13:23:23 -05:00
Kyle Evans 712f81feea include: add a userland version of __assert_unreachable
The kernel has had a version of this since
c79cee7136 ("kernel: provide panicky version of __unreachable"), and
userland can benefit from the same.  __unreachable is largely
inadequate because it's *not* an assertion of any sort, so we're not
really alerted to a problem that we could've anticipated.

Reviewed by:	emaste, imp, jhb, olce
Differential Revision:	https://reviews.freebsd.org/D48077
2025-01-12 18:41:37 -06:00
Alexander Motin e6c96c7af7 Revert "isp: Fix abort issue introduced by previous commit"
This reverts commit 1f7c379c07.

Leaked unintended changes.  I'm sorry.
2025-01-08 13:20:09 -05:00
Alexander Motin 1f7c379c07 isp: Fix abort issue introduced by previous commit
Aborting ATIO while its CTIOs are in progress makes impossible to
handle their completions, making them stuck forever.  Detect this
case by checking ctcnt counter and if so instead of aborting just
mark the ATIO as dead to block any new CTIOs.  It is not perfect
since the task id can not be reused for some more time, but not
as bad as the task stuck forever.

MFC after:	1 week
2025-01-08 13:04:34 -05:00
Warner Losh 6553c31c96 endian.h: Update comments now that POSIX Issue 8 is POSIX.1-2024
Now that Issue 8 has been published, replace the informal Issue 8
language with the more typical POSIX.1-xxxx citation.

Sponsored by:		Netflix
2024-12-30 13:38:39 -07:00
Mark Johnston 9ba7351fcf ssp: Make ssp.h more self-contained
Include a header to provide __size_t.

Fixes:	c10d567ea0 ("include: de-macro __ssp_overlap(), improve semantics and checking")
PR:		283653
Reviewed by:	kevans, imp
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D48226
2024-12-29 17:57:46 +00:00
Kyle Evans 74ecdf86d8 Tweak ppoll() to include 1003.1-2024 visibility, take two
Note in the manpage that the 2024 edition finally added ppoll(), and
also add the appropriate declarations for the correct versions of
_POSIX_C_SOURCE (via __POSIX_VISIBLE).

Differential Revision:	https://reviews.freebsd.org/D48043
2024-12-14 22:40:16 -06:00
Kyle Evans da5aed38d8 Revert "Tweak ppoll() to include 1003.1-2024 visibility"
This reverts commit 212d7f439a.  A last
minute change to remove __BSD_VISIBLE unearthed some breakage that I
failed to re-test.  Sigh.
2024-12-14 01:05:09 -06:00
Kyle Evans 212d7f439a Tweak ppoll() to include 1003.1-2024 visibility
Note in the manpage that the 2024 edition finally added ppoll(), and
also add the appropriate declarations for the correct versions of
_POSIX_C_SOURCE.

Differential Revision:	https://reviews.freebsd.org/D48043
2024-12-13 22:15:19 -06:00