Commit Graph

53357 Commits

Author SHA1 Message Date
Yu Watanabe
eb381e65f1 network/address: update comment
As commented in the code, the check is now redundant. But let's keep
that to make IPv6LL addresses on other interfaces not removed
accidentally.
2025-02-17 06:20:46 +09:00
Yu Watanabe
29c2d4e158 network/address: IFA_FLAGS is supported since kernel v3.14
Our kernel base line is now v5.4.
2025-02-17 06:20:46 +09:00
Yu Watanabe
7d1a8da719 network/bridge-mdb: drop workaround for MDB entry on bridge
Our kernel base line is now v5.4.
2025-02-17 06:20:46 +09:00
Yu Watanabe
0d73214cae network: mention IFLA_PERM_ADDRESS is since kernel v5.6 2025-02-17 06:20:46 +09:00
Yu Watanabe
49625caaa9 network/routing-policy-rule: assume FRA_PROTOCOL attribute is always set
Since kernel v4.17 (1b71af6053af1bd2f849e9fda4f71c1e3f145dcf), the
attribute is always set in each netlink message for routing policy rule.
Now, our base line is v5.4. Hence, we can drop the workaround.
2025-02-17 06:20:36 +09:00
Yu Watanabe
6698795eda network: add/update comments about required kernel configs 2025-02-17 05:13:06 +09:00
Yu Watanabe
034b69d8b8 network: assume nexthop is supported by the kernel
It is supported since kernel v5.3 (65ee00a9409f751188a8cdc0988167858eb4a536),
but our base line is now v5.4.
2025-02-17 04:54:59 +09:00
Daan De Meyer
7db71cd79f ukify: Fix --sign-profile= check for main profile
opts.profile is always an env file so we have to parse the default
value as well to check if it's in --sign-profile= or not.
2025-02-16 18:52:26 +01:00
Luca Boccassi
1f1b403d03 journal-remote: several follow-ups for compression support, and trivial cleanups (#36334)
Follow-ups for cfaf78001c (#34822).
2025-02-16 14:33:47 +00:00
Yu Watanabe
0592f3f413 resolve: refuse ResolveService method if SRV is filtered
Follow-up for 81ae2237c1.
2025-02-16 22:54:56 +09:00
Yu Watanabe
9ec25fba5a resolve: if both A and AAAA are refused, do not resolve address when resolving service
Similarly, set NO_TXT flag if TXT is filtered.

Follow-up for 81ae2237c1.
Fixes https://github.com/systemd/systemd/pull/36353#issuecomment-2659558382.
2025-02-16 22:54:00 +09:00
Yu Watanabe
3c31cc3981 resolve: allow to specify SD_RESOLVED_NO_SEARCH flag in ResolveRecord
The varlink method io.systemd.Resolve.ResolveRecord already accepts the
flag. Let's also the bus method accept the flag, for consistency.
2025-02-16 22:41:10 +09:00
Yu Watanabe
7cf95470f3 resolve: unify two validate_and_mangle_flags()
The argument `Manager *manager`, is currently unused, but will be used
later.
2025-02-16 22:39:52 +09:00
Yu Watanabe
5f494e8fa6 macro-fundamental: add _nonnull_if_nonzero_ and use it in basic/ (#36395) 2025-02-16 20:21:08 +09:00
Yu Watanabe
56ab3ae170 journal-upload: several follow-ups for Accept-Encoding header handling
This makes,
- When a wildcard value '*' is specified, use the first supported
  compression algorithm,
- disable compression if Accept-Encoding header is unspecified or
  no supported compression algorithm specified in the header,
- ignore all errors in parsing the header.
2025-02-16 20:10:27 +09:00
Yu Watanabe
04b096400b journal-upload: split-out update_content_encoding_header()
No functional change, just refactoring and preparation for later commit.
2025-02-16 20:08:39 +09:00
Yu Watanabe
c259c9e253 journal-remote: several follow-ups for Compression= option handling
Follow-ups for cfaf78001c.

- use OrderedHashmap to manage configured compression algorithms, then
  drop CompressionArgs,
- rename CompressionOpts -> CompressionConfig,
- refuse 'none' in Compression= setting, but accept boolean false, which
  disables compression,
- when Compression= option is unspecified, enable all supported compression
  algorithms by default,
- do not set 'none' to the Accept-Encoding header.
2025-02-16 20:08:39 +09:00
Yu Watanabe
8c7e4e0d5e journal-remote: replace extract_first_word() with simple strchr() 2025-02-16 20:08:39 +09:00
Yu Watanabe
c272c06b9e journal-remote: assume received data is not compressed when Content-Encoding header is not set
Also, refuse spurious header `Content-Encoding: none`.
2025-02-16 20:08:39 +09:00
Yu Watanabe
fc1cf91aa8 journal-remote: copy positional arguments
This also fixes several memory leaks.
2025-02-16 20:08:39 +09:00
Yu Watanabe
a8516216d2 journal-remote: trivial coding style fix 2025-02-16 20:08:39 +09:00
Daan De Meyer
eba51a9dbd repart: Delay private key and certificate check until actual use
For many reasons, we might not actually sign a verity signature
partition, even if ope is specified in the partition definition files.
It might already exist, it might be deferred, it might be excluded, ...

Since we cannot check if partition already exists when reading the
configuration, let's delay the check for whether a certificate and
key have been provided until we're actually about to sign a roothash.
2025-02-16 10:43:56 +01:00
Mike Yuan
6da2ea9fa9 basic: use _nonnull_if_nonzero_ where appropriate 2025-02-16 12:37:10 +09:00
Mike Yuan
6bdbfb7eb6 basic/escape: swap 'bad' and 'len' params for decescape()
To follow our usual coding style.
2025-02-16 12:37:10 +09:00
Mike Yuan
7de7c7b6dc basic/escape: accept SIZE_MAX and perform overflow check in cescape_length() and decescape() too
While at it, make cescape() static inline.
2025-02-16 12:37:10 +09:00
Mike Yuan
c7a097d7e1 basic/escape: octescape() doesn't really take 'bad' param 2025-02-16 12:37:10 +09:00
Mike Yuan
3aa0cf23b4 macro-fundamental: add _nonnull_if_nonzero_
Introduced in gcc 15:
19fe55c480
2025-02-16 12:37:10 +09:00
Zbigniew Jędrzejewski-Szmek
8c81f9a3cf ukify: fixes with kernel compression (#36381) 2025-02-14 16:47:49 +01:00
Muhammad Nuzaihan Bin Kamal Luddin
e644b332d0 resolve: clear previous assignments of RefuseRecordTypes= on reload
Follow-up for 81ae2237c1.
2025-02-14 11:54:56 +00:00
Yu Watanabe
225dbd6108 resolve: fix use-after-free
Fixes a bug introduced by 81ae2237c1.
Fixes #36351.
2025-02-14 11:54:56 +00:00
Luca Boccassi
cdedc90caf ukify: do not insist on a stub being available when joining pcrsigs
It is not used in this case, so skip it, otherwise it will need to be
installed even if it is not used

Follow-up for 9876e88e23
2025-02-14 10:57:03 +00:00
Luca Boccassi
0dd03215f1 ukify: if the specified kernel is not a valid PE file try to decompress it
On some distros on some architectures (e.g.: Ubuntu arm64) the kernel is shipped as
a gzipped file, which the UEFI firmware does not understand.
If pefile fails to parse it, try to decompress it.
2025-02-14 10:57:03 +00:00
Luca Boccassi
a6d51ae582 ukify: fix zboot parsing with zstd
The header starts with 'zstd', not 'zstd22':

$ ukify build --linux vmlinuz-6.13+unreleased-cloud-arm64 --initrd /boot/initrd.img-6.12.12-amd64 --output uki
Kernel version not specified, starting autodetection 😖.
Real-Mode Kernel Header magic not found
+ readelf --notes vmlinuz-6.13+unreleased-cloud-arm64
readelf: Error: Not an ELF file - it has the wrong magic bytes at the start
Traceback (most recent call last):
  File "/home/bluca/git/systemd/src/ukify/ukify.py", line 2510, in <module>
    main()
    ~~~~^^
  File "/home/bluca/git/systemd/src/ukify/ukify.py", line 2499, in main
    make_uki(opts)
    ~~~~~~~~^^^^^^
  File "/home/bluca/git/systemd/src/ukify/ukify.py", line 1328, in make_uki
    opts.uname = Uname.scrape(linux, opts=opts)
                 ~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^
  File "/home/bluca/git/systemd/src/ukify/ukify.py", line 384, in scrape
    version = func(filename, opts=opts)
  File "/home/bluca/git/systemd/src/ukify/ukify.py", line 374, in scrape_generic
    text = maybe_decompress(filename)
  File "/home/bluca/git/systemd/src/ukify/ukify.py", line 221, in maybe_decompress
    return get_zboot_kernel(f)
  File "/home/bluca/git/systemd/src/ukify/ukify.py", line 201, in get_zboot_kernel
    raise NotImplementedError(f'unknown compressed type: {comp_type!r}')
NotImplementedError: unknown compressed type: b'zstd\x00\x00'
2025-02-14 10:28:41 +00:00
Luca Boccassi
fbc6fecf1a ukify: switch from zstd to zstandard
The zstd library does not support stream decompression, and it
requires the zstd header to contain extra metadata, that the kernel
build does not append:

$ file -k vmlinuz-6.13+unreleased-cloud-arm64
vmlinuz-6.13+unreleased-cloud-arm64: PE32+ executable (EFI application) Aarch64 (stripped to external PDB), for MS Windows, 2 sections\012- data
$ ukify build --linux vmlinuz-6.13+unreleased-cloud-arm64 --initrd /boot/initrd.img-6.12.12-amd64 --output uki
Kernel version not specified, starting autodetection 😖.
Real-Mode Kernel Header magic not found
+ readelf --notes vmlinuz-6.13+unreleased-cloud-arm64
readelf: Error: Not an ELF file - it has the wrong magic bytes at the start
Traceback (most recent call last):
  File "/home/bluca/git/systemd/src/ukify/ukify.py", line 2508, in <module>
    main()
    ~~~~^^
  File "/home/bluca/git/systemd/src/ukify/ukify.py", line 2497, in main
    make_uki(opts)
    ~~~~~~~~^^^^^^
  File "/home/bluca/git/systemd/src/ukify/ukify.py", line 1326, in make_uki
    opts.uname = Uname.scrape(linux, opts=opts)
                 ~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^
  File "/home/bluca/git/systemd/src/ukify/ukify.py", line 382, in scrape
    version = func(filename, opts=opts)
  File "/home/bluca/git/systemd/src/ukify/ukify.py", line 372, in scrape_generic
    text = maybe_decompress(filename)
  File "/home/bluca/git/systemd/src/ukify/ukify.py", line 219, in maybe_decompress
    return get_zboot_kernel(f)
  File "/home/bluca/git/systemd/src/ukify/ukify.py", line 199, in get_zboot_kernel
    return cast(bytes, zstd.uncompress(f.read(size)))
                       ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^
zstd.Error: Input data invalid or missing content size in frame header.

This appears to be by design:

https://github.com/sergey-dryabzhinsky/python-zstd/issues/53

Switch to python3-zstandard, which works.
2025-02-14 10:28:41 +00:00
Yu Watanabe
dd0d821a33 journal-remote: fix typo
Follow-ups for cfaf78001c.
2025-02-14 13:23:27 +09:00
Yu Watanabe
4053af87bb core/mount: rework GracefulOptions= as x-systemd.graceful-option= (#36356)
Prompted by #36337
2025-02-14 13:01:14 +09:00
Yu Watanabe
daae625140 core/service: drop unneeded unit_add_to_gc_queue() (#36368) 2025-02-14 12:51:48 +09:00
Luca Boccassi
1585237b6a varlink idl fixes (#36376) 2025-02-13 21:16:04 +00:00
Zbigniew Jędrzejewski-Szmek
de02b551ad core/condition: fix segfault when key not found in os-release
'ConditionOSRelease=|ID_LIKE$=*rhel*' results in a segfault.
The key 'ID_LIKE' is not present in Fedora's os-release file.

I think the most reasonable behaviour is to treat missing keys as empty.
This matches the "shell-like" sprit, since in a shell empty keys would
by default be treated as empty too. Thus, "ID_LIKE=" would match, if
ID_LIKE is not present in the file, and ID_LIKE=!$foo" would also match.
The other option would be to make those matches fail, but I think that'd
make the feature harder to use, esp. with negative matches.

Documentation is updated to clarify the new behaviour.

https://bugzilla.redhat.com/show_bug.cgi?id=2345544
2025-02-13 18:16:42 +01:00
Lennart Poettering
2d790b225d logind: map enum strings to underscores in logind
Varlink doesn't know dashes in enums, we use them all the time. Convert
dashes to underscores hence before we pass them through varlink.
2025-02-13 18:16:20 +01:00
Lennart Poettering
0c69a67294 varlink: fix IDL for errno error 2025-02-13 18:15:52 +01:00
Daan De Meyer
b000e16798 ptyfwd: Forward various signals to forked process
We want systemd-pty-forward to be something that can be dropped in
somewhere without too much thought. To enable this, let's make sure
we forward various signals to the forked process. This makes sure that
any signals are delivered to the actual child process regardless of whether
it's running within systemd-pty-forward or not.
2025-02-13 10:21:00 +01:00
msizanoen
a6bccda28d login: Queue session for garbage collection on leader death
This ensures sessions are cleaned up properly in case the user service
manager was manually stopped.
2025-02-13 09:29:11 +07:00
msizanoen
b2a4109031 login: Continue watching leader pidfd after stop
This ensures that garbage collection will be triggered when the leader
process dies.
2025-02-13 09:29:11 +07:00
Mike Yuan
f565e5a94a core/mount: log only once about fs not supporting new mount API 2025-02-12 18:16:44 +01:00
Mike Yuan
c2198d0c3f mountpoint-util: assume fsopen() works in mount_option_supported()
Our baseline includes it now.
2025-02-12 18:16:44 +01:00
Mike Yuan
0d76f1c423 core/mount: rework GracefulOptions= to be just x-systemd.graceful-option=
09fbff57fc introduced new knob
for such functionality. However, that seems unnecessary.

The mount option string is ubiquitous in that all of fstab,
kernel cmdline, credentials, systemd-mount, ... speak it.
And we already have x-systemd.device-bound= that's parsed
by pid1 instead of fstab-generator. It feels hence more natural
for graceful options to be an extension of that, rather than
its own property.

There's also one nice side effect that the setting itself
is now more graceful for systemd versions not supporting
such feature.
2025-02-12 18:16:44 +01:00
Mike Yuan
818315ae61 core/service: drop unneeded unit_add_to_gc_queue()
Follow-up for a1d315730f
and 6ac62d61db

With the aforementioned commits, unit_release_resources()
is dispatched in a dedicated queue, and Service.n_keep_fd_store
has been dropped, hence the comment is outdated. Moreover,
the unit is added to GC queue in unit_notify() already.
No other unit types do this in corresponding _enter_dead()
functions, nor does Service need it anymore.
2025-02-12 17:54:34 +01:00
Mike Yuan
468e87267f core/unit: use UNIT_IS_INACTIVE_OR_FAILED at one more place 2025-02-12 17:49:22 +01:00
Mike Yuan
85f759baee bus-unit-util: add missing assertions 2025-02-12 15:34:54 +01:00