Commit graph

49556 commits

Author SHA1 Message Date
Mike Yuan 0bb4614adc shared/install: modernize unit_file_link
Also eliminate one more use of basename(), yay!
2024-06-11 23:17:21 +01:00
Mike Yuan e9e77e443d install,dbus-manager: make unit_file_* take (char* const*) for strv 2024-06-11 23:17:21 +01:00
Mike Yuan 1ac0056cc2 shared/install: modernize install_info_add 2024-06-11 23:17:21 +01:00
Mike Yuan df152dbbe5 shared/install: modernize find_symlinks and friends 2024-06-11 23:17:21 +01:00
Mike Yuan 1d2e1cad30 shared/install: modernize remove_marked_symlink_fd
Note that we now collect errors from
install_changes_add(), too.
2024-06-11 23:17:21 +01:00
Mike Yuan 05adb256f1 shared/install: return bool where appropriate 2024-06-11 23:17:21 +01:00
Mike Yuan f9ef2aad28 shared/dropin: minor modernization 2024-06-11 23:17:21 +01:00
Lennart Poettering a5139b1415 tpm2-util: tighten rules on the nvindex handle range we allocate from
Let's follow the conventions set by "Registry of Reserved TPM 2.0 Handles
and Localities" and only allocate nvindex currently not assigned to any
vendor.

For details see:

https://trustedcomputinggroup.org/resource/registry/

Section 2.2
2024-06-11 22:40:23 +01:00
Yu Watanabe 7b88bf087f shared: fix typo: dito -> ditto
Follow-up for bc9e5a4c67 and
3572d3df8f.
2024-06-12 02:34:39 +09:00
Zbigniew Jędrzejewski-Szmek 835fbe5f75 bus-unit-util: extend the bus call timeout for UnitFreezer
Follow-up for 1d617b35fe.
Should fix https://github.com/systemd/systemd/issues/33269.

From the logs in the bug:
Jun 10 22:55:37 systemd-logind[909]: The system will suspend now!
Jun 10 22:55:37 ModemManager[996]: <msg> [sleep-monitor-systemd] system is about to suspend
...
Jun 10 22:55:48 systemd-sleep[422408]: Failed to freeze unit 'user.slice': Connection timed out
Jun 10 22:55:48 systemd-sleep[422408]: Performing sleep operation 'suspend'...

The delay is ~11 s, consistent with the patch that set the timeout to 10 s.
Looks like this is not enough. It's the freeze operation that fails, but
thawing might be slow too, so just bump the timeout again.
2024-06-11 14:56:00 +01:00
Daan De Meyer 7efaab482a chase: Tighten "." and "./" check
Currently the check also succeeds if the input path starts with a dot, whereas
we only want it to succeed for "." and "./". Tighten the check and add a test.
2024-06-11 13:55:35 +01:00
Yu Watanabe 60c1fec461 homed: fix typo
Follow-up for c4b5de7eff.
2024-06-11 15:52:13 +09:00
Yu Watanabe 753c896ff9 login: re-used -> reused
Suggested by Fossies.
2024-06-11 15:52:13 +09:00
Mike Gilbert 953c60e2f1 user-util: fix fgetxxent_sane on musl
musl's implementation does not set errno to ENOENT when the end of file
is reached. It returns NULL and leaves errno unchanged.
2024-06-10 11:41:55 +02:00
Daan De Meyer 774eb5dbdd dev-setup: Follow /dev/console symlinks when locking /dev/console
systemd-nspawn sets up /dev/console as a symlink to a pty, so let's
make sure we follow the symlink when trying to lock /dev/console so
we don't fail with ELOOP.
2024-06-07 23:36:43 +01:00
Zbigniew Jędrzejewski-Szmek ddef3ec87c run: do not pass the pty slave fd to transient service in a machine
Follow-up for 28459ba1f4

The pty path returned by OpenMachinePTY() cannot be opened from outside
the machine, hence let's use the plain Standard{Input,Output,Error}=tty
in such a case. This means if --machine= is specified, #32916 would occur.
A comprehensive fix requires a new dbus method in machined, which shall
be material for v257.

See also: https://github.com/systemd/systemd/pull/33216#discussion_r1628020429

Replaces #33216

Co-authored-by: Mike Yuan <me@yhndnzj.com>
2024-06-06 20:37:39 +01:00
Luca Boccassi bed6e7c8b4 Update syscalls tables
ninja -C build update-syscall-tables update-syscall-header
2024-06-06 17:56:12 +01:00
Luca Boccassi b06ab6b92b
Merge pull request #33189 from bluca/fscrypt_flush
homed: flush fscrypt key on lock/deactivate
2024-06-06 16:34:20 +01:00
Luca Boccassi c4b5de7eff homed: flush fscrypt key on lock/deactivate
The fscrypt key is added to the user keyring, and needs to be flushed out too.

Fixes https://github.com/systemd/systemd/issues/33138
2024-06-06 13:52:26 +01:00
Luca Boccassi 67dfbe021c util: add keyring_describe helper and move to basic
So that it can be used from libsystemd. No external dependencies.
2024-06-06 11:39:56 +01:00
Yu Watanabe 01420b2db5 network/ndisc: use router lifetime as one for redirect route
Previously, we did not set lifetime for redirect route, and redirect
routes were removed only when received a RA from the target address.
Thus, routes that redirect on-link addresses were never removed.

RFCs mention nothing about the lifetime of redirection. But the previous
implementation does not pass the IPv6 Core Conformance Tests.

This makes
- remember all received RAs and manage them by the sender address
  (previously, remembered only one with the highest preference),
- then use the router lifetime as one for redirect route,
- remove redirect route also when the router corresponds to the sender
  address is dropped (previously, considered only target address).

Note, even if we recieve a new RA, we do not update existing redirect
routes. The lifetime of the redirect route is updated only when a new
Redirect message is received.

Closes #32527.
2024-06-06 11:19:55 +01:00
Luca Boccassi e5058834cf
Merge pull request #33197 from poettering/cryptsetup-fallback-tweak
cryptsetup: unset an unlock path on each unlock retry
2024-06-05 17:41:55 +01:00
Daan De Meyer 1a48d8549f core: Fix CPUQuotaPerSecUSec unit file serialization
CPUQuota= can deal with float percentages perfectly fine these days
(up to two places after the dot), so let's take that into account
when serializing the value to the transient unit file so we don't lose
precision when specifying e.g. "CPUQuota=0.5%".
2024-06-05 16:50:36 +02:00
Kamil Szczęk 80313c5577 json: use secure un{base64,hex}mem for sensitive variants
While tracing a LUKS code path in homework, I've noticed that we don't
erase buffers when doing unbase64 or unhex on JSON variants, even if the
variant is marked as sensitive.
2024-06-05 14:44:58 +01:00
Yu Watanabe 8b439af2c0 network/route: fix condition in route_can_update()
An existing route with lifetime can be always updated with a new
finite lifetime. As the comment in the code says, we cannot disable the
lifetime. So, the condition must be '==', rather than '!='.

Fixes #33210.
2024-06-05 13:04:52 +01:00
Luca Boccassi d494d6688d cryptsetup: check keyring cache passphrase at least once
The first try will be on the TPM2, so in practice this was always skipped
as it happens only on the first try. Use a different bool to track this.
2024-06-04 23:18:13 +01:00
Lennart Poettering 64f2e1ff05 cryptsetup: unset an unlock path on each unlock retry
If we couldn't unlock a device with the chosen unlock path, let's not
fall back to the lowest one right away, but only flush out one path, and
try the next.

Fixes: #30425
Follow-up-for: #30185
Alternative-to: #33183
2024-06-04 20:42:19 +01:00
David Seifert 80159df741 libpasswdqc: add missing #include "dlfcn-util.h" 2024-06-04 18:29:12 +01:00
Daan De Meyer af21385e76 importctl: Fix 0 flags argument in sd_bus_message_append() 2024-06-03 15:18:13 +09:00
Daan De Meyer 1d877271c4 repart: Fix unused variable warning 2024-06-03 15:18:01 +09:00
Daan De Meyer 9619fdc102
Merge pull request #33157 from DaanDeMeyer/end
test: Run end.sh when running integration tests with mkosi
2024-06-02 21:04:56 +02:00
Daan De Meyer f9fc97824a resolved: Add missing nullable annotation for ifindex in ResolvedRecord 2024-06-02 19:15:21 +02:00
Daan De Meyer 6063978f75 hostnamed: Add missing VSockCID varlink introspection data 2024-06-02 16:38:20 +02:00
Daan De Meyer e77afcc699 pcrlock: Fix ReadEventLog() interface definition 2024-06-02 16:34:33 +02:00
Yu Watanabe 94e8dd54d0 test-async: also check if the directory is removed 2024-06-02 09:19:47 +09:00
Yu Watanabe b593d86d1b test-async: wait a while for fd to be closed
When this is run on slow environment, e.g. sanitizer is enabled,
then waiting for 1 second may not be enough.

Hopefully fixes #33150.
2024-06-02 09:10:06 +09:00
Yu Watanabe 49c27e4b13 network: drop period from the message title
We usually do not add full-stop for policy message title.

Follow-up for f90eb08627.
2024-06-01 15:10:44 +09:00
Daan De Meyer 7ce0104da8 cryptsetup-generator: Fix memory leak 2024-05-31 13:29:22 +02:00
Mike Yuan 3b23501a0d core/unit: refuse to spawn units under frozen cgroup
Currently, Unit.freezer_state is always initialized to
FREEZER_RUNNING. While realizing cgroups for frozen units
was disabled in 7923e9493c,
the commit only checked for freezer_state of the unit inself,
meaning that newly-loaded units might be started and the kernel
would hang pid1 when trying to spawn sd-executor into sub-cgroup.
This can be easily reproduced by the following:

```console
# systemd-run --slice=test.slice sleep infinity
# systemctl freeze test.slice
# systemd-run --slice=test.slice sleep infinity
```

Therefore, let's correctly initialize Unit.freezer_state
based on the parent slice.
2024-05-31 13:25:20 +02:00
Yu Watanabe 8b98d71df5
Merge pull request #33093 from YHNdnzj/freezer-util
bus-unit-util: rework UnitFreezer, explicitly thaw unit
2024-05-31 11:47:19 +09:00
Chris Packham 201148b08d basic: Add BCACHEFS magic
Import magic.h from Linux 6.9 to get the definition of
BCACHEFS_SUPER_MAGIC. Update filesystems-gperf.gperf to add knowledge of
bcachefs.

This fixes the following error building against a bleeding edge kernel.
```
src/basic/meson.build:234:8: ERROR: Problem encountered: Unknown filesystems defined in kernel headers:

Filesystem found in kernel header but not in filesystems-gperf.gperf: BCACHEFS_SUPER_MAGIC
```
2024-05-31 11:14:37 +09:00
Luca Boccassi 0630069f0b
Merge pull request #33081 from keszybz/networkctl-formatting
Fix formatting of speeds in networkctl
2024-05-30 16:33:38 +02:00
Mike Yuan 1d617b35fe
bus-unit-util: extend the bus call timeout for UnitFreezer
Might fix #33083

There's another report available on Mastodon:
https://m.otter.homes/@kaixin/112510783502516607
https://m.otter.homes/@kaixin/112510803023469180
2024-05-30 21:51:48 +08:00
Mike Yuan 61fbc58c46
sleep,home: clean up logs for session freezer a bit 2024-05-30 21:51:48 +08:00
Mike Yuan 12904d5387
bus-unit-util: rework UnitFreezer, explicitly thaw unit
Currently, we don't explicitly call unit_freezer_thaw(),
but rely on the destructor to thaw the frozen unit on
return. This has several problems though, one of them
being that we ignore the return value of ThawUnit(),
which is something we really shouldn't do here,
since such failure can easily leave the whole system
in unusable state. Moreover, the logging is kinda messy,
e.g. homed might log "Everything completed" yet immediately
followed by "Failed to thaw unit". Instead, we should log
consistently and at higher level, to make things more
debuggable.

Therefore, let's step away from the practice. Plus,
make UnitFreezer object heap-allocated, to match
with existing unit_freezer_new() and allow us to
use NULL to denote that the freezer is disabled.
2024-05-30 21:51:48 +08:00
Mike Yuan 759ac0dec3
core/dbus-unit: modernize bus_unit_method_freezer_generic a bit 2024-05-30 21:51:48 +08:00
Mike Yuan 47266ea224
core/dbus-manager: only allow Freeze/ThawUnit() if loaded 2024-05-30 21:51:47 +08:00
Lennart Poettering 43ad199802 homed: drop caches harder
echoing "2" is apparently not enough to erase inodes/dentrys from
memory, hence use "3", which seems to work.

Fixes: #32596
2024-05-30 14:50:40 +02:00
Daan De Meyer 381918edc9
Merge pull request #32866 from DaanDeMeyer/sanitizers
mkosi: Sanitizers
2024-05-30 14:49:13 +02:00
Daan De Meyer 0916532e4b
Merge pull request #33090 from poettering/tpm12-efi-check
efi-api: tighten check for TPM2 systems
2024-05-30 13:32:41 +02:00