Commit Graph

3059 Commits

Author SHA1 Message Date
Jessica Clarke
5181fe24b2 rtld-elf: Reuse _BASENAME_RTLD for debug.h rather than duplicating logic
Reviewed by:	kib, brooks, jhb
Differential Revision:	https://reviews.freebsd.org/D40919
2023-07-09 18:45:49 +01:00
Brooks Davis
f55ef85748 etc/rc.d/routing: use find_system_scripts
In 3693d9140e /etc/rc switched to using
find_system_scripts rather than directly including /etc/rc.d/* in the
list of scripts to run in order to skip .pkgsave files.  Follow suit
in etc/rc.d/routing.

Sponsored by:	DARPA
2023-07-07 23:25:11 +01:00
Dmitry Chagin
ac7759f545 rtld: Annotate .rtld_start on aarch64
1. Add a stop indicator to rtld_start to satisfy unwinders on aarch64:
The right unwinding stop indicator should be CFI-undefined PC.
https://dwarfstd.org/doc/Dwarf3.pdf - page 118:
If a Return Address register is defined in the virtual unwind table,
and its rule is undefined (for example, by DW_CFA_undefined), then
there is no return address and no call address, and the virtual
unwind of stack activations is complete.

2. Add a proper annotations for CFA.

That is allows gdb and libunwind successfully stop when unwinding stack
from global constructors and destructors.

Reviewed by:
Differential Revision:	https://reviews.freebsd.org/D40844
2023-07-07 19:55:28 +03:00
Dmitry Chagin
5645dfb41a rtld: Sligtly optimizing .rtld_start on aarch64
Use the LDP (load pair registers) instruction to load entry point
arguments from the stack.

Reviewed by:
Differential Revision:	https://reviews.freebsd.org/D40843
2023-07-07 19:55:08 +03:00
Alfonso Gregory
69c0fb2a7a Mark usage function as __dead2 in programs where it does not return
In most cases, usage does not return, so mark them as __dead2. For the
cases where they do return, they have not been marked __dead2.

Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/735
2023-07-07 10:45:17 -06:00
Eugene Grosbein
ccc806a049 dumpdev: respect kenv for stable branches
We have somewhat twisted logic to determine actions for dumpdev
considering three sources of information:

* kenv "dumpdev" tunnable supposed to point to specific device;
* /etc/defaults/rc.conf "dumpdev" variable;
* /etc/rc.conf that may be unset or set to "NO", "AUTO" or device name.

For CURRENT without any setting in kenv or /etc/rc.conf
the default is "AUTO". For STABLE branches the default is "NO".

Current implementation breaks for STABLE branches if kenv points
to specific device but /etc/rc.conf does not set "dumpdev" at all.

Let us fix it commenting out "dumpdev" in /etc/defaults/rc.conf
for STABLE branches and making the code to consult kenv
if "dumpdev" is not set elsewhere.

MFC-after:	1 month
2023-07-02 14:54:57 +07:00
Dmitry Chagin
3bdf68086d rtld: Add a stop indicator to rtld_start to satisfy unwinders on x86_64
The right unwinding stop indicator should be CFI-undefined PC.
https://dwarfstd.org/doc/Dwarf3.pdf - page 118:
If a Return Address register is defined in the virtual unwind table,
and its rule is undefined (for example, by DW_CFA_undefined), then
there is no return address and no call address, and the virtual
unwind of stack activations is complete.

That is allows gdb and libunwind successfully stop when unwinding stack
from global constructors and destructors.

Reviewed by:		kib
Differential Revision:	https://reviews.freebsd.org/D40794
2023-07-01 10:51:35 +03:00
Andrew Fengler
f81be7a831 rc.d/routing: Correct setting default gateway for each FIB
There was a mistake in the previous commit, it used the incorrect
spelling of the FIB variable name and was not functional

Also corrects an issue with the IPv6 default route variable name.

Fixes:	30659d1dcb ("Add support for adding default routes for other FIBs")
Sponsored-by:	ScaleEngine Inc.
Differential Revision:	https://reviews.freebsd.org/D37685
2023-06-26 18:43:46 +00:00
John Baldwin
38efd4df23 rtld-elf: Mark tls_init_align __unused in free_tls for Variant I TLS.
Some architectures (powerpc and RISC-V) always use 0 for the post TLS
size in which case tls_init_align isn't used by
calculate_tls_post_size.  Use __unused to quiet the warning for these
platforms.

Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D40673
2023-06-20 12:38:48 -07:00
John Baldwin
1c3424b0d2 rtld-elf: Remove set but unused variable on 32-bit arm. 2023-06-20 09:29:00 -07:00
Eugene Grosbein
79a96e294c motd: unbreak for source upgrade
In case of source upgrade path from 12.x proper merge of new /etc
installs /etc/motd.template. Becase of that, the system in left
without symlink /etc/motd -> /var/run/motd but with stale /etc/motd contents.

Fix it creating symlink despite of presence of /etc/motd.template.

MFC after:	1 week
2023-06-19 14:49:35 +07:00
Konstantin Belousov
a254f67102 rtld: fix typo in comment
Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
2023-06-10 04:35:14 +03:00
Konstantin Belousov
e9a38ed2fa rtld: fix allocate_module_tls() variant I fallback to static allocation
Submitted by:	Joerg Sonnenberger
Fixes:	91880e07f605edb90339685bc934699a4344de3bESC
MFC after:	1 week
2023-06-09 15:13:46 +03:00
Konstantin Belousov
91880e07f6 rtld: do not allow both dynamic DTV index and static TLS offset
If we are allocating static offset for an object with dynamic index,
return failure.  In the opposite case, if dynamic index is requested for
statically allocated TLS area, directly use the offset instead of
setting the index.

Taken from NetBSD Joerg Sonnenberger change for src/libexec/ld.elf_so/tls.c
rev. 1.18.

Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2023-06-05 22:33:18 +03:00
Konstantin Belousov
283a4f4097 rtld: rename tls_done to tls_static
The meaning of the flag is that static TLS allocation was done.

Taken from NetBSD Joerg Sonnenberger change for src/libexec/ld.elf_so/tls.c
rev. 1.18.

Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2023-06-05 22:33:17 +03:00
Konstantin Belousov
a7bca69492 rtld_tls.h: style
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2023-06-05 22:33:17 +03:00
Andrew Gallatin
fd96685a4a Revert "When stopping powerd, set the CPU frequency back to its maximum value"
This reverts commit 1dcb6ad173.

As of "8cb16fdbea6b Restore original frequency on exit.", powerd
restores the original frequency itself.

Further, if the original frequency is not the same as the
first frequency found in the frequency list, then the restoration
done by the powerd_poststop will restore the wrong frequency.
This can happen on Intel machines where Turbo is not enabled,
but the turbo frequency is first in the list of frequencies.
In this case, turbo will be enabled when the user did not want
it to be.

Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D40197
Reviewed by: imp, mav
2023-05-25 09:40:26 -04:00
Christos Margiolis
7900879eec rc.resume: remove obsolete comment
Reviewed by:	markj
Approved by:	markj (mentor)
Differential Revision:	https://reviews.freebsd.org/D40235
2023-05-23 18:26:56 +03:00
Johannes Totz
2cf8ef5910 rc.suspend: execute rc-scripts with suspend keyword
For symmetry with rc.resume, give rc.suspend the ability to execute
rc-scripts. Use the suspend keyword for that.

Use-case is for setting a wake-up time, e.g. via efiwake.

Reviewed by:	christos
Approved by:	markj (mentor)
Differential Revision:	https://reviews.freebsd.org/D39965
2023-05-23 18:11:31 +03:00
Xin LI
634a770a5e /etc/rc.d/motd: Update to accommodate changes in uname(1) and newvers.sh
The recent changes to the uname(1) command removed trailing spaces for
better POSIX conformance, but it broke the regular expression used by
the motd script which expected it.  This commit addresses this by removing
the requirement, as it is no longer present.

Additionally, a recent change in newvers.sh introduced a new format for
uname -v, which omited the build number and build dates to improve
reproducible build support.  This commit adds support for this new format.

Reported-by:	Jamie Landeg-Jones <jamie@catflap.org>
Reviewed-by:	imp
MFC after:	2 weeks
Differential Revision: https://reviews.freebsd.org/D40225
2023-05-22 22:05:35 -07:00
Colin Percival
dc5361ea16 rc.d/netif: Don't DAD if lo0 is the only IPv6 IF
The code in rc.d/netif waiting for IPv6 Duplicate Address Detection if
any network interfaces support IPv6.  Unfortunately, since lo0 *always*
has IPv6 enabled, this means unconditionally sleeping, even on systems
which have no external IPv6 interfaces.

Since we presume that there is little risk of a duplicate address being
assigned on lo0, amend the test to wait only if there is an interface
*other than lo0* which supports IPv6.

Reviewed by:	bz
Differential Revision:	https://reviews.freebsd.org/D40141
2023-05-18 08:20:15 -07:00
Peter Wright
d904b43ba3 dma: install a simple example for the auth.conf file
PR:		270088
MFC After:	3 days
2023-05-15 09:20:14 +02:00
Enji Cooper
46f35bf28d rc.subr(8): delete debug cpuset helper
Summary:
The intention of the original author (I assume) was to add this logic
for testing. This removes the debug statement so it no longer shows up
in calls to `status`.

MFC after:	2 weeks
MFC with:	0661f9389

Reviewers: kevans

Subscribers: imp

Differential Revision: https://reviews.freebsd.org/D40055
2023-05-12 19:50:00 -07:00
Warner Losh
b61a573019 spdx: The BSD-2-Clause-NetBSD identifier is obsolete, drop -NetBSD
The SPDX folks have obsoleted the BSD-2-Clause-NetBSD identifier. Catch
up to that fact and revert to their recommended match of BSD-2-Clause.

Discussed with:		pfg
MFC After:		3 days
Sponsored by:		Netflix
2023-05-12 10:44:04 -06:00
Warner Losh
4d846d260e spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSD
The SPDX folks have obsoleted the BSD-2-Clause-FreeBSD identifier. Catch
up to that fact and revert to their recommended match of BSD-2-Clause.

Discussed with:		pfg
MFC After:		3 days
Sponsored by:		Netflix
2023-05-12 10:44:03 -06:00
Pierre Pronchery
bdf6dee2a9 dma: specify OpenSSL 1.1 API
Reviewed by:	emaste
Sponsored by:	The FreeBSD Foundation
2023-05-11 19:03:34 -04:00
Enji Cooper
4e9041a786 rc.subr(8): run trailing-whitespace-fixer
This change deletes benign trailing whitespace from rc.subr, making
future non-stylistic changes easier to spot.

MFC after:	1 week
2023-05-10 22:39:32 -07:00
Miroslav Lachman
0661f93892 rc: add support for cpuset(1)
If ${name}_cpuset is specified (and /usr is mounted), cpuset(1) will be
run to limit the service to the configured cpuset.

PR:		142434
Reviewed by:	kevans
2023-05-10 23:40:18 -05:00
Ed Maste
ec1e83782d rtld: don't add extraneous -L directory when MK_TOOLCHAIN == no
rtld's Makefile used to add -L${LIBDIR} to LDFLAGS when MK_TOOLCHAIN was
no.  This was done as part of a change to fix building rtld with
MK_TOOLCHAIN == no (although I'm not sure this part was necessary).

In any case as of 5f2e84015d libc_pic.a is built independent of the
MK_TOOLCHAIN setting and the main part of the workaround has already
been removed.  Remove the rest now.

This reverts commit c0f5aeb032.

Reviewed by:	jrtc27
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D39938
2023-05-02 18:01:43 -04:00
Warner Losh
0c4183f02e rc.d/zfsbe: Simplify
So $(foo) is a shorter version of "`foo`".

Sponsored by:		Netflix
Differential Revision:	https://reviews.freebsd.org/D39413
2023-05-01 15:02:53 -06:00
Colin Percival
df53ae0fdd Remove portsnap(8)
Rather than having a tool in the FreeBSD base system for obtaining
the FreeBSD ports tree, users are encouraged to `pkg install git`
and then `git clone https://git.FreeBSD.org/ports.git /usr/ports`.

The portsnap servers will continue operating until FreeBSD 13 reaches
its End-of-Life, and portsnap is available from the ports tree as
ports-mgmt/portsnap.

Requested by:	portmgr
Relnotes:	yes
Differential Revision:	https://reviews.freebsd.org/D39563
X-MFC:		no
2023-04-22 18:12:37 -07:00
Bjoern A. Zeeb
de1dde5dfe network.subr: adjust regex for wlans_xxxxx rc.conf entries
Drivers like ath1[012]k will not match the current wlans_*-regex as
they have digits followed by letters.  Adjust the regex to allow
this combination in order to be able to configure interfaces with
names like wlans_ath11k0="..."

MFC after:	3 days
Reviewed by:	emaste
Differential Revision: https://reviews.freebsd.org/D39674
2023-04-20 14:30:42 +00:00
Simon J. Gerraty
d9a4274795 Update/fix Makefile.depend for userland 2023-04-18 17:14:23 -07:00
John Baldwin
eae7dd0f22 rbootd: Remove an unnecessary (and incomplete) function prototype.
Reviewed by:	emaste
Differential Revision:	https://reviews.freebsd.org/D39522
2023-04-18 11:22:08 -07:00
John Baldwin
e4253ae822 rpc.rstatd/rwalld: Use more accurate function pointer types.
Reviewed by:	zlei, rmacklem
Differential Revision:	https://reviews.freebsd.org/D39521
2023-04-18 11:21:50 -07:00
John Baldwin
8b356c8881 bootpd: Use C89 function definitions.
Trim a few duplicate (but incomplete) function prototypes as well.

Reviewed by:	emaste
Differential Revision:	https://reviews.freebsd.org/D39520
2023-04-18 11:21:15 -07:00
John Baldwin
525438ea71 sendmail: Silence -Wdeprecated-non-prototype warnings.
These will hopefully be fixed upstream eventually, but silence the
warnings until then.

Reviewed by:	emaste
Differential Revision:	https://reviews.freebsd.org/D39518
2023-04-18 11:19:48 -07:00
Konstantin Belousov
7cdfe51f30 rtld: fixes for handling of the grouped options
Do not terminate scanning group when 'd' is encountered.
The 'b' option must be last in the group, same as 'f'.

Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D39544
2023-04-13 17:37:33 +03:00
Ed Maste
29e3a06510 rtld: fix SysV hash function overflow
Quoting from https://maskray.me/blog/2023-04-12-elf-hash-function:

The System V Application Binary Interface (generic ABI) specifies the
ELF object file format. When producing an output executable or shared
object needing a dynamic symbol table (.dynsym), a linker generates a
.hash section with type SHT_HASH to hold a symbol hash table. A DT_HASH
tag is produced to hold the address of .hash.

The function is supposed to return a value no larger than 0x0fffffff.
Unfortunately, there is a bug. When unsigned long consists of more than
32 bits, the return value may be larger than UINT32_MAX. For instance,
elf_hash((const unsigned char *)"\xff\x0f\x0f\x0f\x0f\x0f\x12") returns
0x100000002, which is clearly unintended, as the function should behave
the same way regardless of whether long represents a 32-bit integer or
a 64-bit integer.

Reviewed by:	kib, Fangrui Song
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D39517
2023-04-12 12:44:34 -04:00
Ed Maste
87443cb6c6 rtld: reindent and style(9) elf_hash()
In preparation for an upcoming change (D39517).

Sponsored by:	The FreeBSD Foundation
2023-04-12 12:43:36 -04:00
John Baldwin
7d8e1e8dd9 libcasper: Move helper libraries from /lib/casper to /lib.
These libraries are linked to directly by applications rather than
opened at runtime via dlopen().

Discussed with:	oshogbo
Reviewed by:	markj, emaste
Differential Revision:	https://reviews.freebsd.org/D39245
2023-03-29 15:04:28 -07:00
John Baldwin
3ba927fdc4 rc.d/ldconfig: Remove mips64 check for ldconfig32. 2023-03-29 10:20:03 -07:00
Cy Schubert
052211e08c rc: Chase bfb202c455 and remove ifconfig down/up for wpa_supplicant
bfb202c455 addresses the CTRL-EVENT-SCAN-FAILED. Upstream d807e289d
caused FreeBSD regression in driver_bsd.c, which this rc.d patch
worked around. As of bfb202c455 this workaround is no longer needed.

Reviewed by:	bz (for wireless)
MFC after:	10 days
X-MFC with:	bfb202c455
Differential Revision:	https://reviews.freebsd.org/D39257
2023-03-24 10:07:29 -07:00
Mina Galić
3693d9140e rc: ignore .pkgsave files
The local parts of rc already skip .sample files; we add .pkgsave to the
list, and add logic for base.

Thanks to @RhodiumToad for getting this started.

Differential Revision: https://reviews.freebsd.org/D27962
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/662
2023-03-14 20:52:15 -06:00
Rick Macklem
0bb08f21cc rc.d: Fix NFS server startup scripts to enable vnet prison use
Now that commit cbbb22031f is in main,
it is possible to run nfsd(8), nfsuserd(8), mountd(8),
gssd(8) and rpc.tlsservd(8) in an appropriately configured vnet
prison if the "allow.nfsd" option is specified in jail.conf.

This patch fixes the rc scripts for this.
Mostly just replaces the "nojail" KEYWORD with "nojailvnet",
but also avoids setting vfs.nfsd.srvmaxio in a prison, since it
must be set outside of the prisons and applies to all
nfsd(8) instances.

Reviewed by:	jamie
MFC after:	3 months
Differential Revision:	https://reviews.freebsd.org/D38809
2023-03-12 14:34:25 -07:00
Dag-Erling Smørgrav
1955ad42b3 tftpd: Gracefully skip tests if networking is not enabled.
Sponsored by:	Klara, Inc.
Reviewed by:	asomers
Differential Revision:	https://reviews.freebsd.org/D39012
2023-03-10 13:25:16 +00:00
Dag-Erling Smørgrav
77e83935b7 tftpd: Don't forget to close stderr on startup.
Just like stdin and stdout, stderr is a copy of the listen socket inherited from inetd.  We need to close it so inetd can process further requests, be restarted, etc.

Sponsored by:	Klara, Inc.
Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D38968
2023-03-10 13:25:16 +00:00
Dag-Erling Smørgrav
b4736c90ad tftpd: Don't consume arbitrary requests when failing to fork.
We've already consumed one request, which is sufficient to prevent inetd from endlessly restarting us in this particular and extremely unlikely case.

Sponsored by:	Klara, Inc.
Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D38967
2023-03-10 13:25:16 +00:00
Dag-Erling Smørgrav
e3b4cb1b32 tftpd: Use poll() instead of alarm() + setjmp().
While there, don't log an error when timing out waiting for a possible retransmit after a successful transfer.

Sponsored by:	Klara, Inc.
Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D38966
2023-03-10 13:25:16 +00:00
Dag-Erling Smørgrav
9f6f64941c tftpd: Make the -d option behave as documented.
Sponsored by:	Klara, Inc.
Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D38965
2023-03-10 13:25:16 +00:00
Dag-Erling Smørgrav
36242fc0e5 tftpd: Make the transfer functions return success / failure.
Sponsored by:	Klara, Inc.
Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D38957
2023-03-10 13:25:16 +00:00
Dag-Erling Smørgrav
7c21545c46 tftpd: Ensure that tftp_log() preserves errno.
Sponsored by:	Klara, Inc.
Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D38956
2023-03-10 13:25:16 +00:00
Dag-Erling Smørgrav
a6dfd2015c tftpd: Fix max block size calculation.
Sponsored by:	Klara, Inc.
Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D38953
2023-03-10 13:25:15 +00:00
Ceri Davies
efa3c0af37 rc.conf: update comment referring to /etc/motd 2023-03-09 21:28:30 +00:00
Tijl Coosemans
ecad3f5c4d rc.d: Generate machine-id from hostid_save
rc.d/hostid_save saves a UUID generated by rc.d/hostid in /etc/hostid.
Store the same UUID, without hyphens, in /etc/machine-id.  The hypĥens
are removed with a shell function because hostid_save runs before file
systems are mounted so other tools may not be available yet.

This eliminates some duplication between hostid and machine-id and for
virtual machines machine-id now contains the UUID configured in the
hypervisor like it does on Linux.

Reviewed by:	delphij
Discussed with:	bapt
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D38811
2023-03-09 10:31:55 +01:00
Tijl Coosemans
862aab6281 hostid: Generate random UUID by default
This way MAC addresses are no longer exposed.

Discussed with:	bapt
MFC after:	3 days
2023-03-09 10:31:39 +01:00
Baptiste Daroussin
a28ccb32bf machine-id: generate a compact version of the uuid
dbus and other actually expect an uuid without hyphens

Reported by:	tijl
MFC After:	3 days
2023-03-01 19:16:25 +01:00
Tom Hukins
0f994a19e2 rc.conf(5): describe what unbound(8) does
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/650
2023-02-28 09:36:17 -07:00
Mike Karels
eef9f9900f growfs_fstab startup script: set dumpdev to AUTO
The growfs_fstab script has been testing dumpdev, and if it is AUTO,
enables dumps on the newly-added swap device for the initial boot.
However, dumpdev defaults to AUTO on main, but NO on stable/13 and
release branches.  On the other hand, bsdinstall adds dumpdev="AUTO"
by default (controlled by a menu item).  bsdinstall is not used when
booting an SD card or other disk image.  Adopt the default from
bsdinstall, and set dumpdev to AUTO in /etc/rc.conf in the
growfs_fstab script if a swap partition has been added, along with
the explanatory comment added by bsdinstall.

Differential Revision:	https://reviews.freebsd.org/D38751
2023-02-28 07:55:35 -06:00
Konstantin Belousov
5942b4b6fd sys/param.h: Add _WANT_P_OSREL
Use it instead of defining IN_RTLD by base sources that want P_OSREL_
defines in userspace, but are not rtld.
This allows to remove abuse of IN_RTLD from userspace.

Reviewed by:	dchagin, markj, imp
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D38585
2023-02-15 02:43:18 +02:00
Xin LI
39e8c2a29a cleanvar: Be more careful when cleaning up /var.
The cleanvar script uses find -delete to remove stale files under /var,
which could lead to unwanted removal of files in some unusual scenarios.
For example, when a mounted fdescfs(5) is present under /var/run/samba/fd,
find(1) could descend into a directory that is out of /var/run and remove
files that should not be removed.

To mitigate this, modify the script to use find -x, which restricts the
find scope to one file system only instead of descending into mounted
file systems.

PR:		269213
MFC after:	1 week
2023-02-12 20:56:17 -08:00
Emmanuel Vadot
3662862f55 rc: syscons: Add UEFI special case
Changing cursor, screenmap and setting blanktime doesn't work when booted
with vt(4) and UEFI so add a special case for those depending on machdep.bootmethods.
I have no way to test if this can work with vt(4) and bios boot so just in case
keep calling those for this.

Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D38293
2023-02-08 08:53:20 +01:00
Emmanuel Vadot
eac920e670 utx: Allow disabling user accounting
Make it possible to not run utx at boot.
Default to yes so this is a no-op for everyone.

Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D38292
2023-02-08 08:52:54 +01:00
Emmanuel Vadot
cab549c76c pkgbase: Create a FreeBSD-console-tools package
And put in it:
 - kbdcontrol
 - vidcontrol
 - moused
 - kbdmap

Those aren't useful in a jail or for a modern desktop.
While here, split the devd.conf part into some new files.

Reviewed by:	bapt
Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D38321
2023-02-08 08:52:40 +01:00
Warner Losh
f051d72314 hyperv: Build and install where supported
Remove the hard-coded dependency on HYPERV being only x86. Instead, 100%
rely on MK_HYPERV. It's always right (since it's marked BROKEN (so set
to "no") on architectures we don't support).

Sponsored by:		Netflix
Reviewed by:		bz
Differential Revision:	https://reviews.freebsd.org/D38306
2023-02-01 10:21:57 -07:00
Emmanuel Vadot
cc9b2b58e2 Revert "rc.d: Put growfs script in FreeBSD-ufs"
The growfs script also support zfs.

This reverts commit 36a7fa1e16.

Reported by:	emaste, Mina Galić
2023-01-27 11:30:24 +01:00
Emmanuel Vadot
a6a21bbedc rc.d: Put resolv script in FreeBSD-resolvconf
Differential Revision:	https://reviews.freebsd.org/D37190
2023-01-27 10:35:32 +01:00
Emmanuel Vadot
36a7fa1e16 rc.d: Put growfs script in FreeBSD-ufs
Differential Revision:	https://reviews.freebsd.org/D37189
2023-01-27 10:35:32 +01:00
Emmanuel Vadot
91314ca2ff rc.d: Put ggated script in FreeBSD-ggate
Differential Revision:	https://reviews.freebsd.org/D37188
2023-01-27 10:35:32 +01:00
Emmanuel Vadot
81b18bea09 rc.d: Put dhclient script in FreeBSD-dhclient
Differential Revision:	https://reviews.freebsd.org/D37187
2023-01-27 10:35:32 +01:00
Emmanuel Vadot
d8799160c2 rc.d: Put devmatch script in FreeBSD-devmatch
Differential Revision:	https://reviews.freebsd.org/D37192
2023-01-27 10:35:32 +01:00
Emmanuel Vadot
f043569692 rc.d: Put devd script in FreeBSD-devd package
Differential Revision:	https://reviews.freebsd.org/D37186
2023-01-27 10:35:32 +01:00
Gordon Bergling
30985d19b0 rc.initdiskless: Fix a typo in a comment
- s/attemping/attempting/

MFC after:5 days
2023-01-19 14:17:37 +01:00
Ed Maste
45396fda8b dma: dma.conf.5 as MLINK to dma.8
There's no separate man page for dma.conf, but the format is documented
in dma.8.

Reviewed by:	bapt
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D37944
2023-01-06 09:40:45 -05:00
John Baldwin
b069d3e019 rtld: Revert "When loading dso without PT_GNU_STACK phdr, only call"
After the removal of ia64 and sparc64, all current architectures
support executable stacks at an architectural level.

This reverts commit 1290d38ac5.

Reviewed by:	kib
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D37904
2023-01-04 14:55:00 -08:00
Mike Karels
0e2fdab227 growfs script: fix config-dependent errors
- awk sometimes formatted swapbase as floating point, which gpart
  does not accept; force int.

- Fix typo in code for checking vm.max_swap_pages.

- While here, do not set kernel env if "gpart add" fails.

- Add "gpart show" before modification to verbose output.

Reported by:	marklmi at yahoo dot com
Tested by:	marklmi at yahoo dot com
2023-01-04 14:05:35 -06:00
Cy Schubert
e3e57edf4a network.subr: Fix infinite loop
When setting up carp tunnel, using a password consisting of only the
characters used as hexadecimal characters, i.e. abc-def, there will be
an infinite loop in the shell function ifalias_af_common_handler().
To circumvent this we test for " pass ".

PR:		268378
Reported by:	jyoung15@gmail.com
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D37748
2023-01-02 10:20:05 -08:00
Cy Schubert
87061d3bff network.subr: Add missing brace
PR:		268378
Submitted by:	jyoung15@gmail.com
Reported by:	jyoung15@gmail.com
MFC after:	3 days
2023-01-02 10:20:05 -08:00
Cy Schubert
fef0e429f1 network.subr: Replace "\ " with "[[:space:]]"
"[[:space:]]" is easier to read than "\ " and is conisitent with
clone_up().

Reported by:	eugen
MFC after:	1 month
Differential Revision:	https://reviews.freebsd.org/D37748
2023-01-02 10:20:05 -08:00
David E. O'Brien
96c6fba6fd rc.subr: Minor formatting fix for ac102a2a6 2022-12-28 16:00:56 -08:00
Jose Luis Duran
058ac3e806 atf_pytest_wrapper: fix pytest output truncation
Pass `-vv` to pytest in order to always get the full output.
While here, enforce the modeline.

Differential Revision: https://reviews.freebsd.org/D37894
MFC after:	2 weeks
2022-12-28 17:31:14 +00:00
Mike Karels
4c8a257810 growfs script: fixes
Cannot use single quote in comment in awk script;
add growfs_fstab to Makefile

Fixes:		4a30d7bb373c,d670a8f7c596
2022-12-26 08:51:09 -06:00
Tobias C. Berner
62a149bf62 Add new rc: machine_id to generate /etc/machine-id
This new default-enabled rc will generate a /etc/machine-id file if it
does not exist, and pre-fill it with a newly generated UUID of version 4
[2].

The file is generated in /var/db/machine-id and symlinked to
/etc/machine-id to allow for read-only root partitions.

This file is amongst other things used by libraries like GLib.

Bump FreeBSD version 1400076 to be able to easily add support for older
version of FreeBSD via a package.

[1] Linux machine-id(5): https://www.man7.org/linux/man-pages/man5/machine-id.5.html
[2] f176fe8e7f

Approved by:		bapt
MFC after:		1 week
Differential Revision:	https://reviews.freebsd.org/D37722
2022-12-23 17:33:19 +01:00
Mike Karels
b939fe5ff1 dma mailer.conf: add comments, including pointer for sendmail
Add comments analogous to those that are in the sendmail mailer.conf,
including a pointer to /usr/share/examples/sendmail/mailer.conf.

Reviewed by:	bapt
Differential Revision:	https://reviews.freebsd.org/D37711
2022-12-16 09:12:39 -06:00
Mike Karels
af01b47225 default rc.conf: Add new growfs_swap_size variable
Add new growfs_swap_size variable with a default value of the empty
string, along with comments on other settings.  Used by the growfs
script.

Differential Revision:	https://reviews.freebsd.org/D37464
2022-12-10 13:40:33 -06:00
Mike Karels
d670a8f7c5 growfs_fstab: add new /etc/rc.d script to add swap to fstab
The growfs_fstab script is a helper for the growfs script to add any
new swap partition to /etc/fstab on first boot.  If growfs adds a
swap partition, it sets growfs_swap_pdev in the kenv.   In this case,
after the root file system is read/write, if there is no swap partition
in the fstab, growfs_fstab adds growfs_swap as a swap partition to the
fstab.  Also, it runs dumpon to add the swap partition  (as this
happened earlier in the startup sequence).

Discussed with:	cperciva
Differential Revision:	https://reviews.freebsd.org/D37463
2022-12-10 13:39:59 -06:00
Mike Karels
4a30d7bb37 growfs script: add swap partition as well as growing root
Add the ability to create a swap partition in the course of growing
the root file system on first boot, enabling by default.  The default
rules are: add swap if the disk is at least 15 GB (decimal), and the
existing root is less than 40% of the disk.  The default size is 10%
of the disk, but is limited by the memory size.  The limit is twice
memory size up to 4 GB, 8 GB up to 8 GB memory, and memory size over
8 GB memory. Swap size is clamped at vm.swap_maxpages/2 as well.
The new swap partition is labeled as "growfs_swap".

The default behavior can be overridden by setting growfs_swap_size in
/etc/rc.conf or in the kernel environment, with kenv taking priority.
A value of 0 inhibits the addition of swap, an empty value specifies
the default, and other values indicate a swap size in bytes.

By default, addition of swap is inhibited if a swap partition is found
in the output of the sysctl kern.geom.conftxt before the current root
partition, usually meaning that there is another disk present.
Swap space is not added if one is already present in /etc/fstab.

The root partition is read-only when growfs runs, so /etc/fstab can
not be modified.  That step is handled by a new growfs_fstab script,
added in a separate commit.  Set the value "growfs_swap_pdev" in kenv
to indicate that this should be done, as well as for internal use.

There is optional verbose output meant for debugging; it can only be
enabled by modifying the script (in two places, for sh and awk).
This should be removed before release, after testing on -current.

Discussed with:	cperciva
Reviewed by:	imp (previous version)
Differential Revision:	https://reviews.freebsd.org/D37462
2022-12-10 13:38:36 -06:00
Baptiste Daroussin
d525abd277 dma(8): add newaliases to mailer.conf
Reported by:	karels
MFC After:	3 days
2022-12-06 08:31:23 +01:00
Baptiste Daroussin
9eb502a337 sendmail: revert to use use NONE
The NONE parameter has been deprecated for more than 20 years
but was never removed, its useful to simplify the sendmail
management.

This reverts commit 7cadc52638.
2022-12-05 17:23:08 +01:00
John Baldwin
42fb28cef4 Explicitly set CXXSTD to c++11 for old C++ code using std::auto_ptr<>.
GCC 12 defaults to C++17 which removes (not just deprecates)
std::auto_ptr<>.  Trying to use CXXSTD of c++03 doesn't work with
libc++ headers, but c++11 does.

Reviewed by:	brooks, imp, emaste
Differential Revision:	https://reviews.freebsd.org/D37531
2022-12-04 16:25:21 -08:00
Baptiste Daroussin
280f11f1be flua: chown(2) binding, fix bad copy/paste 2022-11-25 09:05:40 +01:00
Baptiste Daroussin
a1ab15abe2 flua: add a chown(2) binding
The main difference with the chown in luaposix, is that it checks
and reports if a user or a group do exist when a string is passed
as arguments

Reviewed by:	kevans
Differential Revision:	https://reviews.freebsd.org/D37479
2022-11-25 08:49:58 +01:00
John Baldwin
fd5882e1f2 tftpd: Disable -Wformat-nonliteral for GCC.
GCC warns about the non-literal format string passed to strftime().  A
warning here seems a bit odd as strftime() does not take varargs so
there is not a risk of missing args.
2022-11-22 11:12:06 -08:00
John Baldwin
8576f84bc1 tftp: Use printf0 attribute for options_set_request/reply.
These functions accept a NULL format argument so should use the printf0
attribute rather than plain printf.

Reported by:	GCC -Wformat
2022-11-22 08:37:26 -08:00
Goran Mekic
1ffc369aa3 Add dnctl rc.d service
As PF now also supports dummynet but can not configure it on its own,
the service which configures pipes, queues and schedulers is needed.

Reviewed by:	kp
Differential Revision:	https://reviews.freebsd.org/D37451
2022-11-22 10:46:19 +01:00
Dag-Erling Smørgrav
cf325fda86 tftpd: type nit
Sponsored by:	Klara, Inc.
2022-11-18 17:26:54 +01:00
Dag-Erling Smørgrav
b15e052e74 tftpd: Plug memory leaks in option handling code.
Sponsored by:	Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D37423
2022-11-18 16:39:44 +01:00
Dag-Erling Smørgrav
bacb00ab40 tftpd: whitespace cleanup 2022-11-17 16:42:30 +00:00
Dag-Erling Smørgrav
eb0292d929 tftpd: cleanup
Sponsored by:	Klara, Inc.
2022-11-15 23:37:54 +01:00
Baptiste Daroussin
616f32ea6d othermta: remove leftover from 20 years ago
othermta (along with mta_start_script configuration entry in rc.conf)
was a mechanism used to be able to run another mta than sendmail(8) before
"rcng" time 20 years ago.

othermta has not been used since.
2022-11-14 09:08:37 +01:00
Konstantin Belousov
8cc44a1e59 rtld: add support for the $LIB token
similar to the same token in glibc.

Requested and reviewed by:	bapt
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D37329
2022-11-11 12:06:30 +02:00
Baptiste Daroussin
0b1adc42a1 rc.sendmail: remove unused script
20 years ago the use of rc.sendmail script was dropped in favor
of /etc/rc.d/sendmail, it is time to retire the script entirely
now.

MFC after:	1 week
2022-11-09 16:55:18 +01:00
Jose Luis Duran
c7c9836853 sendmail: Add back a comment about "NONE"
Differential Revision:	https://reviews.freebsd.org/D37315
2022-11-09 16:54:34 +01:00
Baptiste Daroussin
7cadc52638 sendmail: do not use NONE
NONE is deprecated, instead of using NONE, switch to "NO" all
the sendmail_*_enable which sendmail_enable=NONE would have done
2022-11-09 15:20:30 +01:00
Baptiste Daroussin
b7104f1914 sendmail: document that sendmail_enable can be set to NONE
setting sendmail_enable to NONE (which is now the default)
turns all the sendmail_*_enable variables to NO

Reported by:	many
2022-11-08 14:39:27 +01:00
Baptiste Daroussin
a67b925ff3 mail: make The Dragonfly Mail Agent (dma) the default mta.
dma accepts mail from a local Mail User Agent (MUA) and delivers it
locally or to a smarthost for delivery. dma does not accept inbound
mail (i.e., it does not listen on port 25) and is not intended to
provide the same functionality as a full MTA like postfix or sendmail.
It is intended for use cases such as delivering cron(8) mail. which
is the default configuration and usage of sendmail in the default
setup of the base system.

In order to switch the default from sendmail to dma, we teach
mailwrapper to fallback on dma directly if the mailer.conf file cannot
be opened.
We install by default a mailer.conf file which points at dma
We install a mailer.conf file for sendmail in the examples.

Relnotes:	yes
Differential Revision:	https://reviews.freebsd.org/D37035
2022-11-07 12:49:56 +01:00
Li-Wen Hsu
72a1cb05cd
rc(8): Add a zpoolupgrade rc.d script
If a zpool is created by makefs(8), its version is 5000, i.e., all
feature flags are off.  Introduce an rc script to run `zpool upgrade`
over the assigned zpools on the first boot.  This is useful to the
ZFS based VM images built from release(7).

Reviewed by:	imp, markj, mav
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D37282
2022-11-07 11:30:09 +08:00
Dag-Erling Smørgrav
eb4d86d529 getty: Avoid NULL deref if stdin is not a tty.
Sponsored by:	Klara, Inc.
Obtained from:	Apple OSS Distributions
Differential Revision: https://reviews.freebsd.org/D37265
2022-11-04 15:54:01 +01:00
Dag-Erling Smørgrav
f285f41498 getty: code cleanup, part 2
* Clean up whitespace
* Reindent

Sponsored by:	Klara, Inc.
2022-11-04 15:22:04 +01:00
Dag-Erling Smørgrav
8ad7a14ab4 getty: code cleanup, part 1
* Avoid unnecessary use of `unsigned char *`
* Use explicit casts when assigning `unsigned char *` to `char *` or vice versa
* Drop unused global variables (and fix memory leak in `gettable()`)
* Use `snprintf()` instead of `strcpy()` + `strcat()`
* Drop spurious braces in switch

Sponsored by:	Klara, Inc.
Obtained from:	Apple OSS Distributions (in part)
Differential Revision: https://reviews.freebsd.org/D37263
2022-11-04 15:19:27 +01:00
Konstantin Belousov
f585d13dd6 rtld: remove unused macro FPTR_TARGET
It is a remnant from the ia64 removal

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
2022-10-22 05:15:06 +03:00
Konstantin Belousov
ca2560bd85 rtld: fix typo in comment
Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
2022-10-17 17:10:03 +03:00
Dag-Erling Smørgrav
0aa2700123 Put OPIE to rest.
Differential Revision: https://reviews.freebsd.org/D36592
2022-10-02 03:37:29 +02:00
Brooks Davis
b4cfdbfed2 manpages: Remove telnetd references
Mostly remove from the SEE ALSO section, adding a mention of the port
where not removed. Elsewhere, remove as appropriate and change from .Xr
to .Nm where a mention of telnetd continues to make sense (or removing
it would require significant reworking of the surrounding text).

Reviewed by:	imp, delphij, emaste
Differential Revision:	https://reviews.freebsd.org/D36785
2022-09-29 17:56:41 +01:00
Brooks Davis
0eea46fb1f Remove telnetd
The telnetd codebase is unmaintained and has a number of quality
issues. Telnet has been largely supplanted by ssh. If needed, a port is
available (net/freebsd-telnetd), but a more maintained implementation
should be prefered.

While the telnet client suffers from the same issues, it is deemed
to be of lower risk and is required to connect to legacy devices, so
it remains.

Reviewed by:	emaste, imp
Differential Revision:	https://reviews.freebsd.org/D36620
2022-09-28 19:53:49 +01:00
Konstantin Belousov
2f72ee987d ldd: remove '[preloaded]' marker for the preloaded objects
for the default output.  For '-a' (per-object needed printout) the
[preloaded] banner is kept.

Instead, use special format2 for printing the preloaded objects (and
vdso), which does not include DT_NEEDED, since there is no object
needing the printed one.

In this way, the output is more compatible with glibc.

Example:
LD_PRELOAD=/lib/libthr.so.3 LD_TRACE_LOADED_OBJECTS=1 /libexec/ld-elf.so.1 /bin/ls
        libutil.so.9 => /lib/libutil.so.9 (0x801099000)
        libncursesw.so.9 => /lib/libncursesw.so.9 (0x8010b0000)
        libc.so.7 => /lib/libc.so.7 (0x801123000)
        [vdso] (0x7ffffffff000)
        /lib/libthr.so.3 (0x80106c000)
Note the absense of the part before and including '=>' for preloaded
libthr.so.3, and for vdso.

PR:	265750
Reviewed by:	jhb
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D36616
2022-09-22 14:20:13 +03:00
Cy Schubert
b77b309968 rc.d/var_run: Add needed "shutdown" keyword
The "shutdown" keyword invokes rcorder with the -k flag, for rc scripts
with the keyword at shutdown.

Reported by:	bdrewery
Fixes:		27b9777c28
MFC after:	3 days
Differential Revision:
2022-09-20 11:44:11 -07:00
Konstantin Belousov
1251cf8a30 rtld-elf/libmap.c: correct comment
There is no intent to support TLS for rtld.

Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2022-09-19 01:49:41 +03:00
Konstantin Belousov
1fd4dec26e rtld-elf/libmap.h: style declarations
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2022-09-19 01:49:41 +03:00
Konstantin Belousov
3aed5ddb8b rtld-elf/libmap.h: add include guard
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2022-09-19 01:49:41 +03:00
Konstantin Belousov
daa85548d5 rtld: teach LD_SHOW_AUXV about AT_USRSTACK*
Reviewed by:	brooks, imp (previous version)
Discussed with:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	2 weeks
Differential revision:	https://reviews.freebsd.org/D36540
2022-09-16 23:24:18 +03:00
Gordon Bergling
4732904942 bootptest: Fix a typo in a source code comment
- s/avaible/available/

MFC after:	3 days
2022-09-15 10:28:52 +02:00
Cy Schubert
27b9777c28 libexec/rc: Add var_run rc script
Users with a tmpfs /var/run will lose the directory tree state of
/var/run at reboot. This rc script will optionally (by default)
capture the state of the directory structure in /var/run prior to
shutdown and recreate it at system boot.

Alternatively a user can save the state of the /var/run directories
manually using service var_run save and disable the autosaving of
/var/run state using the var_run_autosave variable, for those
paranoid SSD users.

PR:			259585, 259699
Reported by:		freebsd@walstatt-de.de,
Reviewed by:		philip, gbe (previous version)
MFC after:		1 week
Differential Revision:	https://reviews.freebsd.org/D36386
2022-09-05 06:19:42 -07:00
Gordon Bergling
7ed279f58f ntpd(8): Correct a typo in comment of the rc script
- s/the the/the/

MFC after:	3 days
2022-09-04 13:02:21 +02:00
Konstantin Belousov
832b40f7ff rtld.c: remove extra blank line
Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	2 weeks
Differential revision:	https://reviews.freebsd.org/D36396
2022-09-04 07:28:02 +03:00
Konstantin Belousov
7444f54bd3 rtld: style the rest of rtld_lock.c
Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	2 weeks
Differential revision:	https://reviews.freebsd.org/D36396
2022-09-04 07:28:02 +03:00
Konstantin Belousov
a687683b99 rtld: mask signals for default read locks
Rtld locks from libthr defer signals delivery, which means that binding
is not possible while a signal handler is executed.

Binding might upgrade read-locked rtld_bind_lock to write-lock, if
symbol resolution requires loading filters.  If a signal would be delivered
while rtld is in read-locked section, and signal handler needs binding
which upgrades the lock, for non-threaded image that uses default rtld
locks, we get the rtld data structures modified under the top-level
active rtld frame.

To correct the problem, mask signals for read-locking of default locks
in addition to the write-locking.  It is very cheap now with
sigfastblock(2).

Note that the global state is used to track pre-locked state of either
sigfastblock(2) or signal mask (if sigfastblock(2) is administratively
disabled).  It is fine for non-threaded images since there are no other
threads.  But I believe that it is fine for threaded images using libc_r
as well, since masking signals disables preemption (I did not tested
it).

NetBSD PR:	https://gnats.netbsd.org/56979
Reported by:	tmunro
Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	2 weeks
Differential revision:	https://reviews.freebsd.org/D36396
2022-09-04 07:28:02 +03:00
Gordon Bergling
3576233cd3 rtld(1): Fix a typo in a source code comment
- s/interger/integer/

MFC after:	3 days
2022-09-03 19:16:32 +02:00
Gordon Bergling
0a81527da8 rc.conf: Fix a typo in a comment
- s/overriden/overridden/

MFC after:	3 days
2022-09-03 14:57:39 +02:00
Bjoern A. Zeeb
e196317370 local_unbound: rc: allow to overwrite pid file path
Certain configurations need to use a different path for pidfile.
Allow rc.conf to overwrite it.

Reviewed by:	cy, 0mp
MFC after:	3 days
Differential Revision: https://reviews.freebsd.org/D36141
2022-09-01 23:51:42 +00:00
Eugene Grosbein
160a2f2cdd rc.conf(5): add <service>_umask to run the service using this value
None of tools working with login classes change umask(1)
and we had no ways to specify non-default umask for a service
not touching its startup script. This change makes in possible.

Some file-sharing services that create new files may benefit from it.

Differential:	https://reviews.freebsd.org/D36309
MFC-after:	3 days
2022-08-28 12:48:58 +07:00
Franco Fichtner
c9be47b34d rc: add ${name}_setup script support
Run a service-based setup script before running the start command.
Useful for automatic configuration file generation.

Reviewed by:	https://reviews.freebsd.org/D36006
2022-08-15 16:43:12 +02:00
Konstantin Belousov
008475d3c8 rtld: fix display of the mapbase for the traced objects
Commit 24d0c9c1f5 introduced the following regression:
% ldd /bin/ls
/bin/ls:
        libutil.so.9 => /lib/libutil.so.9 (0x1021000)
        libncursesw.so.9 => /lib/libncursesw.so.9 (0x1021000)
        libc.so.7 => /lib/libc.so.7 (0x1021000)
Note that the base address is the same for all displayed libraries.

Fix it by passing correct object to trace_print_obj().

Fixes:	24d0c9c1f5
Reviewed by:	jrtc27
MFC after:	3 days
Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
Differential revision:	https://reviews.freebsd.org/D36198
2022-08-14 18:11:06 +03:00
Colin Percival
cc495d3b67 rc.d/hostid: Skip warning on systems w/o smbios
The first time a FreeBSD system boots, it obtains a hostuuid and hostid
from the smbios.system.uuid kernel environment variable.  If this value
is found to be invalid, a warning is printed and the boot pauses for
two seconds to give the user a chance to read it.

If the FreeBSD kernel is launched directly in a virtual machine rather
than via the FreeBSD boot loader, the smbios.system.uuid environment
variable might not be set; in this case, there's no need to alert the
user and delay the boot process since the lack of a "hardware" uuid is
entirely expected.

Distinguish between the cases of "invalid UUID" and "no UUID", warning
and delaying the boot only in the former case.  In both cases we still
generate a random UUID in software.

Reviewed by:	delphij
Sponsored by:	https://www.patreon.com/cperciva
Differential Revision:	https://reviews.freebsd.org/D36185
2022-08-13 15:58:16 -07:00
Mateusz Piotrowski
e7437ae907 rc: Start testing the rc(8) framework (beginning with *_oomprotect)
This change adds 2 tests to make sure that the *_oomprotect variable
sets the protection against OOM killer properly within rc(8) scripts.

This is also adding the first tests for the rc(8) framework. More tests
will be added as we go.

PR:		256148
Approved by:	des
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D35745
2022-07-26 15:39:39 +02:00
Jessica Clarke
becd9908be rtld-elf: Fix leaks and wild frees in origin_subst
55abf23dd3 inverted the value passed to origin_subst_one when rolling
up the existing code into a loop. If the first token is found ($ORIGIN),
this results in a wild free of part of strtab. Processing the second
token works fine and will act how the first should have regardless of
whether found, allocating memory for the string without freeing.
Processing subsequent tokens however will then leak, regardless of
whether found, as they will also believe they need to allocate memory
and can't free the string.

Found by:	CHERI
Reviewed by:	kib, markj
Fixes:		55abf23dd3 ("rtld: make token substitution table-driven")
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D35792
2022-07-12 17:47:47 +01:00
Mateusz Piotrowski
7f6754d965 rc.subr: Fix a typo
MFC after:	3 days
2022-07-08 21:35:34 +02:00
Mike Walker
68e035c017 rc.subr: Make sure oomprotect protects existing children
The rc(8) framework support protecting services from OOM killer.
The current implementation applies the protection after the service has
already started. This works fine if only the main process is to be
protected (*_oomprotect=yes). However, the current implementation fails
to protect existing children when children are also to be protected
(*_oomprotect=all). This patch fixes that.

Note: it is not easy to apply the protectoin earlier because we want to
support both the services which use the "command" variable and those
that use the "start_cmd" variable.

PR:		256148
Approved by:	adrian, osogbo
Tested by:	Jamie Landeg-Jones <jamie@catflap.org>
Fixes:		3bead71e95 - Add a global option where we can protect
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D35747
2022-07-08 08:19:50 +02:00
Alexander V. Chernikov
2bfd8b5b94 testing: provide meaningful error when pytest is not available
atf format does not provide any way of signalling any error message
 back to the atf runner when listing tests. Work this around by
 reporting "__test_cases_list_pytest_binary_not_found__" test instead.

Reviewed By: kp
Differential Revision: https://reviews.freebsd.org/D35721
2022-07-06 19:55:58 +00:00
Mike Karels
1cf8e6339e mountd startup: enable NFSv4 if needed on restart
The mountd script in rc.d sets vfs.nfsd.server_max_nfsvers correctly
when it is run at system startup, relying on the kernel default.
However, if NFSv4 was enabled in /etc/rc.conf later, and the script
was re-run to restart mountd, the sysctl was still set to 3.
Set the sysctl to the right value in all cases.

Reviewed by:	rmacklem
MFC after:	1 week
2022-07-04 08:00:10 -05:00
Mateusz Piotrowski
bad2f716f4 ftp: Use /var/spool/ftp as ftp's home consistently
The home directory of the ftp user is /var/spool/ftp according to
hier(7). Update the manual page of ftpd(8) to reflect that.

MFC after:	2 weeks
2022-06-28 15:20:05 +02:00
Alexander V. Chernikov
513ce835b5 testing: pass ATF vars to pytest via env instead of arguments.
This change is a continuation of 9c42645a1e workaround.
Apparently pytest argument parser is not happy when parsing values
 with spaces or just more than one --atf-var argument.
Switch wrapper to send these kv pairs as env variables. Specifically,
 use _ATF_VAR_key=value format to distinguish from the other vars.

Add the `atf_vars` fixture returning all passed kv pairs as a dict.

Reviewed by:	lwhsu
Differential Revision: https://reviews.freebsd.org/D35625
MFC after:	2 weeks
2022-06-28 12:20:16 +00:00
Alexander V. Chernikov
9c42645a1e testing: workaround pytest parser bug in pytest-atf-wrapper.
Reviewed by:	lwhsu, kp
Differential Revision: https://reviews.freebsd.org/D35614
MFC after:	2 weeks
2022-06-27 17:30:53 +00:00
Alexander V. Chernikov
924226fba1 testing: move atf-pytest-wrapper to /usr/libexec
Move pytest wrapper to the collection of the other atf wrappers
 in libexec. It solves the problem of combining bits & pieces from
 bsd.test.mk and bgs.prog.mk to address "test binary, but not the
 suite binary".

Reviewed by:	kp
Differential Revision: https://reviews.freebsd.org/D35604
MFC after:	2 weeks
2022-06-26 13:25:47 +00:00
наб
11bd40d04a rc.d/hostid: remove useless cat
We've already read it and validated it ‒ re-reading is wasteful

PR:		264376
2022-06-17 21:27:19 -04:00
John Baldwin
1442fed7e2 rc.d/ntpd: Restart ntpd when resuming from sleep.
ntpd does not always gracefully handle clock steps during resume.
This is probably most useful in conjunction with
ntpd_sync_on_start=YES which will work around any clock skew while
suspended.

Reviewed by:	manu
Differential Revision:	https://reviews.freebsd.org/D35479
2022-06-14 10:42:51 -07:00
Cy Schubert
116679b39c rc.d/wpa_supplicant: Remove the sleep to improve boot time
bapt@ had discovered a noticeable boot improvement without the sleep.
Without the sleep does not affect warm or cold boot however a
service netif restart may cause dhclient to spend a few extra seconds
to rerequest the DHCP request.

Reported by:	bapt
Reviewed by:	bapt
MFC after:	2 months
Differential Revision:	https://reviews.freebsd.org/D35457
2022-06-14 07:55:52 -07:00
Baptiste Daroussin
95db9ef565 rc.d/wpa_supplicant: remove support for NDIS
ndis drivers have been remove long ago (early 2021)
2022-06-11 22:25:21 +02:00
Eugene Grosbein
796d48ec41 ftpd(8): do not refer to now unused libxo(3)
In 2018, the commit r328100 (0fdf7fa846)
removed libxo(3) support from ls(1), so ftpd has no reasons to link
with libxo since then.

ls(1) does not depend on libxo in both of stable/12 and stable/13.

MFC after:	2 weeks
2022-06-10 21:09:20 +07:00
Mark Johnston
89e58b955c rc: Fix quoting in the zpoolreguid script
Reported by:	0mp
Fixes:		227caacc91 ("rc: Add a zpoolreguid rc.d script")
Sponsored by:	The FreeBSD Foundation
2022-05-31 10:51:28 -04:00
Mark Johnston
227caacc91 rc: Add a zpoolreguid rc.d script
If one boots up multiple copies of a template VM image containing a
zpool, the pool GUIDs will be identical, making it impossible to, e.g.,
share datasets between them.

This diff introduces a simple workaround for the problem: one can use
the script to, upon first boot, assign a new GUID to one or more zpools.
This will be useful when building ZFS-based VM images from release(7).

Reviewed by:	mav, allanjude, asomers
Reviewed by:	Pau Amma (docs)
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D35336
2022-05-30 10:43:44 -04:00
Cy Schubert
1452bfcd9b libexec/rc.d/hostapd: Down/up interface when interface is specified
When no interface is specified results in a syntax error in the rc
script. Only execute poststart when an interface has been specified.

PR:		263358
Submitted by:	markj
Reported by:	Joshua Kinard <freebsd@kumba.dev>
Fixes:		0da2c91e64
MFC after:	3 days
2022-04-22 09:15:49 -07:00
Andrew Turner
e85eaa9308 Have rtld query the page size from the kernel
To allow for a dynamic page size on arm64 have the runtime linker
query the kernel for the currentl page size.

Reviewed by:	kib
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D34765
2022-04-07 15:37:37 +01:00
Konstantin Belousov
0913953c9e rtld: trace preloaded objects
Before, preloaded objects, if not listed as needed for any normally
linked objects, were silently ignored.

Preloaded objects are printed with the `[preloaded]` herald. The list
includes the objects not listed explicitly as recursive dependencies of
the main object, effectively dsos loaded by LD_PRELOAD mechanism.
vdso is listed as well, since it is not needed by anything.

Since there is no DT_NEEDED entry for LD_PRELOADed objects, they are
usually printed using LD_TRACE_LOADED_OBJECTS_FTM2 format due to the
failure of the heuristic based on the presence of the 'lib' prefix.

Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D34716
2022-04-01 03:51:22 +03:00
Konstantin Belousov
db0372808a rtld trace_loaded_objects(): use bool for the list_containers variable
Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D34716
2022-04-01 03:51:22 +03:00
Konstantin Belousov
b0bc8cc705 rtld: use style(9) for trace_loaded_objects()
Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D34716
2022-04-01 03:51:22 +03:00
Konstantin Belousov
24d0c9c1f5 rtld: extract printer for a single traced object into a helper
Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D34716
2022-04-01 03:51:21 +03:00
Konstantin Belousov
c25f36f630 rtld: extract calculation of the format strings for trace into a helper
Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D34716
2022-04-01 03:51:21 +03:00
Mateusz Piotrowski
97aeda2243 zfskeys: Support autoloading of keys stored on ZFS
The zfskeys service script starts before the zfs service script, so that
dataset decryption keys are available when `zfs mount -a` is run. One of
the potential edge cases of this design is that if a key is stored on
ZFS it won't be loaded until `zfs mount -a` is issued.

In order to address that let's try to load the additional keys and mount
related ZFS datasets after the zfs script finishes its standard mounting
procedure.

PR:		262468
Reported by:	Graham Perrin <grahamperrin@gmail.com>
Reviewed by:	allanjude
Approved by:	allanjude (src)
Fixes:	33ff39796f Add zfskeys rc.d script for auto-loading encryption keys
MFC after:	3 days
Sponsored by:	Modirum
Sponsored by:	Klara Inc.
Differential Revision: https://reviews.freebsd.org/D34601
2022-03-18 14:53:52 +01:00
Mateusz Piotrowski
7846554819 rc.d: Chmod +x all the scripts for consistency
Reviewed by:	lwhsu
Approved by:	lwhsu (src)
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D34589
2022-03-17 20:12:04 +01:00
Jose Luis Duran
19a6267d61 rc.d/*: Use startmsg instead of echo on start messages
By rc.conf(5), setting rc_startmsgs="NO" should silence start messages.

Fix a few rc scripts by using startmsg.

PR:		255207
Reported by:	Jose Luis Duran <jlduran@gmail.com>
Reviewed by:	imp, 0mp
Approved by:	imp (src)
Differential Revision:	https://reviews.freebsd.org/D34514
2022-03-13 18:57:31 +01:00
Jose Luis Duran
325ebf37d8 Introduce startmsg and use it in rc scripts
startmsg is a new rc.subr(8) function function to be used instead of
echo(1) when for boot messages. It replaces the often forgotten

    check_startmsgs && echo ...

with

    startmsg ...

No functional change intended.

I adjusted the commit message and did some final clean-ups of the patch
before committing.

PR:		255207
Reported by:	Jose Luis Duran <jlduran@gmail.com>
Reviewed by:	imp, 0mp
Approved by:	imp (src)
Differential Revision:	https://reviews.freebsd.org/D34514
2022-03-13 18:57:29 +01:00
Ed Maste
67e751f167 dumpon: use underlying device if encrypted swap is in use
/etc/rc.d/dumpon runs before /etc/rc.d/swap.  When encrypted swap is in
use the .eli or .bde device will not exist at the time dumpon runs.

Even if this is addressed it does not make sense to dump core to
encrypted swap, as the encryption key will not be available after
reboot rendering the dump useless.  Thus, for the case that dumpdev=AUTO
and encrypted swap is in use, strip the extension and use the underlying
device.

Emit a warning if we are using the underlying device and the user has not
configured dump encryption, so that the user knows that the will not be
encrypted.

PR:		238301
Reported by:	Ivan Rozhuk
Reviewed by:	jilles
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D34474
2022-03-09 19:43:14 -05:00
Mateusz Piotrowski
c1a76c0486 rc.d/ggated: Simplify service script
- Use the standard *_flags variable for additional flags.
- Style: do not create unnecessary variables
- Do not set the defaults in the service script. This is what
  /etc/defaults/rc.conf is for.
- Do not set additional flags via commands_args. ggated_flags are
  already included in the final invocation. See rc.subr(8) for details.
- Document the meaning of ggated_config in /etc/defaults/rc.conf.

Approved by:	eugen (src)
Fixes:		c068632981 Add ggated rc script
Differential Revision:	https://reviews.freebsd.org/D34439
2022-03-04 17:50:42 +01:00
Alan Somers
c068632981 Add ggated rc script
Reviewed by:	asomers, peterj
Submitted by:	Johannes Totz <jo@bruelltuete.com>
Differential Revision:	https://reviews.freebsd.org/D31709
2022-02-27 21:14:52 -07:00
John F. Carr
6c799530d8 rtld.1: Fix misplaced text
PR:		262194
Fixes:		f90218886f ("rtld: introduce PRELOAD_FDS")
MFC after:	3 days
2022-02-25 11:16:35 -05:00
Mitchell Horne
318d0db5fe rc.subr: boottrace annotations
When enabled, have the framework use the boottrace(8) utility to execute
each rc script, generating trace entries for the entire suite of
scripts.

Reviewed by:	0mp (slightly earlier version)
Sponsored by:	NetApp, Inc.
Sponsored by:	Klara, Inc.
Differential Revision:	https://reviews.freebsd.org/D31930
2022-02-21 20:16:12 -04:00
Rick Macklem
0f5e9425e7 gssd: Modify /etc/rc.d/gssd so that it starts after NETWORKING
Arno Tuber reported via email that he needed to restart the gssd daemon
after booting, to get his Kerberized NFS mount to work.

Without this patch, rcorder shows that the gssd starts before NETWORKING
and kdc. The gssd will need NETWORKING to connect to the KDC and, if
the kdc is running on the same system, it does not make sense to start it
before the kdc.  This fixed the problem for Arno.

While here, I also added a "# BEFORE: mountcritremote".
It does not affect ordering at this time, but I felt
it should be added, since the gssd needs to be running
when remote NFS mounts are done.

PR:	261939
Reported by:	anothatuber@gmail.com
Tested by:	anothatuber@gmail.com
Reviewed by:	rew
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D34265
2022-02-15 14:18:23 -08:00
Konstantin Belousov
b1b5174123 rtld: Add ${TOKEN} aliases to $TOKEN
it seems that glibc supports them, and such spelling is mentioned in the
ld.bfd manual. Idea seems to auto-correct some quoting/makefile sytnax
errors on linker command line.

Reviewed by:	emaste, markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D34247
2022-02-11 20:01:20 +02:00
Konstantin Belousov
55abf23dd3 rtld: make token substitution table-driven
Reviewed by:	emaste, markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D34247
2022-02-11 20:00:47 +02:00
Jose Luis Duran
cb51e2bc3d rc: Allow the removal of firstboot_sentinel on read-only file systems
NanoBSD or, more generally, systems with root_rw_mount="NO" are not able
to remove the firstboot_sentinel file, typically /firstboot, because the
logic in /etc/rc is currently inverted.

When checkyesno root_rw_mount tests on a read-only file system, the
return is 1, hence avoiding the option to mount the system read-write.

Restore the ability to remove the firstboot_sentinel file on read-only
mounted file systems.

This change was introduced in 40adda8665, and partially fixed in
1ce07411fa.

Differential Revision: https://reviews.freebsd.org/D34166
2022-02-10 12:43:19 -07:00
Jose Luis Duran
c96f70e7ac rc: Remove extra whitespace
Differential Revision: https://reviews.freebsd.org/D34165
2022-02-10 12:43:19 -07:00
John Baldwin
d33d8f7ef4 rtld: Fix assertion I broke.
textrel is a bool, not a pointer.

Pointy hat to:	jhb
Reported by:	kevans
Fixes:		6a2d75d248 rtld: Trim a few more MIPS #ifdefs.
2022-01-27 14:42:40 -08:00
John Baldwin
6a2d75d248 rtld: Trim a few more MIPS #ifdefs.
Reviewed by:	imp, kib
Sponsored by:	The University of Cambridge, Google Inc.
Differential Revision:	https://reviews.freebsd.org/D34052
2022-01-27 11:00:24 -08:00
Rick Macklem
f72926eab0 mountd: Delay starting mountd until after mountlate
PR#254282 reports a problem where nullfs mounts cannot be
exported via mountd for FreeBSD 13.0.

The problem seems to be that, to do the nullfs mounts in
/etc/fstab, they require the "late" mount option, so that the
underlying filesystem is mounted (ZFS for the PR).

Adding "mountlate" to the REQUIRE list in /etc/rc.d/mountd
fixes the problem, but that results in a dependency cycle
because /etc/rc.d/lockd specifies:

REQUIRE: nfsd
BEFORE: DAEMON
--> which forces mountd to preceed DAEMON.

This patch removes "nfsd" from REQUIRE for lockd and statd,
then adds mountlate to REQUIRE for mountd, to fix this
problem.  Having lockd REQUIRE nfsd was done in the NetBSD
code when it was pulled into FreeBSD and there does not
seem to be a need for this.

In case this causes problems, a long MFC has been specified.

PR:	254282
Differential Revision:	https://reviews.freebsd.org/D33256
MFC after:	3 months
2022-01-23 14:17:40 -08:00
Robert Wing
6596f19daa etc/defaults/rc.conf: set default of zfskeys_enable to NO
This addresses the following boot message:
    /etc/rc: WARNING: $zfskeys_enable is not set properly - see rc.conf(5).

Reported by:    Mark Millard
Sponsored by:   Modirum MDPay
Sponsored by:   Klara Inc.
Fixes: bfb7a31b6a ("rc: Hook zfskeys to the build")
Fixes: 33ff39796f ("Add zfskeys rc.d script for auto-loading encryption keys")
2022-01-18 14:26:30 -09:00
Cy Schubert
c6806434e7 rc.d/ntp: Ensure ntpd.leap-seconds.list is readable by ntpd
When a use sets umask in login.conf(5) to 027 or 077 a subsequently
fetched /var/db/ntpd.leap-seconds.list will inherit the permissions
allowed by the umask, resulting in a file that may not be readable
ntpd running under the ntp account. This patch adds a umask command
to preempt the umask in login.conf(5) prior to fetching a new copy
of the leap-seconds file.

PR:		261298
Reported by:	Martin Waschbusch <martin@waschbuesch.de>
MFC after:	3 days
2022-01-18 06:21:00 -08:00
Warner Losh
0d1f0898c9 rtld-elf: Remove libsoft support
Remove support for loading libsoft libraries.

Sponsored by:		Netflix
2022-01-06 22:44:07 -07:00
Warner Losh
d418bc27e6 libsoft: Remove runtime ldconfig support for libsoft
Remove the runtime support for running ldconfig at boot to cache lists
of libsoft libbraries.

Sponsored by:		Netflix
2022-01-06 22:34:18 -07:00
Konstantin Belousov
2bf21b0e8e Restore DT_DEBUG processing
Pointed out by:	kevans
Fixes:	292cba9b49
Sponsored by:	The FreeBSD Foundation
2022-01-06 09:14:09 +02:00
Konstantin Belousov
470b98e61d rtld: remove mips arch directory
Reviewed by:	imp
Sponsored by:	The FreeBSD Foundation
Differential revision:	https://reviews.freebsd.org/D33763
2022-01-06 06:00:39 +02:00
Konstantin Belousov
292cba9b49 rtld: remove mips-specific cases from generic code
Reviewed by:	imp
Sponsored by:	The FreeBSD Foundation
Differential revision:	https://reviews.freebsd.org/D33763
2022-01-06 06:00:39 +02:00
Emmanuel Vadot
20cd6e315e pkgbase: Create a FreeBSD-ftpd package
And put ftpd into it.

MFC after:	2 weeks
Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D33453
2021-12-21 10:17:36 +01:00
Emmanuel Vadot
078b764da3 pkgbase: Create a FreeBSD-tcpd package
And put the tcp-wrapper utilities in it.

Reviewed by:	emaste
MFC after:	2 weeks
Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D33439
2021-12-21 10:17:31 +01:00
Emmanuel Vadot
93c4369096 pkgbase: Put more binaries/lib in runtime
Move some needed binaries/libs from FreeBSD-utilities to FreeBSD_runtime.
This is everything needed to boot to multiuser with FreeBSD-rc installed.

MFC after:	2 weeks
Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D33435
2021-12-21 10:17:27 +01:00
Emmanuel Vadot
5abb10faa1 pkgbase: Put yellow pages programs to its own package
YP is less and less used, split them to users have the choice to not
install them.

MFC after:	2 weeks
Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D33441
2021-12-21 10:17:22 +01:00
Cy Schubert
0da2c91e64 hostapd: Fix wlan interfaces not UP/RUNNING
Like wpa_supplicant, hostapd does not automatically UP the interface
when configured. The fix is similar to 5fcdc19a81.

Reported by:	avg
Tested by:	avg
MFC after:	1 week
2021-12-14 06:18:37 -08:00
Bjoern A. Zeeb
e448ff6f0e rc: network.subr improve network6_getladdr()
In network6_getladdr() we are iterating over inet6 lines and are not
interested in any others.  So tell ifconfig to limit output to "inet6"
as much as possible.
This is probably a micro-optimisation but was noticed while looking
at other IPv6-related boot-time improvements.

MFC after:	1 week
2021-12-13 22:12:44 +00:00
John Baldwin
8bcdb144eb TLS: Use <machine/tls.h> for libc and rtld.
- Include <machine/tls.h> in MD rtld_machdep.h headers.

- Remove local definitions of TLS_* constants from rtld_machdep.h
  headers and libc using the values from <machine/tls.h> instead.

- Use _tcb_set() instead of inlined versions in MD
  allocate_initial_tls() routines in rtld.  The one exception is amd64
  whose _tcb_set() invokes the amd64_set_fsbase ifunc.  rtld cannot
  use ifuncs, so amd64 inlines the logic to optionally write to fsbase
  directly.

- Use _tcb_set() instead of _set_tp() in libc.

- Use '&_tcb_get()->tcb_dtv' instead of _get_tp() in both rtld and libc.
  This permits removing _get_tp.c from rtld.

- Use TLS_TCB_SIZE and TLS_TCB_ALIGN with allocate_tls() in MD
  allocate_initial_tls() routines in rtld.

Reviewed by:	kib, jrtc27 (earlier version)
Differential Revision:	https://reviews.freebsd.org/D33353
2021-12-09 13:23:05 -08:00
John Baldwin
299617496c amd64: Allocate TCB with alignment of 16 rather than 8.
This matches the TLS_TCB_ALIGN definition in libc.

Reviewed by:	kib, jrtc27
Sponsored by:	The University of Cambridge, Google Inc.
Differential Revision:	https://reviews.freebsd.org/D33349
2021-12-09 13:16:45 -08:00
John Baldwin
23e0c0e9a3 mips: Add TLS_DTV_OFFSET to the result of tls_get_addr_common.
Previously TLS_DTV_OFFSET was added to the offset passed to
tls_get_addr_common; however, this approach matches powerpc and RISC-V
and better matches the intention.

Reviewed by:	kib, jrtc27
Sponsored by:	The University of Cambridge, Google Inc.
Differential Revision:	https://reviews.freebsd.org/D33347
2021-12-09 13:16:19 -08:00
John Baldwin
03f6b14106 mips: Rename TLS_DTP_OFFSET to TLS_DTV_OFFSET.
This is the more standard name for the bias of dtv pointers used on
other platforms.  This also fixes a few other places that were using
the wrong bias previously on MIPS such as dlpi_tls_data in struct
dl_phdr_info and the recently added __libc_tls_get_addr().

Reviewed by:	kib, jrtc27
Sponsored by:	The University of Cambridge, Google Inc.
Differential Revision:	https://reviews.freebsd.org/D33346
2021-12-09 13:16:00 -08:00
Konstantin Belousov
c210ef1347 rtld: load preloaded vdso
Reviewed by:	emaste
Discussed with:	jrtc27
Tested by:	pho
Sponsored by:	The FreeBSD Foundation
MFC after:	1 month
Differential revision:	https://reviews.freebsd.org/D32960
2021-12-06 20:46:49 +02:00
Konstantin Belousov
63fc4e820c rtld: extract header validation into new helper check_elf_headers()
Reviewed by:	emaste
Discussed with:	jrtc27
Tested by:	pho
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D32960
2021-12-06 20:46:49 +02:00
Konstantin Belousov
01c77a436e Pass vdso address to userspace
Reviewed by:	emaste
Discussed with:	jrtc27
Tested by:	pho
Sponsored by:	The FreeBSD Foundation
MFC after:	1 month
Differential revision:	https://reviews.freebsd.org/D32960
2021-12-06 20:46:49 +02:00
Cy Schubert
db0ac6ded6 Revert "wpa: Import wpa_supplicant/hostapd commit 14ab4a816"
This reverts commit 266f97b5e9, reversing
changes made to a10253cffe.

A mismerge of a merge to catch up to main resulted in files being
committed which should not have been.
2021-12-02 14:45:04 -08:00
Cy Schubert
266f97b5e9 wpa: Import wpa_supplicant/hostapd commit 14ab4a816
This is the November update to vendor/wpa committed upstream 2021-11-26.

MFC after:      1 month
2021-12-02 13:35:14 -08:00
Mateusz Piotrowski
bfb7a31b6a rc: Hook zfskeys to the build
Reviewed by:	allanjude
Approved by:	allanjude (src)
MFC after:	3 days
Sponsored by:	Modirum MDPay
Differential Revision:	https://reviews.freebsd.org/D33230
2021-12-02 20:10:52 +01:00
Colin Percival
e29711da23 etc/defaults/rc.conf: Add -i flag to rtsol/rtsold
This disables the random (between zero and one seconds) delay before
rtsol and rtsold send a a Router Solicitation packet.  This delay is
specified as a SHOULD by RFC 4861 for avoidance of network congestion,
but network speeds have increased enough in the 25 years since this
first appeared (in RFC 1970) that it seems unnecessary as a default
at this point.

This speeds up the FreeBSD boot process by an average of 500 ms.

Reviewed by:	kp
MFC after:	1 week
Relnotes:	yes
Sponsored by:	https://www.patreon.com/cperciva
Differential Revision:	https://reviews.freebsd.org/D33089
2021-11-25 19:08:15 -08:00
Konstantin Belousov
f340188625 rtld_paths.h: Provide _PATH_ELF32_HINTS string, unconditionally
Reviewed by:	emaste
Tested by:	jbeich
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D33058
2021-11-25 01:55:03 +02:00