]> git.ipfire.org Git - thirdparty/systemd.git/log
thirdparty/systemd.git
2 years agobtrfs-util: Add btrfs_subvol_snapshot_at() 27885/head
Daan De Meyer [Thu, 1 Jun 2023 12:59:59 +0000 (14:59 +0200)] 
btrfs-util: Add btrfs_subvol_snapshot_at()

2 years agochattr-util: Make chattr_full() an openat() style function
Daan De Meyer [Thu, 1 Jun 2023 12:52:56 +0000 (14:52 +0200)] 
chattr-util: Make chattr_full() an openat() style function

2 years agobtrfs-util: Add btrfs_subvol_set_read_only_at()
Daan De Meyer [Thu, 1 Jun 2023 12:43:30 +0000 (14:43 +0200)] 
btrfs-util: Add btrfs_subvol_set_read_only_at()

2 years agorm-rf: Add rm_rf_at()
Daan De Meyer [Thu, 1 Jun 2023 12:36:47 +0000 (14:36 +0200)] 
rm-rf: Add rm_rf_at()

2 years agobtrfs-util: Add btrfs_subvol_remove_at()
Daan De Meyer [Thu, 1 Jun 2023 12:32:39 +0000 (14:32 +0200)] 
btrfs-util: Add btrfs_subvol_remove_at()

We also remove btrfs_subvol_remove_fd() because btrfs_subvol_remove_at()
is more general.

2 years agotest-chase: Add one more test for chase_and_openat()
Daan De Meyer [Fri, 2 Jun 2023 09:05:10 +0000 (11:05 +0200)] 
test-chase: Add one more test for chase_and_openat()

2 years agochase: Allow passing NULL as the empty path to chaseat()
Daan De Meyer [Fri, 2 Jun 2023 09:00:48 +0000 (11:00 +0200)] 
chase: Allow passing NULL as the empty path to chaseat()

Per coding style, we should accept NULL as the empty path.

2 years agotest-chase: Fix comment
Daan De Meyer [Fri, 2 Jun 2023 08:55:24 +0000 (10:55 +0200)] 
test-chase: Fix comment

2 years agofd-util: Add path_is_root_at()
Daan De Meyer [Thu, 1 Jun 2023 12:26:35 +0000 (14:26 +0200)] 
fd-util: Add path_is_root_at()

A generalization of dir_fd_is_root() that allows passing a path
component.

2 years agobtrfs-util: Add btrfs_is_subvol_at()
Daan De Meyer [Thu, 1 Jun 2023 11:58:29 +0000 (13:58 +0200)] 
btrfs-util: Add btrfs_is_subvol_at()

2 years agostat-util: Add is_fs_type_at()
Daan De Meyer [Thu, 1 Jun 2023 11:57:58 +0000 (13:57 +0200)] 
stat-util: Add is_fs_type_at()

2 years agostat-util: Follow coding style in xstatfsat()
Daan De Meyer [Thu, 1 Jun 2023 11:57:04 +0000 (13:57 +0200)] 
stat-util: Follow coding style in xstatfsat()

Allow passing NULL to indicate the empty path per coding style.

2 years agofs-util: Allow passing NULL path to xopenat()
Daan De Meyer [Thu, 1 Jun 2023 11:56:05 +0000 (13:56 +0200)] 
fs-util: Allow passing NULL path to xopenat()

We recently codified in the coding style that for openat() style APIs,
an empty path can be passed both as the empty string and as NULL, so
let's make sure we follow that style in xopenat().

2 years agocopy: Merge copy_directory() and copy_directory_fd() into copy_directory_at()
Daan De Meyer [Thu, 1 Jun 2023 11:42:39 +0000 (13:42 +0200)] 
copy: Merge copy_directory() and copy_directory_fd() into copy_directory_at()

Let's merge these two into a single function that can handle both
variants and more.

2 years agotests: fix shellcheck warnings
Luca Boccassi [Mon, 5 Jun 2023 21:48:06 +0000 (22:48 +0100)] 
tests: fix shellcheck warnings

2 years agocgls/cgtop: spell field/column "CGroup" rather than "Control Group"
Lennart Poettering [Mon, 5 Jun 2023 16:40:26 +0000 (18:40 +0200)] 
cgls/cgtop: spell field/column "CGroup" rather than "Control Group"

In the documentation we usually spell the concept "control group".
Internally in code we usually call it "cgroup" or "CGroup". In systemctl output we
called the field "CGroup" so far, i.e. a capitalized version of the
internal name. This is of course very unsystematic. Let's clean this up
a bit: let's now say:

* in docs, continue to spell it out "control groups"
* in brief output call it "CGroup"
* internally call it "cgroup" or "CGroup"

Fixes: #14429
2 years agoMerge pull request #27912 from mrc0mmand/cryptsetup-tests
Yu Watanabe [Mon, 5 Jun 2023 18:34:59 +0000 (03:34 +0900)] 
Merge pull request #27912 from mrc0mmand/cryptsetup-tests

test: add a couple more tests for systemd-cryptsetup

2 years agoMerge pull request #27926 from DaanDeMeyer/repart-offline
Luca Boccassi [Mon, 5 Jun 2023 18:11:41 +0000 (19:11 +0100)] 
Merge pull request #27926 from DaanDeMeyer/repart-offline

repart: Add --offline argument

2 years ago99-systemd.rules.in: guard systemd-backlight udev rules by ENABLE_BACKLIGHT
Simon Braunschmidt [Mon, 5 Jun 2023 11:49:45 +0000 (11:49 +0000)] 
99-systemd.rules.in: guard systemd-backlight udev rules by ENABLE_BACKLIGHT

Linux kernel will, as documented in drivers/video/backlight/backlight.c,
report changes to a backlights brightness as a uevent (ACTION=change).

systemd-udev will consume the uevent, match on this rule and try to
activate the systemd-backlight service for the backlight. BUT when
systemd is not compiled with backlight support, this will lead to
failure that is reported in the journal.

Since the failure to activate systemd-backlight and subsequent failure
log entry happens on every backlight brightness change, we found the
resulting logspam during regular operation excessive and came up with
this patch to mitigate it.

The conditional is also extended to "*kbd_backlight" match, since
even though we did not investigate to see if the logspam would be
similar, the unconditional match to activate systemd-backlight here
would also not make sense when the feature is not compiled in.

Signed-off-by: Simon Braunschmidt <simon.braunschmidt@iba-group.com>
2 years agotest: make sure we unmount /var late during shutdown 27912/head
Frantisek Sumsal [Mon, 5 Jun 2023 14:54:31 +0000 (16:54 +0200)] 
test: make sure we unmount /var late during shutdown

To avoid the "mountpoint is busy" error.

2 years agotest: add a couple more tests for systemd-cryptsetup
Frantisek Sumsal [Sun, 4 Jun 2023 12:44:42 +0000 (14:44 +0200)] 
test: add a couple more tests for systemd-cryptsetup

2 years agotest: make check_result_*() `set -e` friendly
Frantisek Sumsal [Sun, 4 Jun 2023 20:16:58 +0000 (22:16 +0200)] 
test: make check_result_*() `set -e` friendly

2 years agotest: use check_result_common()
Frantisek Sumsal [Sun, 4 Jun 2023 20:13:58 +0000 (22:13 +0200)] 
test: use check_result_common()

The TEST-24 has been silently timing out for quite a while in the C8S
job, as the check_result_qemu() override lacked some error checks,
whoopsie.

2 years agocryptsetup: avoid calling strv_find() on a NULL pointer
Frantisek Sumsal [Sun, 4 Jun 2023 14:02:45 +0000 (16:02 +0200)] 
cryptsetup: avoid calling strv_find() on a NULL pointer

When the header= option comes before any other type= defining one, we
trip over an assertion:

Jun 04 15:45:33 H testsuite-24.sh[752]: + systemctl start systemd-cryptsetup@detached.service
Jun 04 15:45:33 H systemd[1]: Starting systemd-cryptsetup@detached.service...
Jun 04 15:45:33 H systemd-cryptsetup[4641]: Assertion 'name' failed at src/basic/strv.c:21, function strv_find(). Aborting.
...
Jun 04 15:45:33 H systemd-coredump[4643]: Process 4641 (systemd-cryptse) of user 0 dumped core.
...
                                          Stack trace of thread 4641:
                                          #0  0x00007ff9256afe5c __pthread_kill_implementation (libc.so.6 + 0x8ce5c)
                                          #1  0x00007ff92565fa76 raise (libc.so.6 + 0x3ca76)
                                          #2  0x00007ff9256497fc abort (libc.so.6 + 0x267fc)
                                          #3  0x00007ff926076047 log_assert_failed (libsystemd-shared-253.so + 0x276047)
                                          #4  0x00007ff9260ab317 strv_find (libsystemd-shared-253.so + 0x2ab317)
                                          #5  0x0000000000405927 parse_one_option (systemd-cryptsetup + 0x5927)
                                          #6  0x0000000000407793 parse_options (systemd-cryptsetup + 0x7793)
                                          #7  0x000000000040fa0c run (systemd-cryptsetup + 0xfa0c)
                                          #8  0x000000000041137f main (systemd-cryptsetup + 0x1137f)
                                          #9  0x00007ff92564a510 __libc_start_call_main (libc.so.6 + 0x27510)
                                          #10 0x00007ff92564a5c9 __libc_start_main@@GLIBC_2.34 (libc.so.6 + 0x275c9)
                                          #11 0x0000000000403915 _start (systemd-cryptsetup + 0x3915)
                                          ELF object binary architecture: AMD x86-64

2 years agotest: clean up the test cleanup a bit
Frantisek Sumsal [Sun, 4 Jun 2023 13:45:08 +0000 (15:45 +0200)] 
test: clean up the test cleanup a bit

2 years agotest: minor cleanup
Frantisek Sumsal [Sun, 4 Jun 2023 13:33:24 +0000 (15:33 +0200)] 
test: minor cleanup

No functional change.

2 years agotest: make the data partition larger for the cryptsetup test
Frantisek Sumsal [Mon, 5 Jun 2023 07:40:21 +0000 (09:40 +0200)] 
test: make the data partition larger for the cryptsetup test

As we use it for /var and with the default 100 MiB there's not enough
space for the journal.

2 years agotest: make the root/data partition size configurable per test
Frantisek Sumsal [Mon, 5 Jun 2023 07:39:51 +0000 (09:39 +0200)] 
test: make the root/data partition size configurable per test

2 years agotest: introduce test_require_bin() and use it
Frantisek Sumsal [Fri, 2 Jun 2023 19:10:08 +0000 (21:10 +0200)] 
test: introduce test_require_bin() and use it

No functional change.

2 years agotest: fix indentation
Frantisek Sumsal [Fri, 2 Jun 2023 18:56:12 +0000 (20:56 +0200)] 
test: fix indentation

2 years agotest: move TPM2-related setup stuff into test-functions
Frantisek Sumsal [Fri, 2 Jun 2023 18:28:41 +0000 (20:28 +0200)] 
test: move TPM2-related setup stuff into test-functions

And hide it all behind $TEST_SETUP_SWTPM.

2 years agoMerge pull request #27871 from yuwata/udevadm-verify-downgrade-style-issues
Zbigniew Jędrzejewski-Szmek [Mon, 5 Jun 2023 14:07:19 +0000 (16:07 +0200)] 
Merge pull request #27871 from yuwata/udevadm-verify-downgrade-style-issues

udevadm-verify: downgrade log level about style issues

2 years agoMerge pull request #27924 from poettering/low-battery-tool
Zbigniew Jędrzejewski-Szmek [Mon, 5 Jun 2023 14:03:57 +0000 (16:03 +0200)] 
Merge pull request #27924 from poettering/low-battery-tool

ac-power: expose low battery state via systemd-ac-power

2 years agotest: allow running only specified subtests/testcases
Frantisek Sumsal [Mon, 5 Jun 2023 08:47:21 +0000 (10:47 +0200)] 
test: allow running only specified subtests/testcases

Useful when debugging, e.g.:

make -C test/TEST-74-AUX-UTILS clean setup run TEST_MATCH_SUBTEST=run

Resolves: #27914

2 years agotest: Test --offline= in TEST-58-REPART 27926/head
Daan De Meyer [Mon, 5 Jun 2023 13:29:47 +0000 (15:29 +0200)] 
test: Test --offline= in TEST-58-REPART

Instead of using a privileged and unprivileged user to test the
offline and online logic of systemd-repart, let's always run repart
as root and use the --offline= argument to specify repart to use
either the offline or online logic.

2 years agoman: parition → partition typo fix
Lennart Poettering [Mon, 5 Jun 2023 09:04:54 +0000 (11:04 +0200)] 
man: parition → partition typo fix

Follow-up for: #27848

2 years agorepart: Add --offline argument
Daan De Meyer [Mon, 5 Jun 2023 11:56:49 +0000 (13:56 +0200)] 
repart: Add --offline argument

This allows the user to explicit configure whether loop devices
should be used to build the image or not.

2 years agoac-power: add --low switch to systemd-ac-power tool 27924/head
Lennart Poettering [Mon, 5 Jun 2023 10:14:12 +0000 (12:14 +0200)] 
ac-power: add --low switch to systemd-ac-power tool

This allows checking from shell scripts whether the system is in a low
battery state. It just exposed the code we anyway have in a directly
accessible way.

This is also very useful for testing things.

2 years agobattery-util: be more careful when determining whether we are in a low battery state
Lennart Poettering [Mon, 5 Jun 2023 10:12:03 +0000 (12:12 +0200)] 
battery-util: be more careful when determining whether we are in a low battery state

Let's avoid assuming a low battery battery state if in doubt. That
means, handle errors reading battery state gracefully.

2 years agobattery-util: move battery_is_discharging_and_low() to battery-util.[ch]
Lennart Poettering [Mon, 5 Jun 2023 09:56:31 +0000 (11:56 +0200)] 
battery-util: move battery_is_discharging_and_low() to battery-util.[ch]

This moves a first batch of functions from sleep-config.[ch] over to
battery-util.[ch].

In the long run we should probably move even more stuff over, i.e.
anything that deals with the battery sysfs driver interface.

No code change.

2 years agobattery-util: split out code that checks AC power state into its own .c/.h pair
Lennart Poettering [Mon, 5 Jun 2023 09:49:35 +0000 (11:49 +0200)] 
battery-util: split out code that checks AC power state into its own .c/.h pair

No code change, just some splitting out of the relevant code from
udev-util.[ch].

This makes sense on its own, but is also prepartion to move the code
that checks for low battery state into battery-util.[ch], too.

2 years agoadd support for KSM
Stefan Roesch [Tue, 28 Feb 2023 20:39:35 +0000 (12:39 -0800)] 
add support for KSM

This adds support for KSM (kernel samepage merging). It adds a new
boolean parameter called MemoryKSM to enable the feature. The feature
can only be enabled with newer kernels.

2 years agochase: fix triggering assertion
Yu Watanabe [Mon, 5 Jun 2023 04:20:42 +0000 (13:20 +0900)] 
chase: fix triggering assertion

2 years agoci: Report results from CIFuzz using SARIF
jonathanmetzman [Mon, 5 Jun 2023 05:37:34 +0000 (01:37 -0400)] 
ci: Report results from CIFuzz using SARIF

Upload results from CIFuzz using SARIF.
This will allow CIFuzz to report issues in the security tab.
This is a better UI than having to look through logs.
TODO(google/oss-fuzz#10452): Add proper descriptions of UBSAN bugs.

2 years agopath-util: fix typo in comment
Gaël PORTAY [Mon, 5 Jun 2023 04:42:02 +0000 (06:42 +0200)] 
path-util: fix typo in comment

The comment makes a reference to the function fchmod_path() but this
function does not exist in the source tree.

However, the function fchmod_opath() exists; it was introduced by the
commit 4dfaa528d451aa7926be4f1b4cf8d0ffe338421d.

As the comment tells, the function futimens_opath() introduced by the
commit f25bff5eaf6881717e873f27c26f2e8264517c16 is similar to the
function fchmod_opath(); therefore, it should reference it.

This fixes the typo in the comment by referencing the proper function
fchmod_opath().

2 years agoudev: downgrade log level about style issues 27871/head
Yu Watanabe [Thu, 1 Jun 2023 01:10:00 +0000 (10:10 +0900)] 
udev: downgrade log level about style issues

And add --no-style switch that make style issues not critical.

2 years agotest: drop unnecessary copy of expected output
Yu Watanabe [Thu, 1 Jun 2023 02:48:09 +0000 (11:48 +0900)] 
test: drop unnecessary copy of expected output

2 years agoudev-rules: terminate log messages with period
Yu Watanabe [Thu, 1 Jun 2023 01:06:59 +0000 (10:06 +0900)] 
udev-rules: terminate log messages with period

2 years agoMerge pull request #27907 from mrc0mmand/quick-test-tweaks
Yu Watanabe [Sat, 3 Jun 2023 20:22:53 +0000 (05:22 +0900)] 
Merge pull request #27907 from mrc0mmand/quick-test-tweaks

test: a couple of tweaks for recent CI fails

2 years agoMerge pull request #27908 from weblate/weblate-systemd-master
Frantisek Sumsal [Sat, 3 Jun 2023 15:54:46 +0000 (17:54 +0200)] 
Merge pull request #27908 from weblate/weblate-systemd-master

Translations update from Fedora Weblate

2 years agopo: Translated using Weblate (Korean) 27908/head
김인수 [Sat, 3 Jun 2023 15:48:02 +0000 (17:48 +0200)] 
po: Translated using Weblate (Korean)

Currently translated at 100.0% (193 of 193 strings)

Co-authored-by: 김인수 <simmon@nplob.com>
Translate-URL: https://translate.fedoraproject.org/projects/systemd/master/ko/
Translation: systemd/main

2 years agopo: Translated using Weblate (Basque)
Asier Sarasua Garmendia [Sat, 3 Jun 2023 15:48:02 +0000 (17:48 +0200)] 
po: Translated using Weblate (Basque)

Currently translated at 16.5% (32 of 193 strings)

po: Added translation using Weblate (Basque)

Co-authored-by: Asier Sarasua Garmendia <asier.sarasua@gmail.com>
Translate-URL: https://translate.fedoraproject.org/projects/systemd/master/eu/
Translation: systemd/main

2 years agoumount: /usr/ should never be unmounted regardless of HAVE_SPLIT_USR or not
Lennart Poettering [Sat, 3 Jun 2023 07:17:45 +0000 (09:17 +0200)] 
umount: /usr/ should never be unmounted regardless of HAVE_SPLIT_USR or not

Whether we put some binaries in /bin or in /usr/bin should not have any
effect on unmounting during shutdown. Even if people split /usr/ off we
should not try to unmount it, no matter what as it is simply where
binaries are placed.

2 years agotest: drop the --recursive=no test 27907/head
Frantisek Sumsal [Sat, 3 Jun 2023 11:38:29 +0000 (13:38 +0200)] 
test: drop the --recursive=no test

As the outcome also depends on availability of the PID namespace, so
the test might (and does) unexpectedly pass in some environments.

2 years agotest: ignore missing coverage in TEST-82-SOFTREBOOT
Frantisek Sumsal [Sat, 3 Jun 2023 07:49:04 +0000 (09:49 +0200)] 
test: ignore missing coverage in TEST-82-SOFTREBOOT

As we temporarily mount rootfs read-only there.

2 years agosysupdate.d: Add way to drop binaries into $BOOT
Adrian Vovk [Fri, 26 May 2023 04:47:47 +0000 (00:47 -0400)] 
sysupdate.d: Add way to drop binaries into $BOOT

As described in the BLS, we should place binaries into the XBOOTLDR
directory if it is available, otherwise into the ESP. Thus, we might
need to put binaries into /boot or into /efi depending on the existence
of the XBOOTLDR partition.

With this change, we introduce a new PathRelativeTo= config option that
makes this functionality possible

2 years agoMerge pull request #27904 from DaanDeMeyer/lsm
Luca Boccassi [Fri, 2 Jun 2023 22:57:21 +0000 (23:57 +0100)] 
Merge pull request #27904 from DaanDeMeyer/lsm

mkosi: Enable more options

2 years agoMerge pull request #27903 from mrc0mmand/test-followups
Luca Boccassi [Fri, 2 Jun 2023 22:56:58 +0000 (23:56 +0100)] 
Merge pull request #27903 from mrc0mmand/test-followups

test: a couple of systemd-{coredump,pstore,run} followups

2 years agoMerge pull request #27435 from poettering/renew-reboot
Lennart Poettering [Fri, 2 Jun 2023 21:27:45 +0000 (23:27 +0200)] 
Merge pull request #27435 from poettering/renew-reboot

pid1: add a new method of rebooting: userspace only under the name "soft-reboot"

2 years agoMerge pull request #27896 from poettering/umount-detach-rework
Lennart Poettering [Fri, 2 Jun 2023 19:47:09 +0000 (21:47 +0200)] 
Merge pull request #27896 from poettering/umount-detach-rework

shutdown: refactoring + tone down log message a bit

2 years agoMerge pull request #27902 from poettering/round-up
Lennart Poettering [Fri, 2 Jun 2023 19:46:50 +0000 (21:46 +0200)] 
Merge pull request #27902 from poettering/round-up

add ROUND_UP() macro for rounding integer up to next multiple of some value

2 years agoupdate TODO 27435/head
Lennart Poettering [Tue, 2 May 2023 10:39:59 +0000 (12:39 +0200)] 
update TODO

2 years agotest: add integration test for soft reboots incl. fdstore passing
Lennart Poettering [Wed, 3 May 2023 13:05:12 +0000 (15:05 +0200)] 
test: add integration test for soft reboots incl. fdstore passing

2 years agotest: disable SoftReboot() in dfuzzer test for now
Lennart Poettering [Wed, 3 May 2023 07:37:55 +0000 (09:37 +0200)] 
test: disable SoftReboot() in dfuzzer test for now

As requested:

https://github.com/systemd/systemd/pull/27435#issuecomment-1527810336

2 years agoman: document the soft reboot operation
Lennart Poettering [Wed, 3 May 2023 08:33:01 +0000 (10:33 +0200)] 
man: document the soft reboot operation

2 years agofstab-util: consider /run/nextroot/ among extrinsic mounts
Lennart Poettering [Fri, 2 Jun 2023 15:51:37 +0000 (17:51 +0200)] 
fstab-util: consider /run/nextroot/ among extrinsic mounts

This way we'll not add deps for the mount point that unmount it during
shutdown. This is similar as for /run/initramfs/ which we want to
transition into during shutdown.

This way we don't have to add "-o x-initrd.mount" to all bind mounts for
/run/nextroot anymore to make it survive the reboot, it will be implied.

2 years agomount-setup: exclude /run/nextroot/ from relabelling
Lennart Poettering [Fri, 2 Jun 2023 15:50:50 +0000 (17:50 +0200)] 
mount-setup: exclude /run/nextroot/ from relabelling

Just like /run/initramfs/ the data in /run/nextroot/ should be a
self-contained OS tree, and not require labelling, hence don't.

2 years agoswitch-root: automatically make target switch root dir a mount point
Lennart Poettering [Fri, 2 Jun 2023 16:24:27 +0000 (18:24 +0200)] 
switch-root: automatically make target switch root dir a mount point

Let's make sure implicitly that the target directory is a mount point,
instead of doing so manually beforehand. This allows us to drop this
step from the transition into the /run/initramfs/ dir at shutdown.

During the initrd→host transition the switch root operations so far
where towards pre-existing mount points, but there are cetrainly
usecases where it might make sense to siwtch into arbitrary
subdirectories, too.

2 years agomount-util: add fd_make_mount_point() helper
Lennart Poettering [Fri, 2 Jun 2023 16:23:44 +0000 (18:23 +0200)] 
mount-util: add fd_make_mount_point() helper

2 years agomkosi: Enable more options 27904/head
Daan De Meyer [Fri, 2 Jun 2023 15:25:23 +0000 (17:25 +0200)] 
mkosi: Enable more options

We build with support for selinux/apparmor where applicable but
disable them at runtime as even in permissive mode they're horribly
broken.

2 years agotest: probe a couple more paths in systemd-run 27903/head
Frantisek Sumsal [Fri, 2 Jun 2023 14:53:45 +0000 (16:53 +0200)] 
test: probe a couple more paths in systemd-run

2 years agoswitch-root: disable sync() again when we switch root during shutdown
Lennart Poettering [Fri, 19 May 2023 13:52:43 +0000 (15:52 +0200)] 
switch-root: disable sync() again when we switch root during shutdown

Our shutdown binary that takes over as PID 1 when shutting down puts
great efforts into a sync() that comes with a time-out once sync'ing
process stops. If we'd add another dumb sync() here, we kinda defeat all
it is good for. Hence, let's keep the sync() in for most codepats, but
let's disable it for the final shutdown logic when we transition back
into the exitrd. After all we sync()ed more than enough here, no need to
sync() even more.

2 years agoswitch-root: introduce SwitchRootFlags flags parameter to switch_root()
Lennart Poettering [Fri, 19 May 2023 13:48:12 +0000 (15:48 +0200)] 
switch-root: introduce SwitchRootFlags flags parameter to switch_root()

Let's replace the current boolean param with a proper flags param. With
a single flag this doesn't appear to make much sense, though it does
already make things more readable I think.

However, once we add a second flag, it starts to make more sense.

Also, while we are at it, condition the "istmp" determinaton with this
flag too, since we only need it when the flag is set.

2 years agoswitch-root: always use MS_BIND to move api vfs over
Lennart Poettering [Tue, 16 May 2023 12:57:31 +0000 (14:57 +0200)] 
switch-root: always use MS_BIND to move api vfs over

We previously would use MS_MOVE to move the old procfs, sysfs, /dev/ and
/run to the new place in some places, and MS_BIND in others.

The logic when to use MS_MOVE and when to use MS_BIND was pretty
arbitrary so far: we'd use MS_MOVE during the initrd → host transition
and MS_BIND when transitioning from host into the exitrd during
shutdown.

Traditionally, using MS_MOVE was preferable, because we didn't bother
with unmounting the old mount hierarchy before the switch root, and thus
using MS_MOVE did some clean-up as side-effect (because the old mounts
went away this way). But since we nowadays properly umount all remaining
mount points (since 268d1244e87a35ff8dff56c92ef375ebf69d462e) when
transitioning it's pointless.

Let's just use MS_BIND always. Let's tweak it though: let's use
MS_BIND|MS_REC for the kernel API VFS, and MS_BIND without MS_REC for
/run/. The latter reflects the fact that the submounts /run/ has usually
are not so much about just accessing kernel APIs but about auxiliary
user resources. Hence let's only move the main mount over for that.

While we are at it, also set up the base filesystem *before* we move the
mounts from the old to the new root, since the base filesystem setup
logic creates various needed inodes for us, which we really should make
use of instead of creating on our own.

2 years agosystemctl: add "systemctl soft-reboot" command
Lennart Poettering [Thu, 27 Apr 2023 19:56:20 +0000 (21:56 +0200)] 
systemctl: add "systemctl soft-reboot" command

2 years agologind: add support for 'soft-reboot' reboots
Lennart Poettering [Thu, 27 Apr 2023 19:56:14 +0000 (21:56 +0200)] 
logind: add support for 'soft-reboot' reboots

2 years agopid1: add "soft-reboot" reboot method
Lennart Poettering [Thu, 27 Apr 2023 15:23:18 +0000 (17:23 +0200)] 
pid1: add "soft-reboot" reboot method

This adds a new mechanism for rebooting, a form of "userspace reboot"
hereby dubbed "soft-reboot". It will stop all services as in a usual
shutdown, possibly transition into a new root fs and then issue a fresh
initial transaction. The kernel is not replaced.

File descriptors can be passed over, thus opening the door for leaving
certain resources around between such reboots.

Usecase: this is an extremely quick way to reset userspace fully when
updating image based systems, without going through a full
hardware/firmware/boot loader/kernel/initrd cycle. It minimizes "grayout time"
for OS updates. (In particular when combined with kernel live patching)

2 years agotree-wide: port various pieces of code over to ROUND_UP() 27902/head
Lennart Poettering [Fri, 2 Jun 2023 14:40:29 +0000 (16:40 +0200)] 
tree-wide: port various pieces of code over to ROUND_UP()

There's probably more than we can convert to this.

2 years agotest-macro: add ROUND_UP() macro for rounding up to next multiple
Lennart Poettering [Fri, 2 Jun 2023 14:34:32 +0000 (16:34 +0200)] 
test-macro: add ROUND_UP() macro for rounding up to next multiple

In case of overflow will return -1 cast to the first parameter type.

2 years agocoverage: add a wrapper for execvpe()
Frantisek Sumsal [Fri, 2 Jun 2023 14:25:06 +0000 (16:25 +0200)] 
coverage: add a wrapper for execvpe()

It's the exactly same stuff as for execveat() - gcov doesn't have a
wrapper for execvpe() so introduce our own.

2 years agoMerge pull request #27849 from DaanDeMeyer/sign-pcr
Daan De Meyer [Fri, 2 Jun 2023 14:16:41 +0000 (16:16 +0200)] 
Merge pull request #27849 from DaanDeMeyer/sign-pcr

mkosi: Sign expected PCRs

2 years agoshutdown: tone down failure messages a bit 27896/head
Lennart Poettering [Fri, 2 Jun 2023 09:20:21 +0000 (11:20 +0200)] 
shutdown: tone down failure messages a bit

If we are not able to detach all MD/DM/loopback devices this is not
necessarily a failure, it's simply because we might be running off them.
Hence let's tone down our language a bit, and just say "Unable to"
rather than "Failed to".

2 years agodetach-loopback: also don't bother detaching loopback block device /usr/ is running off
Lennart Poettering [Fri, 2 Jun 2023 09:42:08 +0000 (11:42 +0200)] 
detach-loopback: also don't bother detaching loopback block device /usr/ is running off

While we are at it, let's also clean this up a bit: unlike DM/MD devices
loopback devices are likely partitioned, hence trace the block device
through the partition layer and LUKS.

2 years agodetach-md: similar to the DM case, also don't try to detach MD device backing /usr/
Lennart Poettering [Fri, 2 Jun 2023 09:41:40 +0000 (11:41 +0200)] 
detach-md: similar to the DM case, also don't try to detach MD device backing /usr/

2 years agoshutdown: don't attempt to detach DM volume backing /usr/
Lennart Poettering [Fri, 2 Jun 2023 09:08:07 +0000 (11:08 +0200)] 
shutdown: don't attempt to detach DM volume backing /usr/

Since we run off /usr/ it makes no sense to attempt to try to detach any
DM device backing it. Hence skip it just like we skip detaching the DM
device backing the root fs.

Addresses: https://github.com/systemd/systemd/issues/27682#issuecomment-1573328188

2 years agodetach-loopback: also decouple from umount.h
Lennart Poettering [Fri, 2 Jun 2023 09:02:16 +0000 (11:02 +0200)] 
detach-loopback: also decouple from umount.h

Let's introduce LoopbackDevice as replacement for MountPoint, with just
the fields we actually need.

2 years agodetach-md: also decouple structures from umount.h
Lennart Poettering [Fri, 2 Jun 2023 08:57:10 +0000 (10:57 +0200)] 
detach-md: also decouple structures from umount.h

2 years agodetach-dm: decouple from umount.[ch]
Lennart Poettering [Fri, 2 Jun 2023 08:54:03 +0000 (10:54 +0200)] 
detach-dm: decouple from umount.[ch]

Let's also define our own little structure here with just the fields we
need.

2 years agodetach-swap: decouple from umount.h
Lennart Poettering [Fri, 2 Jun 2023 08:51:08 +0000 (10:51 +0200)] 
detach-swap: decouple from umount.h

So far detach-swap.[ch] were still using the MountPoint structure to
store swap device info in. Since it was only using a single field of it
sharing the whole structure is kinda pointless. Hence, let's decouple
this and only add the field we really need.

2 years agoumount: split out swap detachment code too
Lennart Poettering [Fri, 2 Jun 2023 08:46:17 +0000 (10:46 +0200)] 
umount: split out swap detachment code too

2 years agoumount: split out loopback detach code
Lennart Poettering [Fri, 2 Jun 2023 08:36:39 +0000 (10:36 +0200)] 
umount: split out loopback detach code

Like the similar commits, no actual code changes, just splitting up
large C files.

2 years agoumount: similar as previous commit, split out DM detaching
Lennart Poettering [Fri, 2 Jun 2023 08:31:55 +0000 (10:31 +0200)] 
umount: similar as previous commit, split out DM detaching

2 years agoumount: split out MD detaching code from umount.c
Lennart Poettering [Fri, 2 Jun 2023 08:25:19 +0000 (10:25 +0200)] 
umount: split out MD detaching code from umount.c

umount.c does so much stuff, and MD detaching is relatively separate,
hence split it out into its own .c/.h file pair.

2 years agodissect-image: fix partition label version compare
Lennart Poettering [Fri, 2 Jun 2023 10:25:09 +0000 (12:25 +0200)] 
dissect-image: fix partition label version compare

The logic was borked: if we find multiple partitions of the same
designator, we should first prefer the better arch, and then prefer the
better version, and then the first found. Fix that.

Fixes: #27897
2 years agomkosi: Only lower device timeout instead of all timeouts 27849/head
Daan De Meyer [Wed, 31 May 2023 14:19:21 +0000 (16:19 +0200)] 
mkosi: Only lower device timeout instead of all timeouts

We only really care about lowering the device timeout so we get to
a shell faster when the root device doesn't appear so let's only
lower that timeout instead of lowering all default timeouts.

2 years agocore: Add systemd.default_device_timeout_sec= cmdline option
Daan De Meyer [Wed, 31 May 2023 14:16:21 +0000 (16:16 +0200)] 
core: Add systemd.default_device_timeout_sec= cmdline option

2 years agomkosi: Sign expected PCRs
Daan De Meyer [Tue, 30 May 2023 12:09:44 +0000 (14:09 +0200)] 
mkosi: Sign expected PCRs

This is now possible without a TMP device so let's start signing
PCRs when building images with mkosi.

2 years agomkosi: Remove file blacklisting erofs module in opensuse initrd
Daan De Meyer [Fri, 2 Jun 2023 13:42:34 +0000 (15:42 +0200)] 
mkosi: Remove file blacklisting erofs module in opensuse initrd

2 years agomkosi: Enable set -e in postinst script
Daan De Meyer [Fri, 2 Jun 2023 13:42:14 +0000 (15:42 +0200)] 
mkosi: Enable set -e in postinst script

2 years agomkosi: Move python3-pytest-flakes to build packages on opensuse
Daan De Meyer [Fri, 2 Jun 2023 13:41:45 +0000 (15:41 +0200)] 
mkosi: Move python3-pytest-flakes to build packages on opensuse