]> git.ipfire.org Git - thirdparty/systemd.git/log
thirdparty/systemd.git
17 months agomeson: Define __TARGET_ARCH macros required by bpf
Daan De Meyer [Tue, 2 Jul 2024 15:50:57 +0000 (17:50 +0200)] 
meson: Define __TARGET_ARCH macros required by bpf

These are required by the bpf_tracing.h header in libbpf, see
https://github.com/libbpf/libbpf/blob/master/src/bpf_tracing.h.

bpf_tracing.h does have a few fallbacks in case __TARGET_ARCH_XXX
is not defined but recommends using the __TARGET_ARCH macros instead
so let's do that.

17 months agocoredump: correctly take tmpfs size into account for compression
Luca Boccassi [Tue, 2 Jul 2024 14:28:47 +0000 (15:28 +0100)] 
coredump: correctly take tmpfs size into account for compression

We calculate the amount of uncompressed data we can write by taking the limits
into account and halving it to ensure there's room for switching to compression
on the fly when storing cores on a tmpfs (eg: due read-only rootfs).

But the logic is flawed, as taking into account the size of the tmpfs storage
was applied after the halving, so in practice when an uncompressed core file
was larger than the tmpfs, we fill it and then fail.

Rearrange the logic so that the halving is done after taking into account
the tmpfs size.

17 months agodocs/CODING_STYLE: document that we nowadays prefer (const char*) for func ret type
Mike Yuan [Tue, 2 Jul 2024 17:20:01 +0000 (19:20 +0200)] 
docs/CODING_STYLE: document that we nowadays prefer (const char*) for func ret type

Addresses https://github.com/systemd/systemd/pull/33567#discussion_r1662818225

17 months agoMerge pull request #33577 from fbuihuu/testsuite-tweaks-for-v256-on-SUSE
Luca Boccassi [Tue, 2 Jul 2024 21:35:33 +0000 (23:35 +0200)] 
Merge pull request #33577 from fbuihuu/testsuite-tweaks-for-v256-on-SUSE

Testsuite tweaks for v256 on suse

17 months agoMerge pull request #33574 from poettering/get-efi-var-raw
Lennart Poettering [Tue, 2 Jul 2024 19:16:37 +0000 (21:16 +0200)] 
Merge pull request #33574 from poettering/get-efi-var-raw

efi: efi variable refactoring

17 months agotest: fix TEST-74-AUX-UTILS.ssh.sh on SUSE 33577/head
Franck Bui [Tue, 2 Jul 2024 16:55:17 +0000 (18:55 +0200)] 
test: fix TEST-74-AUX-UTILS.ssh.sh on SUSE

17 months agotest: preserve symlink in inst_recursive()
Franck Bui [Tue, 2 Jul 2024 13:20:18 +0000 (15:20 +0200)] 
test: preserve symlink in inst_recursive()

On SUSE this function is used to copy symlinks installed in *.wants/
directories.

17 months agotest: fix TEST-24-CRYPTSETUP on SUSE
Franck Bui [Tue, 2 Jul 2024 08:33:29 +0000 (10:33 +0200)] 
test: fix TEST-24-CRYPTSETUP on SUSE

/etc/systemd/journald.conf.d drop-in dir already exists on SUSE.

17 months agotest: install /etc/hosts
Franck Bui [Mon, 1 Jul 2024 16:06:45 +0000 (18:06 +0200)] 
test: install /etc/hosts

Needed for resolving the "localhost" hostname.

17 months agoefivars: rename efivar_get_uint_string() → efivar_get_uint64_str16() 33574/head
Lennart Poettering [Tue, 2 Jul 2024 16:09:55 +0000 (18:09 +0200)] 
efivars: rename efivar_get_uint_string() → efivar_get_uint64_str16()

Be explicit with the type, and more inline with our other code, that
likes to indicate the string char width in the name.

Also, switch to a fixed size type, since EFI variables should really be
binary exact the same on all archs.

17 months agoefi: rename efivar_(set|get)() → efivar_(set|get)_str16()
Lennart Poettering [Tue, 2 Jul 2024 16:07:35 +0000 (18:07 +0200)] 
efi: rename efivar_(set|get)() → efivar_(set|get)_str16()

These functions after all write EFI UTF-16 strings, i.e. are relatively
high-level, hence give them a specific name indicating the type, to
match our other helpers that have similar type suffixes.

17 months agoefivars: use appropropriate uint8_t type when dealing with "raw" bytes
Lennart Poettering [Tue, 2 Jul 2024 15:50:47 +0000 (17:50 +0200)] 
efivars: use appropropriate uint8_t type when dealing with "raw" bytes

We don't actually want chars here, but rather raw bytes, in particular
to avoid signedness issues. Hence, let's use uint8_t here.

17 months agoefivars: change return parameter of efivar_get_raw() to be void**
Lennart Poettering [Tue, 2 Jul 2024 15:49:52 +0000 (17:49 +0200)] 
efivars: change return parameter of efivar_get_raw() to be void**

This is the "raw", untyped version after all, hence we should return a
void pointer, and let the client cast, if they know more.

Replaces: #30812

17 months agoefi: split out efivars.[ch] from util.[ch]
Lennart Poettering [Tue, 2 Jul 2024 15:44:24 +0000 (17:44 +0200)] 
efi: split out efivars.[ch] from util.[ch]

These are quite a bunch of functions, let's give them their own file.

No code changes, just some trivial refactoring.

17 months agomkosi: Install perf
Daan De Meyer [Tue, 2 Jul 2024 13:46:09 +0000 (15:46 +0200)] 
mkosi: Install perf

It's already installed on ubuntu via linux-tools-common.

17 months agoupdate TODO
Lennart Poettering [Tue, 2 Jul 2024 13:59:00 +0000 (15:59 +0200)] 
update TODO

17 months agotest: split the resolved test suite into separate test cases
Daniel Rusek [Thu, 6 Jun 2024 21:44:38 +0000 (23:44 +0200)] 
test: split the resolved test suite into separate test cases

Although being far from ideal and the first two test cases have to be run
before the setup phase otherwise they will fail, it still makes the test
suite look much better and easier to read

17 months agoMerge pull request #33496 from YHNdnzj/fd-is-mount-symlink
Luca Boccassi [Tue, 2 Jul 2024 08:07:20 +0000 (10:07 +0200)] 
Merge pull request #33496 from YHNdnzj/fd-is-mount-symlink

mountpoint-util: do not assume symlinks are not mountpoints

17 months agoMerge pull request #33560 from YHNdnzj/trivial-cleanup-2
Luca Boccassi [Tue, 2 Jul 2024 08:05:49 +0000 (10:05 +0200)] 
Merge pull request #33560 from YHNdnzj/trivial-cleanup-2

2 trivial follow-ups for recent PRs

17 months agoMerge pull request #33523 from neighbourhoodie/fix/dns-opt-extended-rcode
Luca Boccassi [Mon, 1 Jul 2024 23:48:40 +0000 (01:48 +0200)] 
Merge pull request #33523 from neighbourhoodie/fix/dns-opt-extended-rcode

Fix DNS OPT extended rcode parsing

17 months agobuild(deps): bump github/codeql-action from 3.24.7 to 3.25.11
dependabot[bot] [Mon, 1 Jul 2024 11:19:36 +0000 (11:19 +0000)] 
build(deps): bump github/codeql-action from 3.24.7 to 3.25.11

Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.24.7 to 3.25.11.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](https://github.com/github/codeql-action/compare/3ab4101902695724f9365a384f86c1074d94e18c...b611370bb5703a7efb587f9d136a52ea24c5c38c)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
17 months agomkosi: update debian commit reference
Luca Boccassi [Mon, 1 Jul 2024 14:49:55 +0000 (15:49 +0100)] 
mkosi: update debian commit reference

abf24e775c Add recommends on linux-sysctl-defaults
76cb4138d2 autopkgtest: skip qemu tests on arm64
0935d73526 Install new systemd-import generator

17 months agoshared/condition: add missing space after 'if' 33560/head
Mike Yuan [Mon, 1 Jul 2024 17:13:58 +0000 (19:13 +0200)] 
shared/condition: add missing space after 'if'

Follow-up for 98b1ecc9175a8bb241292f6f441a754b6759dd97

17 months agoshared/mount-util: return early if param is NULL
Mike Yuan [Mon, 1 Jul 2024 16:59:28 +0000 (18:59 +0200)] 
shared/mount-util: return early if param is NULL

To make things more readable and consistent.

17 months agoMerge pull request #33475 from poettering/name-to-handle-at-fid
Lennart Poettering [Mon, 1 Jul 2024 16:53:14 +0000 (18:53 +0200)] 
Merge pull request #33475 from poettering/name-to-handle-at-fid

teach inode_same() the concept of name_to_handle_at() FIDs to properly detect inode identities

17 months agomkfs-util: Simplify logic
Daan De Meyer [Mon, 1 Jul 2024 12:25:20 +0000 (14:25 +0200)] 
mkfs-util: Simplify logic

17 months agounits: add dep on systemd-logind.service by user@.service
Lennart Poettering [Mon, 1 Jul 2024 10:40:33 +0000 (12:40 +0200)] 
units: add dep on systemd-logind.service by user@.service

Let's make sure logind is accessible by the time user@.service runs, and
that logind stays around as long as it does so.

Addresses an issue reported here:

https://lists.freedesktop.org/archives/systemd-devel/2024-June/050468.html

This addresses an issued introduced by
278e815bfa3e4c2e3914e00121c37fc844cb2025, which dropped the a dependency
from user@.service systemd-user-sessions.service without replacement.
While dropping that dependency does make sense, it should have been
replaced with the weaker dependency on systemd-logind.service, hence fix
that now.

user@.service is after all a logind concept, hence logind really should
be around for its lifetime.

systemd-user-sessions.service is a later milestone that only really
should apply to regular users (not root), hence it's too strong a
requirement.

17 months agoUse read_full_file_full() in read_smbios11_field()
Daan De Meyer [Fri, 28 Jun 2024 18:12:51 +0000 (20:12 +0200)] 
Use read_full_file_full() in read_smbios11_field()

read_virtual_file() will only read up to page size bytes of data
from /sys/firmware/dmi/entries/.../raw so let's use read_full_file_full()
instead to make sure we read all data.

This should be safe since smbios11 data can be considered immutable
during the lifetime of the system.

17 months agoMerge pull request #33553 from poettering/list-devices
Lennart Poettering [Mon, 1 Jul 2024 16:51:54 +0000 (18:51 +0200)] 
Merge pull request #33553 from poettering/list-devices

add --list-devices switch to various tools that accept block devices to list candidate devices

17 months agostoragetm: add --list-devices command 33553/head
Lennart Poettering [Mon, 1 Jul 2024 09:55:52 +0000 (11:55 +0200)] 
storagetm: add --list-devices command

17 months agorepart: add --list-devices switch for listing candidate block devices
Lennart Poettering [Mon, 1 Jul 2024 09:54:21 +0000 (11:54 +0200)] 
repart: add --list-devices switch for listing candidate block devices

17 months agocryptenroll: add --list-devices switch that shows candidate block devices
Lennart Poettering [Mon, 1 Jul 2024 09:51:14 +0000 (11:51 +0200)] 
cryptenroll: add --list-devices switch that shows candidate block devices

17 months agoutil: add generic block device listener helper
Lennart Poettering [Mon, 1 Jul 2024 09:45:12 +0000 (11:45 +0200)] 
util: add generic block device listener helper

Various of our tools operate on block devices, and it's not always
obvious to know which block devices are actually appropriate for use.
Hence, let's add a helper that allows to list block devices, and
supports some limited filtering.

17 months agoblockdev-util: add partscan check function that takes an sd_device*
Lennart Poettering [Mon, 1 Jul 2024 09:44:26 +0000 (11:44 +0200)] 
blockdev-util: add partscan check function that takes an sd_device*

17 months agorepart: add sections to --help text
Lennart Poettering [Mon, 1 Jul 2024 08:25:38 +0000 (10:25 +0200)] 
repart: add sections to --help text

17 months agotest: beef up test case for fid-based equality checks 33475/head
Lennart Poettering [Tue, 25 Jun 2024 11:03:55 +0000 (13:03 +0200)] 
test: beef up test case for fid-based equality checks

17 months agostat-util: port inode_same_at() to use FID file handle data to determine inode identity
Lennart Poettering [Tue, 25 Jun 2024 10:46:52 +0000 (12:46 +0200)] 
stat-util: port inode_same_at() to use FID file handle data to determine inode identity

Let's be good boys, and use FID for this.

17 months agomountpoint-util: clarify that EOVERFLOW is visible on nfs4/autofs mounts
Lennart Poettering [Tue, 25 Jun 2024 10:46:19 +0000 (12:46 +0200)] 
mountpoint-util: clarify that EOVERFLOW is visible on nfs4/autofs mounts

17 months agomountpoint-util: use the FID stuff for detecting the root of mounts
Lennart Poettering [Tue, 25 Jun 2024 10:44:19 +0000 (12:44 +0200)] 
mountpoint-util: use the FID stuff for detecting the root of mounts

In the unlikely event that sandboxes block statx() but let
name_to_handle_at() through it's a good way to determine the root inode
of the namespace, since its parent inode will have the same FID and
mnt_id.

17 months agomountpoint-util: add new helper name_to_handle_at_try_fid()
Lennart Poettering [Tue, 25 Jun 2024 10:41:03 +0000 (12:41 +0200)] 
mountpoint-util: add new helper name_to_handle_at_try_fid()

Newer kernels support a new flag for name_to_handle_at(): AT_HANDLE_FID.
This flag is supposed to return an identifier for an inode that we can
use for checking inode identity. It's supposed to be a replacement for
checking .st_ino which doesn't work anymore today because inode numbers
are no longer unique on file systems (not on overlayfs, and not on btrfs
for example). Hence, be a good citizen and add infrastructure to support
AT_HANDLE_FID. Unfortunately that doesn't work for old kernels, hence
add a fallback logic: if we can use the flag, use it. If we cannot use
name_to_handle_at() without it, which might give us a good ID too. But
of course tha tcan fail as well, which callers have to check.

17 months agomountpoint-util: use ERRNO_IS_xyz() at more places
Lennart Poettering [Tue, 25 Jun 2024 10:39:55 +0000 (12:39 +0200)] 
mountpoint-util: use ERRNO_IS_xyz() at more places

17 months agomountpoint-util: add public helper for comparing file handles
Lennart Poettering [Tue, 25 Jun 2024 10:37:32 +0000 (12:37 +0200)] 
mountpoint-util: add public helper for comparing file handles

We already have the code, let's move it to a function of its own and
export it.

17 months agomountpoint-util: make is_name_to_handle_at_fatal_error() an exported API
Lennart Poettering [Tue, 25 Jun 2024 10:35:29 +0000 (12:35 +0200)] 
mountpoint-util: make is_name_to_handle_at_fatal_error() an exported API

And while we are at it, make it use ERRNO_IS_xyz() where appropriate.

And move it up a bit, so we can use in the whole of mountpoint-util.c
(which we want to later).

17 months agobuild(deps): bump actions/checkout from 4.1.6 to 4.1.7
dependabot[bot] [Mon, 1 Jul 2024 09:49:46 +0000 (09:49 +0000)] 
build(deps): bump actions/checkout from 4.1.6 to 4.1.7

Bumps [actions/checkout](https://github.com/actions/checkout) from 4.1.6 to 4.1.7.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/a5ac7e51b41094c92402da3b24376905380afc29...692973e3d937129bcbf40652eb9f2f61becf3332)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
17 months ago Conditional PSI check to reflect changes done in 5.13
rhellstrom [Thu, 27 Jun 2024 08:00:00 +0000 (11:00 +0300)] 
Conditional PSI check to reflect changes done in 5.13

cpu.pressure 'full' is undefined for system-wide checks since 5.13 but still reported with values set to 0 for backwards compatibility. Made changes to reflect this for system-wide checks so that the conditional comparison is not made against the 0 value and instead fall back to 'some'.

https://www.kernel.org/doc/html/latest/accounting/psi.html

17 months agocore: try again bind mounting if the destination was already created
Luca Boccassi [Sat, 29 Jun 2024 17:31:23 +0000 (18:31 +0100)] 
core: try again bind mounting if the destination was already created

If the destination mount point is on a shared filesystem and is
missing on the first attempt, we try to create it, but then
fail with -EEXIST if something else created it in the meanwhile.
Enter the retry logic on EEXIST, as we can just use the mount
point if it was already created.

Fixes https://github.com/systemd/systemd/issues/29690

17 months agoMerge pull request #33544 from DaanDeMeyer/sector-size
Luca Boccassi [Sat, 29 Jun 2024 19:31:04 +0000 (21:31 +0200)] 
Merge pull request #33544 from DaanDeMeyer/sector-size

repart: Two sector size improvements

17 months agoNEWS: fix typo
Mike Yuan [Sat, 29 Jun 2024 14:48:18 +0000 (16:48 +0200)] 
NEWS: fix typo

17 months agoNEWS: nscd has been dropped for good
Mike Yuan [Sat, 29 Jun 2024 14:35:26 +0000 (16:35 +0200)] 
NEWS: nscd has been dropped for good

Follow-up for 28f1f1a5e652508d6e61ace8918e8b831e4b62b4

17 months agoMerge pull request #33258 from YHNdnzj/cg-runtime-accounting
Mike Yuan [Sat, 29 Jun 2024 14:11:44 +0000 (16:11 +0200)] 
Merge pull request #33258 from YHNdnzj/cg-runtime-accounting

core/cgroup: various fixes for accounting

17 months agomkfs-util: Set sector size for btrfs as well 33544/head
Daan De Meyer [Sat, 29 Jun 2024 13:27:02 +0000 (15:27 +0200)] 
mkfs-util: Set sector size for btrfs as well

btrfs used to default the sector size to the page size and didn't
support anything else. Since 6.7, it defaults to 4K and using 4K
makes the filesystem compatible with all page sizes. So let's make
sure we use minimum 4K as well (lower causes failures on systems with
a 4K page size) but still allow larger sector sizes if specified by
the user.

17 months agorepart: Don't set filesystem sector size to 512
Daan De Meyer [Sat, 29 Jun 2024 13:36:28 +0000 (15:36 +0200)] 
repart: Don't set filesystem sector size to 512

We want to use 4K as the default sector size for filesystems so they
don't have to be regenerated to work on 512, 2048 or 4096 sector sizes.

17 months agoAdded mised EVDEV_ABS_35 & EVDEV_ABS_36 for GAOMON s620
DocNITE [Fri, 28 Jun 2024 15:47:15 +0000 (18:47 +0300)] 
Added mised EVDEV_ABS_35 & EVDEV_ABS_36 for GAOMON s620

17 months agoMerge pull request #30360 from keszybz/nscd-drop
Luca Boccassi [Sat, 29 Jun 2024 08:36:16 +0000 (10:36 +0200)] 
Merge pull request #30360 from keszybz/nscd-drop

Drop support for nscd

17 months agoMerge pull request #33536 from teknoraver/hashmap_ensure_replace
Luca Boccassi [Sat, 29 Jun 2024 08:31:11 +0000 (10:31 +0200)] 
Merge pull request #33536 from teknoraver/hashmap_ensure_replace

Hashmap ensure replace

17 months agorepart: Log more about filesystem sector size
Daan De Meyer [Fri, 28 Jun 2024 17:36:50 +0000 (19:36 +0200)] 
repart: Log more about filesystem sector size

17 months agoMerge pull request #33518 from DaanDeMeyer/aarch64
Luca Boccassi [Sat, 29 Jun 2024 00:09:21 +0000 (02:09 +0200)] 
Merge pull request #33518 from DaanDeMeyer/aarch64

Various integration test fixes

17 months agocore/unit: follow merged units before updating SourcePath= timestamp too
Mike Yuan [Fri, 28 Jun 2024 13:32:33 +0000 (15:32 +0200)] 
core/unit: follow merged units before updating SourcePath= timestamp too

Currently, we only follow merged units for unit_load_dropin() call.
But if the unit is an alias, we should always perform operations
on the "canonical" unit.

17 months agoUse hashmap_ensure_replace() 33536/head
Matteo Croce [Fri, 28 Jun 2024 15:19:26 +0000 (17:19 +0200)] 
Use hashmap_ensure_replace()

Use the new function `hashmap_ensure_replace()` where we're using
`hashmap_ensure_allocated()` and `hashmap_ensure_replace()`.

Signed-off-by: Matteo Croce <teknoraver@meta.com>
17 months agoMerge pull request #33517 from keszybz/a-few-unrelated-cleanups
Luca Boccassi [Fri, 28 Jun 2024 17:06:31 +0000 (19:06 +0200)] 
Merge pull request #33517 from keszybz/a-few-unrelated-cleanups

A few unrelated cleanups

17 months agointroduce hashmap_ensure_replace()
Matteo Croce [Fri, 28 Jun 2024 14:16:50 +0000 (16:16 +0200)] 
introduce hashmap_ensure_replace()

Similar to hashmap_ensure_put(), but replace existing items in the map,
as hashmap_replace().

17 months agomeson: use less verbose quoting 30360/head
Zbigniew Jędrzejewski-Szmek [Fri, 28 Jun 2024 16:52:59 +0000 (18:52 +0200)] 
meson: use less verbose quoting

17 months agoDrop support for nscd
Zbigniew Jędrzejewski-Szmek [Tue, 11 Jul 2023 21:43:27 +0000 (23:43 +0200)] 
Drop support for nscd

nscd is known to be racy [1] and it was already deprecated and later dropped in
Fedora a while back [1,2]. We don't need to support obsolete stuff in systemd,
and the cache in systemd-resolved provides a better solution anyway.

We announced the plan to drop nscd in d44934f3785ad9ca4aab757beb80a9b11ba4bc04.

[1] https://fedoraproject.org/wiki/Changes/DeprecateNSCD
[2] https://fedoraproject.org/wiki/Changes/RemoveNSCD

The option is kept as a stub without any effect to make the transition easier.

17 months agoMerge pull request #33202 from bluca/extension_dedup
Luca Boccassi [Fri, 28 Jun 2024 16:25:36 +0000 (18:25 +0200)] 
Merge pull request #33202 from bluca/extension_dedup

core: deduplicate identical dm-verity ExtensionImages=

17 months agoTEST-54-CREDS: Use UEFI firmware if available 33518/head
Daan De Meyer [Fri, 28 Jun 2024 14:22:15 +0000 (16:22 +0200)] 
TEST-54-CREDS: Use UEFI firmware if available

On aarch64, SMBIOS is only available when using UEFI, so let's make
sure that the creds test uses UEFI when available so that it can
read creds from SMBIOS when running in a virtual machine.

17 months agoTEST-18-FAILUREACTION: Set auto firmware
Daan De Meyer [Fri, 28 Jun 2024 14:21:51 +0000 (16:21 +0200)] 
TEST-18-FAILUREACTION: Set auto firmware

This test runs in nspawn by default but will still run in qemu when
tests are run unprivileged so make sure we use UEFI if available to
avoid hangs when using the linux firmware.

17 months agoTEST-09-REBOOT: Set auto firmware
Daan De Meyer [Fri, 28 Jun 2024 14:19:38 +0000 (16:19 +0200)] 
TEST-09-REBOOT: Set auto firmware

This test runs in nspawn by default but will still run in qemu when
tests are run unprivileged so make sure we use UEFI if available to
avoid hangs when using the linux firmware.

17 months agoTEST-06-SELINUX: Explicitly pull in autorelabel.service
Daan De Meyer [Fri, 28 Jun 2024 13:50:35 +0000 (15:50 +0200)] 
TEST-06-SELINUX: Explicitly pull in autorelabel.service

17 months agoTEST-70-TPM2: Use UEFI firmware if available
Daan De Meyer [Fri, 28 Jun 2024 13:28:16 +0000 (15:28 +0200)] 
TEST-70-TPM2: Use UEFI firmware if available

On x86 this doesn't matter but on aarch64 we need to make sure UEFI
is used so that /sys/kernel/security/tpm0/binary_bios_measurements
is there which is required for TEST-70-TPM2.

17 months agocore: do not set up cgroup runtime on coldplug 33258/head
Mike Yuan [Wed, 5 Jun 2024 18:45:12 +0000 (20:45 +0200)] 
core: do not set up cgroup runtime on coldplug

Currently, unit_setup_cgroup_runtime() is called in
various _coldplug() functions if the unit is not inactive.
That seems unnecessary though, and kinda defeats the purpose
of CGroupRuntime. If we need to fork off a process for the unit
or got something during deserialization, the CGroupRuntime
would be automatically set up by unit_prepare_exec() /
cgroup_runtime_deserialize_one(). Otherwise it would mean
the cgroup doesn't exist and we don't need to allocate
that in the first place.

Plus, note that socket units might also carry a cgroup with
ExecStartPre=/ExecStartPost=/... Hence the existing code
is really inconsistent.

17 months agocore: cast ignored retval of unit_realize_cgroup to void
Mike Yuan [Wed, 5 Jun 2024 18:41:27 +0000 (20:41 +0200)] 
core: cast ignored retval of unit_realize_cgroup to void

17 months agocore: do not drop CGroupRuntime when unit stops, but only on GC
Mike Yuan [Wed, 5 Jun 2024 18:06:46 +0000 (20:06 +0200)] 
core: do not drop CGroupRuntime when unit stops, but only on GC

Fixes #33149
Replaces #33145

17 months agocore/cgroup: drop spurious ", ignoring" for unit_cgroup_is_empty
Mike Yuan [Wed, 5 Jun 2024 18:06:13 +0000 (20:06 +0200)] 
core/cgroup: drop spurious ", ignoring" for unit_cgroup_is_empty

17 months agocore/cgroup: actually make use of the cached accounting values
Mike Yuan [Thu, 13 Jun 2024 09:01:03 +0000 (11:01 +0200)] 
core/cgroup: actually make use of the cached accounting values

If cgroup is already gone, i.e. CGRuntime.cgroup_path is NULL,
do not return -ENODATA prematurely, but check for cached values
first.

For #33149

17 months agocore/cgroup: check root cgroup earlier for unit_get_memory_accounting
Mike Yuan [Thu, 13 Jun 2024 09:00:26 +0000 (11:00 +0200)] 
core/cgroup: check root cgroup earlier for unit_get_memory_accounting

17 months agocore: unify reset_accounting handling
Mike Yuan [Sat, 1 Jun 2024 23:50:09 +0000 (07:50 +0800)] 
core: unify reset_accounting handling

Since the introduction of CGroupRuntime, there's no need
to call *_reset_accounting in unit_new(), hence make those
static. While at it, refrain from hardcoding default values
in cgroup_runtime_new(), but call the corresponding funcs.

This also corrects the default value of io_accounting_base.

Fixes #33482

17 months agocore/cgroup: call bpf_firewall_close in cgroup_runtime_free
Mike Yuan [Wed, 19 Jun 2024 19:07:07 +0000 (21:07 +0200)] 
core/cgroup: call bpf_firewall_close in cgroup_runtime_free

No functional change, just deduplicate default values
in cgroup_runtime_free() and remove pointless call in
unit_free() (at the time it's called the CGRuntime has
been destroyed already).

17 months agocore/cgroup: make unit_has_host_root_cgroup take const Unit*
Mike Yuan [Sat, 15 Jun 2024 11:15:08 +0000 (13:15 +0200)] 
core/cgroup: make unit_has_host_root_cgroup take const Unit*

17 months agocore/cgroup: check CGroupRuntime.cgroup_path rather than _realized for freezer
Mike Yuan [Wed, 5 Jun 2024 17:23:40 +0000 (19:23 +0200)] 
core/cgroup: check CGroupRuntime.cgroup_path rather than _realized for freezer

The same check is used everywhere else.

17 months agocore/cgroup: use > 0 comparison rather than == 1
Mike Yuan [Sat, 1 Jun 2024 22:37:08 +0000 (06:37 +0800)] 
core/cgroup: use > 0 comparison rather than == 1

17 months agocore/cgroup: correct macro alignment
Mike Yuan [Wed, 5 Jun 2024 17:22:11 +0000 (19:22 +0200)] 
core/cgroup: correct macro alignment

17 months agoTODO: add note about DDI deduplication 33202/head
Luca Boccassi [Tue, 25 Jun 2024 12:08:30 +0000 (13:08 +0100)] 
TODO: add note about DDI deduplication

17 months agocore: deduplicate identical dm-verity ExtensionImages=
Luca Boccassi [Tue, 4 Jun 2024 15:00:03 +0000 (16:00 +0100)] 
core: deduplicate identical dm-verity ExtensionImages=

It turns out OverlayFS doesn't handle gracefully when the same source is
specified multiple times in lowerdir= and it fails with ELOOP:

Failed to mount overlay (type overlay) on /run/systemd/mount-rootfs/opt (MS_RDONLY "lowerdir=/run/systemd/unit-extensions/1/opt:/run/systemd/unit-extensions/0/opt:/run/systemd/mount-rootfs/opt"): Too many levels of symbolic links

This happens even if we mount each image in a different internal mount
path, as OverlayFS will resolve it and look for the backing device, which
will be the same device mapper entity, and return a hard error.
This error does not appear if dm-verity is not used, so it is very
confusing for users, and unnecessary.

When mounting ExtensionImages, check if an image is dm-veritied,
and drop duplicates if the root hashes match, to avoid this user-unfriendly
hard error.

17 months agoman/varlinkctl: add `list-methods` command to synopsis and fix typo
Antonio Alvarez Feijoo [Fri, 28 Jun 2024 12:22:55 +0000 (14:22 +0200)] 
man/varlinkctl: add `list-methods` command to synopsis and fix typo

Follow-up for 16cfe84c2495c1d9e753e2b8e21b69bea21ebaf4

17 months agoresolved: correct parsing of OPT extended RCODEs 33523/head
James Coglan [Fri, 28 Jun 2024 12:58:22 +0000 (13:58 +0100)] 
resolved: correct parsing of OPT extended RCODEs

The DNS_PACKET_RCODE() function works out the full RCODE by taking the
first octet from the OPT record TTL field and bitwise-OR-ing this with
the basic RCODE from the packet header. This results in RCODE values
being lower than they should be.

For example, if the first TTL octet is 0x7a and the basic RCODE is 3,
this function currently returns `0x7a | 3` = 123, rather than 0x7a3 =
1955.

The first TTL octet is supposed to form the upper 8 bits of a 12-bit
value, whereas the current implementation constraints the value to 8
bits and results in mis-interpreted RCODEs.

This fixes things by shifting the TTL 20 places instead of 24 and
masking off the low nibble that comes from the upper bits of the version
octet.

Note that dns_packet_append_opt() correctly converts the input RCODE
into the high octet of the OPT TTL field; this problem only affects
parsing of incoming packets.

17 months agoTEST-45-TIMEDATE: Use syslog identifier journalctl match
Daan De Meyer [Fri, 28 Jun 2024 12:51:10 +0000 (14:51 +0200)] 
TEST-45-TIMEDATE: Use syslog identifier journalctl match

Using a unit match is racy whereas a syslog identifier match is
reliable.

17 months agoMerge pull request #33370 from grawity/run-title
Zbigniew Jędrzejewski-Szmek [Fri, 28 Jun 2024 12:46:27 +0000 (14:46 +0200)] 
Merge pull request #33370 from grawity/run-title

run: add option to prevent the setting of terminal title

17 months agoMerge pull request #33516 from poettering/more-stub-tweaks
Luca Boccassi [Fri, 28 Jun 2024 12:46:16 +0000 (14:46 +0200)] 
Merge pull request #33516 from poettering/more-stub-tweaks

sd-stub: three more tweaks

17 months agoresolved: allow the full TTL to be used by OPT records
James Coglan [Fri, 28 Jun 2024 12:41:31 +0000 (13:41 +0100)] 
resolved: allow the full TTL to be used by OPT records

Whereas RFC 1035 says the TTL field takes the "positive values of a
signed 32 bit number", and RFC 2181 says "Implementations should treat
TTL values received with the most significant bit set as if the entire
value received was zero,", the dns_packet_read_rr() function sets
rr->ttl to zero if the MSB is set.

However, EDNS(0) as specified in RFC 6891 repurposes the TTL field's 4
octets to store other information, c.f.:

                  +0 (MSB)                            +1 (LSB)
       +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
    0: |         EXTENDED-RCODE        |            VERSION            |
       +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
    2: | DO|                           Z                               |
       +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+

The first octet extends the usual 4-bit RCODE from the packet header by
providing an additional 8 bits of space, extending the RCODE to 12 bits.
But, our handling of the TTL field means that the high bit in the first
octet is not actually usable, since setting it will mean these 4 octets
are replaced with 0. This may have the effect of making us believe a
server does not support DNSSEC when it actually set the DO bit in its
OPT record.

Here we change things so that the TTL is only set to zero for record
types other than OPT.

17 months agoTEST-64-UDEV-STORAGE: Make nvme_subsystem expected pci symlinks more generic
Daan De Meyer [Fri, 28 Jun 2024 12:20:34 +0000 (14:20 +0200)] 
TEST-64-UDEV-STORAGE: Make nvme_subsystem expected pci symlinks more generic

When running the test on aarch64 the symlinks look as follows:

"""
[root@H ~]# ls /dev/disk/by-path
platform-4010000000.pcie-pci-0000:00:04.0-scsi-0:0:0:0       platform-4010000000.pcie-pci-0000:00:04.0-scsi-0:0:0:0-part1  platform-4010000000.pcie-pci-0000:00:05.0-nvme-16
platform-4010000000.pcie-pci-0000:00:04.0-scsi-0:0:0:0-part  platform-4010000000.pcie-pci-0000:00:04.0-scsi-0:0:0:0-part2  platform-4010000000.pcie-pci-0000:00:05.0-nvme-17
"""

So let's make the PCI patterns a little more generic so they match
both the x86 and the aarch64 paths.

17 months agoLICENSES/README: expand text to summarize state for binaries and libs
Zbigniew Jędrzejewski-Szmek [Fri, 28 Jun 2024 11:22:40 +0000 (13:22 +0200)] 
LICENSES/README: expand text to summarize state for binaries and libs

We would say how *sources* are licensed, but actually most user care about the
resulting binaries. So say how the *binaries* are licensed. I used the word
"effectively" because the permissive licenses don't set any requirements on the
binaries, so the license of sources is a complex mix, but the resulting
binaries have a simple effective license.

Also, make it clear that the GPLv2 license applies to udev programs, but not
the shared library. Based on private correspondence, there's some confusion
about this.

17 months agomkosi: Install pciutils
Daan De Meyer [Fri, 28 Jun 2024 11:41:12 +0000 (13:41 +0200)] 
mkosi: Install pciutils

17 months agotest: pull in multi-user.target explicitly
Daan De Meyer [Fri, 28 Jun 2024 11:34:37 +0000 (13:34 +0200)] 
test: pull in multi-user.target explicitly

Let's make sure we pull in multi-user.target so that we get a console
when a test fails and we're running meson test with --interactive.

17 months agoTEST-64-UDEV-STORAGE: Fix python 3.9 compatibility
Daan De Meyer [Fri, 28 Jun 2024 10:51:46 +0000 (12:51 +0200)] 
TEST-64-UDEV-STORAGE: Fix python 3.9 compatibility

Using double quotes in f-strings only works from python 3.12 onwards.
Use single quotes to make sure python 3.9 works as well.

Also clean up quotes a little in general.

17 months agoTEST-64-UDEV-STORAGE: Use bus pci slot 1 instead of 0
Daan De Meyer [Fri, 28 Jun 2024 10:50:49 +0000 (12:50 +0200)] 
TEST-64-UDEV-STORAGE: Use bus pci slot 1 instead of 0

Trying to use bus pci slot 0 fails on aarch64 so let's use 1 instead.

The error:

"""
qemu-system-aarch64: -device virtio-blk-pci,drive=drive0,scsi=off,bus=pci_bridge25: Unsupported PCI slot 0 for standard hotplug controller. Valid slots are between 1 and 31.
"""

17 months agosd-bus: drop bytefield annontations 33517/head
Zbigniew Jędrzejewski-Szmek [Fri, 28 Jun 2024 09:45:41 +0000 (11:45 +0200)] 
sd-bus: drop bytefield annontations

It's the same old story: 'struct sd_bus' is generally instantiated once, so
bitfields, for which we pay with more complicated code in all users of this
struct, are counterproductive. In some progs the structure may be instantiated
a few times, but it's still not worth it because we save a few bytes of memory
in one place and pay for this with many more bytes in the code.

$ size build/libsystemd.so.0.39.0{.orig,}
   text    data     bss     dec     hex filename
2452757   65376    3768 2521901  267b2d build/libsystemd.so.0.39.0.orig
2451669   65376    3768 2520813  2676ed build/libsystemd.so.0.39.0

$ diff -u <(pahole build/libsystemd.so.0.39.0.orig) <(pahole build/libsystemd.so.0.39.0)
...
-       /* size: 1960, cachelines: 31, members: 105 */
-       /* sum members: 1944, holes: 3, sum holes: 9 */
-       /* sum bitfield members: 25 bits, bit holes: 2, sum bit holes: 31 bits */
+       /* size: 1984, cachelines: 31, members: 105 */
+       /* sum members: 1971, holes: 4, sum holes: 13 */
        /* member types with holes: 1, total: 1 */

i.e. 2452757 - 2451669 = 1088 extra bytes of code and slower execution, to save
24 bytes of memory per instance of the struct. (But the number of cachelines
doesn't change, so the smaller struct most likely has no effect on memory
access, and the alignment of the struct most likely means that the memory
saving is illusory too, we just end up with a few bytes of padding after the
struct.)

In the other structs, the alignment prevent the bitfield for having any effect
on memory use, but the compiler would still generate more complicated code,
i.e. we pay something for nothing.

For example:

$ diff -u <(pahole build/libsystemd.so.0.39.0.orig) <(pahole build/libsystemd.so.0.39.0)
...
 struct node_callback {
        struct node *              node;                 /*     0     8 */
-       _Bool                      is_fallback:1;        /*     8: 0  1 */
+       _Bool                      is_fallback;          /*     8     1 */

-       /* XXX 7 bits hole, try to pack */
        /* XXX 3 bytes hole, try to pack */

        unsigned int               last_iteration;       /*    12     4 */
@@ -455,15 +448,13 @@
        struct node_callback *     callbacks_prev;       /*    32     8 */

        /* size: 40, cachelines: 1, members: 6 */
-       /* sum members: 36, holes: 1, sum holes: 3 */
-       /* sum bitfield members: 1 bits, bit holes: 1, sum bit holes: 7 bits */
+       /* sum members: 37, holes: 1, sum holes: 3 */
        /* last cacheline: 40 bytes */
 };

I kept the bitfield in sd_bus_slot because it prevents the struct from growing
from 112 to 120 bytes by reducing the alignment requirement for subsequent
fields, and we potentially can have this instantiated many times.

17 months agosd-bus: simplify handling of 'types' in convenience methods
Zbigniew Jędrzejewski-Szmek [Wed, 26 Jun 2024 11:07:03 +0000 (13:07 +0200)] 
sd-bus: simplify handling of 'types' in convenience methods

The arg types==NULL has different meanings for different functions. Some
functions like sd_bus_message_appendv() require a non-null param and treat "" as
"no data". Other functions like sd_bus_skip() treat null as "process one item",
while the convenience functions treat NULL the same as "". So I think it's
reasonable to make the convenience functions handle NULL explicitly, separately
from "". That way the logical separation of concerns is clearer, and e.g.
sd_bus_message_appendv() handles all non-null strings, while e.g.
sd_bus_call_methodv() doesn't look into the string at all.

Behaviour is unchanged.

17 months agomkosi: move variable to the right scope
Zbigniew Jędrzejewski-Szmek [Thu, 6 Jun 2024 11:23:17 +0000 (13:23 +0200)] 
mkosi: move variable to the right scope

17 months agoTEST-58-REPART: reverse order of diff args
Zbigniew Jędrzejewski-Szmek [Thu, 30 May 2024 09:33:20 +0000 (11:33 +0200)] 
TEST-58-REPART: reverse order of diff args

I expect the test output to be the second argument, so we're diffing "expected"
and "output", not the other way around.

I noticed this when working on https://github.com/systemd/systemd/pull/33081.

17 months agomeson: Drop genkey target
Daan De Meyer [Fri, 28 Jun 2024 07:58:56 +0000 (09:58 +0200)] 
meson: Drop genkey target

In mkosi.images/system/mkosi.conf, we configure the certificate as
an extra tree so it's available inside the image. However, we pick up
the certificate from the top level repository directory and not from the
build directory where it is generated by the genkey meson target.

We currently have no way to access the build directory that mkosi was
invoked from when parsing the configuration file. Thus we have no way to
specify the correct location to the certificate when it's located in the
build directory.

For now, let's look for the key and certificate in the top level repository
root directory and drop the genkey target.

We don't have to change the Github Actions CI because it already runs genkey
manually before the image build (which is something we forgot to remove when
introducing the genkey target and is the reason this didn't cause issues before).