Commit Graph
53231 Commits
Author SHA1 Message Date
Zbigniew Jędrzejewski-Szmek 40ff0dec08 test/ukify: deduplicate path specification 2025-02-14 17:27:12 +01: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
Mike Yuan 0fa062f983 core/dbus-mount: add missing ReloadResult and CleanResult properties 2025-02-12 15:34:54 +01:00
Mike Yuan c7c6cf2031 core/mount: trivial coding style cleanups 2025-02-12 15:34:53 +01:00
Mike Yuan 74c0d9726c core/mount: report accurate can_start and can_reload 2025-02-12 15:33:11 +01:00
Mike Yuan 65bc0c03b9 core/mount: check parameters_fragment first in mount_enter_(re)mounting()
I.e. don't perform any action if we can't spawn mount task anyway.
Later the same check would be added to mount_can_start/reload(),
so this makes things more coherent too.
2025-02-12 15:32:30 +01:00
Mike Yuan 7e9a78d6be core/mount: filter out "fail" option as well 2025-02-12 14:43:06 +01:00
Mike Yuan 5fe4c30ca7 core/dbus-service: fix alignment 2025-02-12 14:43:04 +01:00
Daan De Meyer 7ee5b95f6b udev: several improvements for debugging logs (#36357) 2025-02-12 14:35:46 +01:00
Paul Fertser a3aad16c6e socket: resolve unit specifiers in BindToDevice
There are cases where templated Socket unit files are used for network services
with interface name used as an instance. This patch allows using %i for
BindToDevice setting to limit the scope automatically.
2025-02-12 12:03:42 +01:00
Yu Watanabe b3b4420620 udev-watch: do not try to remove invalid watch handle
When a new device is processed, there should be no watch handle for
the device, hence udev_watch_clear() provides -1. Let's not try to call
inotify_rm_watch() in that case.

This should not change any behavior. Just for suppressing spurious
debugging log:
=====
(udev-worker)[3626140]: zram1: Removing watch handle -1.
=====
2025-02-12 09:27:24 +09:00
Yu Watanabe a52aad3b4b udev-watch: mention that the failure is ignored 2025-02-12 09:26:51 +09:00
Yu Watanabe 951def0e27 udev-worker: add debugging log about success of flock() for whole block device 2025-02-12 09:20:58 +09:00
Anthony Messina 6cbd126b0b nspawn: add @keyring to default syscall allow_list
Keyring namespacing introduced in kernel version v5.3-rc1 https://github.com/torvalds/linux/commit/c84ca912b07901be528e5184fd254fca1dddf2ac

Fixes #17606
2025-02-12 08:05:11 +09:00
Mike Yuan a31f7bc2ac test-xattr-util: return early if not privileged enough to set trusted.* 2025-02-11 17:00:42 +01:00
Mike Yuan d696e9e64f test-xattr-util: relax listxattr() retval check
Follow-up for d228afd792

Apparently security.selinux might get set on the file too,
behind our back.
2025-02-11 16:57:56 +01:00
Mike Yuan 78b47a4e89 xattr-util: drop unnecessary nofollow normalization
Follow-up for b8df25dcfe

This is some leftover from get/listxattrat() usage which
got dropped later.
2025-02-11 16:57:56 +01:00
Muhammad Nuzaihan Bin Kamal Luddin 81ae2237c1 resolve: add an option to explicitly disable query AAAA, SRV, MX, etc... (#34165)
Based on this patch i had submitted to RedHat
(https://issues.redhat.com/browse/RHEL-56280), i am submitting this
patch to this upstream systemd.

There is no way to explicitly enable/disable IPv6 AAAA queries.

Problem was that i am using RHEL9 and some applications does not use a
newer glibc that supports `no-aaaa` option in `/etc/resolv.conf`. So
some applications will still resolve IPv6 AAAA even with `no-aaaa`
option and it is inconsistent across the system where some work and some
don't.

So this systemd-resolved patch catch-all queries and disable IPv6 AAAA
queries for all applications in the OS by having an option
`RefuseRecordTypes=AAAA` to disable IPv6 AAAA queries.

Although https://github.com/systemd/systemd/pull/28136 tries to fix this
automatically but it still does not work with
`net.ipv6.conf.all.disable_ipv6 = 1`. Also tried with explicitly
removing the conditional and force set `family = AF_INET` and still
resolves AAAA records.

The issue is that i want to explicitly disable IPv6 AAAA queries instead
of systemd-resolved to figure out itself which address family it is
using, which always have problems.
2025-02-11 18:29:39 +09:00
Mike Yuan 63ed611579 string-util: modernize strextendn() a bit
l == SIZE_MAX requires no special handling, since we assert
on (s || l == 0) above.
2025-02-10 19:39:22 +01:00
Mike Yuan 146b2ed6a6 string-util: drop now unused strnappend() 2025-02-10 19:39:22 +01:00
Mike Yuan ea5fbc3938 env-util: use strextendn() instead of strnappend() where appropriate 2025-02-10 19:39:21 +01:00
Mike Yuan ce0a510667 cryptsetup: port to strprepend() 2025-02-10 19:39:21 +01:00
Mike Yuan b40694f5fc string-util: introduce strprepend() helper 2025-02-10 19:39:21 +01:00
Lennart Poettering fd2a114061 bootctl: fix potential uninitialized memory access (#36329) 2025-02-10 15:34:38 +01:00
Lennart Poettering ceebfc3fbe escape: apply the minimal ansi highlighting on --help we usually do (#36339) 2025-02-10 15:33:59 +01:00
Lennart Poettering 37252381d2 bootctl,kernel-install: suffix some paths referring to dirs in log messages with / 2025-02-10 01:15:52 +01:00
Lennart Poettering af5b961ad8 bootctl: minor reordering of fields in output
Let's move the currently used/default/oneshot entry output after the
basic info about the boot loader itself, since conceptually these are
objects kinda "one level down" from the boot loader perspective. Hence,
let's *first* show all info about the boot loader itself before we
display the objects it manages.

This is just a trivial change in output, just swaps th elines for these
fields with the ones showing where the boot loader is installed.
2025-02-09 23:34:29 +01:00
Luca Boccassi 2ac8fcf656 ukify: add --pcr-certificate= parameter
Public keys and certificates are not the same, as the latter embeds more
information that the former, and other tools like sd-measure have distinct
parameters for each of them.
Add a new --pcr-certificate= parameter to ukify, and use it to pass certs
down to sd-measure, as an alternative to --pcr-public-key=. Do not allow
specifying both.
2025-02-09 22:24:00 +00:00