Commit graph

3173 commits

Author SHA1 Message Date
Adrian Chadd
d8503e8768 rc: add wlan_gcmp to the hostapd / wpa_supplicant rc scripts
Add wlan_gcmp as a module to check for before starting hostapd/wpa_supplicant.

Differential Revision:	https://reviews.freebsd.org/D49344
Reviewed by:	bz, cy
2025-03-26 18:28:46 -07:00
Konstantin Belousov
1c8cdd807a rtld: fix several style(9) bugs
Sponsored by:	The FreeBSD Foundation
2025-03-18 03:34:03 +02:00
Brooks Davis
d6c34d1444 rc.d/sendmail: remove a obsolete upgrade seatbelt
This check was in place to aid the transition from sendmail pre-8.10.
8.10 was released in 2000.  It's not possible to upgrade directly from
such as system (Freebsd 3?) to FreeBSD 15 so we can drop this.

Reviewed by:	gshapiro, jhb
Differential Revision:	https://reviews.freebsd.org/D49308
2025-03-13 19:41:35 +00:00
Cy Schubert
5ca7754519 Revert "ntpd: Use the ntpd -u option in preference to the rc su plumbing"
Using the ntpd -u option to set the credentials ntpd is to run under
while still using rc(8) to invoke causes some FreeBSD installs to fail
to load mac_ntp. The fact that that can_run_nonroot() does not
indicate why failures occur leaves people on the mailing lists
guessing as to why there are failures. Let's revert back to using
the rc(8) provided su. The ntpd rc script will be rewritten when
the ntpd chroot will be implemented.

Reported on:	freebsd-stable@
MFC after:	immediately

This reverts commit 521f66715a.
2025-03-11 10:51:11 -07:00
Konstantin Belousov
d40daefca6 libc/gen: split user-visible opendir()-like functions into separate source files
This allows, for instance, to interpose opendir() with an implementation
that calls into fdopendir(), without causing multiple symbol definitions
when libc is linked in statically.

This is aligned with the quality of implementation principle that single
object file from a static library should not provide more than one
app-visible symbol.

[The copyright for fopendir() was copied, it might be refined by the
author]

Reviewed by:	brooks
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D49089
2025-02-25 09:09:29 +02:00
Brooks Davis
cdb24fbb0a libsys: Don't create or expose __realpathat
Previously, __realpathat was in libc and libsys (as is currently
standard), but not exported from libc which meant the stub in libc was
not filtered and thus libc's copy of the syscall was used.  This broke
an upcoming change to CheriBSD limiting syscalls to libsys.

The realpath(3) implementation now uses __sys___realpathat so there are no
consumers of __realpathat.  Switch it to PSEUDO (only _foo and __sys_foo
symbols) and remove __realpathat from Symbol.map.

This is a corrected version of 58d43a3cd7.

Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D49049
2025-02-19 20:05:47 +00:00
Cy Schubert
ed9712f894 var_run: Clean up style
Clean up style and make more consistent.

Replace test with if-then-else to make the script more legible.

Replace the call to dirname with the shell %/* operator avoiding a
fork & exec.

Reorder the test for $var_run_autosave before the test for /var/run on
tmpfs. This avoids gratuitously scanning the mount table for a tmpfs
/var/run.

Initial concept by and in discussion with:
	Harry Schmalzbauer <freebsd@omnilan.de>

No functional change intended.

MFC after:		2 weeks
Differnential revision:	https://reviews.freebsd.org/D47773
2025-02-18 18:42:34 -08:00
Cy Schubert
521f66715a ntpd: Use the ntpd -u option in preference to the rc su plumbing
Using the rc plumbing to setuid(2) is preferred as it allows the user
to use the -i option in ntpd_flags to chroot ntpd.

Chrooting ntpd by default will be a 2025 project.

MFC after:		1 week
Reviewed by:		markj
Differential Revision:	https://reviews.freebsd.org/D48191
2025-02-18 09:11:38 -08:00
Minsoo Choo
ca4eddea97 src: Use gnu17 as the default C standard for userland instead of gnu99
Tracking newer versions of C (and C++) permits assuming newer language
features in the base system.  Some C11 extensions are already used in
the base system but implemented on top of GNU C extensions such as
_Alignas and _Static_assert.  In some cases the fallback versions in
cdefs.h are more limited than the native C11 extensions.

Even though C11 is the next major version of C, C17 is chosen instead
since C17 does not add new features to C but merely fixes defects in
C11.  It is also well supported by a wide range of clang (7.0.0+) and
GCC (8.1+) versions.

Along with changing the default, this change also removes explicit
requests for c11 via the CSTD variable in various Makefiles.

Libraries and binaries for ZFS continue to use c99.

PR:		284039 (exp-run)
Reviewed by:	imp, arichardson, emaste
Differential Revision:	https://reviews.freebsd.org/D43237
2025-02-11 09:16:25 -05:00
Simon J. Gerraty
f8f5b658bc rc.subr:rc_trace take advantage of sdot
Since we now have sdot, use it to get RC_LEVEL from rc.conf.d/rc_trace
also avoid logging execution of ':' when RC_LEVEL > 0

Reviewed by:	stevek
Differential Revision:	https://reviews.freebsd.org/D48856
2025-02-10 14:23:38 -08:00
Navdeep Parhar
41594021fa rc.d/iovctl: Start the iovctl service after kld.
Drivers, including those that support SR-IOV, can be loaded via kld_list
and it makes sense to process iovctl configuration files afer all
drivers have been loaded.

MFC after:	1 week
Sponsored by:	Chelsio Communications
Reviewed by:	0mp, jhb
Differential Revision:	https://reviews.freebsd.org/D47937
2025-02-07 12:17:32 -08:00
Konstantin Belousov
e917958c36 rtld: clear any holes in the struct utrace_rtld passed to kernel logger
This should avoid an (almost) false positive from Valgrind, by filling
the padding on LP64.

PR:	284563
Reported by:	Paul Floyd <pjfloyd@wanadoo.fr>
Reviewed by:	emaste
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D48854
2025-02-05 12:33:29 +02:00
Warner Losh
e3898d552c Revert "rc.d: Add hastd as a prereq for devd"
This reverts commit 2d17f44a5a. It hangs
the boot. It turns out I installed my test on the wrong machine and
rebooted the other one...

Sponsored by:		Netflix
2025-02-04 22:11:40 -07:00
Warner Losh
2d17f44a5a rc.d: Add hastd as a prereq for devd
Setuping up CARP and HAST described in:
	https://www.freebsd.org/doc/en/books/handbook/disks-hast.html
doesn't work at boot time because devd start before hastd.

PR: 199733
Submitted-by: hs_fbsd@on-sky.net (no name given)
2025-02-04 17:47:21 -07:00
Gordon Bergling
5da0eee3d8 bootptest: Fix a typo in a source code comment
- s/tralier/trailer/

MFC after: 3 days
2025-01-26 13:06:55 +01:00
Keve Müller
3c61bbebc4 Update rc.initdiskless, fix error handling of remount_optional
chkerr() ignores the exit code of a preceding mount command in case a
file ```remount_optional``` exists.  The check is performed and a
subshell is launched to log the informational message and return.  The
return is executed in the context of the subshell, not the context of
the chkerr() function, hence is a NOP.  The remount_optional check is
hence ineffective.

Change the code to if/then/fi, so the return is evaluated in the context
of the chkerr function, to make the check effective.

Reviewed by: imp, emaste
Pull Request: https://github.com/freebsd/freebsd-src/pull/1497
2025-01-24 12:40:33 -07:00
Konstantin Belousov
78b5dadb58 rtld-elf/i386/reloc.c: apply clang-format
Discussed with:	emaste, imp
Sponsored by:   The FreeBSD Foundation
Differential revision:	https://reviews.freebsd.org/D48509
2025-01-21 03:44:58 +02:00
Konstantin Belousov
3a85aa6a1d rtld-elf/amd64/reloc.c: apply clang-format
Discussed with:	emaste, imp
Sponsored by:   The FreeBSD Foundation
Differential revision:	https://reviews.freebsd.org/D48509
2025-01-21 03:44:49 +02:00
Konstantin Belousov
e3035c52f2 rtld-elf/{amd64,i386}/reloc.c: remove unneeded #ifdef dbg
Discussed with:	emaste, imp
Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
Differential revision:	https://reviews.freebsd.org/D48509
2025-01-21 03:44:42 +02:00
Konstantin Belousov
986c96b54b rtld-elf/map_object.c: apply clang-format
Discussed with:	emaste, imp
Sponsored by:   The FreeBSD Foundation
Differential revision:	https://reviews.freebsd.org/D48509
2025-01-21 03:44:35 +02:00
Konstantin Belousov
bf3fbf74d1 rtld obj_remap_relro(): unindent the loop body
Discussed with:	emaste, imp
Sponsored by:	The FreeBSD Foundation
Differential revision:	https://reviews.freebsd.org/D48509
2025-01-21 03:44:22 +02:00
Konstantin Belousov
7e2f38311e rtld-elf/rtld.c: apply clang-format
Discussed with:	emaste, imp
Sponsored by:	The FreeBSD Foundation
Differential revision:	https://reviews.freebsd.org/D48509
2025-01-21 03:44:12 +02:00
Konstantin Belousov
dd1d72961b rtld-elf/rtld.c: fix typo in comment
Discussed with:	emaste, imp
Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
Differential revision:	https://reviews.freebsd.org/D48509
2025-01-21 03:43:54 +02:00
Minsoo Choo
2cadbe468a tcp_wrappers: Use default C standard version
Reviewed by:	emaste, arichardson, jhb
Differential Revision: https://reviews.freebsd.org/D43236
2025-01-09 13:07:51 -05:00
Mark Johnston
872686b17e rc: Document rtadvd_flags
PR:		283696
MFC after:	1 week
2025-01-06 23:20:00 +00:00
Simon J. Gerraty
203027b2d5 Update libexec/rc/debug.sh and hooks.sh
Use local_works() to test if 'local' actually works for
current shell.
2024-12-31 10:47:06 -08:00
Kyle Evans
17aec740b0 devmatch: do nothing if booted in safe mode
Safe mode may be enabled because of some problem discovered with a kmod,
thus wanting to avoid devmatch.  Honor it and let the user deal with
the fallout of not autoloading modules.  We've at least made it to
userland and the user demonstrably has a local console as they selected
safe mode in the first place, so this shouldn't be fatal if we don't,
e.g., load a necessary NIC driver.
2024-12-13 22:31:38 -06:00
Franco Fichtner
bf847ea31a rc: ignore InsydeH2O UEFI BIOS UUID placeholder for hostid
This caused MAC addresses (e.g. bridge0) to clash on systems
running this particular BIOS.

Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/1544
2024-12-11 15:58:14 -07:00
John Baldwin
fda0403eb0 rtld: Support multiple PT_GNU_RELRO program headers
Iterate over all the program headers in obj_remap_relro and remove the
relro fields from Obj_Entry.

Skip the call to obj_enforce_relro() in relocate_object() for the rtld
object as well as the main program object.  obj_enforce_relro() is
called later when it safe to reference globals such as page_size.

Reviewed by:	kib
Obtained from:	CheriBSD
Sponsored by:	AFRL, DARPA
Differential Revision:	https://reviews.freebsd.org/D47884
2024-12-06 17:37:50 -05:00
Tijl Coosemans
6b17d944a1 rc.d/sendmail: Fix error with some configurations
The sendmail startup script can run 4 daemons: sendmail, sendmail_submit,
sendmail_outbound, and sendmail_msp_queue.  Of the first 3 at most one
can be enabled.  There's a run_rc_command call for each and the ones for
sendmail and sendmail_msp_queue run unconditionally.  For some rc
commands this triggers warnings or errors when sendmail_enable="NO" or
sendmail_msp_queue_enable="NO".  Since d2e7bb630b these errors are
propagated and the whole script fails.

Fix this by first determining which daemons are enabled, setting ${name}
and ${rcvar} accordingly, and then always calling run_rc_command
conditionally.

Also replace ${name}.cf with sendmail.cf because ${name} isn't always
sendmail.

PR:		282585
Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D47757
2024-12-03 11:46:39 +01:00
Ed Maste
91629228e3 comsat: move uid/gid setting earlier
It's good to reduce privilege as early as possible.

Suggested by:	jlduran
Reviewed by:	jlduran
Obtained from:	NetBSD
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D47869
2024-12-02 14:57:13 -05:00
Ed Maste
d4dd9e22c1 comsat: Use initgroups and setgid not just setuid
PR:		270404
Reviewed by:	jlduran
Obtained from:	NetBSD
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D47828
2024-12-01 15:29:02 -05:00
Ed Maste
062b69ba04 comsat: Improve use of setuid()
Just return from jkfprintf if either (a) user lookup fails (that is,
getpwnam fails) or (b) setuid() to the user's uid fails.  If comsat is
invoked from inetd using the default of tty:tty we will now return due
to setuid() failing rather than fopen() failing.

PR:		270404
Reviewed by:	kevans
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D47823
2024-11-28 08:04:10 -05:00
Baptiste Daroussin
f3b371f4d9 nuageinit: remove redundant mkdirs 2024-11-27 10:03:06 +01:00
Baptiste Daroussin
41fe9d5300 nuageinit: implement ssh_keys support
MFC After:	1 week
Sponsored by:	OVHCloud
2024-11-27 09:53:04 +01:00
Cy Schubert
8585680682 Revert "rc.d/var_run: Fix typo in comment"
svcj is not a typo.

Noted by:	jlduran
MFC after:	3 days

This reverts commit bef05a7537.
2024-11-25 10:43:54 -08:00
Cy Schubert
4d58cf6ff9 rc.d/var_run: Add missing $(dirname)
We intend to create the containing directory here. Fix this typo.

PR:		282939
MFC after:	3 days
2024-11-25 09:16:59 -08:00
Cy Schubert
bef05a7537 rc.d/var_run: Fix typo in comment 2024-11-25 09:10:13 -08:00
John Baldwin
73b42eff25 rc.conf: Update commented examples for lo0 to use CIDR
In particular, a bare IP address no longer works.

Reviewed by:	bz, imp, emaste
Differential Revision:	https://reviews.freebsd.org/D47716
2024-11-25 10:14:33 -05:00
Baptiste Daroussin
3e2a7a2cbe nuageinit: add test about encrypted passwords
While here fix fc34a2463c where the
adduser_passwd.lua file was not added
2024-11-20 11:02:55 +01:00
Baptiste Daroussin
3e50286607 nuageinit: use io.popen instead of pipes in shell for password
using echo in a sh(1) command line, requires many escaping to be done
right, using io.popen we don't need to do this escaping anymore.
2024-11-20 10:41:46 +01:00
Baptiste Daroussin
fc34a2463c nuageinit: add test for the password 2024-11-20 10:41:46 +01:00
Konstantin Belousov
5bc24fd7a2 rtld: drop RTLD_INIT_PAGESIZES_EARLY
No arch defines it after ia64 decomissioning.

Discussed with:	jhb
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2024-11-20 08:59:32 +02:00
Franco Fichtner
43e045c173 atf: Guard libexec/atf with WITH_TESTS_SUPPORT
Other atf components are guarded by WITH_TESTS_SUPPORT already.
WITH_TESTS is for actual tests.

Reviewed by:	markj
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D47660
2024-11-18 18:36:46 +00:00
Kyle Evans
1426fd6cff rtld: implement _dl_iterate_phdr_locked
Some sanitizers need to be able to use dl_iterate_phdr() after stopping
the rest of the process, but it's very hard to do so reliably as a
non-participant in the main logic of the program.

Introduce _dl_iterate_phdr_locked to bypass the locking that's normally
required for dl_iterate_phdr() and slap some scary warning on it.  It
will remain undocumented and probably shouldn't be used for anything
else.

Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D47558
2024-11-13 19:33:59 -06:00
Konstantin Belousov
16d000bdac rtld.1: cross-reference rtld_get_var.3
Reviewed by:	Alexander Ziaee
Discussed with:	emaste
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D47351
2024-11-07 07:15:30 +02:00
Konstantin Belousov
c56df6ce71 rtld: add rtld_{get,set}_var
Reviewed by:	brooks (previous version)
Discussed with:	emaste
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D47351
2024-11-07 07:15:23 +02:00
Konstantin Belousov
d7214577ff rtld: make it easier to add sparce non-default members to ld_env_var_desc
by making the LD_ENV_DESC() macro variadic.

Suggested by:	brooks
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D47351
2024-11-07 07:14:38 +02:00
Konstantin Belousov
450e684e0f rtld: 1-bit for bool is enough
Reviewed by:	brooks
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D47351
2024-11-07 07:14:38 +02:00
Simon J. Gerraty
a4e7810f71 debug.sh check for :debug_add:
When we match a tag and turn tracing, see if we have any
$DEBUG_ON:debug_add:tag in DEBUG_SH and if so add the new tag.

This allows for more focused debugging during boot.

Reviewed by:	stevek
2024-11-04 12:30:01 -08:00