1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-11-24 07:40:52 +00:00
Commit Graph

3095 Commits

Author SHA1 Message Date
Mateusz Piotrowski
401516dbc5 rc.subr: Consistently use an absolute path for sysrc
MFC after:	2 weeks
Approved by:	christos
2024-09-20 19:28:59 +01:00
Baptiste Daroussin
696922fbfa flua: add freebsd.kenv, kenv(2) bindings
Add bindings for kenv(2) right now only get() has been created
it allows do dump into a key/value table the kernel environement if
no argument is passed, or it returns the value associated to the
provided key.

Reviewed by:	imp, kevans, markj
Accepted by:	imp, kevans
Differential Revision:	https://reviews.freebsd.org/D46654
2024-09-14 07:43:50 +02:00
R. Christian McDonald
4269d1a2e4 rc.subr: fix typo "save_dot" -> "safe_dot"
Reviewed by:	sjg
Approved by:	kp
MFC after:	1 week
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D46644
2024-09-13 16:51:40 -04:00
Baptiste Daroussin
fa4b5aa51f freebsd.sys.linker: remove license to only keep SPDX line 2024-09-13 07:07:23 +02:00
Doug Ambrisko
408087f128 zfskeys: allow prompt to entered during boot up
If the ZFS key is setup in prompt mode, use zfs to prompt to load the key
during boot to unlock it.

Reviewed by:	jhb
Differential Revision:	https://reviews.freebsd.org/D36081
2024-09-12 08:46:49 -07:00
Baptiste Daroussin
cbf53f5e37 flua: install linker in the right patch
When moving the freebsd.sys.linker sources the installation path
was lost.

Fixes 7899f917b1
2024-09-12 14:43:56 +02:00
Baptiste Daroussin
7899f917b1 flua: move modules source into the main source directory
Follow the path of what is done with bsnmp, build the modules along
with the main binary, this allows to build the modules at a moment
where all needed libraries are already built and available in the
linker path instead of having to declare all the libraries which a
flua module will be linked to in _prebuild_libs.

Discused with:	markj
Reviewed by:	markj, jrtc27, kevans, imp
Accepted by:	kevans, imp
Differential Revision:	https://reviews.freebsd.org/D46610
2024-09-12 09:03:44 +02:00
Simon J. Gerraty
7e1c014a9e debug.sh take advantage of hooks.sh
Allow Debug{On,Off} to run associated hooks.
This makes it feasible to collect extra debug info at runtime
without needing to modify any potentially verified and hence immutable
scripts.

Like debug.sh, hooks.sh is extremely handy and used extensively
in many parts of Junos and its build environment.
It is provided here in the hope that others may benefit.

We do not dot hooks.sh by default to reduce overhead, but it can
but done from rc.conf et al using

$_HOOKS_SH . /libexec/hooks.sh

to avoid including more than once.

Reviewed by:	stevek
Sponsored by:	Juniper Networks, Inc.
Differential Revision:	https://reviews.freebsd.org/D46552
2024-09-10 12:04:15 -07:00
R. Christian McDonald
b5f6beefa0 rc.subr: ensure run_rc_script return code is not masked by DebugOff
Ensure that run_rc_script returns the true return code of the
rc command and not the return code of DebugOff

Reviewed by:	sjg
Approved by:	kp
MFC after:	1 week
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D46626
2024-09-10 14:58:47 -04:00
Baptiste Daroussin
bb2d016afb flua: make the ucl module a dynamic module
Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D46569
2024-09-06 17:21:29 +02:00
Bjoern A. Zeeb
ed4d2a54fc rc: network.subr update consitency with older change (v6/v4 order)
As of 1b5be7204e we setup parts of IPv6
before IPv4 if configured.  For consistency change a case in ifn_start()
calling ipv6_up() before ipv4_up() and reverse in ifn_stop().

MFC after:	10 days
Reviewed by:	zlei
Differential Revision: https://reviews.freebsd.org/D33426
2024-09-05 19:53:57 +00:00
Mark Johnston
1726db7af6 flua: Add wrappers for sys/utsname.h
This allows one to invoke uname from lua scripts.

Reviewed by:	bapt, kevans, emaste
MFC after:	1 month
Differential Revision:	https://reviews.freebsd.org/D42017
2024-09-05 15:53:52 +00:00
Jessica Clarke
62775aebf7 rc.d/devmatch: Silence sysctl hw.bus.devctl_nomatch_enabled=1
As with various other rc scripts, we don't want the output from this
being visible in the boot log.

Fixes:		6437872c1d ("New sysctl to disable NOMATCH until devmatch runs")
MFC after:	1 week
2024-08-29 00:26:26 +01:00
Alex Richardson
04262ed78d rtld-elf: Add CFI annotation for .rtld_start on RISC-V
Without this change, unwinders such as LLVM libunwind will attempt to
unwind beyond the start of RTLD and get stuck in an infinite loop or
crash (depending on the current values on the stack).
This fixes an infinite loop in the LLVM libunwind test suite on RISC-V.

See also https://reviews.freebsd.org/D40844 for AArch64

Reviewed By:	#riscv, jhb
MFC After:	2 weeks
Differential Revision: https://reviews.freebsd.org/D46406
2024-08-25 21:51:55 -07:00
Jessica Clarke
729d2b16b7 rtld-elf: Support IFUNCs on riscv
GNU/Linux has historically had the following two resolver prototypes:

  1. Elf_Addr(uint64_t, void *)
  2. Elf_Addr(uint64_t, void *, void *)

For the former, AT_HWCAP is passed in the first argument, and NULL in
the second. For the latter, AT_HWCAP is still passed, and the second
argument is a pointer to their home-grown __riscv_hwprobe function.
Should they want to use the third argument in future, they'll have to
introduce yet another prototype to allow for later expansion, and then
all users will have to check whether the second argument is NULL to know
if the third argument really exists. This is all rather silly and will
surely prove fun in the face of type-checking CFI.

Instead, be like arm64 and just define all 8 possible general purpose
register arguments up front. To naive source code that forgets non-Linux
OSes exist this will be compatible with prototype 1 above, since the
second argument will be 0 and it won't look further (though should we
start using the second argument for something that wouldn't be true any
more and it might think it's __riscv_hwprobe, but that incompatibility
is one we can defer committing to, and can choose to never adopt).

Until the standard interface for querying extension information[1] is
settled and implemented in FreeBSD there's not much you can do in a
resolver other than use HWCAP_ISA_B, but this gets the infrastructure in
place for when that day comes.

[1] https://github.com/riscv-non-isa/riscv-c-api-doc/pull/74

Reviewed by:	kib, mhorne
MFC after:	1 month
Differential Revision:	https://reviews.freebsd.org/D46278
2024-08-22 20:36:44 +01:00
Jessica Clarke
33658afd4e rtld-elf: Pass parsed aux_info to ifunc_init
Currently we pass the raw pointer to the on-stack auxargs. This can
legitimately have fewer than AT_COUNT entries, so the use of
__min_size(AT_COUNT), i.e. static AT_COUNT, is inaccurate, and also
needlessly forces the callee to iterate over the elements to find the
entry for a given type. Instead we can just pass aux_info like we use
for everything else.

Note that the argument has been left unused by every callee since its
introduction in 4352999e0e ("Pass CPUID[1] %edx (cpu_feature), %ecx
(cpu_feature2) and CPUID[7].%ebx (cpu_stdext_feature), %ecx
(cpu_stdext_feature2) to the ifunc resolvers on x86.")

Reviewed by:	kib
MFC after:	1 month
Differential Revision:	https://reviews.freebsd.org/D46276
2024-08-22 20:36:44 +01:00
Baptiste Daroussin
a6ecbf2b35 nuageinit: improve debugging when mkdir fails 2024-08-20 12:09:43 +02:00
Baptiste Daroussin
19fb9ad746 nuageinit: readd ssh key parsing when key is in meta_data.json
in openstack when no user is specified but a sshkey is provided
the information is stored in meta_data.json under "public_keys"

PR:	280461
Reported by:	tdb
2024-08-20 12:08:29 +02:00
Simon J. Gerraty
35399f68c8 safe_dot check file is a file
Since we are being paranoid, check that each arg to safe_dot is
actually a file as well as non-empty.

Check for white-space in filenames - these require special handling.
2024-08-16 13:15:20 -07:00
Simon J. Gerraty
82cb2a4158 Update safe_eval.sh to support --export
This update allows

safe_dot --export file ...

to export any variables that get set.

Reviewed by: obrien
2024-08-15 15:42:39 -07:00
Isaac Cilia Attard
503adcdf1d dhclient: rc.conf option to disable ARP resolution
Introduce a new rc.conf option to not wait for ARP resolution within
dhclient. This is plausible on many modern networks where it is possible
to trust the DHCP server to know whether an IP address is available.

Sponsored by:	Google LLC (GSoC 2024)
Signed-off-by:	Isaac Cilia Attard <icattard@FreeBSD.org>
MFC after:	10 days
Reviwed by:	cperciva, brooks, Tom Hukins, Alexander Ziaee
Pull Request:	https://github.com/freebsd/freebsd-src/pull/1368
2024-08-09 14:49:51 -07:00
Simon J. Gerraty
6502c60c22 Move fetch of DEBUG_SH from kenv to rc
We only need to check kenv for DEBUG_SH once.
We also need to export DEBUG_SH to be useful.

Sponsored by:	Juniper Networks, Inc.

Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D46219
2024-08-03 10:56:48 -07:00
Ed Maste
5c2bc3db20 Remove "All Rights Reserved" from FreeBSD Foundation copyrights
These ones were unambiguous cases where the Foundation was the only
listed copyright holder.

Sponsored by:	The FreeBSD Foundation
2024-07-30 12:16:36 -04:00
Konstantin Belousov
860c4d94ac rtld: add LD_NO_DL_ITERATE_PHDR_AFTER_FORK env var
which makes threaded fork ignore the phdr rtld lock, in particular
allowing the dl_iterate_phdr() to block in callback.  The cost is that
the image started in this mode cannot use dl_iterate_phdr() after fork.

PR:	280318
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2024-07-30 02:57:33 +03:00
Konstantin Belousov
47315d6d35 rtld: make ld_get_env_var() usable for all rtld source files
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2024-07-30 02:57:33 +03:00
Konstantin Belousov
bc25bc6850 rtld(1): Spell value as VALUE, not NAME
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2024-07-30 02:57:33 +03:00
Jose Luis Duran
8edd6c07c8 nuageinit: Fix tests
Commit 07d17ca189 set the recommended
permissions for the SSH authorized keys file and directory.  The tests,
however, were failing on CI.

Use stat to check for the proper permissions.

Fixes:	07d17ca189 nuageinit: Set recommended SSH permissions
Reported by:	Jenkins
2024-07-25 11:15:29 +02:00
Jose Luis Duran
7aecd689e3 nuageinit: Fix the homedir variable name
cloud-init uses homedir, not home.
2024-07-25 11:15:29 +02:00
Jose Luis Duran
07d17ca189 nuageinit: Set recommended SSH permissions
As stated in sshd(8), the recommended permissions for ~/.ssh are
read/write/execute for the user, and not accessible by others; and the
recommended permissions for ~/.ssh/authorized_keys are read/write for
the user, and not accessible by others.
2024-07-23 15:02:28 +02:00
Jose Luis Duran
7b73ecfe64 nuageinit: Accept plain text passwords
Per pw(8), when -H is set, the password should be supplied already
encrypted in a form suitable for writing directly to the password
database (passwd in cloud-init tems); -h provides a special interface by
which interactive scripts can set an account password using pw(8) in
plain text (plain_text_passwd in cloud-init terms).

The default user (freebsd) is defined with a plain_text_passwd
(freebsd), not with an encrypted one.
2024-07-23 15:01:54 +02:00
Cy Schubert
66f360515d rc.conf: Leap-seconds sources: Add IANA back
11da791920 switched Leap-seconds source from IANA to IERS, as IERS
is the canonoical source. The problem ist that IERS is not accessible
from IPv6 only networks. To work around this we must add IANA back in
order to provide IPv6-only users a source for leap-seconds fetch.

PR:		279413
Fixes:		11da791920
MFC after:	3 days
2024-07-19 11:24:31 -07:00
Warner Losh
e9ac41698b Remove residual blank line at start of Makefile
This is a residual of the $FreeBSD$ removal.

MFC After: 3 days (though I'll just run the command on the branches)
Sponsored by: Netflix
2024-07-15 16:43:39 -06:00
Warner Losh
82dfbaf7e7 rtld-elf: Fix signed conversion for %hh
While char is signed on some of FreeBSD's architecutres, it's unsigned
on others. So the naked 'char' cast here needs to be 'signed char'
because in this context, we want the signed interpretation.

We don't really use %hh conversions in the run time linker, so this is
likely a nop. However, for correctness, we need this, like we did in the
kernel in fc3e5334ab. It's a nop on x86 and riscv due to defaults as
well, but does fix a bug on arm and powerpc where char is unsigned.

Suggested by: kib
Sponsored by: Netflix
2024-07-14 12:01:43 -06:00
Dag-Erling Smørgrav
c15290fb9d tftpd: Code cleanup.
MFC after:	3 days
Sponsored by:	Klara, Inc.
Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D45871
2024-07-06 00:05:49 +02:00
Alexander Ziaee
088cc7d221 man filesystems: fix more xrefs after move to s4
Fixes: 1a720cbec5
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/1282
2024-06-27 18:32:05 -06:00
Baptiste Daroussin
cde6642431 nuageinit: check for both user_data and user-data
openstack, ec2 and other implementation of cloudinit disagrees on the
name of the file "user-data" or "user_data", test both and use the first
found

PR:	279876
2024-06-27 10:32:14 +02:00
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