Commit Graph

332 Commits

Author SHA1 Message Date
Eugene Grosbein
af1b0aa5b9 rc.subr: improve description for ${name}_offcmd
Clarify that ${name}_offcmd is for method start.

MFC after:	3 days
2024-06-18 16:13:51 +07:00
Alexander Leidinger
2d08f6b577 rc.subr: add some sanity checks for service jails
Add some sanity checks when service jails are used in jails:
 - children.max > 0
 - children.max - children.cur > 0

The nesting is too deep at those places to have a sane formatting, so no
line wrapping at the usual column.
If someone has a better idea how to format this: feel free to go ahead.
2024-06-14 20:15:46 +02:00
Alexander Leidinger
a70ecfb117 rc.subr: add new sysv option for service jails
Clarify that the "sysvipc" svcj option inherits from the host / parent.
Add "sysvipcnew" which creates a new SysV namespace for the service
jail.
Sanity check that only one of them is used.
2024-06-14 20:15:45 +02:00
Eugene Grosbein
c2db3a0c7d rc.subr(8): fix debugging message after previous commit
Fixes:		32a579e4fc
2024-06-03 02:41:10 +07:00
Eugene Grosbein
32a579e4fc rc.subr(8): introduce ${name}_offcmd
New variable ${name}_offcmd may be used to supply commands
executed if named service is not enabled. Previously start_precmd
could be used for such a task but now rc.subr(8) does not call it
if a service is not enabled.

Fix devd startup script to use it instead of start_precmd.

PR:		279198
MFC after:	2 weeks
Reported by:	Dmitry S. Lukhtionov
Tested by:	Dmitry S. Lukhtionov
2024-06-03 02:29:22 +07:00
Alex Samorukov
f13275cf03 export $autoboot var when running from $boottrace_cmd
At the moment, if bootrace profiling is enabled, autoboot is not
exported to the rc scripts. This causes fsck to not check the root
filesystem.  To fix this, pass _boot, rc_fast and autoboot to the
boottrace process to mimic what diretly sourcing the rc.d scripts.

PR: 278993
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/1261
2024-05-29 13:29:53 -06:00
Franco Fichtner
11333dd580 rc: improve NAME_setup handling
Reload is used for service reconfiguration as well
and lacks a NAME_prepend-like mechanism so it makes
sense to extend the NAME_reload hook into this
action.

precmd may use configuration checks and blocks setup
from doing its designated work (e.g. nginx).  In moving
the invoke of the setup script in front allows us to
provide custom scripts for config file generation and
fixing prior to precmd checking configuration integrity.

Also introduce _run_rc_setup to separate the launcher
from the main one.  Let it run correctly in the case
of restart_precmd and block further execution as
would be the case in start due to the internal plumbing
of restart being split into calling stop and start
afterwards.

Differential-Revsiion: https://reviews.freebsd.org/D36259
Signed-off-by: Franco Fichtner <franco@opnsense.org>
Reviewed by: imp, oshogbo
Pull Request: https://github.com/freebsd/freebsd-src/pull/1258
2024-05-29 11:23:46 -06:00
Alexander Leidinger
f99f0ee14e rc.d: add a service jails config to all base system services
This gives more permissions to services (e.g. network access to
services which require this) when they are started as an automatic
service jail.

The sshd patch is important for the sshd-related functionality as
described in the man-page in the service jails part.

The location of the added env vars is supposed to allow overriding them
in rc.conf, and to hard-disable the use of svcj for some parts where it
doesn't make sense or will not work.

Only a subset of all of the services are fully tested (I'm running this
since more than a year with various services started as service jails).
The untested parts should be most of the time ok, in some edge-cases
more permissions are needed inside the service jail.
Differential Revision:	https://reviews.freebsd.org/D40371
2024-05-22 15:41:49 +02:00
Alexander Leidinger
2efbd480f1 rc: add service jails framework
This takes a rc.d-service and starts it in a jail which shares the same
root-path as the host (or parent jail) and may inherit the network from
the host (or parent jail). Per service there is the possibility to
specify some arguments which give more permissions (e.g. netv4, netv6,
sysvipc...).
Reviewed by:	bcr (man page)
Relnotes:	yes
Differential Revision:	https://reviews.freebsd.org/D40370
2024-05-22 15:41:48 +02:00
Simon J. Gerraty
dc501a9ec0 Allow DEBUG_SH=rc:all to debug all rc.d
Usually a bad idea but there are exceptions to every rule.
Allso debugging all rc.d scripts or all with a given arg.
2024-05-21 19:44:20 -07:00
Baptiste Daroussin
5681636ead nuageinit: by default to not enable nuageinit
MFC After:	1 day
Reported by:	karels@
2024-05-14 14:16:45 +02:00
Isaac Cilia Attard
6437872c1d New sysctl to disable NOMATCH until devmatch runs
Introduce hw.bus.devctl_nomatch_enabled and use it to suppress NOMATCH
until devmatch runs

There's a lot of NOMATCH events generated at boot. We also run devmatch
once during early boot to load unmatched devices. To avoid redundant
work, don't start generating NOMATCH events until after devmatch runs.
Set hw.bus.devctl_nomatch_enabled=1 just before we run devmatch. The
kernel will suppress NOMATCH events until this is set to true.

This saves about 170ms from the boot on aarch64 running atop Apple
M-series processors and the VMWare Fusion hypervisor.

Reviewed by:    imp, cperciva
MFC after:      3 days
Sponsored by:   Google Summer of Code
Pull Request:   https://github.com/freebsd/freebsd-src/pull/1213
2024-05-09 17:56:40 -07:00
Poul-Henning Kamp
66bee50af7 Remove cross-references to GBDE 2024-05-07 07:35:33 +00:00
Poul-Henning Kamp
bbc36ba969 Remove documentation of GBDE rc support 2024-05-07 07:25:51 +00:00
Poul-Henning Kamp
0c7237d7e2 Remove GBDE rc support 2024-05-07 07:23:03 +00:00
Lexi Winter
2f9966ff63 packages: add package for NTP
Reviewed by: imp, manu
Pull Request: https://github.com/freebsd/freebsd-src/pull/1193
2024-05-04 07:41:54 -06:00
Lexi Winter
1b3c07bed6 package: move OpenBSM auditing into its own package
Move auditing runtime (auditd, etc.) into the new FreeBSD-audit package.
Also move the runtime OpenBSM manual pages from libbsm into auditd so
they get installed with the right package.

Add an UPDATING entry noting the new packages.

Reviewed by: imp, manu
Pull Request: https://github.com/freebsd/freebsd-src/pull/1197
2024-04-28 22:33:06 -06:00
Cy Schubert
9e248b7f64 kdc: Add restart option
Add a new kdc_restart rc variable that manages kdc (or krb5kdc) under
daemon(8). This automatically restarts the kdc should it fail, i.e.
when it's configured to use LDAP as a backend and cannot connect to its
LDAP directory.

Set kdc_restart="YES" to auto restart kdc on abnormal termination.

Set kdc_restart_delay="N" to the number of seconds to delay before
restarting the kdc. The daemon(8) default seconds applies when not set.

Reported by:		Lexi Winter <lexi.freebsd@le-fay.org>
PR:			278395
Differential Revision:	https://reviews.freebsd.org/D44898
2024-04-23 22:50:38 -07:00
Mark Johnston
6d5ce2bb63 nfsserver: Default to nfs_reserved_port_only="YES"
This setting causes the NFS server to check that all RPCs are sent from
a privileged (<= 1023) port, rejecting those that are not.  This
slightly raises the bar for a user with network access to an
unauthenticated NFS server to access exported NFS filesystems.

Users that use traditional NFS clients (e.g., those provided by FreeBSD
or Linux) should not see any difference, assuming that unprivileged
filesystem mounting is disallowed.

Note that the setting is per-VNET, so may be overridden in VNET jails
without affecting the rest of the system.

Discussed with:	freebsd-arch@
Reviewed by:	rmacklem, bz, emaste
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D44906
2024-04-23 12:54:46 -04:00
Lexi Winter
7209444a80 package: move cron into its own package
Reviewed by: imp, manu, Mina Galic
Pull Request: https://github.com/freebsd/freebsd-src/pull/1172
2024-04-22 22:36:35 -06:00
Lexi Winter
dbd0366f34 package: move lpr into its own package
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/1171
2024-04-19 16:54:31 -06:00
Baptiste Daroussin
b6a4776008 nuageinit: start the script after zfs
It prevents the home directory for the new users to be hidden
by late mount of the home directory
2024-04-17 16:25:02 +02:00
John Baldwin
4bf5db113f defaults/rc.conf: Remove /usr/lib32 from ldconfig32_paths
Commit 99132daf6f prepends /usr/lib32 to
the list of paths in ldconfig32_paths since it is a standard library
path in ld-elf32.so.1.  Remove /usr/lib32 from the value in rc.conf so
that it is not listed twice.

Reviewed by:	olce, kib
Sponsored by:	University of Cambridge, Google, Inc.
Differential Revision:	https://reviews.freebsd.org/D44752
2024-04-12 14:35:23 -07:00
Konrad Witaszczyk
e6e38bc522 rc.d/ldconfig: Compute ldconfig paths in a function
Move logic that computes paths passed to ldconfig(8) to a
ldconfig_paths() function that can be called for multiple ABIs.

Reviewed by:	olce, kib
Obtained from:	CheriBSD
Differential Revision:	https://reviews.freebsd.org/D44751
2024-04-12 14:34:59 -07:00
Jose Luis Duran
bb4116576f rc.initdiskless: Disable soft-updates in mdmfs (again)
Re-apply the -S switch to disable soft-updates in memory disks (commit
8b1292ac52). This might be beneficial when tmpfs(5) is not present in
the kernel, as this can cause mdmfs(8)'s auto keyword to fallback to
using md(4).

PR:		85558
MFC after:	1 week
Reviewed by:	imp, emaste, brooks
Differential Revision:	https://reviews.freebsd.org/D43242
2024-03-20 00:54:18 -04:00
Baptiste Daroussin
9eae9233fd nuageinit: be case insentive when looking got labels
Reported by:	Marek Zarychta <zarychtam@plan-b.pwste.edu.pl>
2024-03-15 15:15:03 +01:00
Baptiste Daroussin
a42d6f7601 nuageinit: add basic support for cloudinit.
this is a very early script to support cloudinit, it does not intend to
be a full featured cloudinit client, but will support a good enough
subset to be viable in most case.

It support nocloud and openstack config-2 config drive mode (iso9660 or
msdosfs)

The following features are currently supported:
- adding users (including a default user named 'freebsd' with password
  'freebsd'
- adding groups
- adding ssh keys
- static ipv4, static ipv6, dynamic ipv4

With this one is able to use the 'bring your own image feature" out of
box.

It is expected that the script grows the support of other clouds
supporting cloud-init, contributions are welcomed.

It is designed to be only run once via the firstboot mecanism.

Sponsored by:	OVHCloud
MFC After:	3 weeks
Differential Revision:	https://reviews.freebsd.org/D44141
2024-03-15 09:22:16 +01:00
Emmanuel Vadot
72b045386d rc: Set var_run_enable to enable by default
This will load/save the /var/run directories at boot/shutdown if
and only if /var/run/ is a tmpfs mount so it is a win for tmpfs
users and a no-op for everyone else.

Reviewed by:	bapt
Differential Revision:	https://reviews.freebsd.org/D44097
Sponsored by:	Beckhoff Automation GmbH & Co. KG
2024-02-28 08:17:58 +01:00
Robert Wing
c7d5cc6f5e Revert "rc.d/mountlate: discard output from nextboot"
This reverts commit 4cea0cbcc9.

Requested by:   imp
2024-02-20 21:04:15 -09:00
Robert Wing
4cea0cbcc9 rc.d/mountlate: discard output from nextboot
silent the warning seen at boot:

    Mounting late filesystems:.
    nextboot: unlink /boot/nextboot.conf: No such file or directory

    Sun Feb 18 23:31:52 AKST 2024

    FreeBSD/amd64 (main) (ttyv0)

    login:

Differential Revision:	https://reviews.freebsd.org/D43979
2024-02-20 20:50:43 -09:00
Simon J. Gerraty
b75bb99621 rc.subr add Exists so we can find sed
SED=`Exists -x /usr/bin/sed /rescue/sed`

avoids adding /rescure to $PATH, and allows use of sed
before /usr is mounted (if a separate filesystem).

Reviewed by:	jlduran_gmail.com
Differential Revision:	https://reviews.freebsd.org/D43826
2024-02-12 14:39:20 -08:00
Simon J. Gerraty
15483f9620 rc.subr avoid noise if /usr not mounted
basename, sed and tty are all in /usr/bin and not available
until /usr is mounted.

basename and tty we can replace with a function, but sed is more
important.  Fix o_verify to just use shell builtins, and
rc_trace should avoid trying to set RC_LEVEL until sed is available.
2024-02-10 10:14:23 -08:00
Simon J. Gerraty
aa3b7a2fbc /etc/rc add trace debug and verify
Debugging boot issues can be helped by
logging each rc.d script as it is run
and being able to selectively enable/disable set -x
debug.sh provides an elaborate framework for debugging shell scripts.

For secure systems, we want to be paranoid about what we read
during boot.

dot()	simply reads (.) arg file if it exists
vdot()	if mac_veriexec is active, ignore unverified files
	otherwise behaves much the same as dot()
safe_dot()  in safe_eval.sh allows reading an untrusted file;
	limiting the input to simple variable assignments.

In load_rc_config allow caller to provide an option to indicate how to
handle its arg:
	-v use vdot()
	-s use sdot() which will try to use vdot() and fallback to safe_dot()
	The default is to read using dot()

rc_run_scripts()
	encapsulate the running of rc.d scripts
	so that we can easily call it more than twice.

We vdot local.rc.subr to pick up extensions (like
run_rc_scripts_final) and overrides.

We also allow rc.subr.local or rc.conf to set rc_config_xtra
eg (rc_config_xtra=XXX for historic compatibility)

rc use set -o verify around the reading in of rc.subr
This has no effect if mac_veriexec is not active, but if it is; ensures
rc.subr has not been tampered with.

Reviewed by:	imp
Sponsored by:	Juniper Networks, Inc.
Differential Revision:	https://reviews.freebsd.org/D43671
2024-02-09 09:15:58 -08:00
Warner Losh
11da791920 leapseconds: Update to the canonical place.
IERS is the source of truth for leap seconds. Their leapsecond file is
updated most quickly and is always right (unlike the IANA one which
often lags). IERS operates this public service for the express purpose
of random people downloading it. Their terms of service are compatible
with open source (we could include this in our release). Rather than
fighting with questions around this because the IANA one changed
locations or the auto update script broken, just use this.

This is in preference to the NIST ftp copy. NIST is in the process of
retiring their FTP services.

Sponsored by:		Netflix
Reviewed by:		philip, delphij, cy
Differential Revision:	https://reviews.freebsd.org/D43752
2024-02-06 16:12:59 -07:00
Cy Schubert
91f78c32be rc.d/kdc: Support start of MIT krb5kdc
Some users wishing to use the MIT krb5kdc have discovered the
kdc script workaround applied to the MIT krb5 ports is insufficient.
Let's build into this rc script the smarts to determine whether
base or ports Hiemdal kdc is being invoked or the MIT krb5kdc.

While at it, remove kdc_start_precmd(). This will simplify a future
jail patch.

Suggested by:		netchild
Original patch:		netchild
Reviewed by:		emaste, netchild
MFC after:		1 week
Differential Revision:	https://reviews.freebsd.org/D43523
2024-01-21 16:06:26 -08:00
Alexander Leidinger
0b49e504a3 rc.d/jail: add legacy compatibility for zfs.dataset
Evaluate the jail_${jailname}_zfs_dataset variable for legacy
jail managers.

This variable can take a space separated list of datasets.
The singular was used specially to allow unmaintained jail
managers like ezjail to use this (simply rename
jail_${jailname}_zfs_datasets in the ezjail config to
jail_${jailname}_zfs_dataset).
2024-01-17 13:38:00 +01:00
Mark Johnston
1809089a96 rc.d: Process autobridge_* in vnet jails
Reviewed by:	kp
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D43316
2024-01-04 13:57:05 -05:00
Jose Luis Duran
a04ca1c229 rc.initdiskless: Remove bogus plus sign
Reviewed by:	imp, dab
Fixes:		Fixes: 93b7818226 ("libexec/rc/rc.initdiskless: make tar's path flexible")
Differential Revision:	https://reviews.freebsd.org/D43241
2023-12-31 13:39:37 -05:00
Cheng Cui
93b7818226
libexec/rc/rc.initdiskless: make tar's path flexible
Summary:
PR:		274977
Reviewed by: rgrimes,imp
Approved by: rgrimes
MFC after:      1 month
2023-12-15 03:46:44 -05:00
Philip Paeps
b1c95af454 rc.conf: correct $ntp_leapfile_sources
IETF is no longer serving leap-seconds.list.  Point at IANA instead.

This fixes "service ntpd fetch".

MFC after:	1 day
2023-12-07 13:48:13 +08:00
Warner Losh
43581d7b66 libexec: Remove ancient SCCS tags.
Remove ancient SCCS tags from the tree, automated scripting, with two
minor fixup to keep things compiling. All the common forms in the tree
were removed with a perl script.

Sponsored by:		Netflix
2023-11-26 22:23:28 -07:00
Cy Schubert
ac910ad995 rc.d/ldconfig: Remove stray ;;
Stray ";;" causes the ldconfig rc script to fail at boot. Remove it.

Fixes:		73902ed85a
2023-11-24 12:11:45 -08:00
Konstantin Belousov
73902ed85a ldconfig: only configure compat32 when kernel supports it
and eliminate hard-coded arch list.

Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D42669
2023-11-24 18:38:42 +02:00
Konstantin Belousov
806e4e3273 ldconfig: filter out non-existing directories from default path
This is done only for ld-elf32.so.1, where /lib32 is kept in the path
due to the way STANDARD_LIBRARY_PATH is defined in rtld_paths.h.

This change fixes innocent warning appearing after
99132daf6f

Reviewed by:	dim, emaste
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D42626
2023-11-20 13:26:00 +02:00
Jens Schweikhardt
f06fda7ff1 Spaces to tabs for consistency. No content change. 2023-11-18 16:05:22 +01:00
John W. O'Brien
99132daf6f rc.d/ldconfig: Prepend rtld stdlib paths to ldconfig(32)_paths
Ensure that ldconfig-managed elf and elf32 hints always include
the standard library paths that are known independently to rtld.

PR:			275031
Reviewed by:		kib
MFC after:		2 weeks
Sponsored by:		Saltant Solutions LLC
Differential Revision:	https://reviews.freebsd.org/D42557
2023-11-14 01:39:17 +02:00
Alexander Leidinger
cb57f50e64 defaults: oomprotect sshd and local_unbound
Add sshd and local_unbound to the oom protected services.
syslogd is protected by default already, document it.

This was discussed on arch@, see
    https://lists.freebsd.org/archives/freebsd-arch/2023-November/000543.html

sshd is protected to be able to investigate and fix oom issues on systems
which don't have out-of-band console access.
local_unbound is protected as it may be enabled for local use and without
DNS a lot grinds to a halt (including sshd).

Relnotes:		yes
MFC after:		1 month
Differential Revision:	https://reviews.freebsd.org/D42544
2023-11-13 09:48:51 +01:00
Jamie Gritton
a2440348ee jail: avoid a clash with /etc/jail.conf.d between rc and jail(8)
Since 13.1, /etc/rc.d/jail has looked for a per-jail config file in
/etc/jail.conf.d. For RELENG 14, the ".include" directive was added to
jail(8), with a sample line in the jail.conf(5) man page that includes
"/etc/jail.conf.d/*.conf".

These two use cases don't work together. When the jail.conf.d files
are included from a master jail.conf, the files in jail.conf.d are
likely to hold only partial configurations, and shouldn't be directly
loaded by rc.d/jail. But there are existing configurations that depend
on the current rc.d behavior. While users could be advised not to
include from /etc/jail.conf.d, it's the natural choice even if not
mentioned in jail.conf.5.

The workaround is for rc.d/jail to continue to load the individual
files, but only when /etc/jail.conf doesn't include from that
directory (via a simple grep test), This allows the current use
while not breaking the previous use.
Reported by:	antranigv at freebsd.am
Differential Revision:	https://reviews.freebsd.org/D41962
2023-09-24 17:03:09 -07:00
Daniel Tameling
ba793728a8 rc.subr: don't require service to be enabled for status
For a service that sets an rcvar, there is a check whether it has been
enabled before the actual command is executed. If the check fails, one
gets a message to enable it and the returned exit status is 0.
However, this is usually undesirable for the status command, which is
a) supposed to check whether the service is running anyway and
b) returns a non-zero exit code if that is not the case.
Thus, skip the check for the status command.

PR:		272282
Reviewed by:	emaste
MFC after:	3 days
2023-09-21 19:28:40 -04:00
Ed Maste
4722ceb7d5 Use 115200 bps by default for serial communication
9600 was a standard baud rate decades ago, but 115200 is now more common
so choose defaults that are useful to the largest number of users.

Note that boot0sio does not support rates above 9600 so it remains
unchanged.

Reviewed by:	bz, imp, manu
Relnotes:	Yes
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D36295
2023-08-17 13:31:38 -04:00