Commit Graph

3460 Commits

Author SHA1 Message Date
Christos Margiolis b2677d002e rc: virtual_oss: Handle absent pidfile properly
Instead of throwing errors from the programs that use it, print a
warning if the file does not exist.

Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Reviewed by:	0mp, jrm
Pull-Request:	https://ron-dev.freebsd.org/FreeBSD/src/pulls/33
2026-05-28 16:06:06 +02:00
Christos Margiolis 803f686938 rc: virtual_oss: Wait for process to exit
Sometimes virtual_oss processes do not exit immediatelly. If we do not
wait for the processes to fully exit before returning from
virtual_oss_stop(), then the service restart operation might call
virtual_oss_start() too early and fail, because it will think the
service wasn't stopped and is still running.

Reported by:	jrm
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Reviewed by:	0mp, jrm
Pull-Request:	https://ron-dev.freebsd.org/FreeBSD/src/pulls/33
2026-05-28 16:06:06 +02:00
Christos Margiolis a576e5140e rc: virtual_oss: Define some variables in rc.conf
They will now be part of /etc/defaults/rc.conf and be accessible by
sysrc(8).

Fixes:		70e27ecba5 ("virtual_oss: Introduce virtual_oss_default_control_device rc variable")
PR:		295560
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Reviewed by:	0mp, jrm
Pull-Reqeust:	https://ron-dev.freebsd.org/FreeBSD/src/pulls/33
2026-05-28 16:06:06 +02:00
Dag-Erling Smørgrav 05e8f2bf09 ttymsg: Overhaul
* Instead of an error string, return the usual 0 or -1 and let the caller
  figure out what, if anything, to tell the user.

* Avoid string manipulations by opening /dev first and using openat()
  with O_RESOLVE_BENEATH.

* Add a boolean argument which, if false, causes ttymsg() to return
  without sending the message if the tty's group-writable bit is not
  set.  This saves programs that respect this setting (like syslogd(8))
  from having to check before calling ttymsg().

* Update all callers.

The observable effect of this change is minimal except for slightly
different error messages when ttymsg() fails.  However, syslogd(8) will
no longer print spurious error messages on the console after trying and
failing to write a log message to an X11 session.

PR:		295171
MFC after:	1 week
Reviewed by:	jfree, markj
Differential Revision:	https://reviews.freebsd.org/D57018
2026-05-25 18:52:15 +02:00
Dag-Erling Smørgrav 76c3387024 tftpd: Simplify packet drop macro
The first argument is always the function name, for which we can simply
use __func__.  This leaves only the optional return value, so we can use
a single variadic macro instead of two nearly-identical copies.

MFC after:	1 week
Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D57076
2026-05-22 19:57:35 +02:00
Dag-Erling Smørgrav 9338937713 tftpd: Add missing bounds checks
In send_[rw]rq(), we were using strlcpy() to avoid overflowing our
packet buffer, then failing to check the result and blithely advancing
our pointer by the full length.

Luckily, this code is only ever used by tftp(1), not tftpd(8).

MFC after:	1 week
Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D57075
2026-05-22 19:57:31 +02:00
Christos Margiolis 8532b4a436 rc: virtual_oss: Create a loopback device in the default configuration
The loopback device allows us to record desktop sound by reading from
it, or even use it as an input device, for example during a call.

Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Reviewed by:	emaste
Pull-Request:	https://ron-dev.freebsd.org/FreeBSD/src/pulls/16
2026-05-21 19:37:34 +02:00
Simon J. Gerraty 701d7be6e4 Add test cases for safe_eval.sh
safe_set is the routine that does all the work.

In safe_set; if we replace one=`cmd arg` or two=$(cmd arg) add quotes
around the result eg. one="_cmd arg_"
Also lines containing `` or $() are too likely to result in syntax
errors, so just delete them.

Differential Revision:	https://reviews.freebsd.org/D56795
2026-05-18 10:51:18 -07:00
Baptiste Daroussin 8b70a203be 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)

MFC After: 1 day
2026-05-12 09:52:32 +02:00
Baptiste Daroussin 8b03193289 nuageinit: add update_sshd_config tests 2026-05-10 17:54:48 +02:00
Baptiste Daroussin 0f92bee2b3 nuageinit: add adddoas tests 2026-05-10 17:54:48 +02:00
Baptiste Daroussin a49b3b10aa nuageinit: add addsudo tests 2026-05-10 17:54:47 +02:00
Baptiste Daroussin 68fd0feacb nuageinit: add decode_base64 tests 2026-05-10 17:50:53 +02:00
Baptiste Daroussin 2a86992ab5 nuageninit: modify the test to show the issue fixed inc316ec259011
Ensure the script used is invalid when parsed by libyaml which
highlight the issue revealed in PR295062

while at here validate the mode of the file is properly changed

PR:		295062
MFC After:	1 day
2026-05-06 23:16:37 +02:00
Baptiste Daroussin c316ec2590 nuageinit: only parse user_data as yaml when necessary
This fixes a regression introduced in cae280931c which prevents
user_data as a shell script to be used

PR:		295062
Reported by:	Ross McKelvie <ross@exitzero.uk>
MFC After:	1 day
2026-05-06 22:20:45 +02:00
Lexi Winter c4b244af42 acpi: Remove userland bits on non-ACPI platforms
ACPI is only supported on amd64, arm64 and i386.  Don't install the
power_profile rc script or devd configuration on other platforms.

This avoids creating a useless FreeBSD-acpi package on those platforms.

MFC after:	2 weeks
Reviewed by:	imp
Sponsored by:	https://www.patreon.com/bsdivy
Differential Revision:	https://reviews.freebsd.org/D56650
2026-04-28 20:50:41 +01:00
Lexi Winter b7daab8be1 apm: Only install rc script on i386
The apm(8) rc script only works on i386, but it's installed on all
platforms.  Only install it on i386, which avoids creating a useless
FreeBSD-apm package on other platforms.

While here, build the acpi package on i386.

MFC after:	2 weeks
Reviewed by:	imp
Sponsored by:	https://www.patreon.com/bsdivy
Differential Revision:	https://reviews.freebsd.org/D56629
2026-04-26 17:47:27 +01:00
Simon J. Gerraty 566cc00581 safe_set treat ':' and '#' differently
Treat '#' as a comment anywhere,
but ':' only at start of line.
2026-04-22 09:37:35 -07:00
Simon J. Gerraty 69cc351c4c safe_set ignore leading white-space
Also treate ':' at the start of a line as for '#'
ie. a comment.
2026-04-22 09:15:13 -07:00
Konstantin Belousov 9b844b495e rtld: fix processing of preloaded z_initfirst objects
After we found some preloaded z_initfirst object, we must process till
the end of the preload list still, not stopping on the first found
object.

Reported by:	des
Reviewed by:	des, markj, siderop1@netapp.com
Fixes:	78aaab9f1c
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D56466
2026-04-20 20:25:20 +03:00
Jose Luis Duran 8e08080ee5 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
2026-04-17 13:55:16 +00:00
Christos Margiolis 70e27ecba5 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
2026-04-16 16:51:02 +02:00
Aotian Cao 47a9af4b39 rc.d/NETWORKING: remove the NETWORK alias
NETWORKING is the documented placeholder, while
/etc/rc.d/NETWORKING still provides the legacy alias
NETWORK.

The NETWORKING script was originally introduced to avoid
conflicts with NetBSD's lowercase network script on
case-insensitive file systems.  The NETWORK alias was
retained for compatibility with older scripts.

Following the discussion in PR 293652, remove the legacy
NETWORK alias from 16-CURRENT.  Keeping both names adds
more confusion than value now that NETWORKING is the
documented placeholder and current base system and ports
tree uses are already clean.

Add an UPDATING entry to note that local RC scripts using
REQUIRE: NETWORK should be migrated to REQUIRE: NETWORKING.

PR:		293652
Reviewed by:	michaelo, jlduran
Relnotes:	yes
Differential Revision:	https://reviews.freebsd.org/D56300
2026-04-15 11:06:32 +02:00
Simon J. Gerraty de9fe28ab8 Allow passing xtras to safe_set
This allows safe_set to be leveraged in other contexts
where additional chars like '*' or '!' or even '\[\]' need to
be preserved in the result.
2026-04-10 09:11:21 -07:00
Konstantin Belousov 72252591ac rtld: add test for dlopen("#dirfd/path")
Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	 https://reviews.freebsd.org/D56152
2026-04-02 05:41:56 +03:00
Konstantin Belousov ffbf3fecde rtld: allow dlopen("#<number>/<path>")
When a specially formatted path is passed to dlopen(), of the form
  #number/path
and the number is the valid dirfd file descriptor listed in the
LD_LIBRARY_FDS, interpret it as a relative path name against dirfd
number.

This complements the result returned from dladdr() for such objects
in dli_fname.

Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D56152
2026-04-02 05:41:55 +03:00
Konstantin Belousov 7cfffe25da rtld: check for overflow in parse_integer()
Reviewed by:	dim, emaste, markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D56151
2026-03-30 19:56:52 +03:00
Dag-Erling Smørgrav 0a6dbf51d8 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
2026-03-30 16:03:29 +02:00
Jose Luis Duran 4f0d0ed5cb libexec: Add pkg-serve directory
Add pkg-serve to the list of subdirectories in the Makefile.

Reviewed by:	bapt
Fixes:		b42e852e89 ("pkg-serve(8): serve pkg repositories over TCP via inetd (8)")
Differential Revision:	https://reviews.freebsd.org/D56009
2026-03-29 16:13:09 +00:00
Alex S 9f16078b5f rtld: add a test for rtld_set_var (with LIBRARY_PATH_FDS)
PR:	294054
Reviewed by:	kib
MFC after:	1 week
2026-03-27 01:41:23 +02:00
Konstantin Belousov b9f046d941 rtld: properly handle update of several vars in rtld_set_var()
Besides setting the value in the array of the values, rtld sometimes
needs to recalculate some internal control variable for the change to
take effect.  Allow the variable description to supply a method called
on the update.  Lock the function with the bind lock for safe operation.

Mark several variables as allowed for update, since the on_update method
is provided for them.  The list is LD_BIND_NOW, LD_BIND_NOT,
LD_LIBMAP_DISABLE, LD_LOADFLTR.

Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D56055
2026-03-27 01:41:23 +02:00
Baptiste Daroussin b42e852e89 pkg-serve(8): serve pkg repositories over TCP via inetd (8)
Reviewed by:	manu, bdrewery (previous version)
Differential Revision:	https://reviews.freebsd.org/D55895
2026-03-20 13:29:48 +01:00
Jessica Clarke c70f382a8b rtld-elf: Remove stray _exit prototype for aarch64
It's not clear why this is here. It's existed since the very first
version of rtld-elf for aarch64 but has never been used, and anything
actually using exit or _exit should be using rtld_libc.h's #define that
aliases them to __sys_exit.

Fixes:	047c6e3ae6 ("Add the arm64 code to the runtime linker. It's not able to be built as we still need libc_pic for a few things, but this is expected to be ready soon.")
2026-03-13 19:25:04 +00:00
Kyle Evans bc531a96c9 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
2026-03-09 16:39:10 -05:00
Samvel Khalatyan 895a97c875 rc.d/zfs: align zfs mount verbosity in host and jail environments
ZFS script runs different startup seqneces depending on where it runs:
on the host (`zfs_start_main()`) or in a jail (`zfs_start_jail()`):

- `zfs_start_main()` mounts ZFS datasets in verbose mode `zfs mount -va`
- `zfs_start_jail()` mounts ZFS datasets silently `zfs mount -a`.

This change aligns the verbose levels.

NO_ISSUE

Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/2030
2026-03-07 00:51:16 -07:00
Kalevi Kolttonen d7922c3d23 Fix debug.sh comment typo
Signed-off-by: Kalevi Kolttonen <kalevi@kolttonen.fi>
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/2012
2026-03-07 00:51:15 -07:00
Kalevi Kolttonen 3be98a0c86 Fix hooks.sh comment typo
Signed-off-by: Kalevi Kolttonen <kalevi@kolttonen.fi>
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/2013
2026-03-07 00:51:15 -07:00
Christos Margiolis e85f221def rc: virtual_oss: Silence potential hw.snd.default_unit error
PR:		293582
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2026-03-06 13:27:03 +01:00
Navdeep Parhar df5014f71c 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'.

MFC after:	1 week
Sponsored by:	Chelsio Communications
Reviewed by:	maxim
Differential Revision:	https://reviews.freebsd.org/D55547
2026-02-28 08:52:40 -08:00
Quentin Thébault 06b466526a 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
2026-02-23 13:33:33 +01:00
Artem Bunichev ab835b3707 debug.sh: Fix a typo
MFC after:		3 days
Reviewed by:		emaste, guest-seuros, sjg, ziaee
Differential Revision:	https://reviews.freebsd.org/D55416
2026-02-23 03:31:34 -05:00
Thibault Payet d3ed0e0ab0 rc.d: Convert more service to Use startmsg
Signed-off-by: Thibault Payet <contact@thibaultpayet.fr>
Reviewed by: imp,mhorne
Pull Request: https://github.com/freebsd/freebsd-src/pull/2001
2026-02-08 13:58:44 -07:00
Jesús Daniel Colmenares Oviedo 436af5715c flua: Fix SIGSEGV in lua_chown when uid/gid doesn't exist
When lua_chown is used to call chown(2) internally, it first resolves
the user and/or group by calling the getpwnam_r(3) and getgrnam_r(3)
functions, respectively. However, although it checks for errors, it does
not check when entries are not found (which is not an error), which
means that the buffer will be set to NULL, and since lua_chown attempts
to access the NULL structure, it will receive a SIGSEGV signal.

Reviewed by:			imp@
Approved by:			imp@
Differential Revision:		https://reviews.freebsd.org/D55172
2026-02-08 16:35:25 -04:00
Jessica Clarke 5beaa1ee75 Revert "Additional icache paranoia: non-PLT relocations can modify the text segment."
reloc_nonplt_object, and thus reloc_non_plt, only ever handles data
relocations, so this paranoia is completely unfounded and only has the
effect of significantly slowing down program startup for binaries with
large amounts of code, like Clang.

If this breaks any systems, that would likely be due to insufficient
flushing in the pmap implementation for executable mappings, as this
existing rtld behaviour would mask any such bugs.

This reverts commit 4b51c69976.

Reviewed by:	adrian
Differential Revision:	https://reviews.freebsd.org/D54221
2026-02-08 16:39:44 +00:00
Enji Cooper fd6217075e tftpd tests: clean trailing whitespace
No functional change intended.

MFC after:	1 week
2026-02-02 21:19:08 -08:00
Kyle Evans d3f21856aa 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
Differential Revision:	https://reviews.freebsd.org/D54995
2026-02-02 21:21:42 -06:00
Baptiste Daroussin 90a7728cd8 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
2026-01-29 11:03:06 +01:00
Eric A. Borisch 1b2d495a24 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
2026-01-29 09:33:59 +02:00
Kyle Evans b41b6fdb3a 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.

Fixes:	c2caf3b331 ("flua: lposix: add more useful functions [...]")
Reported by:	des
Reviewed by:	des
Sponsored by:	Klara, Inc.
Sponsored by:	NetApp, Inc.
2026-01-28 09:43:14 -06:00
John Baldwin 6d6bf4a892 rtld: Use a helper variable to simplify a few lines
Reviewed by:	kib
Sponsored by:	AFRL, DARPA
Differential Revision:	https://reviews.freebsd.org/D54507
2026-01-15 13:23:42 -05:00