Commit Graph

3059 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
Jessica Clarke
9820007780 rtld-elf: Use a proper struct type for tlsdesc entries
This clarifies the code and makes it less error-prone. It also makes it
easier to extend downstream in CheriBSD (where pointer and integer
members no longer have the same representation and an additional member
is present).

Reviewed by:	jhb, kib
Differential Revision:	https://reviews.freebsd.org/D45143
2024-06-05 17:41:54 +01:00
Baptiste Daroussin
8d7331e62a nuageinit: fix authorized_key test
After miss reading the cloudinit spec I ended up writting a wrong
test for basic ssh key setup, nuageinit has been fixed, but not
the test, here is the actual fix.

Reported by:	markj
2024-06-05 11:00:54 +02:00
Baptiste Daroussin
fa07b02f6e nuageinit: make addsshkey friendly for testsuite 2024-06-05 11:00:53 +02:00
Baptiste Daroussin
83fcab792c nuageinit: use pw(8) instead of getent(1)
pw(8) allows to seek for users in a custom rootdir, which makes it
easier for a testsuite

MFC After:	3 days
2024-06-05 11:00:53 +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
Allan Jude
e209715001 ftpd: stop using -g flag for /bin/ls
In 3bfbb521 the behaviour of ls was changed such that -g was no longer
a noop for compatibility with BSD 4.3, but instead changed the output
of long mode to exclude the owner of the file and display only the
group.

Update how FTPd invokes ls to restore the previous behaviour

Reported-by:	Andrew Fengler <andrew.fengler@scaleengine.com>
Reviewed-by:	jrtc27, des, imp
MFC after:	3 days
Sponsored-by:	ScaleEngine Inc.
Fixes:		3bfbb521fe ("ls: Improve POSIX compatibility for -g and -n.")
2024-05-21 22:50:14 +00:00
Jeremy Collin
48edad2edf fix (nuageinit): SSH keys are not handled in metadata but in userdata
MFC After: 1 day
2024-05-21 16:52:42 +02:00
Andrew Turner
2228d7c599 Revert "rtld: Add arm64 variant pcs tests"
It's missing an mtree update

This reverts commit 9e48c30e25.
2024-05-17 11:19:24 +00:00
Andrew Turner
1cd90a2c16 rtld: Move powerpc specific code to powerpc files
There are two variables set by dynamic tags in the powerpc runtime
linker. Now we have a way to split out architecture-specific dynamic
tags use it to handle these.

Reviewed by:	kib, jhibbits
Obtained from:	jhibbits (earlier version)
Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D45182
2024-05-17 09:37:23 +00:00
Andrew Turner
9e48c30e25 rtld: Add arm64 variant pcs tests
When marking a function as variant pcs we can use registers not normally
used in procedure calls. Add a test that uses this and stores all
general purpose registers to a buffer and compare this buffer with the
expected value later.

Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D44870
2024-05-17 09:37:23 +00:00
Andrew Turner
d51fa0a9b1 rtld: Add support for arm64 variant pcs
The aarch64 ELF spec has support for a variant of the normal procedure
call standard that doesn't follow the normal register convention, e.g.
using more registers as arguments, or different register state is
preserved.

Add support to rtld to handle this. As we don't know which registers
need to be preserved disable lazy binding for these functions.

Reviewed by:	kib
Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D44869
2024-05-17 09:37:23 +00:00
Andrew Turner
dd4155bec7 rtld: Add arch_digest_dynamic
This will be used to handle the DT_AARCH64_VARIANT_PCS tag.

Reviewed by:	kib
Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D45117
2024-05-17 09:37:12 +00:00
Andrew Turner
06db20ffec rtld: Add MD_OBJ_ENTRY to extend Struct_Obj_Entry
Add a macro the architectures can use to add per-arch fields to
Struct_Obj_Entry.

Reviewed by:	kib
Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D45116
2024-05-17 09:36:08 +00: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
Kyle Evans
9bfd3b4076 Add a build knob for _FORTIFY_SOURCE
In the future, we will Default to _FORTIFY_SOURCE=2 if SSP is enabled,
otherwise default to _FORTIFY_SOURCE=0.  For now we default it to 0
unconditionally to ease bisect across older versions without the new
symbols, and we'll put out a call for testing.

include/*.h include their ssp/*.h equivalents as needed based on the
knob. Programs and users are allowed to override FORTIFY_SOURCE in their
Makefiles or src.conf/make.conf to force it off.

Reviewed by:	des, markj
Relnotes:	yes
Sponsored by:	Stormshield
Sponsored by:	Klara, Inc.
Differential Revision:	https://reviews.freebsd.org/D32308
2024-05-13 00:23:50 -05:00
Dag-Erling Smørgrav
25945af47e tftpd: silence gcc overflow warnings
GCC 13 complains that we might be writing too much to an on-stack buffer
when createing a filename.

In practice there is a check that filename isn't too long given the
time format and other static characters so GCC is incorrect, but GCC
isn't wrong that we're potentially trying to put a MAXPATHLEN length
string + some other characters into a MAXPATHLEN buffer (if you ignore
the check GCC can't realistically evaluate at compile time).

Switch to snprintf to populate filename to ensure that future logic
errors don't result in a stack overflow.

Shorten the questionably named yyyymmdd buffer enough to slience the
warning (checking the snprintf return value isn't sufficent) while
preserving maximum flexibility for admins who use the -F option.

MFC after:	3 days
Sponsored by:	Klara, Inc.
Reviewed by:	brooks
Differential Revision:	https://reviews.freebsd.org/D45086
2024-05-10 23:16:26 +02:00
Dag-Erling Smørgrav
4d09eb87c5 tftpd: Satisfy clang-analyzer.
* Replace `random()` with `arc4random()`.
* Change some variable types.
* Drop some unused assignments.

MFC after:	3 days
Sponsored by:	Klara, Inc.
Reviewed by:	imp, markj
Differential Revision:	https://reviews.freebsd.org/D45132
2024-05-10 23:16:26 +02:00
Dag-Erling Smørgrav
ae285a8cbf tftpd: Add missing include.
This went unnoticed due to namespace pollution in our headers.

MFC after:	3 days
Sponsored by:	Klara, Inc.
Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D45131
2024-05-10 23:16:26 +02:00
Dag-Erling Smørgrav
1111da6b7c tftpd: Drop unneeded includes.
MFC after:	3 days
Sponsored by:	Klara, Inc.
Reviewed by:	imp, markj
Differential Revision:	https://reviews.freebsd.org/D45130
2024-05-10 23:16:26 +02:00
Dag-Erling Smørgrav
816c4d3dcf tftpd: Add missing -S option to synopsis.
MFC after:	3 days
Sponsored by:	Klara, Inc.
Reviewed by:	imp, markj
Differential Revision:	https://reviews.freebsd.org/D45129
2024-05-10 23:16:26 +02:00
Paweł Krawczyk
783baf0012 at cron file is now in /etc/cron.d
PR: 243380
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/1106
2024-05-09 22:34:06 -06: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
Dag-Erling Smørgrav
21b5829d28 tftpd: Untangle a conditional.
MFC after:	1 week
Sponsored by:	Klara, Inc.
Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D45026
2024-04-30 16:56:17 +02:00
Olivier Certner
9b30b96c1f
Remove remnants of portsnap(8)
This was prompted by noticing that '/var/db/portsnap' still exists on
newly-installed machines.

With this change, all mentions of portsnap(8) in the tree are gone,
except for the historical note in the AUTHORS section of manpage
phttpget(8).

locate(1) will thus start indexing again '/var/db/portsnap' on machines
where this directory still exists, which may be a good way to push
administrators to delete it.

Reviewed by:            cperciva
Approved by:            emaste (mentor)
MFC after:              3 days
Sponsored by:           The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D45023
2024-04-30 22:44:34 +09:00
Konstantin Belousov
6a7819e43f rtld.1: clarify interaction between -u and -o
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2024-04-30 03:26:55 +03:00
Konstantin Belousov
ef2694f368 rtld direct exec: make -u behavior match the description
Instead of only ignoring insecure env vars, clear them all.

Reviewed by:	emaste, markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D44999
2024-04-30 03:26:49 +03:00
Konstantin Belousov
d1cd0cc32b rtld: add direct-exec option -o
allowing to set any known LD_ parameter for the current rtld invocation,
but without polluting the activated' binary environment.  In other
words, the set parameter is not exported into the environment.

Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D44988
2024-04-30 03:16:05 +03: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
Konstantin Belousov
56ee5fc43c rtld snprintf: do not erronously skip a char at the buffer boundary
Reviewed by:	emaste, markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D44987
2024-04-28 22:42:12 +03:00
Dag-Erling Smørgrav
9f231af307 tftpd: Immediately reject any request shorter than 4 bytes.
MFC after:	1 week
Sponsored by:	Klara, Inc.
Reviewed by:	kevans
Differential Revision:	https://reviews.freebsd.org/D44957
2024-04-25 20:36:13 +02:00
Dag-Erling Smørgrav
83a6e984ac tftpd: Check the server status after each test.
* In the setup phase, wait for the server to start (or fail to start)
  before proceeding with the test.  This makes it possible to write test
  cases that don't expect a response from the server without ending up
  in a race over the server PID file.
* After running each test, wait up to 30 seconds for the server to exit
  and check that the exit status matches what the test case says to
  expect (usually 0).
* We still kill and collect the server in the cleanup phase, in case the
  test ended early.

MFC after:	1 week
Sponsored by:	Klara, Inc.
Reviewed by:	kevans
Differential Revision:	https://reviews.freebsd.org/D44956
2024-04-25 20:36:13 +02:00
Dag-Erling Smørgrav
7ab7ecfcfe tftpd: Clean up the tests.
MFC after:	1 week
Sponsored by:	Klara, Inc.
Reviewed by:	kevans
Differential Revision:	https://reviews.freebsd.org/D44955
2024-04-25 20:36:13 +02:00
Dag-Erling Smørgrav
1ed44fcc44 tftpd: Use size_t where appropriate.
* Limit the use of `ssize_t` to only where it's needed.
* Correct one case of `int` being used for a length.

MFC after:	1 week
Sponsored by:	Klara, Inc.
Reviewed by:	kevans
Differential Revision:	https://reviews.freebsd.org/D44954
2024-04-25 20:36:12 +02: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
Konstantin Belousov
8d74737035 rtld(1): minor clarification for LD_STATIC_TLS_EXTRA
Also properly style the paragraph.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
2024-04-20 16:50:27 +03:00