Commit graph

2771 commits

Author SHA1 Message Date
Tijl Coosemans
71d88613d1 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 hyphens
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
Approved by:	re (cperciva)
Differential Revision:	https://reviews.freebsd.org/D38811

(cherry picked from commit ecad3f5c4d)
(cherry picked from commit d6852eed98ed32ad51120a22aa1ebdf0601917b3)
2023-03-12 22:46:07 +01:00
Tijl Coosemans
a379d5c5ef hostid: Generate random UUID by default
This way MAC addresses are no longer exposed.

Discussed with:	bapt
Approved by:	re (cperciva)

(cherry picked from commit 862aab6281)
(cherry picked from commit baf1e9713969fccdaf7481e3568ca89b7237dafd)
2023-03-12 22:45:59 +01:00
Mike Karels
62679a0594 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.

Approved by:	re (cperciva)
Differential Revision:	https://reviews.freebsd.org/D38751

(cherry picked from commit eef9f9900f)
(cherry picked from commit 009abff336b6e83219178e7d87f6a91f54e31839)
2023-03-09 07:05:01 -06:00
Baptiste Daroussin
63270222c1 machine-id: generate a compact version of the uuid
dbus and other actually expect an uuid without hyphens

Approved by:	re (cperciva)
Reported by:	tijl
MFC After:	3 days

(cherry picked from commit a28ccb32bf)
2023-03-06 22:18:00 +01:00
Xin LI
57c37babde 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
Approved by:	re (cperciva)

(cherry picked from commit 39e8c2a29a)
(cherry picked from commit 0699f0d43416776d87d20d7953b7d686f1e2e572)
2023-02-21 07:37:30 -08:00
Jose Luis Duran
a28a4cb5e9 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

(cherry picked from commit 058ac3e806)
2023-02-09 15:45:28 +00:00
Emmanuel Vadot
037902038e rc.d: Put resolv script in FreeBSD-resolvconf
Differential Revision:	https://reviews.freebsd.org/D37190

(cherry picked from commit a6a21bbedc)
2023-02-02 11:41:11 +01:00
Emmanuel Vadot
0b6df226db rc.d: Put dhclient script in FreeBSD-dhclient
Differential Revision:	https://reviews.freebsd.org/D37187

(cherry picked from commit 81b18bea09)
2023-02-02 11:35:59 +01:00
Emmanuel Vadot
9cfd02f5ce rc.d: Put devmatch script in FreeBSD-devmatch
Differential Revision:	https://reviews.freebsd.org/D37192

(cherry picked from commit d8799160c2)
2023-02-02 11:35:48 +01:00
Emmanuel Vadot
68ee29c97d rc.d: Put devd script in FreeBSD-devd package
Differential Revision:	https://reviews.freebsd.org/D37186

(cherry picked from commit f043569692)
2023-02-02 11:35:34 +01:00
Cy Schubert
40455909e1 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
Differential Revision:	https://reviews.freebsd.org/D37748

(cherry picked from commit e3e57edf4a)
2023-01-31 18:53:11 -08:00
Cy Schubert
3f89a29748 network.subr: Replace "\ " with "[[:space:]]"
"[[:space:]]" is easier to read than "\ " and is conisitent with
clone_up().

Reported by:	eugen
Differential Revision:	https://reviews.freebsd.org/D37748

(cherry picked from commit fef0e429f1)
2023-01-31 18:53:11 -08:00
Baptiste Daroussin
dc730e70a4 dma(8): add newaliases to mailer.conf
Reported by:	karels
MFC After:	3 days

(cherry picked from commit d525abd277)
2023-01-25 09:52:29 +01:00
Baptiste Daroussin
1054b8fdc3 flua: chown(2) binding, fix bad copy/paste
(cherry picked from commit 280f11f1be)
2023-01-25 09:51:35 +01:00
Baptiste Daroussin
c69a31795b 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

(cherry picked from commit a1ab15abe2)
2023-01-25 09:51:23 +01:00
Gordon Bergling
ed89b5fe0b rc.initdiskless: Fix a typo in a comment
- s/attemping/attempting/

(cherry picked from commit 30985d19b0)
2023-01-24 09:03:40 +01:00
Ed Maste
de1ce17d23 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

(cherry picked from commit 45396fda8b)
2023-01-16 19:32:59 -05:00
Alexander V. Chernikov
1c78434956 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

(cherry picked from commit 2bfd8b5b94)
2023-01-13 21:24:10 +00:00
Alexander V. Chernikov
cdd12f62eb 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

(cherry picked from commit 513ce835b5)
2023-01-13 21:24:10 +00:00
Alexander V. Chernikov
1c97b8e2eb testing: workaround pytest parser bug in pytest-atf-wrapper.
Reviewed by:	lwhsu, kp
Differential Revision: https://reviews.freebsd.org/D35614
MFC after:	2 weeks

(cherry picked from commit 9c42645a1e)
2023-01-13 21:24:10 +00:00
Alexander V. Chernikov
8a92302311 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

(cherry picked from commit 924226fba1)
2023-01-13 21:24:10 +00:00
Mike Karels
8a16a2cb09 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

(cherry picked from commit 0e2fdab227)
2023-01-13 13:15:54 -06:00
Mike Karels
a7fde0e038 growfs script: fixes
Cannot use single quote in comment in awk script;
add growfs_fstab to Makefile

Fixes:		4a30d7bb373c,d670a8f7c596
(cherry picked from commit 4c8a257810)
2023-01-13 13:15:51 -06:00
Mike Karels
2726074f81 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

(cherry picked from commit af01b47225)
2023-01-13 13:15:35 -06:00
Mike Karels
67fc403e36 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

(cherry picked from commit d670a8f7c5)
2023-01-13 13:15:02 -06:00
Mike Karels
d6ee3d22f5 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

(cherry picked from commit 4a30d7bb37)
2023-01-13 13:14:47 -06:00
Scott Long
e51074735f MFC growfs script change from August 2021:
- Fix the growfs rc script to cope with diskid labels.
- Fix a warning in growfs. gpart commit is supposed to be called on disk
  device.
- Silence a gpart commit warning in growfs.

Submitted by: loos
Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D31587
Sponsored by: Rubicon Communications, LLC ("Netgate")

(cherry picked from commit 045001075e)
2023-01-13 13:11:30 -06:00
Tobias C. Berner
17333d9264 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.

Bump FreeBSD version 1301511 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

(cherry picked from commit 62a149bf62)
2023-01-10 08:51:01 +01:00
Cy Schubert
d30b57252d network.subr: Add missing brace
PR:		268378
Submitted by:	jyoung15@gmail.com
Reported by:	jyoung15@gmail.com

(cherry picked from commit 87061d3bff)
2023-01-04 16:35:46 -08:00
Andrew Fengler
c6ec1b441a Add support for adding default routes for other FIBs
Make rc.d/routing read defaultrouter_fibN and ipv6_defaultrouter_fibN, and
set it as the default gateway for FIB N, where N is from 1 to (net.fibs - 1)
This allows adding gateways for multiple FIBs in the same format as the main
gateway. (FIB 0)

Reviewed by:	olivier, rgrimes, bcr (man page)
Sponsored by:	ScaleEngine Inc.
Differential Revision:	https://reviews.freebsd.org/D22706

(cherry picked from commit 30659d1dcb)
2022-12-02 21:27:57 +00:00
Chuck Tuffli
d878a66a9a wait for device mounts in zpool and dumpon
If the root file system is composed from multiple devices, wait for
devices to be ready before running zpool and dumpon rc scripts.

An example of this is if the bulk of the root file system exists on a
fast device (e.g. NVMe) but the /var directory comes from a ZFS dataset
on a slower device (e.g. SATA). In this case, it is possible that the
zpool import may run before the slower device has finished being probed,
leaving the system in an intermediate state.

Fix is to add root_hold_wait to the zpool and dumpon (which has a
similar issue) rc scripts.

PR:		242189

(cherry picked from commit f30f11f878)
2022-11-19 09:40:48 -08:00
Konstantin Belousov
c23f077cc4 rtld: add support for the $LIB token
MFC note: the arm soft case is not handled, it is probably worth
expanding $LIB to libsoft there.

(cherry picked from commit 8cc44a1e59)
2022-11-18 04:15:18 +02:00
Dag-Erling Smørgrav
d488e8d037 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

(cherry picked from commit 8ad7a14ab4)

getty: code cleanup, part 2

* Clean up whitespace
* Reindent

Sponsored by:	Klara, Inc.

(cherry picked from commit f285f41498)

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

(cherry picked from commit eb4d86d529)
2022-11-14 12:22:42 +01:00
Ceri Davies
17948f07eb Remove references to timed(8)
There are still references to timed(8) and timedc(8) in the base system,
which were removed in 2018.

PR: 255425
Reported by:	Ceri Davies <ceri at submonkey dot net>
Reviewed by:	ygy, gbe
Differential Revision:	https://reviews.freebsd.org/D30232

(cherry picked from commit 1760799b4c)
2022-11-14 10:18:52 +01:00
Konstantin Belousov
bc53b440fb rtld: remove unused macro FPTR_TARGET
(cherry picked from commit f585d13dd6)
2022-10-25 03:37:43 +03:00
Konstantin Belousov
d074059e98 rtld: fix typo in comment
(cherry picked from commit ca2560bd85)
2022-10-19 18:00:42 +03:00
Konstantin Belousov
5955bc6b69 rtld: teach LD_SHOW_AUXV about AT_USRSTACK*
(cherry picked from commit daa85548d5)
2022-09-30 03:29:10 +03:00
Konstantin Belousov
6958ee33b7 ldd: remove '[preloaded]' marker for the preloaded objects
PR:	265750

(cherry picked from commit 2f72ee987d)
2022-09-29 03:29:09 +03:00
Konstantin Belousov
5593488d8b rtld-elf/libmap.c: correct comment
(cherry picked from commit 1251cf8a30)
2022-09-25 14:18:25 +03:00
Konstantin Belousov
b76c89cb33 rtld-elf/libmap.h: style declarations
(cherry picked from commit 1fd4dec26e)
2022-09-25 14:18:25 +03:00
Konstantin Belousov
eb9f61ee16 rtld-elf/libmap.h: add include guard
(cherry picked from commit 3aed5ddb8b)
2022-09-25 14:18:24 +03:00
Cy Schubert
8c857fedfe 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

(cherry picked from commit b77b309968)
2022-09-22 17:42:07 -07:00
Bjoern A. Zeeb
fe67d32550 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
Differential Revision: https://reviews.freebsd.org/D36141

(cherry picked from commit e196317370)
2022-09-21 11:38:56 +00:00
Gordon Bergling
88b7b11e98 bootptest: Fix a typo in a source code comment
- s/avaible/available/

(cherry picked from commit 4732904942)
2022-09-18 08:04:15 +02:00
Konstantin Belousov
fd73d53223 rtld.c: remove extra blank line
(cherry picked from commit 832b40f7ff)
2022-09-18 03:33:46 +03:00
Konstantin Belousov
b09c2d924f rtld: style the rest of rtld_lock.c
(cherry picked from commit 7444f54bd3)
2022-09-18 03:33:45 +03:00
Konstantin Belousov
982584532d rtld: mask signals for default read locks
(cherry picked from commit a687683b99)
2022-09-18 03:33:45 +03:00
Cy Schubert
3418c14040 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)
Differential Revision:	https://reviews.freebsd.org/D36386

(cherry picked from commit 27b9777c28)
2022-09-11 17:40:37 -07:00
Gordon Bergling
3887ce6c19 ntpd(8): Correct a typo in comment of the rc script
- s/the the/the/

(cherry picked from commit 7ed279f58f)
2022-09-07 09:22:57 +02:00
Gordon Bergling
eadbe9faeb rtld(1): Fix a typo in a source code comment
- s/interger/integer/

(cherry picked from commit 3576233cd3)
2022-09-06 07:42:17 +02:00