Commit graph

415 commits

Author SHA1 Message Date
Eugene Grosbein
24e8ed535f network.subr: correct return code in case of bad call to ifisup()
This is rather cosmetic correction.

PR:		287872
MFC-after:	2 weeks
X-MFC-With:	6d3bc576ab
2025-07-01 21:33:19 +07:00
Eugene Grosbein
6d3bc576ab libexec/rc: improve performance of pccard_ether script
Replace "ifconfig -ul" with "ifconfig -n" because netlink-enabled
/sbin/ifconfig utility has sub-optimal performance for listing.

Combined with the commit b1b17432aa,
these changes mostly eliminate performance regression of the command
"service devd start" for a system having hundreds of network interfaces
created before devd starts, after FreeBSD 14+ switched
/sbin/ifconfig to netlink(4)

PR:		287872
MFC-after:	2 weeks
2025-07-01 21:13:10 +07:00
Mark Johnston
9c014cc25c Revert "rc: Disable pathname expansion when calling run_rc_command()"
At least nuageinit is broken after this commit, breaking some downstream
CI systems.  It also disables globbing for rc.local scripts, which is
likely to break users in surprising ways.

This reverts commit 4deb9760a9.
2025-06-27 20:18:36 +00:00
Mark Johnston
d783591a7d Revert "rc: Fix scripts that need pathname expansion"
The commit which motivated this is being reverted.

This reverts commit 7faddeb395.
2025-06-27 20:18:24 +00:00
Sebastien Baylocq
7ad574b3e3 nuageinit: fix log name 2025-06-27 16:35:55 +02:00
Sebastien Baylocq
dba00b1c6b nuageinit: launch post network script with postnet citype
Sponsored by:	OVHCloud
2025-06-26 09:26:11 +02:00
Cy Schubert
abd3c20a03 mountcritlocal: Check only first byte for comment
Check for a "#" at the start of the line regardless whether it is its
own token or not. We avoid unecessary calls to rc.d/zpool.

Suggested by:	ivy
Fixes:		b6e33f0cd5
2025-06-17 12:59:36 -07:00
Baptiste Daroussin
2a05d577ab nuageinit: add a post network script
refactor nuageinit to allow a 3rd execution point during boot:
1. nuageinit is invoked before NETWORKING with a minimalistic network setup
   for openstrack and potentially other network config setup. it tries
   to configure everything which is not requiring any network.
2. nuageinit is invoked again post NETWORKING but pre SERVERS, in the
   phase it does all that requires network, like dealing with packages.
   Note that creating users have been moved to this phase to allow the
   installation of shells like bash or zsh prior the creation of the
   users, before that the user creation was failing if a non installed
   shell was requested.
3. nuageinit will execute at the rc.local time all the specified scripts
   and commands.

MFC After: 1 week
2025-06-16 10:29:19 +02:00
Cy Schubert
4103f8dd57 rc.d: Add MIT KRB5 krb5kdc support
MIT KRB5 krb5kdc differs from the Heimdal kdc.

- The MIT kdc is named krb5kdc while the Heimdal one is named kdc.
- krb5kdc -d flag has a different meaning. krb5kdc -d specifies a
  database name. While the Heimdal kdc uses the -d flag to daemonize
  it. krb5kdc automaticially daemonizes itself unless the -n flag is
  specified.

We do this by looking at the name of the kdc program to determine if
we assume it's a Heimdal kdc or the MIT krb5kdc.

Sponsored by:		The FreeBSD Foundation
Differential revision:	https://reviews.freebsd.org/D50813
2025-06-15 19:49:37 -07:00
Cy Schubert
b6e33f0cd5 rc.d/mountcritlocal: Make sure zpools are imported for legacy ZFS
Legacy ZFS uses fstab to mount its datasets. In an attempt to fix
another problem 900bc02063 broke legacy ZFS in fstab(5). This
comit works around the problem by mountcritlocal scanning /etc/fstab
for zfs mountpoint and if any are found invoke /etc/rc.d/zpool start.

Reviewed by:		imp
Differential Revision:	https://reviews.freebsd.org/D50844
2025-06-14 21:39:36 -07:00
Hiroki Sato
7faddeb395
rc: Fix scripts that need pathname expansion
Reported by:	Kenneth Raplee
Differential Revision:	https://reviews.freebsd.org/D45855
2025-06-15 05:24:41 +09:00
Siva Mahadevan
900bc02063 rc.d/zpool: change mountcritlocal dep from BEFORE to REQUIRE
In cases where the `/boot` directory is mounted from a different disk,
`/boot/zfs/zpool.cache` will not be found during a `rc.d/zpool`
run. This is because `/etc/fstab` mounts are mounted in
`rc.d/mountcritlocal`, which currently runs AFTER (i.e. `REQUIRE:`)
`rc.d/zpool`.

This change swaps the `rcorder` of `rc.d/zpool`'s dependency on
`mountcritlocal` from `BEFORE:` to `REQUIRE:`. This will ensure that
`/boot` (or even `/etc/` in some configurations) to be visible while
searching for `zpool.cache`.

Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/1614
Closes: https://github.com/freebsd/freebsd-src/pull/1614
2025-06-13 09:47:25 -06:00
Baptiste Daroussin
cae3d6c8d4 nuageinit: fix typo
PR:	287503
Reported by:	crest@rlwinm.de
2025-06-13 17:33:53 +02:00
Hiroki Sato
4deb9760a9
rc: Disable pathname expansion when calling run_rc_command()
Variables for command-line options like $foo_flags can contain characters
that perform pathname expansions, such as '[', ']', and '*'.  They were
passed without escaping, and the matched entries in the working directory
affected the command-line options.  This change turns off the expansion
when run_rc_command() is called.

While this changes the current behavior, an invocation of a service
program should not depend on entries in the working directory.

Differential Revision:	https://reviews.freebsd.org/D45855
2025-06-13 03:19:32 +09:00
Baptiste Daroussin
8feca60d6e nuageinit: runcmd should also be executed late
Execute the runcmd specified in cloudinit at the same moment as the
user_data script aka late in the boot process, to respect cloudinit
specifications
2025-06-10 11:28:49 +02:00
Baptiste Daroussin
09545628f0 nuageinit: fix using user_data as a script
In official cloudinit, when a user_data file starts with '#!' it
should be execute late in the boot process. To respect this nuageinit
now copy the user_data script into a /var/cache/nuageinit/user_data if
found and a new "firsboot" rcscript anchored to the 'local' rc script is
responsible to execute it if found.

Note by doing this, we fix another issue we had with nuageinit, if the
cloudinit provider provides the user_data scriptout with the executable
permission, previous implementation was not working, like apparently
what Digital Ocean is doing.

PR:		287183
Reported by:	olgeni@
2025-06-10 09:20:23 +02:00
Baptiste Daroussin
9a62e1d98d nuageinit: log nuageinit execution
Sponsored by:	OVHCloud
2025-06-06 13:07:32 +02:00
Lexi Winter
08419bf194 don't gate ctl{d,adm} behind MK_ISCSI
These are no longer specific to iSCSI; always build them.

Reviewed by:	kevans, jhb
Approved by:	kevans (mentor)
Differential Revision:	https://reviews.freebsd.org/D50625
2025-06-01 03:08:40 +01:00
Lexi Winter
06c41801af svcj: correctly handle kernels without INET or INET6
If either INET or INET6 is not enabled in the kernel, then the jail(8)
options ip4=<new|inherit> resp. ip6=<new|inherit> are not available.
Detect this case and don't try to provide those options, otherwise
svcjs will not start.

Do this automatically (without a warning) so that net_basic, which
includes both netv4 and netv6, continues to work as expected.

If _svcj_ipaddrs is explicitly configured with an address for an IP
version not supported by the kernel, issue a warning but continue to
start the service.  This can result in the service being started with
fewer addresses than expected, but never more.

Reviewed by:	netchild, des
Approved by:	des (mentor)
Differential Revision:	https://reviews.freebsd.org/D49976
2025-05-28 02:16:30 +01:00
Lexi Winter
76a612526c packages: move ctl{d,stat,adm} to the ctl package
This leaves the iscsi package for the iSCSI initiator, and the new
package provides the CAM target layer (including the iSCSI target).

Reviewed by:	manu, des, jhb
Approved by:	des (mentor)
Differential Revision:	https://reviews.freebsd.org/D50287
2025-05-28 02:16:29 +01:00
Simon J. Gerraty
b0ada425ef safe_eval allow : and + in values 2025-05-25 20:06:47 -07:00
Lexi Winter
9a79f1b8c3 Remove vestiges of keyserv(8)
This daemon has been removed; also remove things which reference it.

Reviewed by:	manu, des, emaste
Approved by:	des (mentor)
Differential Revision:	https://reviews.freebsd.org/D50441
2025-05-23 22:59:33 +01:00
Lexi Winter
f6328f0525 rc.subr: remove the dependency on bsdconfig
rc.subr uses sysrc(8) for the 'enable' and 'disable' commands, which
means the entire rc(8) stack depends on bsdconfig.  Instead, provide a
minimal amount of rc.conf-editing functionality in rc.subr and use it to
implement these commands.

Reviewed by:	des, bapt
Approved by:	des (mentor)
Differential Revision:	https://reviews.freebsd.org/D50325
2025-05-15 01:02:52 +01:00
Lexi Winter
0268d03ba1 svcj: add "routing" option
"routing" enables the jail allow.routing permission, which allows the jail to
modify the system routing table.  this can be used to run routing daemons
(e.g., BIRD) in a service jail.

Reviewed by:	jamie, des
Approved by:	des (mentor)
Differential Revision:	https://reviews.freebsd.org/D49844
2025-05-12 23:25:45 +01:00
Olivier Certner
6463754087
rc/tests: Fix process flags checks using ps(1)
These checks use ps(1) with both the '-p' and '-a' flags, which worked
so far as ps(1)'s '-a' option was buggy.  Since the fix in commit
"ps(1): Make '-a' and '-A' always show all processes"
(93a94ce731), such a command-line always selects all processes,
making the specified '-p' useless and the test wrong.  Remove the
useless '-a'.

While here, remove the redundant '-x', as '-p' implies '-x' by default.

MFC after:      1 day
Sponsored by:   The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D50201
2025-05-07 11:14:55 +02:00
Lexi Winter
fd03d573cb mountd, showmount: move to the nfs package
while here, alphabetise ${NFS}.

Reviewed by:	des, emaste, rmacklem
Approved by:	des (mentor)
Differential Revision:	https://reviews.freebsd.org/D50169
2025-05-05 23:14:47 +01:00
Konstantin Belousov
384d976725 rc.d: Add precious_machine rc.conf knob to create /var/run/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:05:03 +03:00
Lexi Winter
89aa99816e rpc.statd: move to nfs package
rpc.statd is not technically specific to NFS, but NFS is the only thing
which has ever actually used it, so this is the most appropriate place
to put it.

Reviewed by:	rmacklem, des, bapt, emaste
Approved by:	des (mentor)
Differential Revision:	https://reviews.freebsd.org/D50162
2025-05-05 16:39:25 +01:00
Lexi Winter
f91d251b39 rc.d: move some rc scripts to their packages
several rc.d scripts are installed by the FreeBSD-rc package, but they
don't work without their respective packages installed.  move these rc
scripts into the appropriate packages so they're installed along with
the services they start.

this should be undisruptive to users since the scripts don't work
without those packages installed anyway.  (for this reason, do not move
the Kerberos scripts, because the MIT Kerberos port uses the base rc.d
scripts.)

PR:	282324
Reviewed by:	manu, des, bapt
Approved by:	des (mentor)
Differential Revision:	https://reviews.freebsd.org/D50137
2025-05-05 16:39:25 +01:00
Lexi Winter
1271b1d747 rc.d: remove obsolete /etc/rc.d/keyserv
the keyserv daemon was removed in 9dcb984251.  also remove its rc
script.

Reviewed by:	kevans, adrian, emaste
Approved by:	kevans (mentor)
Fixes: 9dcb984251 ("Remove publickey(5) stuff")
Differential Revision:	https://reviews.freebsd.org/D50135
2025-05-03 16:44:03 +01:00
Lexi Winter
3a0eb29316 rc.subr: add 'settime' to svcj options
<svc>_svcj_options="settime" enables the jail allow.settime privilege,
which allows to set and slew the system clock.  this allows NTP daemons
to run in a service jail.

Reviewed by:	jamie, kevans, des, #jails, #manpages
Approved by:	kevans (mentor)
Differential Revision:	https://reviews.freebsd.org/D49845
2025-04-21 01:38:29 +01:00
Jose Luis Duran
44b69b1a96
sshd: Retire DSA support
Chase 3dcf2c2caf ("OpenSSH: remove ability to enable DSA support (in
configure)").

Reviewed by:	emaste
Approved by:	emaste (mentor)
Differential Revision:	https://reviews.freebsd.org/D49740
2025-04-17 19:11:46 +00:00
Lexi Winter
6fbd1bed6e
rc.subr: add ${svc}_svcj_ipaddrs option
setting ${svc}_svcj_ipaddrs to a list of IP addresses causes rc.subr to
set ip6.addr and/or ip4.addr when starting the jail, restricting it to
those IP addresses rather than inheriting all IP addresses.

for example:

inetd_enable=YES
inetd_svcj=YES
inetd_svcj_options="net_basic"
inetd_svcj_ipaddrs="::1 127.0.0.1 2001:db8::1"

if not specified, the default value is unchanged (inherit all addresses
if networking is enabled).

Reviewed by:	netchild
2025-04-14 15:11:06 +02:00
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
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
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
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
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
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
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
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
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