Commit Graph

7309 Commits

Author SHA1 Message Date
Yu Watanabe
2d6dd692be cgroup-util: drop cgroup v1 support in cg_get_path()
We have dropped cgroup v1 support in v258. Let's assume we are running
on cgroup v2 and drop unused legacy code.
2025-11-17 21:30:29 +09:00
Yu Watanabe
f5a48af34b cgroup-util: use cg_is_available() in cg_kill_supported() 2025-11-17 21:30:29 +09:00
Yu Watanabe
57c16d344b cgroup-util: drop cgroup v1 support from cg_mask_supported_subtree()
We have dropped cgroup v1 support in v258. Let's drop unused legacy code.
2025-11-17 21:30:29 +09:00
Yu Watanabe
0ab90015e0 tree-wide: replace cg_get_path_and_check() with cg_get_path()
We have dropped cgroup v1 support in v258. When running on cgroup v2,
cg_get_path_and_check() with SYSTEMD_CGROUP_CONTROLLER as controller is
equivalent with checking if we are running on cgroup v2 and then
cg_get_path(). As we can assume we are running on cgroup v2, then the
check is not necessary anymore, thus we can replace
cg_get_path_and_check() with cg_get_path().
2025-11-17 21:30:29 +09:00
Yu Watanabe
b525a72f7b cgroup-util: drop cgroup v1 support from cg_pid_get_path()
We have dropped cgroup v1 support in v258. Let's drop legacy code.
Then, we can drop 'controller' argument from cg_pid_get_path() and
cg_pidref_get_path().
2025-11-17 21:30:29 +09:00
Yu Watanabe
6475926a59 cgroup-util: drop 'controller' argument from cg_path_open()
Nowadays it always takes SYSTEMD_CGROUP_CONTROLLER as controller.
Let's drop it.

No functional change, just refactoring.
2025-11-17 21:30:29 +09:00
Yu Watanabe
4dbf06bd85 cgroup-util: drop 'controller' argument from cg_set_attribute(), cg_get_attribute() and friends
Non-null controller arguments are always ignored when running on cgroup v2.
Let's drop the argument.

No functional change, just refactoring.
2025-11-17 21:30:29 +09:00
Yu Watanabe
4d1badbbc4 cgroup-util: drop 'controller' argument from cg_enumerate_subgroups()
Nowadays it always takes SYSTEMD_CGROUP_CONTROLLER as controller.
Let's drop it.

No functional change, just refactoring.
2025-11-17 21:30:29 +09:00
Yu Watanabe
f8de2107a7 cgroup-util: drop 'controller' argument from cg_enumerate_processes()
Nowadays it always takes SYSTEMD_CGROUP_CONTROLLER as controller.
Let's drop it.

No functional change, just refactoring.
2025-11-17 21:30:29 +09:00
Yu Watanabe
4365351b93 cgroup-util: introduce cg_is_available() and check it in tests
Now most of our code does not support cgroup v1. Let's skip test cases
if we are running on cgroup v1.
2025-11-17 21:29:51 +09:00
Yu Watanabe
07e437f569 musl: glob-util: filter out . and .. even if GLOB_ALTDIRFUNC is not supported
musl neither support GLOB_ALTDIRFUNC nor GLOB_BRACE.
Let's make safe_glob() work even when GLOB_ALTDIRFUNC is not supported.
Currently, GLOB_BRACE is simply ignored when it is not supported.
2025-11-17 12:19:22 +09:00
Yu Watanabe
e7254f9f4e efivars: fix typo
Follow-up for ab69a04600.
2025-11-16 11:12:10 +09:00
Yu Watanabe
6412e540bc path-util: add generic ignore extension to the hidden files (#39554) 2025-11-15 10:05:38 +09:00
Mike Yuan
0cb7dd5b96 fd-util: do not block O_TMPFILE with -EISDIR
Follow-up for 7cf4f07567
2025-11-14 21:51:28 +01:00
Mike Yuan
87ed096657 fs-util: simplify open_parent_at() a bit
Let's refrain from specifying any access mode when opening
a directory, which matches our usual style and allows us
to drop one condition.
2025-11-14 21:51:28 +01:00
Daan De Meyer
bc8aebdce9 log-context: Don't add log context if value is NULL
This avoids if conditions at the callsite which mess up stack based
lifetimes.
2025-11-14 11:38:59 +01:00
Daan De Meyer
5cf894ad58 basic-forward: Add WaitFlags forward decl 2025-11-14 11:38:59 +01:00
Mike Yuan
b0e7c6141f efivars: insert a newline below fstat() call 2025-11-13 21:17:32 +01:00
Yu Watanabe
1abe8dd9eb efivarfs readv() size fixes and more (#39715)
Fixes: #39695
2025-11-14 00:38:29 +09:00
Yu Watanabe
32d1bed50b tree-wide: assorted fixes/workarounds for supporting musl (#39687) 2025-11-14 00:16:50 +09:00
Lennart Poettering
dbc25d84ae efivars: seek back to beginning in each efi_get_variable() loop
We try to read again from the beginning, hence let's seek back.
Apparently efivarfs doesn't strictly require this, but it's really weird
that it doesn't.
2025-11-13 14:19:29 +01:00
Lennart Poettering
40cb2aa4f8 efivars: validate we are actually talking about a regular file
We already have the stat data, let's actually check if things are
alright before relying on .st_size
2025-11-13 14:19:29 +01:00
Lennart Poettering
ab69a04600 efivars: fix size checks in efi_get_variable()
writev() returns the full size, not just the payload size, hence always
add sizeof(attr) where necessary.

Let's also change a couple of "4" into sizeof(attr) all over the place,
to make clear what they are about.

Fixes: #39695
Follow-up for: 9db9d6806e
2025-11-13 14:19:29 +01:00
Lennart Poettering
88e26303ce efivars: don't bother with realloc() if we have no interest in the old data
We shouldn't ask glibc to keep the old data around (which realloc() is
about), given we overwrite it entirely anyway. Let's hence speed things
up here, and allow glibc to just allocate a new block for us (and
shorten the code a bit)
2025-11-13 12:37:08 +01:00
Mike Yuan
6dd412bc50 time-util: do not carry musl-specific fallback logic on glibc systems
Follow-up for 3ac4d68498

We have no sensible way to detect why strptime() fails, hence
the fallback path as it is now would fire on glibc systems too,
pointlessly. Let's guard it behind ifdeffery.
2025-11-13 09:40:20 +01:00
Yu Watanabe
4a028994df user-util: fix typo
Follow-up for b10fd796f5.
2025-11-13 15:36:47 +09:00
Yu Watanabe
a580dd4e53 musl: format-util: use %llu for formatting rlim_t
glibc uses uint32_t or uint64_t for rlim_t, while musl uses unsigned long long.
2025-11-13 08:02:05 +09:00
Yu Watanabe
4b774c740b musl: build-path: fix reading DT_RUNPATH or DT_RPATH
musl records DT_STRTAB as offset, rather than address. So, need to add
obtained bias to read runpath or rpath.
2025-11-13 08:02:05 +09:00
Yu Watanabe
5bb9063505 musl: hostname-util: introduce LINUX_HOST_NAME_MAX
glibc defines HOST_NAME_MAX as 64 and our code rely on that, but musl
defines the constant as 255. Let's provide our own definition for the
maximum length.
2025-11-13 08:02:05 +09:00
Yu Watanabe
43e4c91fc0 musl: avoid conflict between fcntl.h and basic-forward.h
glibc defines AT_FDCWD as -100, but musl defines it as (-100).
In basic-forward.h, we also define AT_FDCWD as -100, hence musl's fcntl.h
conflicts with forward.h. This is for avoiding the conflict.
2025-11-12 23:28:01 +01:00
Yu Watanabe
fe6e6cb6a0 time-util: several fixlets/workarounds for supporting musl (#39688) 2025-11-13 05:18:25 +09:00
Yu Watanabe
8d5b306bb9 musl: time-util: skip tm.tm_wday check
musl does not set tm_wday when it is explicitly requested.
The check is not necessary at all, it is just for safety.
Let's skip it when built with musl.
2025-11-13 03:13:59 +09:00
Yu Watanabe
6431f2e072 musl: time-util: introduce get_tzname() helper function
musl leaves the DST timezone name unset if there is no DST.
The helper function maps that back to no DST.
2025-11-13 03:13:55 +09:00
Yu Watanabe
3ac4d68498 musl: time-util: make parse_gmtoff() accept extended timezone offset format
musl v1.2.5 does not support %z specifier in strptime(). Since
fced99e93d
%z is supported, but it only supports strict RFC-822/ISO 8601 format,
that is, 4 digits with sign (e.g. +0900 or -1400), but does not support
extended format: 2 digits or colon separated 4 digits (e.g. +09 or -14:00).
Let's add fallback logic to make it support the extended timezone spec.
2025-11-13 02:40:32 +09:00
Mike Yuan
7cf4f07567 fd-util: introduce fd_vet_accmode()
Inspired by #39674
2025-11-12 15:44:50 +01:00
Zbigniew Jędrzejewski-Szmek
3b3113b87c locale-util: two fixlets for supporting musl (#39689) 2025-11-12 10:38:29 +01:00
Yu Watanabe
9b55c4b859 tree-wide: drop redundant inclusion of linux/prctl.h
sys/prctl.h anyway includes linux/prctl.h and actually these .c files
includes sys/prctl.h. Hence, it is not necessary to explicitly include
linux/prctl.h.
2025-11-12 14:17:44 +08:00
Yu Watanabe
361beb82a5 musl: locale-util: explicitly check existence of locale file
musl's newlocale() always provides a locale object even the requested
locale does not exist. Let's explicitly check the existence of the
requested locale file.
2025-11-12 11:43:13 +09:00
Yu Watanabe
b2a2f670ae musl: locale-util: introduce musl specific locale enumerator
Both add_locales_from_archive() and add_locales_from_libdir() are glibc
specific, and the logic cannot be applied when built with musl.
2025-11-12 11:43:13 +09:00
Dimitri John Ledkov
31b4dea5f0 bootctl: calculate secureboot state taking MokSBStateRT into account (#39298)
shim is often used as part of the EFI boot chain with Linux kernels.

shim has an option to disable all verification of binaries it loads.
This can be performed by end-user using mokutil / mokmanager EFI app,
which set BootServices only variable MokSBState. shim honors that, and
mirrors it as readonly MokSBStateRT for the post-ExitBootService access.

Thus presense of MokSBStateRT is an indicator that shim was used during
boot chain.

Some OEM vendors are known to set MokSBState variable, without user
having done so.

When verification is disabled, one should assume secureboot is insecure,
because any EFI binary was allowed to run, including but not limited to
unsigned or revoked:
- grub
- systemd-boot
- UKI
- linux kernel

Linux kernel also has code to check this variable, and correctly report
that Secure Boot is disabled, see:
-
3a86608788/drivers/firmware/efi/libstub/secureboot.c (L57)

With this change bootctl output changes like this:
```diff
 System:
       Firmware: n/a (n/a)
  Firmware Arch: x64
-   Secure Boot: enabled (user)
+   Secure Boot: disabled (insecure)
   TPM2 Support: yes
   Measured UKI: no
   Boot into FW: supported
```

This implementation is trying to mimic mokutil behaviour like this one:
```
$ mokutil --sb-state
SecureBoot enabled
SecureBoot validation is disabled in shim
```

As well as the linux kernel behavior of:
```
$ journalctl -b | grep 'Secure boot disabled'
kernel: Secure boot disabled
```

Note that MokSBState is extended into PCR7 as well as also into PCR14.
For more details see https://github.com/rhboot/shim/blob/main/README.tpm
2025-11-12 08:47:44 +09:00
Mike Yuan
686117e5b0 process-util: prefix FORK_PID_ONLY with _ to signify it is internal 2025-11-10 02:44:57 +01:00
Yu Watanabe
88f6611260 tar-util: make sure we can unpack hardlinked symlinks (#39619) 2025-11-08 00:08:44 +09:00
Lennart Poettering
0ab316ff14 chase: fix typo in log message
(While we are at it, add quotes around user provided strings)
2025-11-07 14:04:19 +01:00
Zbigniew Jędrzejewski-Szmek
492ae9ec4e ssh-generator: filter out bogus vsock addresses
When VirtIO VSOCK device is not present, IOCTL_VM_SOCKETS_GET_LOCAL_CID
returns VMADDR_CID_LOCAL/1, and we issue a hint to connect to vsock%1.
This does not work. Filter out VMADDR_CID_LOCAL and VMADDR_CID_HOST,
those are not real addresses that can be used from the outside.
2025-11-06 10:32:12 +01:00
Zbigniew Jędrzejewski-Szmek
3bfdc950f7 basic/vsock: report result of IOCTL_VM_SOCKETS_GET_LOCAL_CID 2025-11-05 18:33:44 +01:00
Yu Watanabe
71d64f0527 core/service: reload fixlets (#39376)
Fixes https://github.com/systemd/systemd/issues/37515
2025-11-05 02:54:38 +09:00
Christoph Anton Mitterer
843262fa5f path-util: add generic ignore extension to the hidden/backup files
All currently ignored extensions either “belong” to some other program (and may
thus be used, changed or interpreted by that) or imply a certain meaning (like
`bak`, `old` and `new`).

This adds the more generic extension `ignore` which is meant to imply no purpose
whatsoever.

A use case would be the following scenario:

One might want to share a drop-in configuration over multiple units like in:
`/etc/systemd/system/a.service/foo.conf` and
`/etc/systemd/system/b.service/foo.conf`, which then would be symbolic links to
the actual file.

Of course one could place that actual file in a directory that is not parsed by
systemd, but it is unit-configuration after all, so it would be nice to have it
somewhere beneath `/etc/systemd/system` (or other parsed directories).

However, placing it there needs a way to ensure that it’s never accidentally
used by systemd, which this extension is meant for.
2025-11-04 15:45:45 +01:00
Mike Yuan
b03e1b09af core/service: rework ExecReload= + Type=notify-reload interaction, add ExecReloadPost=
When Type=notify-reload got introduced, it wasn't intended to be
mutually exclusive with ExecReload=. However, currently ExecReload=
is immediately forked off after the service main process is signaled,
leaving states in between essentially undefined. Given so broken
it is I doubt any sane user is using this setup, hence I took a stab
to rework everything:

1.  Extensions are refreshed (unchanged)
2.  ExecReload= is forked off without signaling the process
3a. If RELOADING=1 is sent during the ExecReload= invocation,
    we'd refrain from signaling the process again, instead
    just transition to SERVICE_RELOAD_NOTIFY directly and
    wait for READY=1
3b. If not, signal the process after ExecReload= finishes
    (from now on the same as Type=notify-reload w/o ExecReload=)
4.  To accomodate the use case of performing post-reload tasks,
    ExecReloadPost= is introduced which executes after READY=1

The new model greatly simplifies things, as no control processes
will be around in SERVICE_RELOAD_SIGNAL and SERVICE_RELOAD_NOTIFY
states.

See also: https://github.com/systemd/systemd/issues/37515#issuecomment-2891229652
2025-11-04 12:18:33 +01:00
Mike Yuan
eaebc33220 fileio: mask off O_NOFOLLOW in xfopenat_regular() for fd_reopen()
in a similar fashion as xopenat_full()
2025-11-03 22:32:25 +01:00
Lennart Poettering
d2d1fc59b4 conf-files: optionally truncate suffix from discovered files 2025-11-02 21:14:35 +01:00