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

3134 Commits

Author SHA1 Message Date
Baptiste Daroussin
3e2a7a2cbe nuageinit: add test about encrypted passwords
While here fix fc34a2463c where the
adduser_passwd.lua file was not added
2024-11-20 11:02:55 +01:00
Baptiste Daroussin
3e50286607 nuageinit: use io.popen instead of pipes in shell for password
using echo in a sh(1) command line, requires many escaping to be done
right, using io.popen we don't need to do this escaping anymore.
2024-11-20 10:41:46 +01:00
Baptiste Daroussin
fc34a2463c nuageinit: add test for the password 2024-11-20 10:41:46 +01:00
Konstantin Belousov
5bc24fd7a2 rtld: drop RTLD_INIT_PAGESIZES_EARLY
No arch defines it after ia64 decomissioning.

Discussed with:	jhb
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2024-11-20 08:59:32 +02:00
Franco Fichtner
43e045c173 atf: Guard libexec/atf with WITH_TESTS_SUPPORT
Other atf components are guarded by WITH_TESTS_SUPPORT already.
WITH_TESTS is for actual tests.

Reviewed by:	markj
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D47660
2024-11-18 18:36:46 +00:00
Kyle Evans
1426fd6cff rtld: implement _dl_iterate_phdr_locked
Some sanitizers need to be able to use dl_iterate_phdr() after stopping
the rest of the process, but it's very hard to do so reliably as a
non-participant in the main logic of the program.

Introduce _dl_iterate_phdr_locked to bypass the locking that's normally
required for dl_iterate_phdr() and slap some scary warning on it.  It
will remain undocumented and probably shouldn't be used for anything
else.

Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D47558
2024-11-13 19:33:59 -06:00
Konstantin Belousov
16d000bdac rtld.1: cross-reference rtld_get_var.3
Reviewed by:	Alexander Ziaee
Discussed with:	emaste
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D47351
2024-11-07 07:15:30 +02:00
Konstantin Belousov
c56df6ce71 rtld: add rtld_{get,set}_var
Reviewed by:	brooks (previous version)
Discussed with:	emaste
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D47351
2024-11-07 07:15:23 +02:00
Konstantin Belousov
d7214577ff rtld: make it easier to add sparce non-default members to ld_env_var_desc
by making the LD_ENV_DESC() macro variadic.

Suggested by:	brooks
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D47351
2024-11-07 07:14:38 +02:00
Konstantin Belousov
450e684e0f rtld: 1-bit for bool is enough
Reviewed by:	brooks
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D47351
2024-11-07 07:14:38 +02:00
Simon J. Gerraty
a4e7810f71 debug.sh check for :debug_add:
When we match a tag and turn tracing, see if we have any
$DEBUG_ON:debug_add:tag in DEBUG_SH and if so add the new tag.

This allows for more focused debugging during boot.

Reviewed by:	stevek
2024-11-04 12:30:01 -08:00
Jose Luis Duran
8934526be1
rc: Update ipfilter example rules location
It was originally /usr/src/contrib/ipfilter/rules and moved to
/usr/src/share/examples/ipfilter/rules in 41edb306f0.

Point to users to /usr/src/share/examples/ipfilter instead, as the base
directory also contains example rules.

Reviewed by:	emaste
Approved by:	emaste (mentor)
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D47392
2024-11-04 20:02:01 +00:00
Mark Johnston
79c342aaf8 tftpd: Address flaky tests
The tftpd tests all follow the same pattern:
1. open a UDP socket,
2. fork a child to exec tftpd, which subsequently handles requests on
   the socket,
3. use a client socket to send some message to the tftpd daemon.

However, tftpd's first action is to mark its socket as non-blocking and
then read a request from it.  If no data is present in the socket, tftpd
exits immediately with an error.  So, there is a race; we often see
tftpd test timeouts when running tests in parallel.  These timeouts also
arise periodically in CI runs.

One solution is to restructure each test to create the server socket,
then write the request to the client socket, then fork tftpd.  This
closes the race.  However, this involves a lot of churn.

This patch fixes the problem a different way, by adding a new -b flag to
tftpd which makes it block to read the initial request.  Each test is
modified to use -b, closing the race.

Reviewed by:	imp, asomers
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D47404
2024-11-03 16:47:38 +00:00
Cy Schubert
8d6feaaaa2 ipfilter: Set ipf -T optionlist at boot
There is no easy way to set ipfilter optionlist variables during boot.
Add plumbing to the rc script to support this.

PR:			130555
Reviewed by:		jlduran
MFC			1 week
Differential Revision:	https://reviews.freebsd.org/D47346
2024-11-01 11:08:14 -07:00
Baptiste Daroussin
2775b9b0bc nuageinit: add support for OpenStack network config
Add naive support for openstack network config.
if no config driver have been found, try to detect that we are running a
VM on openstack via the smbios information, use the first iface
available and temporary activate dhcp on it, to be able to fetch the
necessary informations for cloudinit.

While here make the rc script execute after devmatch, some ethernet
device might be attached via devmatch and may be needed for cloudinit.

Tested on OVHCloud Public Cloud.

MFC after:	3 weeks
Sponsored by:	OVHCloud
2024-10-29 14:23:47 +01:00
Mark Johnston
207ab5f4f1 rc.d/opensm: Only install when MK_OFED_EXTRA is set
opensm itself is only installed when MK_OFED_EXTRA is set, so it only
makes sense for the same to be true of the rc script.

PR:		257646
Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D47313
2024-10-29 13:01:00 +00:00
Mateusz Piotrowski
a5ad360ff9 rc: Remove rc_fast_and_loose
The rc_fast_and_loose variable allowed rc(8) to start services
by sourcing them into rc's own shell environment. Normally, each rc
service script is started by being sourced into its own subshell
instead.  The feature was meant to speed up rc(8) by avoiding the extra
forking necessary to spawn subshells.

In practice, the feature has been broken for a long time now. One of the
reasons is that some rc service scripts call the exit builtin to return
non-zero error codes, which not only terminates the service subshell
but also rc(8) when rc_fast_and_loose is enabled. For example,
a system running any of the supported FreeBSD releases
with rc_fast_and_loose=yes would abort rc(8) as early as rc.d/hostid,
due to an "exit 0".

Fixing rc_fast_and_loose support would require rewriting some rc scripts
to support being sourced directly into rc(8) process. This would muddy
the code base and also would prove difficult to maintain long term
as this is simply not how rc(8) users write scripts. The potential
performance benefits are unlikely to be significant even for use cases
such as Morello under qemu.

Instead, remove support for rc_fast_and_loose completely from rc(8)
and inform users about the change.

PR:		282255
Reviewed by:	brooks, christos, mhorne
Approved by:	christos (mentor), markj (mentor)
MFC after:	2 weeks
Relnotes:	yes
Differential Revision:	https://reviews.freebsd.org/D47264
2024-10-28 22:10:49 +01:00
Stefan Eßer
f35ccf46c7 flua: lposix: add fnmatch function
The fnmatch function matches a string against a shell-style filename
pattern. It is a complex function and cannot easily be implenented
using regular expressions. Adding fnmatch to flua increases the amd64
binary by less than 1 KB.

Approved by:	markj
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D46849
2024-10-28 16:31:08 +01:00
Graham Percival
b74aaa1a21 manuals: Fix dates
These were reported by `mandoc -T lint ...` as warnings.

Signed-off-by:	Graham Percival <gperciva@tarsnap.com>
Reviewed by:	mhorne
MFC after:	3 days
Sponsored by:	Tarsnap Backup Inc.
Pull Request:	https://github.com/freebsd/freebsd-src/pull/1475
2024-10-28 12:26:03 -03:00
Robert William Vesterman
65691b2daf libexec/rc/rc.d/netif: Typo fix
Just fixing a typo ("configuriing" => "configuring").

MFC after:	3 days
Pull Request:	https://github.com/freebsd/freebsd-src/pull/1484
2024-10-27 20:30:19 -07:00
Mark Johnston
3e55170e0f rc.d/kld: Print modules being loaded, take three
Some kernel modules will print informative messages when they are
loaded, making the output confusing.  Print everything up front instead.

Fixes:	152382e661 ("rc.d/kld: Print the kernel modules being loaded")
2024-10-26 19:20:29 +00:00
Mark Johnston
cdb3cda6fd rc.d/kld: Avoid printing a trailing space
Fixes:		152382e661 ("rc.d/kld: Print the kernel modules being loaded")
Reported by:	jrtc27
2024-10-26 19:07:22 +00:00
Mark Felder
152382e661 rc.d/kld: Print the kernel modules being loaded
PR:		282269
MFC after:	2 weeks
2024-10-26 18:43:46 +00:00
Simon J. Gerraty
02653835cd debug.sh add DebugAdd
Sometimes it is desirable while debugging one script for it to enable
debugging of a child.
We can do that with

$DEBUG_DO DebugAdd tag

to add tag to DEBUG_SH but only when we are already debugging.
2024-10-22 11:07:37 -07:00
Mateusz Piotrowski
d2e7bb630b rc.d/sendmail: Return non-zero if the daemon fails to start or is not running
If you have a mail server that is running sendmail daemon
(sendmail_enable=YES) and sendmail queue runner (sendmail_msp_queue=YES)
and the sendmail daemon dies, /etc/rc.d/sendmail status does see the
daemon is not running but returns 0 as the exit code.  This prevents
other programs (like puppet) from restarting sendmail to fix the issue.

Make sure that the exit code is propagated towards the end of the script
if any of the sendmail services fail.

This patch does not call exit directly but instead just sets the exit
status code by calling exit in a subshell. This way we do not exit the
current shell in case the service script is sourced (e.g., when
rc_fast_and_loose is active).

PR:		223132
MFC after:	2 weeks
Reported by:	pirzyk
Discussed with:	jilles, eugen
Reviewed by:	christos, gshapiro (previous version), markj
Approved by:	christos (mentor), markj (mentor)
Differential Revision:	https://reviews.freebsd.org/D46862
Co-authored-by: Jim Pirzyk <pirzyk@FreeBSD.org>
2024-10-21 21:20:36 +02:00
Simon J. Gerraty
a64729f507 Update Makefile.depend files
After building packages we have a number of new
and updated Makefile.depend files

Reviewed by:	stevek
2024-10-14 10:26:17 -07:00
Mateusz Piotrowski
6fa42b91ca rc/tests: Skip oomprotect tests in a jail
oomprotect cannot be used in a jail.

Reviewed by:	bnovkov, christos, markj
Approved by:	bnovkov (mentor), christos (mentor), markj (mentor)
MFC after:	1 week
2024-10-14 12:30:23 +02:00
Mateusz Piotrowski
8751fbe36f rc.d/sendmail: Fix stopping service during shutdown
The sendmail service script needs to be stopped during shutdown
to ensure a clean shutdown of active SMTP connections (and writing
any in memory queue files).

rcorder(8) requires the rcorder block to be an uninterrupted sequence of
REQUIRE, PROVIDE, BEFORE, and KEYWORD lines. Having a comment in between
REQUIRE and KEYWORD makes rcorder stop parsing the block when it reaches
the comment.

Fix that by moving the comment out from the rcorder block.

Reviewed by:	bnovkov, christos, gshapiro, markj
Approved by:	bnovkov (mentor), christos (mentor), markj (mentor)
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D46924
2024-10-10 13:43:37 +02:00
Kyle Evans
aad507854e Fix the cross-build after recent commits
- Provide a sys/md4.h in the cross-build environment to fix bootstrap
    of libmd.
- flua now exposes WTRAPPED which isn't incredibly common- make it
    conditional, we probably won't be using it in any bootstrap context
    any time soon.

Fixes:	442e0975ee ("Consolidate md4 implementations written in C")
Fixes:	c2caf3b331 ("flua: posix: add more useful functions [...]")
2024-09-30 00:08:49 -05:00
Kyle Evans
c2caf3b331 flua: lposix: add more useful functions for general purpose scripts
unistd:
- _exit
- close
- fork
- getpid
- pipe
- read
- write

libgen:
- basename, dirname

stdlib:
- realpath

These are sufficient for a number of real world scenarios.  In our first
application of them, we use the libgen+stdlib additions to grab the
script dir based on argv[0].  The unistd assortment is then used to
outsource a bunch of work to forks and report back to the main process.

Reviewed by:	emaste, imp
Differential Revision:	https://reviews.freebsd.org/D39083
2024-09-29 22:52:20 -05:00
Jose Luis Duran
e72457c4f5 nuageinit: tests: Cleanup
- Export NUAGE_FAKE_ROOTDIR only once
- Use the header section of the test to require the root user
- Use the PWD environment variable
- Set the root/sys shell as /bin/sh
- Use RFC 5737 reserved IP addresses

Signed-off-by: Jose Luis Duran <jlduran@gmail.com>
2024-09-26 13:00:16 +02:00
Jose Luis Duran
b9ce743c54 nuageinit: Fix passwords
The hashed password usually contains a "$" sign, which, when used on a
shell, must be escaped.  Also, the plain text password may contain
special characters that require escaping.

Add a quick fix by enclosing it in single quotes.  Note that if the
plain text password contains a "'", it will still fail.  This will be
properly fixed in later commits.

Some here documents require the document to be a string literal,
especially when passing invalid characters.  Enclose it in single
quotes.

Signed-off-by: Jose Luis Duran <jlduran@gmail.com>
2024-09-26 12:59:56 +02:00
Jose Luis Duran
38bb6f79e3 nuageinit: Standardize user-facing error messages
Signed-off-by: Jose Luis Duran <jlduran@gmail.com>
2024-09-26 12:59:24 +02:00
Jose Luis Duran
945632ca76 nuageinit: Standardize warning/error messages
Standardize the utilities from nuage.lua, to return nil on failure, plus
an error message as a second result, and some value different from nil
on success.

Make warnmsg() and errmsg() append "nuageinit: " by default.  Pass an
optional second parameter as false to avoid printing this tag.

Signed-off-by: Jose Luis Duran <jlduran@gmail.com>
2024-09-26 12:59:14 +02:00
Jose Luis Duran
9b2d92addc nuageinit: Replace os.execute with Lua libraries
Prefer posix.sys.stat's chmod() to os.execute().  While here, change the
name of the locals to be more descriptive.

Signed-off-by: Jose Luis Duran <jlduran@gmail.com>
2024-09-26 12:59:00 +02:00
Jose Luis Duran
d71e2c037c nuageinit: Silence an fstyp(8) warning
Silence a warning emitted by fread(3) in fstyp(8)'s read_buf(), when
detecting the file system type of the cloud-init device:

    % fstyp /dev/iso9660/cidata
    fstyp: fread: Invalid argument
    cd9660

Also rephrase slightly a comment while here.

Signed-off-by: Jose Luis Duran <jlduran@gmail.com>
2024-09-26 12:58:42 +02:00
Jose Luis Duran
504981357a nuageinit: Lua check and lint files
Mostly white space, style, and luacheck compliance.

Signed-off-by: Jose Luis Duran <jlduran@gmail.com>
2024-09-26 12:58:00 +02:00
Mateusz Piotrowski
91fac46bf7 rc.d/dnctl: Chmod +x for consistency with other rc scripts
MFC after:	1 week
Approved by:	bnovkov
2024-09-22 19:24:39 +01:00
Warner Losh
f5a8f6f71a rtld: Catch up to 07d90ee0a6 in subr_prf.c: Fix '+' conversion handling
Sponsored by:		Netflix
2024-09-22 10:52:11 -06:00
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