]> git.ipfire.org Git - thirdparty/systemd.git/log
thirdparty/systemd.git
2 years agoukify: make the certficate validity configurable 27946/head
Zbigniew Jędrzejewski-Szmek [Wed, 14 Jun 2023 10:38:37 +0000 (12:38 +0200)] 
ukify: make the certficate validity configurable

Requested in https://github.com/systemd/systemd/pull/27946/commits/4cc743319ae378d458050d6e0cfdeaa03addd379#r1228592001

2 years agoman/ukify: add structure to describe verbs, document genkey
Zbigniew Jędrzejewski-Szmek [Mon, 12 Jun 2023 10:22:32 +0000 (12:22 +0200)] 
man/ukify: add structure to describe verbs, document genkey

This just adds two paragraphs of text, but moves a lot of the text
one level down into a subsection.

2 years agotest_ukify: skip test requiring cryptography
Zbigniew Jędrzejewski-Szmek [Wed, 7 Jun 2023 08:05:02 +0000 (10:05 +0200)] 
test_ukify: skip test requiring cryptography

I'll add the dep in Fedora spec so it does get tested at least
in some cases.

2 years agoman: add example how to configure automatic signing
Zbigniew Jędrzejewski-Szmek [Tue, 6 Jun 2023 19:31:17 +0000 (21:31 +0200)] 
man: add example how to configure automatic signing

Fixes #978.

2 years agotest_ukify: cleanups suggested by pylint
Zbigniew Jędrzejewski-Szmek [Tue, 6 Jun 2023 19:07:58 +0000 (21:07 +0200)] 
test_ukify: cleanups suggested by pylint

2 years agoukify: add 'genkey' verb
Zbigniew Jędrzejewski-Szmek [Tue, 6 Jun 2023 19:06:20 +0000 (21:06 +0200)] 
ukify: add 'genkey' verb

The idea is to make it easy to generate all the signing key and certs
that can be used for local signing. The verb is the modeled after
'mkosi genkey', but there are some important differences: we generate
the keys to the paths where they will be read from, both pcr signing
keys and the SecureBoot certificate+key.

If any of the outputs exist, operation is refused. Maybe we could add a
--force option in the future, but this operation should be rare, so I think
it's better to refuse to overwrite anything initially.

I'm only doing a token man page change here.
https://github.com/systemd/systemd/pull/27621 reworks the man page,
and the changes done here would conflict heavily with that work. I'll
submit a follow-up patch later.

2 years agoukify: move verb mangling to finalize_options()
Zbigniew Jędrzejewski-Szmek [Wed, 7 Jun 2023 07:10:49 +0000 (09:10 +0200)] 
ukify: move verb mangling to finalize_options()

This simplifies the logic: finalize_options() is the step that does the
checks and the mangling. The checks for consistency are done in more places,
so we need to pass a verb (we only have 'build', but once we add other verbs,
any would do).

2 years agoukify: split out iteration over phase path groups and keys
Zbigniew Jędrzejewski-Szmek [Tue, 6 Jun 2023 19:03:10 +0000 (21:03 +0200)] 
ukify: split out iteration over phase path groups and keys

In preparation for future changes.

2 years agoman,test: root or hardware is not needed for ukify
Zbigniew Jędrzejewski-Szmek [Tue, 6 Jun 2023 18:32:33 +0000 (20:32 +0200)] 
man,test: root or hardware is not needed for ukify

2 years agoukify: fix synopsis in --help
Zbigniew Jędrzejewski-Szmek [Tue, 6 Jun 2023 18:27:48 +0000 (20:27 +0200)] 
ukify: fix synopsis in --help

Missed in a3b227d28a823d59e3281109f5369d0f63b40f62.

2 years agoukify: use pager for --help
Zbigniew Jędrzejewski-Szmek [Tue, 6 Jun 2023 15:32:47 +0000 (17:32 +0200)] 
ukify: use pager for --help

The output is now too long to fit on one page, let's use a pager automatically
like in other places.

The implementation is copied from mkosi, but adjusted to follow what other
systemd tools do.

2 years agoukify: add 'build' verb 27938/head
Zbigniew Jędrzejewski-Szmek [Tue, 6 Jun 2023 11:23:49 +0000 (13:23 +0200)] 
ukify: add 'build' verb

The old syntax with linux + initrds as positional arguments is still accepted,
but a warning is emitted. We should remove the support for this after the
next release or so.

Adding a single verb by itself is not very useful, but opens the door to adding
other verbs.

2 years agotest_ukify: pass through path to addon stub
Zbigniew Jędrzejewski-Szmek [Tue, 6 Jun 2023 11:03:41 +0000 (13:03 +0200)] 
test_ukify: pass through path to addon stub

Without this, the tests would generally be skipped, since we haven't made a
release with the addon stub yet. But even if the file is there, we always want
to test the freshly-built item.

2 years agotest_ukify: no stinky root needed for signing
Zbigniew Jędrzejewski-Szmek [Tue, 6 Jun 2023 10:18:56 +0000 (12:18 +0200)] 
test_ukify: no stinky root needed for signing

C.f. b2efe286587e11e2aa4a6c7e4a2c15da3bb58a2a.

2 years agoukify: simplify creation of parser
Zbigniew Jędrzejewski-Szmek [Mon, 5 Jun 2023 13:47:00 +0000 (15:47 +0200)] 
ukify: simplify creation of parser

00e5933f57c6e336ebed18601299acc6855bb3c2 made all the positional arguments
optional, so let's take advantage of this to simplify variuos callers.

2 years agoukify: make code pylint clean
Zbigniew Jędrzejewski-Szmek [Thu, 1 Jun 2023 08:39:54 +0000 (10:39 +0200)] 
ukify: make code pylint clean

The linter is imperfect, but it is useful as a very quick
check for typos and other silly mistakes. Add a few annotations
and do one small change to make it think the code is perfect.

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 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 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

2 years agomkosi: Add missing tss2 dependencies
Daan De Meyer [Fri, 2 Jun 2023 13:41:12 +0000 (15:41 +0200)] 
mkosi: Add missing tss2 dependencies

2 years agomeson: Add missing tss2-tcti-device dependency
Daan De Meyer [Fri, 2 Jun 2023 13:40:35 +0000 (15:40 +0200)] 
meson: Add missing tss2-tcti-device dependency

2 years agomkosi: Update to latest
Daan De Meyer [Thu, 1 Jun 2023 10:45:45 +0000 (12:45 +0200)] 
mkosi: Update to latest

2 years agofstab-generator: if we mount via roothash=/usrhash= let's imply "ro" mount option
Lennart Poettering [Fri, 2 Jun 2023 07:54:18 +0000 (09:54 +0200)] 
fstab-generator: if we mount via roothash=/usrhash= let's imply "ro" mount option

If we discover the root or /usr/ fs via roothash=/usrhash= we know the
file system mounted on it will be read-only, since Verity volumes are by
definition immutable. Hence, let's imply the "ro" mount option for them.

This way the "kernel: /dev/mapper/usr: Can't open blockdev" boot-time
log message goes away, reported here:

https://github.com/systemd/systemd/issues/27682

(I do wonder though why erofs even tries to open the block device as
writable, that sounds utterly pointless for a file system that carries
the fact it is read-only even in the name...)

2 years agotest: sync with the fake binary before killing it
Frantisek Sumsal [Fri, 2 Jun 2023 11:24:32 +0000 (13:24 +0200)] 
test: sync with the fake binary before killing it

On faster machines we might be too fast and kill the fake binary during
fork() which then makes kernel report a "wrong" binary in the coredump,
e.g.:

[   31.408078] testsuite-74.sh[548]: + /tmp/make-dump /tmp/test-dump SIGTRAP
[   31.409720] testsuite-74.sh[560]: + bin=/tmp/test-dump
[   31.409720] testsuite-74.sh[560]: + sig=SIGTRAP
[   31.409720] testsuite-74.sh[560]: + ulimit -c unlimited
[   31.409720] testsuite-74.sh[560]: + pid=561
[   31.409720] testsuite-74.sh[560]: + sleep 1
[   31.409720] testsuite-74.sh[560]: + kill -s SIGTRAP 561
[   31.409720] testsuite-74.sh[560]: + wait 561
[   31.491757] systemd[1]: Created slice system-systemd\x2dcoredump.slice.
[   31.524488] systemd[1]: Started systemd-coredump@0-563-0.service.
[   31.616372] systemd-coredump[564]: [🡕] Process 561 (make-dump) of user 0 dumped core.

                                      Stack trace of thread 561:
                                      #0  0x00007ff86bb49af7 _Fork (libc.so.6 + 0xd4af7)
                                      #1  0x00007ff86bb4965f __libc_fork (libc.so.6 + 0xd465f)
                                      #2  0x000055e88011b0ad make_child (bash + 0x550ad)
                                      #3  0x000055e8800fd05f n/a (bash + 0x3705f)
                                      #4  0x000055e880100116 execute_command_internal (bash + 0x3a116)
                                      #5  0x000055e8801011f2 execute_command_internal (bash + 0x3b1f2)
                                      #6  0x000055e8801025b6 execute_command (bash + 0x3c5b6)
                                      #7  0x000055e8800f134b reader_loop (bash + 0x2b34b)
                                      #8  0x000055e8800e757d main (bash + 0x2157d)
                                      #9  0x00007ff86ba98850 n/a (libc.so.6 + 0x23850)
                                      #10 0x00007ff86ba9890a __libc_start_main (libc.so.6 + 0x2390a)
                                      #11 0x000055e8800e83b5 _start (bash + 0x223b5)
                                      ELF object binary architecture: AMD x86-64
[   31.666617] testsuite-74.sh[560]: /tmp/make-dump: line 12:   561 Trace/breakpoint trap   (core dumped) "$bin" infinity
...
$ coredumpctl list --file system.journal
TIME                         PID UID GID SIG     COREFILE EXE            SIZE
Fri 2023-06-02 10:42:10 CEST 561   0   0 SIGTRAP journal  /usr/bin/bash     -
Fri 2023-06-02 10:42:11 CEST 570   0   0 SIGABRT journal  /tmp/test-dump    -
Fri 2023-06-02 10:42:12 CEST 582   0   0 SIGTRAP missing  /tmp/test-dump    -
Fri 2023-06-02 10:42:13 CEST 593   0   0 SIGABRT missing  /tmp/test-dump    -

2 years agotest: clean up our mess after the pstore test
Frantisek Sumsal [Fri, 2 Jun 2023 08:07:57 +0000 (10:07 +0200)] 
test: clean up our mess after the pstore test

2 years agoMerge pull request #27891 from mrc0mmand/more-tests-again
Frantisek Sumsal [Fri, 2 Jun 2023 08:05:17 +0000 (10:05 +0200)] 
Merge pull request #27891 from mrc0mmand/more-tests-again

test: improve systemd-pstore tests & add a couple of tests for systemd-run

2 years agoMerge pull request #27889 from poettering/no-usr-verity-detach
Lennart Poettering [Fri, 2 Jun 2023 04:24:13 +0000 (06:24 +0200)] 
Merge pull request #27889 from poettering/no-usr-verity-detach

veritysetup: make sure we don't try to detach /usr/ verity on shutdown

2 years agotest: add a couple of tests for systemd-run 27891/head
Frantisek Sumsal [Thu, 1 Jun 2023 06:47:51 +0000 (08:47 +0200)] 
test: add a couple of tests for systemd-run

2 years agosocket: avoid memory leak on incomplete SocketPort object
Frantisek Sumsal [Thu, 1 Jun 2023 20:11:01 +0000 (22:11 +0200)] 
socket: avoid memory leak on incomplete SocketPort object

==1==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 17 byte(s) in 1 object(s) allocated from:
    #0 0x7fc096c7243b in strdup (/lib64/libasan.so.8+0x7243b)
    #1 0x7fc095db3899 in bus_socket_set_transient_property ../src/core/dbus-socket.c:386
    #2 0x7fc095db5140 in bus_socket_set_property ../src/core/dbus-socket.c:460
    #3 0x7fc095dd20f1 in bus_unit_set_properties ../src/core/dbus-unit.c:2473
    #4 0x7fc095d87d53 in transient_unit_from_message ../src/core/dbus-manager.c:1025
    #5 0x7fc095d8872f in method_start_transient_unit ../src/core/dbus-manager.c:1112
    #6 0x7fc0944ddf4f in method_callbacks_run ../src/libsystemd/sd-bus/bus-objects.c:406
    #7 0x7fc0944e7854 in object_find_and_run ../src/libsystemd/sd-bus/bus-objects.c:1319
    #8 0x7fc0944e8f03 in bus_process_object ../src/libsystemd/sd-bus/bus-objects.c:1439
    #9 0x7fc09454ad78 in process_message ../src/libsystemd/sd-bus/sd-bus.c:3011
    #10 0x7fc09454b302 in process_running ../src/libsystemd/sd-bus/sd-bus.c:3053
    #11 0x7fc09454e158 in bus_process_internal ../src/libsystemd/sd-bus/sd-bus.c:3273
    #12 0x7fc09454e2f2 in sd_bus_process ../src/libsystemd/sd-bus/sd-bus.c:3300
    #13 0x7fc094551a59 in io_callback ../src/libsystemd/sd-bus/sd-bus.c:3642
    #14 0x7fc094727830 in source_dispatch ../src/libsystemd/sd-event/sd-event.c:4187
    #15 0x7fc094731009 in sd_event_dispatch ../src/libsystemd/sd-event/sd-event.c:4808
    #16 0x7fc094732124 in sd_event_run ../src/libsystemd/sd-event/sd-event.c:4869
    #17 0x7fc095f7af9f in manager_loop ../src/core/manager.c:3242
    #18 0x41cc7c in invoke_main_loop ../src/core/main.c:1937
    #19 0x4252e0 in main ../src/core/main.c:3072
    #20 0x7fc092a4a50f in __libc_start_call_main (/lib64/libc.so.6+0x2750f)

SUMMARY: AddressSanitizer: 17 byte(s) leaked in 1 allocation(s).

2 years agoman: fix sd_journal_*_with_location's func argument
Hannu Lounento [Tue, 30 May 2023 10:48:20 +0000 (13:48 +0300)] 
man: fix sd_journal_*_with_location's func argument

`sd_journal_print_with_location` and similar functions behave
inconsistently compared to their documentation, which says:

    sd_journal_print_with_location(), sd_journal_printv_with_location(),
    sd_journal_send_with_location(), sd_journal_sendv_with_location(),
    and sd_journal_perror_with_location() [...] accept additional
    parameters to explicitly set the source file name, function, and
    line. Those arguments must contain valid journal entries including
    the variable name, e.g. "CODE_FILE=src/foo.c", "CODE_LINE=666",
    "CODE_FUNC=myfunc".

Calling e.g. `sd_journal_sendv_with_location` with
`CODE_FUNC=myfunction` as the value of the argument `func` results in

    "CODE_FUNC" : "CODE_FUNC=myfunction"

because `sd_journal_*_with_location` implicitly prefix the argument
`func` with `CODE_FUNC=`. For example:

    _public_ int sd_journal_sendv_with_location(
                    const char *file, const char *line,
                    const char *func,
                    const struct iovec *iov, int n) {
            [...]
            char *f;
            [...]
            niov = newa(struct iovec, n + 3);
            [...]
            ALLOCA_CODE_FUNC(f, func);
            [...]
            niov[n++] = IOVEC_MAKE_STRING(f);

            return sd_journal_sendv(niov, n);
    }

where `ALLOCA_CODE_FUNC` is:

    #define ALLOCA_CODE_FUNC(f, func)                 \
            do {                                      \
                    size_t _fl;                       \
                    const char *_func = (func);       \
                    char **_f = &(f);                 \
                    _fl = strlen(_func) + 1;          \
                    *_f = newa(char, _fl + 10);       \
                    memcpy(*_f, "CODE_FUNC=", 10);    \
                    memcpy(*_f + 10, _func, _fl);     \
            } while (false)

The arguments `file` and `line` are _not_ prefixed similarly but
expected to be prefixed already with `CODE_FILE=` and `CODE_LINE=`
respectively and sent as is like the documentation describes.

That is, the argument `func` is treated differently and behaves
inconsistently compared to the arguments `file` and `line`. The behavior
seems still intentional:

    _public_ int sd_journal_printv_with_location(int priority, const char *file, const char *line, const char *func, const char *format, va_list ap) {
            [...]
            /* func is initialized from __func__ which is not a macro, but
            * a static const char[], hence cannot easily be prefixed with
            * CODE_FUNC=, hence let's do it manually here. */
            ALLOCA_CODE_FUNC(f, func);
            [...]
    }

Thus, change the documentation to match the actual behavior.

Note: `sd_journal_{print,send}` and `sd_journal_{print,send}v` work as
expected as they only pass the function name (i.e. without `CODE_FUNC=`)
to the `func` argument of the `sd_journal_*_with_location` functions
they call. For example:

    #define sd_journal_print(priority, ...) sd_journal_print_with_location(priority, "CODE_FILE=" __FILE__, "CODE_LINE=" _SD_STRINGIFY(__LINE__), __func__, __VA_ARGS__)

2 years agodbus-util: let's take it down a notch when converting file mode to string
Frantisek Sumsal [Thu, 1 Jun 2023 18:22:20 +0000 (20:22 +0200)] 
dbus-util: let's take it down a notch when converting file mode to string

I'm definitely a fan of precision, but in this case it's a bit too much:

    $ systemd-run --unit=test --socket-property=ListenFIFO=/tmp/foo --socket-property=SocketMode=0644 true
    $ systemctl cat test.socket
    # /run/systemd/transient/test.socket
    # This is a transient unit file, created programmatically via the systemd API. Do not edit.
    [Unit]
    Description=/usr/bin/true

    [Socket]
    ListenFIFO=/tmp/foo
    SocketMode=0000000000000000000000000000000000000644

2 years agotest: make the multiple-file test more thorough
Frantisek Sumsal [Thu, 1 Jun 2023 18:02:20 +0000 (20:02 +0200)] 
test: make the multiple-file test more thorough

Let's check if we keep the old records after multiple systemd-pstore
invocations (i.e. simulate a scenario where we get multiple crashes and
multiple machine reboots).

2 years agoveritysetup: remove double escaping of data device + hash device spec 27889/head
Lennart Poettering [Thu, 1 Jun 2023 17:15:10 +0000 (19:15 +0200)] 
veritysetup: remove double escaping of data device + hash device spec

generator_write_veritysetup_service_section() already escapes the
parameters internally, doing so in the caller means double escaping,
which is a bug. Fix it.

2 years agoveritysetup: minor renaming of functions
Lennart Poettering [Thu, 1 Jun 2023 16:54:33 +0000 (18:54 +0200)] 
veritysetup: minor renaming of functions

create_device() and create_disk() so far did very similar things, but
the name didn't give a hint what the difference was.

Hence let's rename them to create_special_device() and
create_veritytab_device() to make this more understandabe, as one
creates /proc/cmdline specified roothash=/usrhash= devices, and the
other one devices for items listed in /etc/veritytab.

No code changes besides renaming.

2 years ago{crypt|verity}setup: mention volume name in some error messages
Lennart Poettering [Thu, 1 Jun 2023 13:31:25 +0000 (15:31 +0200)] 
{crypt|verity}setup: mention volume name in some error messages

2 years ago{crypt|verity}setup: replace dep on systemd-tmpfiles-setup-dev.service by modprobe...
Lennart Poettering [Thu, 1 Jun 2023 13:00:27 +0000 (15:00 +0200)] 
{crypt|verity}setup: replace dep on systemd-tmpfiles-setup-dev.service by modprobe@loop.service

Both should have the same effect: the /dev/loop-control devices should
become available. systemd-tmpfiles-setup-dev.service creates the device
node "dry" based on modalias data, while modprobe@loop.service creates
it fully, because the module backing it is loaded properly. This should
shorten the deps chain a bit, simplify things and allows us to focus on
the stuff we actually need (i.e. the loopback infra) instead of all
entrypoints anyone might possibly need (i.e. the device nodes)