Commit graph

3411 commits

Author SHA1 Message Date
Franco Fichtner
3d6d1fbf87 tty: patch in 3wire autologin support
PR: https://github.com/opnsense/core/issues/3921
2026-06-19 09:47:29 +02:00
Baptiste Daroussin
2ebec3c7ea nuageinit: fix command injection and related issues
- Add shell_escape() helper to safely escape shell arguments
- Apply shell_escape to all user-controlled values in shell commands:
  adduser (usershow, useradd, lock, primary_group, groups)
  addgroup (groupshow, groupadd, members)
  exec_change_password (usermod)
  settimezone (tzsetup root and timezone)
  install_package (pkg package names)
- Escape double quotes in hostname when writing rc.conf.d/hostname
- Add missing 'local' declaration for resolvconf_command in nameservers()
- Escape interface name in resolvconf -a command
- Change open_resolvconf_conf() from 'w' to 'a' mode to prevent
  data loss when nameservers() is called multiple times
- Clean up stale resolvconf.conf at the start of each boot
  (skip on postnet to preserve config written by first call)

Approved by:	re (cperciva)
MFC After: 1 day

(cherry picked from commit 8b70a203be10411c560ed303ab25713d70b316e9)
(cherry picked from commit 87b18b611ec9a70347fdd239345fa23977bcb2d0)
2026-05-14 12:06:56 -07:00
Baptiste Daroussin
78c1ba506b nuageinit: only parse user_data as yaml when necessary
This fixes a regression introduced in cae280931c9e which prevents
user_data as a shell script to be used

Approved by:	re (cperciva)
PR:		295062
Reported by:	Ross McKelvie <ross@exitzero.uk>
MFC After:	1 day

(cherry picked from commit c316ec259011e9e22e40eaa72d834f3bfac95c28)
(cherry picked from commit 4211f280ba087c75dcd84f9b592238b2eae33af9)
2026-05-07 13:18:43 -07:00
Alex Richardson
9c4106c350 rtld: silence clang's unterminated-string-initialization warning
Since the initializer is used in other places where we can't just
replace it with a char-by-char initializer, this adds a macro for the
nonstring attribute (match the linuxkpi definition).

Reviewed by:	emaste, jhb
MFC after:	1 week
Differential Revision: https://reviews.freebsd.org/D52535

(cherry picked from commit 86f325711c07b723b85c031d581d0a5c1a0964f3)
2026-04-24 11:26:39 -04:00
John Baldwin
c57d2b6f97 rtld: Use a helper variable to simplify a few lines
Reviewed by:	kib
Sponsored by:	AFRL, DARPA
Differential Revision:	https://reviews.freebsd.org/D54507

(cherry picked from commit 6d6bf4a892d6be84ec59fce5419eab616bcabb40)
2026-04-24 11:26:38 -04:00
John Baldwin
4f536daec8 rtld: Switch to using <assert.h> for assert
The stock assert() works because rtld-libc includes a custom
implementation of __assert().

Reviewed by:	imp, kib
Obtained from:	CheriBSD
Sponsored by:	AFRL, DARPA
Differential Revision:	https://reviews.freebsd.org/D54712

(cherry picked from commit 3ea97c9de2b24c685d42be12dd57fad2f67b3f1b)
2026-04-24 11:26:38 -04:00
John Baldwin
3c01c7df98 rtld: Use uintptr_t instead of Elf_Addr for init/fini function pointers
This is a no-op on non-CHERI architectures, but is required for CHERI
where Elf_Addr is only an address and not a complete pointer.

While here, consistently use `uintptr_t *` for arrays of init/fini
function pointers.

Reviewed by:	imp, kib
Effort:		CHERI upstreaming
Obtained from:	CheriBSD
Sponsored by:	AFRL, DARPA
Differential Revision:	https://reviews.freebsd.org/D54711

(cherry picked from commit e96ec1a1eb935aa2febcbf9629a52c85297a088e)
2026-04-24 11:26:38 -04:00
John Baldwin
4bbc387783 rtld: Simplify walking program headers
Store phnum in Obj_Entry instead of phsize and use that to simplify
the terminate expressions when iterating over program headers.

Reviewed by:	kib
Obtained from:	CheriBSD
Sponsored by:	AFRL, DARPA
Differential Revision:	https://reviews.freebsd.org/D54710

(cherry picked from commit 31a440a0e9a26fee109ed753e3493c72b9dc05e9)
2026-04-24 11:26:38 -04:00
Konstantin Belousov
0b6f465fc5 rtld: fix processing of preloaded z_initfirst objects
(cherry picked from commit 9b844b495e8e63439ffe523757ac7444a16317af)
2026-04-23 20:08:50 +03:00
Christos Margiolis
f89909e462 virtual_oss: Introduce virtual_oss_default_control_device rc variable
The -t option gives the user the ability to create a control device for
a given virtual_oss(8) instance, so that the instance's configuration
can be manipulated during runtime with virtual_oss_cmd(8). As is
expected, the control device's name is not known, since it is specified
by the user.

This patch introduces a virtual_oss_default_control_device rc variable,
which defaults to "vdsp.ctl". The goal of this is that third-party
programs and scripts can access the control device of the default
virtual_oss(8) configuration without guessing. This is especially useful
for sbin/devd/snd.conf which deals with hot-swapping sound devices using
virtual_oss(8).

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

(cherry picked from commit 70e27ecba51892cbe4cc94bbf785c6dd261dfd57)
2026-04-23 10:41:15 +02:00
Jose Luis Duran
16719d3407
rc.conf: Fix typo in comment
The correct path is /etc/defaults/rc.conf (defaults in plural).

Reviewed by:	netchild
Fixes:		cc4eb1ea10 ("Add support for a /etc/defaults/vendor.conf override file")
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D56456

(cherry picked from commit 8e08080ee581dfd30c128d032035da7b6ae44463)
2026-04-20 04:43:27 +00:00
Kyle Evans
ebf890d48f rc: run the zfs rc script before tmp
The tmp rc script has much the same problem that the var does: it wants
to test if /tmp is writable, and mount a tmpfs if it's not.  This means
that we actually want our zfs datasets mounted first, because we might
have a /tmp dataset that changes the story.

The ordering problem is particularly noticable with a r/o zfs root,
since the write test will fail and we'll mount a tmpfs that later gets
covered by our /tmp dataset.  If that /tmp dataset inherited readonly,
then we're still in trouble.

This also fixes `tmpmfs=yes`, which would again get covered by a zfs
dataset with the existing ordering.

Reviewed by:	des

(cherry picked from commit d3f21856aa72c28408660ed40ce76bbd0716a991)
2026-04-11 22:15:11 -05:00
Kyle Evans
5183de1947 stand: lua: break out a few more dirent types in lfs
These are non-standard and specific to the version used in loader.  We
have some desire to recognize symlinks to avoid filtering out kernel
symlinks in the autodetection bits when they would be perfectly fine to
`load`.

This won't be usable right away, so any impending use will need to be
careful to account for nil.

Reported by:	leres

(cherry picked from commit bc531a96c9b28b1cabcd5deb0c9f8f6d815cfebc)
2026-04-10 22:19:20 -05:00
Kyle Evans
ec37fd5422 flua: lposix: fix WARNS=6 issues
lposix is the last holdout of modules built into flua until we can fix
the module design to have the right parts require()able.  Address a
valid bug in lua_read() found at a higher WARNS and drop the override
entirely.  Some of the modules could possibly be re-evaluated.

Reported by:	des
Reviewed by:	des
Sponsored by:	Klara, Inc.
Sponsored by:	NetApp, Inc.

(cherry picked from commit b41b6fdb3a1635de4c2a9280aab12b83e3aeffc5)
2026-04-10 22:18:47 -05:00
Kyle Evans
9ba365ad53 flua: kick out the remaining builtin modules
Bootstrap flua has some magic now to handle modules by building them in
and discovering them via linker sets.  This is slightly cleaner than
always building them in and baking them into loadedlibs for both
bootstrap and system flua.

Adjust the stand build now that these three libs have their own new
homes.  lposix remains builtin because it's structured incorrectly in
our version.

Reviewed by:	bapt, emaste, markj

(cherry picked from commit b11a5709ec2b61fefb03bfdd38e2f06d2c1107c1)
(cherry picked from commit 9c7db0931d486ce800aa71d9f41abfad9f7f691f)
(cherry picked from commit d505ef08ffbe3b7383fbc6ed30121de9256ac18e)
2026-04-10 22:18:35 -05:00
Kyle Evans
2ef21abe89 flua: support our flua modules in the bootstrap flua
This version builds every module into the flua binary itself, since all
of the bootstrap tools are built -DNO_SHARED.  As a result, we also
cannot dlsym(), so we can't really discover the names of our newly
builtin modules.  Instead, just build out a linker set with all of our
luaopen_*() functions to register everything up-front.

Building in all of the modules isn't strictly necessary, but it means
that we have an example of how to add a bootstrap module everywhere you
go and one doesn't need to consider whether bootstrap flua can use a
module when writing scripts.  On my build machine, the consequence on
our binary size is an increase from around 1.6M -> 1.9M, which isn't
really that bad.

.lua modules can install into their usual path below $WORLDTMP/legacy
and we'll pick them up automagically by way of the ctor that sets up
LUA_PATH early on.

This re-lands bootstrap module support with a more sensible subset, and
after having verified that it cross-builds fine on macOS and Linux -- we
cannot do libfreebsd on !FreeBSD because it's more system header
dependant.  We also need to bootstrap libmd to bring in libhash, and
libucl + libyaml.

Reviewed by:	bapt, emaste (both previous version)

(cherry picked from commit 1953a12ee2cde1afacb3e3f7612d89695c96e04f)
(cherry picked from commit 80ada959004c4386880e47b11618f8abfc2d80e1)
(cherry picked from commit 31320402472394af57eb3a36bee7f944117ca0ed)
(cherry picked from commit 981cf36d64c48ebfa22d44ac83b6d448c2974f23)
(cherry picked from commit d4c973fa148544a0b949ceb1efb6c68096f02baf)
(cherry picked from commit bbef1c72b4873b657fdb0466b48b15d1d4f0a731)
(cherry picked from commit 151bd3516b541823b16793460d73916e63d2b9c1)

build: don't create duplicate bootstrap-tools targets

The general problem is that we might have a somewhat complicated
dependency tree depending on bootstrap version requirements.  We could
document when multiple bootstrap tools might have a shared dependency
and be careful to add them only once to the list, but that is a little
more fragile- particularly if we purge some bootstrap tools and need to
re-work the logic a little bit.

Just avoid redefining the build commands as we're iterating over the
list so that we can keep the actual requirements intact.

Reported by:	dhw, others
Reviewed by:	imp

(cherry picked from commit ab492c08fc3cbf4fb5d569663c0751bc2a41cb1f)
2026-04-10 22:18:20 -05:00
Kyle Evans
072ca5df87 nuageinit: require lfs where it's needed
nuageinit largely already did this, but one spot was missed -- add the
necessary require() in to get the module loaded.

(cherry picked from commit bb4167463ac44b47ded4e0223a0abd8381ca6cd8)
2026-04-10 22:17:19 -05:00
Artem Bunichev
1242ffc567
debug.sh: Fix a typo
MFC after:		3 days
Reviewed by:		emaste, guest-seuros, sjg, ziaee
Differential Revision:	https://reviews.freebsd.org/D55416

(cherry picked from commit ab835b37075e6478ef82f8c807a2335f5d19edaf)
2026-04-10 14:27:55 -04:00
Konstantin Belousov
20318719df rtld: add test for dlopen("#dirfd/path")
(cherry picked from commit 72252591ac01037fa53501adb88f00d5d3cc09ed)
2026-04-08 21:22:39 +03:00
Konstantin Belousov
8fb16a5c7f rtld: allow dlopen("#<number>/<path>")
(cherry picked from commit ffbf3fecdeffa17c0745e7ed342989acb620d68e)
2026-04-08 21:22:39 +03:00
Dag-Erling Smørgrav
4f13c347fb pkgbase: Move all of ATF into the atf package
Parts of ATF (including the licence and some of the documentation) were
for some reason part of the tests package instead of the atf package.
Moving them to where they logically belong poses no problem since tests
already depends on atf.

PR:		294129
MFC after:	1 week
Reviewed by:	ivy
Differential Revision:	https://reviews.freebsd.org/D56158

(cherry picked from commit 0a6dbf51d8ea112a1d164be260004ec795b4368d)
2026-04-07 15:52:08 +00:00
Konstantin Belousov
60b2eb959e rtld: check for overflow in parse_integer()
(cherry picked from commit 7cfffe25da3fbc2db4bcf073ff2d240f84233973)
2026-04-02 05:13:50 +03:00
Alex S
a91b307668 rtld: add a test for rtld_set_var (with LIBRARY_PATH_FDS)
PR:	294054

(cherry picked from commit 9f16078b5f8c44d5718ecc940ab0b4ed5a1877a5)
2026-04-02 05:13:50 +03:00
Konstantin Belousov
1e4debcf69 rtld: properly handle update of several vars in rtld_set_var()
(cherry picked from commit b9f046d941c4dbd0e4fc634827ada6e7cf6a6bcf)
2026-04-02 05:13:50 +03:00
Jonathan Matthews
3bfda6f6b8
nuageinit.7: fix cloud-config header line
This updates the nuageinit man page by aligning mentions of the
cloud-config header line with the cloud-init documentation[0], removing
an unwanted "!" character.

[0] https://docs.cloud-init.io/en/latest/explanation/about-cloud-config.html#how-do-i-create-a-cloud-config-file

Signed-off-by: Jonathan Matthews <freebsd@hello.jonathanmatthews.com>
Differential Revision:	https://reviews.freebsd.org/D53706
(cherry picked from commit 4ab2d625e1462e9a78cb8086906c1a3da3aa6713)
2026-03-20 12:32:57 -04:00
Christos Margiolis
63888350d5 rc: virtual_oss: Silence potential hw.snd.default_unit error
PR:		293582
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week

(cherry picked from commit e85f221def717660c9daf4c0616dfb9cdfb75827)
2026-03-13 12:49:23 +01:00
Navdeep Parhar
11e670ccf2 nuageinit.7: Fix a couple of minor errors
Use the correct key name in the chpasswd section.
Remove a stray line to fix the description of 'password'.

Sponsored by:	Chelsio Communications
Reviewed by:	maxim
Differential Revision:	https://reviews.freebsd.org/D55547

(cherry picked from commit df5014f71cff2c02f46afa8823370d7f61494bdb)
2026-03-07 17:50:18 -08:00
Quentin Thébault
960ef72179 virtual_oss: use hw.snd.default_unit by default
Reviewed by:	christos
MFC after:	1 week
Signed-off-by: 	Quentin Thébault <quentin.thebault@defenso.fr>
Sponsored by: 	Defenso
PR:		293130
Pull Request:	https://github.com/freebsd/freebsd-src/pull/2043
(cherry picked from commit 06b466526a7fc35cc6fc5bf6f6269e7f3a0a7aea)
2026-03-02 15:46:00 +01:00
Enji Cooper
3882602bac tftpd tests: clean trailing whitespace
No functional change intended.

MFC after:	1 week

(cherry picked from commit fd6217075e6a5926bdc627145b38194b6c5ba8da)
2026-02-21 19:37:16 -08:00
Sarah Walker
dd80750453 rtld-elf: Pass HWCAP flags to ifunc resolver functions
Function arguments are based on Section 9.4.1 "GNU C Library IFUNC interface"
from "System V ABI for the Arm 64-bit Architecture (AArch64)", 2025Q1.
(https://github.com/ARM-software/abi-aa/releases/download/2025Q1/sysvabi64.pdf)

Reviewed by:	kib, andrew
Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D54559

(cherry picked from commit a652357fb59f03bee85d61814002f9c60ea52340)
2026-02-09 14:50:03 +00:00
Baptiste Daroussin
cfd1ade5c7 nuageinit: support fetching configuration on multiple iface
On some environement a VM can be connected to multiple ifaces but only
one will respond to dhcp and able to fetch the metadata.

Launch the early dhclient on all available ifaces and as soon as one
dhcp has successfully configured an iface, proceed with fetching the
metadata.

MFC After:	1 week
Reported by:	mateusz.klejn@ovhcloud.com
Tested by:	mateusz.klejn@ovhcloud.com
Sponsored by:	OVHcloud

(cherry picked from commit 90a7728cd8905cd26b90d06f7873df8bad43ae9a)
2026-02-05 15:09:50 +01:00
Eric A. Borisch
33c49c35d0 Set virtual_oss_enable="NO" in /etc/defaults/rc.conf
This prevents 'service -e' from emitting (/var/log/messages):

/usr/sbin/service: WARNING: $virtual_oss_enable is not set properly - see rc.conf(5)

Pull Request:	https://github.com/freebsd/freebsd-src/pull/1987
Reviewed by:	christos
Signed-off-by:	eborisch@gmail.com
MFC after:	1 week

(cherry picked from commit 1b2d495a24c36d81b14178a2f898025946bff2d8)
2026-01-30 18:30:10 +02:00
Christos Margiolis
2bee4bb7f1 src.opts: Introduce MK_SOUND
PR:		291853
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Reviewed by:	zarychtam_plan-b.pwste.edu.pl, markj
Differential Revision:	https://reviews.freebsd.org/D54456

(cherry picked from commit f74f891581bc4df20431607de9b761107f6a0aa7)
(cherry picked from commit 37164224eefd11278b0203e1367e1d9d1454da3f)
(cherry picked from commit 241a43cf9da8933f500e7d0df7fff621fd52168c)
(cherry picked from commit cf34eb8264954a8fd1e92081bcf67719bddbc2aa)
(cherry picked from commit 466bad427d74e666e85445729b2e63b82e10d18f)
2026-01-21 18:06:42 +02:00
Gonéri Le Bouder
92a3d6c190 nuageinit: set the hostname when user-data is missing
This address the situation reported here
https://github.com/freebsd/freebsd-src/pull/1952#issuecomment-3720210259

The user-data file was missing and the `sethostname` function is never
called. This commit adjusts slightly the logic to avoid the `exit()` call
when the `user-data` file is missing.

MFC After:	1 week
Signed-off-by: Gonéri Le Bouder <goneri@lebouder.net>
Differential Revision:	https://github.com/freebsd/freebsd-src/pull/1953
(cherry picked from commit cae280931c9e1f072d8bf300c377ae120300b898)
2026-01-14 13:30:43 +01:00
Baptiste Daroussin
4039401974 nuageinit: fix test after recent behaviour change
with recent change nuageinit always create a "freebsd" user, if no
users are specified, which means we do need to get the rootdir in the
testsuite containing a group file otherwise pw complains and the tests
fails.

(cherry picked from commit 65e77d34fdff9065616cfaedef3ef53329cdad26)
2026-01-14 13:30:43 +01:00
Gonéri Le Bouder
9d2c4e83c9 nuageinit: only create the default user when needed
The "default" user should only be created when:

- the `users` key is missing
- or the `default` string is present in the `users` list

Since the `public_keys` is extracted from the meta-data, this patch has
to slightly adjust the way they are loaded.
The change simplify the logic around the default user SSH key injection.
Both `ssh_authorized_keys` and `public_keys` are handled at the same time.

MFC After:	1 week
Signed-off-by: Gonéri Le Bouder <goneri@lebouder.net>
Pull Request:	https://github.com/freebsd/freebsd-src/pull/1952
(cherry picked from commit cbc00fcc2b92e6e38b0a180261547b1a22b461bd)
2026-01-14 13:30:43 +01:00
Baptiste Daroussin
57a7fa9c92 nuageinit(7): pert mandoc linter
MFC After: 	1 week

(cherry picked from commit 9ea30bbb0e3c34b3ea369e217d930e2165610c0c)
2026-01-14 13:30:43 +01:00
Gonéri Le Bouder
4702a1166a nuageinit: config2_network support dns service cfg
This change enhances `config2_network()` to honor the DNS
configuration, when it's defined through the `services` section.

The `network_data.json` file can hold DNS configuration at two different
places:
- within a network configuration entry
- or `dns` entry in the `services` section, in this case the configuration is global.

An example of such configuration:

{"links": [{"id": "interface0", "type": "phy",
"ethernet_mac_address": "52:54:00:01:59:03"}], "networks": [{"id": "private-ipv4-0", "type": "ipv4", "link": "interface0",
"ip_address": "192.168.123.5", "netmask": "255.255.255.0", "routes": [{"network": "0.0.0.0", "netmask": "0.0.0.0", "gateway":
"192.168.123.1"}], "network_id": "9e5b1ed9-f5e6-4941-a90f-2e06bab858de", "dns_nameservers": ["192.168.123.1"], "services": [{"type":
 "dns", "address": "192.168.123.1"}]}], "services": [{"type": "dns", "address": "192.168.123.1"}]}

See: https://docs.openstack.org/nova/latest/user/metadata.html

MFC After: 	1 week
Signed-off-by: Gonéri Le Bouder <goneri@lebouder.net>
Pull Request: 	https://github.com/freebsd/freebsd-src/pull/1941
(cherry picked from commit 7af8b75201b7af353fa74c8feb937b52f5ccf9bb)
2026-01-14 13:30:43 +01:00
Gonéri Le Bouder
5ec4bf7781 nuageinit/man: clarify how to enable sudo and doas
Clarify that both `sudo` and `doas` are not part of the base system and
they need to be listed in the `packages` section if the user wants to
enable them.

MFC After: 	1 week
Signed-off-by: Gonéri Le Bouder <goneri@lebouder.net>
Pull Request:	https://github.com/freebsd/freebsd-src/pull/1944
(cherry picked from commit 402f1353707783e2adc8d0bff01faf557820f6f5)
2026-01-14 13:30:42 +01:00
Mark Johnston
7999ce0d29 rc.subr: Use the variable we defined to invoke setaudit(8)
Reported by:	gtetlow
Fixes:		39ee24182b92 ("rc.subr: Support setting the audit user when starting services")
MFC after:	1 week

(cherry picked from commit 9dda51f13cd85791c0f18782461219f5a88e2d67)
2025-12-29 14:31:31 +00:00
Dag-Erling Smørgrav
8959eda100 noshutdown: Fix startup order
This rc script exists solely to create a file, so have it explicitly
require FILESYSTEMS.  In its current form, it was as likely as not to
end up running before cleanvar, which would undo its work.

MFC after:	3 days
Fixes:		384d976725 ("rc.d: Add precious_machine rc.conf knob to create /var/run/noshutdown")
Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D54119

(cherry picked from commit e540e8b2c04f03b4210a3bf2f421c05b918d1b51)
2025-12-13 22:01:14 +00:00
Dag-Erling Smørgrav
ca876906cf cleanvar: Fix startup order
Instead of having FILESYSTEMS require cleanvar, which doesn't really
make semantic sense, say that cleanvar needs to run before FILESYSTEMS.

MFC after:	3 days
Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D54118

(cherry picked from commit 6ce227d6274869a95150746d2f2d8c8c5ed9a266)
2025-12-13 22:01:14 +00:00
Cy Schubert
d9b9de6608 rc.d/ipfilter: ipfilter must be enabled for options to take
ipfilter options are erased and reset to default when ipfilter is
disabled. This results in nullifying options from rc.conf that were
previously set.

8d6feaaaa2, which added this code, was incorrect as it was for a bug in
ipfilter 4.2.28 and no longer applies to ipfilter 5.1.2.

Fixes:		8d6feaaaa2

(cherry picked from commit cc1e4aae5a67a20f3c0fff13612364e6e4404f93)
2025-12-10 13:10:07 -08:00
Cy Schubert
f9a4a42eed rc.d/{ipfilter,ippool}: Fix typo in variable name
(cherry picked from commit f04b23ce3547c238dcd52d4fa1a7d401ad38d1b1)
2025-12-10 13:10:06 -08:00
Mark Johnston
7edef91176 rc.subr: Support setting the audit user when starting services
When an unprivileged user restarts a service using, e.g., sudo, the
service runs with the audit user ID set to that of the unprivileged
user.  This can have surprising effects: for instance, a user that
restarts a jail that is running sshd will end up with their UID attached
to all audit logs associated with users who log in via that sshd
instance.  (sshd will set the audit user, but this is disallowed in
jails by default.)

Add support for rc.conf directives which cause rc to override the audit
user.  Specifically, make <name>_audit_user=foo cause the audit user to
be set to "foo" for service <name>.  A plain audit_user=foo directive
causes all services to be started as foo.

Note, like other similar rc features, this feature is limited to rc
services which are run by executing a command.  Shell functions can't be
wrapped this way.

Reviewed by:	0mp
MFC after:	2 weeks
Sponsored by:	Modirum MDPay
Sponsored by:	Klara, Inc.
Differential Revision:	https://reviews.freebsd.org/D53747

(cherry picked from commit 39ee24182b92114d006abc2b8095334a1d8a083c)
2025-12-08 14:14:58 +00:00
Mark Johnston
e4e7b5840f rc.subr: Remove misguided cpuset usage
When running an rc command, if the target rc script defines
<command>_cmd, e.g., start_cmd=..., then the run_rc_command() executes
that instead of $command.  In general it's a shell function, and
"cpuset -l <n> <shell function>" doesn't work.

Moreover, it doesn't really make sense to run cpuset for anything other
than start_cmd.

Other optional isolation mechanisms (e.g., <name>_fib,
<name>_chroot) are only used when invoking $command directly as part of
the "start" command.  Make <name>_cpuset consistent with everything else
by removing these extraneous cpuset invocations.

Reviewed by:	0mp
MFC after:	2 weeks
Sponsored by:	Modirum MDPay
Sponsored by:	Klara, Inc.
Differential Revision:	https://reviews.freebsd.org/D53746

(cherry picked from commit 71f6592a01506899efd91306b6d8147f14a6b219)
2025-12-08 14:14:58 +00:00
Mark Johnston
cd0e5f95d0 rc.subr: Try to make svjc option handling a bit easier to read
Specifically, make this code fit in fewer columns:
- deindent cases to conform to the usual style,
- use a local variable to minimize duplication in each case.

No functional change intended.

Reviewed by:	0mp, netchild
MFC after:	2 weeks
Sponsored by:	Klara, Inc.
Sponsored by:	Modirum MDPay
Differential Revision:	https://reviews.freebsd.org/D53754

(cherry picked from commit 7861d051de2ea2f244bcf73111a04389dc5bcf51)
2025-12-08 14:14:57 +00:00
Dag-Erling Smørgrav
74b10f0b57 rtld-elf: Mark LD_SHOW_AUXV insecure
This prevents dumping the memory layout of setugid processes.

MFC after:	3 days
Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D54033

(cherry picked from commit 5242bcff202fa2a5a39895423c8d8c11c02ad76a)
2025-12-05 15:08:55 +00:00
Cy Schubert
d7129761f5 ipfilter: Load optionlist prior to ippool invocation
As a safety precaution df381bec2d2b limits ippool hash table size to 1K.
This causes any legitimely large hash table to fail to load. The
htable_size_max ipf tuneable adjusts this but the adjustment is made
in the ipfilter rc script, invoked after the ippool script (because it
depends on ippool). Let's load the ipfilter_optionlist in ippool as well.
ipfilter_optionlist load will also occur in the ipfilter rc script in case
the user uses ipfilter without ippool.

Fixes:		df381bec2d2b
(cherry picked from commit d5d005e9bf4933d5680dd0bb5d42bdf440122aa4)
2025-12-02 07:28:15 -08:00
Konstantin Belousov
b903f27e17 rtld: fix powerpc build
(cherry picked from commit 0628c252bd161ccdd1228a3b8aefeb471044ca04)
2025-11-28 02:44:15 +02:00