]> git.ipfire.org Git - thirdparty/systemd.git/log
thirdparty/systemd.git
3 months agocore: add 'DefaultRestrictSUIDSGID' config option
Grimmauld [Tue, 8 Jul 2025 19:21:25 +0000 (21:21 +0200)] 
core: add 'DefaultRestrictSUIDSGID' config option

closes #37602

On typical systems, only few services need to create SUID/SGID files.
This often is limited to the user explicitly setting suid/sgid, the
`systemd-tmpfiles*` services, and the package manager. Allowing a default
to globally restrict creation of suid/sgid files makes it easier to apply
this restriction precisely.

3 months agounits/systemd-tmpfiles-setup.service: explicitly set RestrictSUIDSGID=no
Grimmauld [Tue, 8 Jul 2025 20:02:46 +0000 (22:02 +0200)] 
units/systemd-tmpfiles-setup.service: explicitly set RestrictSUIDSGID=no

The tmpfiles service is used to set file permissions, e.g. for setting
suid bit on the journal log directory [1].

[1] https://github.com/systemd/systemd/blob/48e0f7bc2f94e74d15eed5c9e70b1c0269a495ec/tmpfiles.d/systemd.conf.in#L24-L25

3 months agocore: fix owner check of PIDFile=, and update document (#38115)
Yu Watanabe [Tue, 8 Jul 2025 14:58:19 +0000 (23:58 +0900)] 
core: fix owner check of PIDFile=, and update document (#38115)

Closes #38108.

3 months agoA few changes related to linking and bitfields (#38118)
Yu Watanabe [Tue, 8 Jul 2025 14:57:44 +0000 (23:57 +0900)] 
A few changes related to linking and bitfields (#38118)

3 months agomeson: drop -ffunction-sections -fdata-sections 38118/head
Zbigniew Jędrzejewski-Szmek [Tue, 8 Jul 2025 11:18:07 +0000 (13:18 +0200)] 
meson: drop -ffunction-sections -fdata-sections

I added them in 41afb5eb7214727301132aedc381831fbfc78e37 without too
much explanation. Most likely the idea was to get rid of unused code
in libsystemd.so [1]. But now that I'm testing this, it doesn't seem
to have an effect. LTO is needed to get rid of unused functions, and
it's enough to have LTO without those options. Those options might have
some downsides [2], so let's disable them since there are doubts and no
particularly good reason to have them.

But keep the -Wl,--gc-sections option. Without this, libsystemd.so
grows a little:
-rwxr-xr-x 1 zbyszek zbyszek 5532424 07-08 13:24 build/libsystemd.so.0.40.0-orig
-rwxr-xr-x 1 zbyszek zbyszek 5614472 07-08 13:26 build/libsystemd.so.0.40.0-no-sections
-rwxr-xr-x 1 zbyszek zbyszek 5532392 07-08 13:27 build/libsystemd.so.0.40.0

Let's apply the --gc-sections option always to make the debug and final
builds more similar.

We need to verify that distro packages don't unexpectedly grow after this.

[1] https://unix.stackexchange.com/a/715901
[2] https://stackoverflow.com/a/36033811

3 months agobasic/stdio-util: use a fixed message in xsprintf
Zbigniew Jędrzejewski-Szmek [Tue, 8 Jul 2025 10:44:06 +0000 (12:44 +0200)] 
basic/stdio-util: use a fixed message in xsprintf

We put the name of the variable in the message, but it is a local variable
and the name does not have global meaning. We end up with pointless copies
of the error string:

$ strings build/libsystemd.so.0.40.0 | grep 'big enough'
xsprintf: p[] must be big enough
xsprintf: error[] must be big enough
xsprintf: prefix[] must be big enough
xsprintf: pty[] must be big enough
xsprintf: mode[] must be big enough
xsprintf: t[] must be big enough
xsprintf: s[] must be big enough
xsprintf: spid[] must be big enough
xsprintf: header_priority[] must be big enough
xsprintf: header_pid[] must be big enough
xsprintf: path[] must be big enough
xsprintf: buf[] must be big enough

The error message already shows the file, line, and function name, which
is enough to identify the problem:

  Assertion 'xsprintf: buffer too small' failed at src/test/test-string-util.c:20, function test_xsprintf(). Aborting.

3 months agotest-string-util: add a small test for xsprintf
Zbigniew Jędrzejewski-Szmek [Tue, 8 Jul 2025 10:55:17 +0000 (12:55 +0200)] 
test-string-util: add a small test for xsprintf

3 months agoMerge shared/exec-directory-util.? into basic/unit-def.?
Zbigniew Jędrzejewski-Szmek [Tue, 8 Jul 2025 10:09:31 +0000 (12:09 +0200)] 
Merge shared/exec-directory-util.? into basic/unit-def.?

Suggested in
https://github.com/systemd/systemd/pull/35892#discussion_r2180322856.

This is a tiny amount of code and does not warrant having a separate file
and spawning a separate instance of the compiler during the build.

Note: it took me a while to confirm that the contents of that table and
function don't end up in libsystemd.so. The issue is that they _are_ present in
it, unless LTO is used. We actually use link_whole[libbasic_static] for
libsystemd, so we end up with all that code there. LTO is needed to clean
that up.

3 months agoman: mention relative PIDFile= in user service is prefixed with $XDG_RUNTIME_DIR 38115/head
Yu Watanabe [Tue, 8 Jul 2025 08:49:52 +0000 (17:49 +0900)] 
man: mention relative PIDFile= in user service is prefixed with $XDG_RUNTIME_DIR

3 months agocore: allow to use PIDFile= in user session services
Yu Watanabe [Tue, 8 Jul 2025 08:37:33 +0000 (17:37 +0900)] 
core: allow to use PIDFile= in user session services

Fixes #38108.

Co-authored-by: 铝箔 <38349409+Sodium-Aluminate@users.noreply.github.com>
3 months agoupdate TODO
Lennart Poettering [Tue, 8 Jul 2025 08:53:51 +0000 (10:53 +0200)] 
update TODO

3 months agoshared/open-file: add line break
Zbigniew Jędrzejewski-Szmek [Mon, 7 Jul 2025 09:13:26 +0000 (11:13 +0200)] 
shared/open-file: add line break

We don't generally parenthesize additions, so drop that too.

3 months agoAdjust bitfields in struct Condition
Zbigniew Jędrzejewski-Szmek [Tue, 1 Jul 2025 11:39:00 +0000 (13:39 +0200)] 
Adjust bitfields in struct Condition

As is usually the case, the bitfields don't create the expected space savings,
because the field that follows needs to be aligned. But we don't want to fully
drop the bitfields here, because then ConditionType and ConditionResult are
each 4 bytes, and the whole struct grows from 32 to 40 bytes (on amd64). We
potentially have lots of little Conditions and that'd waste some memory.

Make each of the four fields one byte. This still allows the compiler to
generate simpler code without changing the struct size:

E.g. in condition_test:
                 c->result = CONDITION_ERROR;
-   78fab:      48 8b 45 e8             mov    -0x18(%rbp),%rax
-   78faf:      0f b6 50 01             movzbl 0x1(%rax),%edx
-   78fb3:      83 e2 03                and    $0x3,%edx
-   78fb6:      83 ca 0c                or     $0xc,%edx
-   78fb9:      88 50 01                mov    %dl,0x1(%rax)
+   78f8b:      48 8b 45 e8             mov    -0x18(%rbp),%rax
+   78f8f:      c6 40 03 03             movb   $0x3,0x3(%rax)

3 months agoupdate TODO
Lennart Poettering [Tue, 8 Jul 2025 07:56:24 +0000 (09:56 +0200)] 
update TODO

3 months agotest: invoke systemd-nspawn properly from a session
Lennart Poettering [Wed, 2 Jul 2025 13:22:35 +0000 (15:22 +0200)] 
test: invoke systemd-nspawn properly from a session

Let's not run user code outside of user context, that's not how things
are deployed, and means we cannot test the session setup properly

3 months agominor fixes to nspawn, machined, vmspawn (#38110)
Yu Watanabe [Tue, 8 Jul 2025 06:54:49 +0000 (15:54 +0900)] 
minor fixes to nspawn, machined, vmspawn (#38110)

Nothing earth shattering. Just clean-ups.

3 months agonspawn: Support idmapped mounts on homed managed home directories (#38069)
Lennart Poettering [Tue, 8 Jul 2025 04:51:41 +0000 (06:51 +0200)] 
nspawn: Support idmapped mounts on homed managed home directories (#38069)

Christian made this possible in Linux 6.15 with a new system call
open_tree_attr() that combines open_tree() and mount_setattr(). Because
idmapped mounts are (rightfully) not nested, we have to do some extra
shenanigans to make source we're putting the right source uid in the
userns for any idmapped mounts that we do in nspawn.

Of course we also add the necessary boilerplate to make open_tree_attr()
available in our code and wrap open_tree_attr() and the corresponding
fallback in a new function which we then use everywhere else.

3 months agovmspawn: tighten parser of EXIT_STATUS= 38110/head
Lennart Poettering [Mon, 16 Jun 2025 08:52:26 +0000 (10:52 +0200)] 
vmspawn: tighten parser of EXIT_STATUS=

The EXIT_STATUS is supposed to encapuslate an ANSI C process exit
status, which is 8bit unsigned. Hence parse it as such, do not accept
negative values, or values > 255.

3 months agonspawn: fix parser of --notify-ready=
Lennart Poettering [Mon, 16 Jun 2025 08:45:47 +0000 (10:45 +0200)] 
nspawn: fix parser of --notify-ready=

This switch takes a bool only, not an enum, hence don't claim otherwise
in the error log message.

3 months agonspawn: add argument comments to various calls
Lennart Poettering [Thu, 12 Jun 2025 15:38:04 +0000 (17:38 +0200)] 
nspawn: add argument comments to various calls

3 months agonspawn: don't use strjoina() for user controlled strings
Lennart Poettering [Thu, 12 Jun 2025 15:37:45 +0000 (17:37 +0200)] 
nspawn: don't use strjoina() for user controlled strings

3 months agomachinectl: fix status output indentation
Lennart Poettering [Mon, 30 Jun 2025 21:12:36 +0000 (23:12 +0200)] 
machinectl: fix status output indentation

All other status output lines use tabs, use that for the ID shift line
too. otherwise output will appear unaligned if log viewers have fixed
tab stop positions.

3 months agoadd api to kill subcgroups of units (#38102)
Lennart Poettering [Tue, 8 Jul 2025 04:33:32 +0000 (06:33 +0200)] 
add api to kill subcgroups of units (#38102)

3 months agotree-wide: switch a bunch of sd_bus_error_setf() to sd_bus_error_set()
Lennart Poettering [Tue, 8 Jul 2025 01:08:56 +0000 (03:08 +0200)] 
tree-wide: switch a bunch of sd_bus_error_setf() to sd_bus_error_set()

4 months agotest: add testcase for subcgroup killing 38102/head
Lennart Poettering [Mon, 30 Jun 2025 12:54:36 +0000 (14:54 +0200)] 
test: add testcase for subcgroup killing

4 months agosystemctl: add --kill-subgroup= switch for killing subcgroup
Lennart Poettering [Mon, 30 Jun 2025 12:54:12 +0000 (14:54 +0200)] 
systemctl: add --kill-subgroup= switch for killing subcgroup

4 months agopid1: add ability to kill processes in a subgroup of a unit
Lennart Poettering [Mon, 19 May 2025 15:38:26 +0000 (17:38 +0200)] 
pid1: add ability to kill processes in a subgroup of a unit

This is useful for things like machined, where the system machined wants
to manage a machine owned by the user somewhere down the tree.

4 months agopid1: properly report if we managed to kill a process by cgroup
Lennart Poettering [Mon, 30 Jun 2025 12:53:30 +0000 (14:53 +0200)] 
pid1: properly report if we managed to kill a process by cgroup

4 months agocore: add quota support for State, Cache, and Log exec directories (#35892)
Yu Watanabe [Tue, 8 Jul 2025 00:18:20 +0000 (09:18 +0900)] 
core: add quota support for State, Cache, and Log exec directories (#35892)

Based on https://github.com/systemd/systemd/issues/7820, this adds support for
quota enforcement to State, Cache, and Log exec directories.
* Add new directives, StateDirectoryQuota=, CacheDirectoryQuota=, and
  LogDirectoryQuota=, to define quotas as percentages (hard limits for
  blocks and inodes) or absolute values (hard limits for blocks only).
* Add new directives, StateDirectoryQuotaAccounting=,
  CacheDirectoryQuotaAccounting= and LogDirectoryQuotaAccounting= to keep
  track of storage quotas but not enforce them (effectively just assigning
  a project ID to defined exec directories).

Example:
```
StateDirectory=quotadir
StateDirectoryQuota=1%

Jan 06 22:55:46 abeltran: Storage quotas set for /var/lib/private/quotadir. Block limit = 2639404, inode limit = 671088

root@abeltran:/var/lib/private# lsattr -pR
3153000189 --------------e----P-- ./quotadir

root@abeltran:/var/lib/private# repquota  -P /datadrive
*** Report for project quotas on device /dev/sdc1
Block grace time: 7days; Inode grace time: 7days
                        Block limits                File limits
Project         used    soft    hard  grace    used  soft  hard  grace
----------------------------------------------------------------------
#0        --  213200       0       0           4086     0     0
#3153000189 -- 2639404       0 2639404              2     0 671088
```

4 months agobootspec: fix string table naming for BootEntryType/BootEntrySource (#38106)
Yu Watanabe [Tue, 8 Jul 2025 00:11:30 +0000 (09:11 +0900)] 
bootspec: fix string table naming for BootEntryType/BootEntrySource (#38106)

This was all very confusing and not matching our coding style
recommendations. Let's fix that.

Prompted by #37897, which really should make use of BootEntryType, but
we better clean it up first.

4 months agoman: also use title case in systemd.service(5)
Lennart Poettering [Mon, 7 Jul 2025 16:11:03 +0000 (18:11 +0200)] 
man: also use title case in systemd.service(5)

Follow-up for: 172dd81e92198d4903a52001e20f0da7f0b9d8b2

4 months agocore/cgroup: prepare for removal of tracking/bookkeeping logic specific to cgroup...
Yu Watanabe [Mon, 7 Jul 2025 23:37:01 +0000 (08:37 +0900)] 
core/cgroup: prepare for removal of tracking/bookkeeping logic specific to cgroup v1 (#38099)

4 months agotest: add test for quotas on Exec directories 35892/head
Andres Beltran [Mon, 16 Jun 2025 23:44:35 +0000 (23:44 +0000)] 
test: add test for quotas on Exec directories

4 months agoAdd quota support for systemctl
Andres Beltran [Tue, 1 Jul 2025 17:41:31 +0000 (17:41 +0000)] 
Add quota support for systemctl

4 months agoAdd quota support for DBus
Andres Beltran [Tue, 1 Jul 2025 17:40:47 +0000 (17:40 +0000)] 
Add quota support for DBus

4 months agocore: add quota support for State, Cache, and Log exec directories
Andres Beltran [Tue, 1 Jul 2025 17:37:48 +0000 (17:37 +0000)] 
core: add quota support for State, Cache, and Log exec directories

4 months agoshared: add exec-directory-util.ch
Andres Beltran [Tue, 1 Jul 2025 17:24:56 +0000 (17:24 +0000)] 
shared: add exec-directory-util.ch

4 months agoquota-util: add methods to read and set project IDs
Andres Beltran [Mon, 16 Jun 2025 23:39:25 +0000 (23:39 +0000)] 
quota-util: add methods to read and set project IDs

4 months agochattr-util: add helpers to read and set project IDs
Andres Beltran [Mon, 16 Jun 2025 23:38:25 +0000 (23:38 +0000)] 
chattr-util: add helpers to read and set project IDs

4 months agobootspec: boot_entry_source_to_json_string() to boot_entry_source_to_string() 38106/head
Lennart Poettering [Mon, 7 Jul 2025 16:26:59 +0000 (18:26 +0200)] 
bootspec: boot_entry_source_to_json_string() to boot_entry_source_to_string()

As with the previous changes for BootEntryType, let's also clean up the
naming for BootEntrySource.

4 months agobootspec: rename boot_entry_source_to_string() to boot_entry_source_description_to_st...
Lennart Poettering [Mon, 7 Jul 2025 16:25:22 +0000 (18:25 +0200)] 
bootspec: rename boot_entry_source_to_string() to boot_entry_source_description_to_string()

Similar to the previous changes, let's make clear this string table
contains *descriptive*, i.e. meaningful human-readable strings.

4 months agobootspec: rename BootEntryType values
Lennart Poettering [Mon, 7 Jul 2025 16:10:13 +0000 (18:10 +0200)] 
bootspec: rename BootEntryType values

So we exposed different names for the entry types in JSON than we named
our enum values. Which is very confusing. Let's unify that. Given that
the JSON fields are externally visible let's stick to that naming, even
though I think "unified" and "conf" would have been more descriptive.

This ensures we follow our usual logic that the enum identifiers and the
strings they map to use the same naming.

4 months agobootspec: include 'UKI' in descriptive name for type #2
Lennart Poettering [Mon, 7 Jul 2025 13:54:17 +0000 (15:54 +0200)] 
bootspec: include 'UKI' in descriptive name for type #2

I am pretty sure that "UKI" is the best known name for type #2 boot
loader spec entries, hence we really should put it in the name.

4 months agobootspec: rename boot_entry_type_to_string() to boot_entry_type_description_to_string()
Lennart Poettering [Mon, 7 Jul 2025 13:52:17 +0000 (15:52 +0200)] 
bootspec: rename boot_entry_type_to_string() to boot_entry_type_description_to_string()

This helper does not translate BootEntryType to a string matching the
enum's value names, but instead returns a human readable descriptive
string. Let's make it clearer what this, by including "description" in
the name.

4 months agoTODO: add future deprecation of DefaultMemoryMin/Low= 38099/head
Mike Yuan [Sun, 6 Jul 2025 10:41:29 +0000 (12:41 +0200)] 
TODO: add future deprecation of DefaultMemoryMin/Low=

4 months agocore/cgroup: unit_realize_cgroup_now_disable() is NOP for non-slice units
Mike Yuan [Sat, 5 Jul 2025 23:24:29 +0000 (01:24 +0200)] 
core/cgroup: unit_realize_cgroup_now_disable() is NOP for non-slice units

4 months agocore/cgroup: make unit_get_ancestor_disable_mask() static
Mike Yuan [Sat, 5 Jul 2025 22:18:40 +0000 (00:18 +0200)] 
core/cgroup: make unit_get_ancestor_disable_mask() static

4 months agocore/cgroup: tweak unit_invalidate_cgroup_bpf() a bit
Mike Yuan [Tue, 27 May 2025 23:02:04 +0000 (01:02 +0200)] 
core/cgroup: tweak unit_invalidate_cgroup_bpf() a bit

- Rename to unit_invalidate_cgroup_bpf_firewall() to make it clear
  that this is about CGROUP_CONTROLLER_BPF_FIREWALL only
- Report whether things changed in unit_invalidate_cgroup()
  to avoid duplicate checks

4 months agocore/cgroup: dial down "controller" noise
Mike Yuan [Sun, 6 Jul 2025 00:04:10 +0000 (02:04 +0200)] 
core/cgroup: dial down "controller" noise

Add some missing assertions while at it.

4 months agocore/cgroup: workaround for kernel < 5.4 is now irrelevant
Mike Yuan [Sat, 5 Jul 2025 23:57:51 +0000 (01:57 +0200)] 
core/cgroup: workaround for kernel < 5.4 is now irrelevant

4 months agocore/cgroup: remove any reference to cgv1 controllers
Mike Yuan [Sat, 5 Jul 2025 21:50:48 +0000 (23:50 +0200)] 
core/cgroup: remove any reference to cgv1 controllers

4 months agocore/cgroup: regroup functions
Mike Yuan [Sat, 5 Jul 2025 23:54:45 +0000 (01:54 +0200)] 
core/cgroup: regroup functions

4 months agocore/cgroup: drop unneeded cast
Mike Yuan [Sat, 5 Jul 2025 23:46:59 +0000 (01:46 +0200)] 
core/cgroup: drop unneeded cast

4 months agocore/cgroup: introduce cgroup_context_has_device_policy() helper
Mike Yuan [Sat, 5 Jul 2025 21:47:06 +0000 (23:47 +0200)] 
core/cgroup: introduce cgroup_context_has_device_policy() helper

4 months agocore/cgroup: drop dangling cgroup_context_copy() prototype
Mike Yuan [Sat, 5 Jul 2025 21:39:46 +0000 (23:39 +0200)] 
core/cgroup: drop dangling cgroup_context_copy() prototype

Follow-up for 8c35e8a9d2b0c26453108d51873991af7ec7dfe1

4 months agocore/cgroup: constify CGROUP_TASKS_MAX_UNSET
Mike Yuan [Sat, 5 Jul 2025 21:27:54 +0000 (23:27 +0200)] 
core/cgroup: constify CGROUP_TASKS_MAX_UNSET

4 months agoman/supported-controllers: refresh list
Mike Yuan [Sun, 6 Jul 2025 00:40:13 +0000 (02:40 +0200)] 
man/supported-controllers: refresh list

4 months agonspawn: Support idmapped mounts on homed managed home directories 38069/head
DaanDeMeyer [Fri, 4 Jul 2025 18:19:26 +0000 (20:19 +0200)] 
nspawn: Support idmapped mounts on homed managed home directories

Christian made this possible in Linux 6.15 with a new system call
open_tree_attr() that combines open_tree() and mount_setattr().
Because idmapped mounts are (rightfully) not nested, we have to do
some extra shenanigans to make source we're putting the right source
uid in the userns for any idmapped mounts that we do in nspawn.

Of course we also add the necessary boilerplate to make open_tree_attr()
available in our code and wrap open_tree_attr() and the corresponding
fallback in a new function which we then use everywhere else.

4 months agoforward: Add struct mount_attr forward declaration
DaanDeMeyer [Fri, 4 Jul 2025 18:19:06 +0000 (20:19 +0200)] 
forward: Add struct mount_attr forward declaration

4 months agobasic: Add open_tree_attr() syscall wrapper
DaanDeMeyer [Fri, 4 Jul 2025 18:18:39 +0000 (20:18 +0200)] 
basic: Add open_tree_attr() syscall wrapper

4 months agobasic: Use Static_assert() in missing_syscall_def.h
DaanDeMeyer [Fri, 4 Jul 2025 16:56:42 +0000 (18:56 +0200)] 
basic: Use Static_assert() in missing_syscall_def.h

Let's use Static_assert() so we don't have to include forward.h in
missing_syscall_def.h.

4 months agoman: improve Description= documentation (#38101)
Zbigniew Jędrzejewski-Szmek [Mon, 7 Jul 2025 09:56:09 +0000 (11:56 +0200)] 
man: improve Description= documentation (#38101)

Fixes: #36165
4 months agoman: improve Description= documentation 38101/head
Lennart Poettering [Mon, 7 Jul 2025 08:10:29 +0000 (10:10 +0200)] 
man: improve Description= documentation

This is an attempt to address the issues raised in #36165.

Fixes: #36165
4 months agotree-wide: "human readable" → "human-readable"
Lennart Poettering [Mon, 7 Jul 2025 07:48:42 +0000 (09:48 +0200)] 
tree-wide: "human readable" → "human-readable"

Apparently, the spelling with a hyphen is better style in the English
language.

Suggested by: #36165

4 months agobuild(deps): bump github/codeql-action from 3.28.18 to 3.29.2
dependabot[bot] [Tue, 1 Jul 2025 11:21:37 +0000 (11:21 +0000)] 
build(deps): bump github/codeql-action from 3.28.18 to 3.29.2

Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.28.18 to 3.29.2.
- [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/ff0a06e83cb2de871e5a09832bc6a81e7276941f...181d5eefc20863364f96762470ba6f862bdef56b)

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

Signed-off-by: dependabot[bot] <support@github.com>
4 months agoUnify error messages for transient settings, fix handling of Ex variants (#38083)
Lennart Poettering [Mon, 7 Jul 2025 07:39:40 +0000 (09:39 +0200)] 
Unify error messages for transient settings, fix handling of Ex variants (#38083)

4 months agoExplicitly include more headers (#38100)
Daan De Meyer [Mon, 7 Jul 2025 06:26:46 +0000 (08:26 +0200)] 
Explicitly include more headers (#38100)

Continuation of 4f18ff2e29b8054f30b084abcabf5f689f4b340b.

4 months agotimesync,test: explicitly include sys/timex.h when struct timex is used 38100/head
Yu Watanabe [Mon, 7 Jul 2025 03:40:11 +0000 (12:40 +0900)] 
timesync,test: explicitly include sys/timex.h when struct timex is used

struct timex is defined by sys/timex.h -> bits/timex.h.
Glibc includes the header in time.h, but let's explicitly include it
when the struct is used.

Similar to 4f18ff2e29b8054f30b084abcabf5f689f4b340b, but for sys/timex.h.

4 months agotree-wide: include sys/stat.h where necessary
Yu Watanabe [Mon, 7 Jul 2025 02:40:42 +0000 (11:40 +0900)] 
tree-wide: include sys/stat.h where necessary

These source files uses symbols provided by sys/stat.h, e.g. struct stat,
S_IFREG, S_IFBLK, and so on. Let's explicitly include sys/stat.h where
necessary.

Glibc's fcntl.h includes bits/stat.h, which provides these symbols, so
these symbols can be used without explicitly including sys/stat.h. But,
based on the discussion in #37922, we should explicitly include relevant
headers, and should not rely on the indirect inclusion.

Similar to 4f18ff2e29b8054f30b084abcabf5f689f4b340b, but for sys/stat.h.

4 months agoTwo follow-ups for recent PRs (#38062)
Lennart Poettering [Sun, 6 Jul 2025 20:06:52 +0000 (22:06 +0200)] 
Two follow-ups for recent PRs (#38062)

4 months agosystemd-analyze: stop printing Ex transient settings 38083/head
Zbigniew Jędrzejewski-Szmek [Sat, 5 Jul 2025 11:01:18 +0000 (13:01 +0200)] 
systemd-analyze: stop printing Ex transient settings

The test will fail if we ever add one again in the future by mistake.

4 months agoshared/bus-unit-util: fix PrivateTmp=/PrivateUsers=/ProtectControlGroups= and Ex...
Zbigniew Jędrzejewski-Szmek [Sat, 5 Jul 2025 07:22:16 +0000 (09:22 +0200)] 
shared/bus-unit-util: fix PrivateTmp=/PrivateUsers=/ProtectControlGroups= and Ex variants

For some fields, we perform careful parsing and verification on the sender
side. For other fields, we accept any string or strv. I think that actually
this is fine: we should optimize for the correct case, i.e. the user runs a
command that is valid. The server must perform parsing in all cases, so doing
the verification on the sender side doesn't add value. When doing parsing
locally, in case of invalid or unsupported input, we would generate the error
message locally, so we would avoid the D-Bus call, but the message itself is
not better and from the user's point of view, the result is the same. And by
doing the parsing only on the server side, we deal better with the case where
the sender has an older version of the software. By not doing verification, we
implicitly "support" new values. And when the sender has a newer version that
supports additional fields, that does not help as long as the server uses an
older version. So in case of version mismatches, parsing on the server side is
as good or better.

Resolves https://github.com/systemd/systemd/issues/37174.

4 months agoshared/bus-unit-util: tweak bus_append_exec_command to use Ex prop only if necessary
Zbigniew Jędrzejewski-Szmek [Fri, 4 Jul 2025 17:32:51 +0000 (19:32 +0200)] 
shared/bus-unit-util: tweak bus_append_exec_command to use Ex prop only if necessary

This changes little in behaviour, the conceptual part is more important. The
non-Ex variant is the actual name on the command line, and we should use the
non-Ex D-Bus property too, if it works. This increases compatibility with old
versions. But the code was mostly doing the right thing. Even the tests tested
the right thing.

Follow-up for b3d593673c5b8b0b7d781fd26ab2062ca6e7dbdb and
898fc00e794d714e2f01409bef440d910c22502a.

The test is simplified by taking advantage of the fact that both names
on the commandline are supposed to behave identically.

Partially resolves https://github.com/systemd/systemd/issues/37174.

4 months agoshared/bus-unit-util: rework error messages for NFTSet=
Zbigniew Jędrzejewski-Szmek [Sat, 5 Jul 2025 11:26:07 +0000 (13:26 +0200)] 
shared/bus-unit-util: rework error messages for NFTSet=

Let's be nice to the user and print the exact reason why we won't accept
a setting.

4 months agoshared/bus-unit-util: rework error messages
Zbigniew Jędrzejewski-Szmek [Fri, 4 Jul 2025 15:18:16 +0000 (17:18 +0200)] 
shared/bus-unit-util: rework error messages

We generally want to have error messages with a fixed structure that convey the
important information, i.e. field name, error value, and the offending text for
options that take short values. (The text is not printed for strings encoded with
base64 and hexmem or for credentials.)

Let's use a helper that prints the message in a fixed format in the majority of
cases. In the few places where a custom message is useful, the helper is not
used. The helper:
- prints the field name, value, and error info,
- quotes the value,
- handles -ENOMEM, so we don't need to handle it separately everywhere.

When this code was originally written, parse functions would return -1
as error. Nowadays day all return a good errno, so it is fine if we print
the corresponding strerror.

4 months agoshared/bus-unit-util: tweak error handling in bus_append_exec_command
Zbigniew Jędrzejewski-Szmek [Fri, 4 Jul 2025 12:06:52 +0000 (14:06 +0200)] 
shared/bus-unit-util: tweak error handling in bus_append_exec_command

exec_command_flags_to_strv() should not fail, unless we screwed up, so assert
instead of returning an error. Also, no need to strdup constant _PATH_BSHELL;
drop that so that we can get rid of the oom error handling. Finally, rename
l → cmdline for clarity.

4 months agobasic/include: replace _Static_assert() with static_assert()
Yu Watanabe [Sun, 6 Jul 2025 02:33:58 +0000 (11:33 +0900)] 
basic/include: replace _Static_assert() with static_assert()

If one of the header is included in a C++ source file, then using
_Static_assert() triggers compile error for some reasons.
Let's use static_assert(), which can be used by both C and C++ code.

4 months agoci: add test timeout multiplier for ppc64le
Luca Boccassi [Sun, 6 Jul 2025 10:02:20 +0000 (11:02 +0100)] 
ci: add test timeout multiplier for ppc64le

The slow tests have timed out at least a couple of times,
so add a multiplier

1252/1633 systemd:libsystemd / test-sd-device      TIMEOUT 30.04s killed by signal 15 SIGTERM
1633/1633 systemd:libsystemd / test-journal-verify TIMEOUT 90.01s killed by signal 15 SIGTERM

Follow-up for 8a1d1341444aaf143108e0ca85741c779014d8b2

4 months agocore: rename ExecContext.ioprio_set -> .ioprio_is_set
Yu Watanabe [Sun, 6 Jul 2025 01:43:18 +0000 (10:43 +0900)] 
core: rename ExecContext.ioprio_set -> .ioprio_is_set

To make it not conflict with syscall ioprio_set().
This is important as we have
```
 #define ioprio_set missing_ioprio_set
```
in missing_syscall.h.

4 months agoanalyze: include unistd.h
Yu Watanabe [Sun, 6 Jul 2025 06:22:43 +0000 (15:22 +0900)] 
analyze: include unistd.h

The source file uses symbols e.g. execl(), execvp(), _exit(), and so on,
without including unistd.h.

Continuation of 4f18ff2e29b8054f30b084abcabf5f689f4b340b.

Follow-up for 9a08000d186396bc8bcb8fe057720417543c3bf0.

4 months agonamespace-util,nsresource: explicitly include sched.h
Yu Watanabe [Wed, 25 Jun 2025 16:03:26 +0000 (01:03 +0900)] 
namespace-util,nsresource: explicitly include sched.h

These source files uses symbols provided by sched.h, e.g.
setns(), unshare(), CLONE_NEWNS, and friends, but they do not explicitly
include sched.h. Currently, it is included indirectly via missing_syscall.h,
which is included by e.g. pidfd-util.h.
Let's explicitly include headers that provides symbols used in the code.

This is similar to 4f18ff2e29b8054f30b084abcabf5f689f4b340b, but for sched.h.

4 months agotree-wide: several cleanups for reading/writing /proc/sys/fs/nr_open
Yu Watanabe [Sat, 5 Jul 2025 07:42:41 +0000 (16:42 +0900)] 
tree-wide: several cleanups for reading/writing /proc/sys/fs/nr_open

- use unsigned for the return value of read_nr_open(), as it does not
  fail, and the kernel internally uses unsigned for the value,
- when bumping the value by PID1, let's start from the kernel's maximum
  value defined in fs/file.c. The maximum value should be mostly an API
  of the kernel, but may changed in a future, hence still try several
  times if we fail to bump the value.

Co-authored-by: Jared Baur <jaredbaur@fastmail.com>
Co-authored-by: John Rinehart <johnrichardrinehart@gmail.com>
4 months agoukify: fix parsing uname version with '+'
Luca Boccassi [Sat, 5 Jul 2025 20:10:01 +0000 (21:10 +0100)] 
ukify: fix parsing uname version with '+'

Debian started using '+' in the kernel uname version, which fails the
regex in ukify. Fix it.

4 months agocgroup-util: clean up skip_{slices,session,user_manager} (#38089)
Yu Watanabe [Sun, 6 Jul 2025 07:37:28 +0000 (16:37 +0900)] 
cgroup-util: clean up skip_{slices,session,user_manager} (#38089)

4 months agohwdb: fix typo in 70-maker-tools.hwdb, and add the file to meson.build (#38090)
Yu Watanabe [Sun, 6 Jul 2025 07:31:23 +0000 (16:31 +0900)] 
hwdb: fix typo in 70-maker-tools.hwdb, and add the file to meson.build (#38090)

4 months agomeson fixlets (#38086)
Yu Watanabe [Sun, 6 Jul 2025 07:27:31 +0000 (16:27 +0900)] 
meson fixlets (#38086)

Some fixes for issues found while doing a minimal aarch64 cross build

4 months agohwdb: fix typo in 70-maker-tools.hwdb 38090/head
AsciiWolf [Sat, 5 Jul 2025 21:44:08 +0000 (23:44 +0200)] 
hwdb: fix typo in 70-maker-tools.hwdb

4 months agohwdb: add 70-maker-tools.hwdb to meson.build
AsciiWolf [Sat, 5 Jul 2025 21:32:09 +0000 (23:32 +0200)] 
hwdb: add 70-maker-tools.hwdb to meson.build

The hwdb file was not added there in 3dcb56f5e0fe4d937a003bf89496a27b52c5c69e for some reason

4 months agocore/cgroup: drop outdated comment 38089/head
Mike Yuan [Thu, 5 Jun 2025 00:14:15 +0000 (02:14 +0200)] 
core/cgroup: drop outdated comment

4 months agocgroup-util: clean up skip_{slices,session,user_manager}
Mike Yuan [Tue, 27 May 2025 16:32:44 +0000 (18:32 +0200)] 
cgroup-util: clean up skip_{slices,session,user_manager}

Let's avoid obscure memcmp()s in skip_* and instead use
strndupa() to extract the bits we care and call usual
string routines on it.

4 months agostring-table: drop unneeded initialization
Mike Yuan [Tue, 27 May 2025 14:55:43 +0000 (16:55 +0200)] 
string-table: drop unneeded initialization

4 months agomeson: call qemu with -machine virt on aarch64 38086/head
Luca Boccassi [Sat, 5 Jul 2025 19:21:51 +0000 (20:21 +0100)] 
meson: call qemu with -machine virt on aarch64

'qemu-system-aarch64 -device help' fails when no machine is specified.
Use the 'virt' type which seems to be what everyone uses for VMs.

4 months agomeson: do not reference variable unless feature that defines it is enabled
Luca Boccassi [Sat, 5 Jul 2025 19:21:00 +0000 (20:21 +0100)] 
meson: do not reference variable unless feature that defines it is enabled

SYSTEMD_LANGUAGE_FALLBACK_MAP is used by the localed test, and
language_fallback_map is defined by the localed meson.
If the feature is disabled, the test is not built so the env var
is not needed, and the meson variable is not defined so the build
fails.

4 months agoanalyze: fix typo
Yu Watanabe [Sat, 5 Jul 2025 16:42:24 +0000 (01:42 +0900)] 
analyze: fix typo

Follow-up for 9a08000d186396bc8bcb8fe057720417543c3bf0.

4 months agoman/analyze: fix typo
Yu Watanabe [Sat, 5 Jul 2025 16:41:44 +0000 (01:41 +0900)] 
man/analyze: fix typo

Follow-up for a839c4b7b7b5ddfd2187d1c3975ed6a203d37f90.

4 months agoTODO: fix typo
Yu Watanabe [Sat, 5 Jul 2025 16:41:14 +0000 (01:41 +0900)] 
TODO: fix typo

4 months agocore/socket: fix typo
Yu Watanabe [Sat, 5 Jul 2025 16:38:10 +0000 (01:38 +0900)] 
core/socket: fix typo

Follow-up for 1b4ab5a209c4874e01cf9577c740b82567458b09.

4 months agoask-password-api: Add more debug logging
DaanDeMeyer [Sat, 5 Jul 2025 09:19:59 +0000 (11:19 +0200)] 
ask-password-api: Add more debug logging

4 months agomkosi: enable arm64 job and test fixlets (#38066)
Luca Boccassi [Sat, 5 Jul 2025 10:46:30 +0000 (11:46 +0100)] 
mkosi: enable arm64 job and test fixlets (#38066)

Enable nspawn job, as there's no nested kvm so VMs are too slow. Fix
some tests that fail in a VM anyway, might add a nightly job later that
runs them.

4 months agochase: introduce openat_opath_with_automount() helper 38062/head
Mike Yuan [Thu, 3 Jul 2025 20:40:15 +0000 (22:40 +0200)] 
chase: introduce openat_opath_with_automount() helper

Follow-up for c5de7b14ae2e08d267d8d75bc88934ac6aa7dcd6

chase() is arguably a hot path in our code, hence it deserves
some caching whether open_tree() is available. Moreover,
the manual set of r to -EPERM feels kinda ugly. Let's
instead extract this bit into its own function.