Commit Graph
83733 Commits
Author SHA1 Message Date
Lennart Poettering 722d3f712a audit: shortcut some audit syscalls if we are compiled without audit support anyway 2025-09-19 16:30:13 +02:00
Lennart Poettering 4d8c5c657a build: make libaudit dep dlopen() 2025-09-19 16:30:13 +02:00
Daan De Meyer 93ed79c0b0 core: Expose oom kills and managed oom kills as properties (#38906)
It can be useful for users to know this information so let's expose it
as properties so it can be queried.
2025-09-19 16:19:19 +02:00
Daan De Meyer 8796164189 tree-wide: Remove unused includes (#39023) 2025-09-19 16:07:04 +02:00
Daan De Meyer 9adb4685df tree-wide: Remove unused includes 2025-09-19 14:46:55 +02:00
Daan De Meyer d4da97400c test: Add tests for systemd's kernel oom kill handling 2025-09-19 13:54:54 +02:00
Daan De Meyer 9cf6ad16dd core: Expose oom kills and managed oom kills as properties
It can be useful for users to know this information so let's expose
it as properties so it can be queried.
2025-09-19 13:54:54 +02:00
Daan De Meyer e03e5056db core: Use oom_group_kill attribute if OOMPolicy=kill
For managed oom kills, we check the user.oomd_ooms property which
reports how many times systemd-oomd recursively killed the entire
cgroup. For kernel OOM kills, we check the oom_kill property from
memory.events which reports how many processes were killed by the
kernel OOM killer in the corresponding cgroup and its child cgroups.
For units with Delegate=yes, this is problematic, becase OOM kills
in child cgroups that were handled by the delegated unit will still
be treated as unit OOM kills by systemd.

Specifically, if systemd is managing the delegated cgroup and
memory.oom.group=1 is set on both the service cgroup and the child
cgroup, if the child cgroup is OOM killed and this is handled by systemd
running inside the delegated units, when the unit exits later, it will
still be treated as oom-killed because oom_kill in memory.events will
contain the OOM kills that happened in the child cgroup.

To allow addressing this, the oom_group_kill property was added to the
memory.events and memory.events.local files which allows reading how many
times the entire cgroup was oom killed by the kernel if memory.oom.group=1.
If we read this from memory.events.local, we know how many times the unit's
entire cgroup (plus child cgroups) got oom killed by the kernel. This matches
what we report for systemd-oomd managed oom kills and avoids reporting the
unit as oom-killed if a child cgroup was oom killed by the kernel due to
having memory.oom.group=1 set on it.

Since this is only available from kernel 5.12 onwards, we fall back to
reading the oom_kill field from memory.events if the oom_group_kill property
is not available.
2025-09-19 13:54:54 +02:00
Daan De Meyer db35a83fe9 mkosi: Add stress-ng to sanitizer wrapper programs 2025-09-19 13:54:54 +02:00
Yu Watanabe e37e64e942 man/varlink: fix typo
Follow-up for 04e2cb8928.
2025-09-19 20:25:26 +09:00
Yu Watanabe cbdbf68a72 man/repart: fix typo
Follow-up for 49dcc89ddc.
2025-09-19 20:24:09 +09:00
Yu Watanabe 2672108a1e creds-util: fix typo
Follow-up for 9be0a94b98.
2025-09-19 20:23:05 +09:00
Yu Watanabe b0f6d31f6f varlink: flag -> flags
Follow-up for 86fd19af14.
2025-09-19 20:21:22 +09:00
Luca Boccassi 12ef7e0a2c docs: use '_' as separator for OSC page
Make it consistent with other pages

Fixes https://github.com/systemd/systemd/issues/39019
2025-09-19 20:11:46 +09:00
Mike Yuan 01184496a2 virt: revert to detect chroot by comparing with / rather than /proc/PID/root
This partially reverts d6267b9b18

So, arch-chroot currently uses a rather cursed setup:
it sets up a PID namespace, but mounts /proc/ from the outside
into the chroot tree, and then call chroot(2), essentially
making it somewhere between chroot(8) and a full-blown
container. Hence, the PID dirs in /proc/ reveal the outer world.
The offending commit switched chroot detection to compare
/proc/1/root and /proc/OUR_PID/root, exhibiting the faulty behavior
where the mentioned environment now gets deemed to be non-chroot.

Now, this is very much an issue in arch-chroot. However,
if /proc/ is to be properly associated with the pidns,
then we'd treat it as a container and no longer a chroot.
Also, the previous logic feels more readable and more
honestly reported errors in proc_mounted(). Hence I opted
for reverting the change here. Still note that the culprit
(once again :/) lies in the arch-chroot's pidns impl, not
systemd.

Fixes https://gitlab.archlinux.org/archlinux/packaging/packages/systemd/-/issues/54
2025-09-19 13:09:34 +02:00
Yu Watanabe c3c42b30dd firewall-util: remove iptables/libiptc backend support (#38976)
This removes iptables/libiptc backend support in firewall-util, as
already announced by 5c68c51045.
Then, this drops meaningless `FirewallContext` wrapper.
2025-09-19 19:54:17 +09:00
Daan De Meyer 3111327ca4 include: Add missing IWYU pragmas 2025-09-19 12:44:29 +02:00
Daan De Meyer 1403faeb15 tree-wide: Fix two curl warnings 2025-09-19 11:32:04 +02:00
Lennart Poettering bdd8728c91 various: port remaining users of setmntent() to libmount (#38929) 2025-09-19 09:26:06 +02:00
Yu Watanabe fbbbff01fb various tweaks for systemd-creds & related (#38979) 2025-09-19 16:21:12 +09:00
Yu Watanabe 542552612b chase: tweaks to chase_open()/chase_openat() (#38984) 2025-09-19 16:11:24 +09:00
Yu Watanabe 9a8f2b628d chattr-util/acl-util: add helpers that tells us if an inode type can do chattr/acl (#39003)
Split out of #38728 but I think this makes things more readable in
general and makes sense on its own.
2025-09-19 15:50:18 +09:00
Yu Watanabe 8835034df8 importd: some minor tweaks (#39008) 2025-09-19 15:48:14 +09:00
Lennart Poettering 625c2e10c6 importd: port to PidRef 2025-09-19 15:45:46 +09:00
Lennart Poettering 93dea63fab fileio: modernize xopendirat() a bit 2025-09-19 08:39:32 +02:00
ners 7b7f0983e0 localectl: use XKB path specified from environment variable 2025-09-19 15:37:52 +09:00
Yu Watanabe 56f003d164 firewall-util: rename firewall-util-nft.c to firewall-util.c 2025-09-19 15:33:17 +09:00
Yu Watanabe 7184f8366f firewall-util: drop FirewallContext
After iptables support is dropped, FirewallContext is a trivial
wrapper of sd_netlink. Let's drop it and directly use sd_netlink.
2025-09-19 15:33:17 +09:00
Yu Watanabe 9b75c41cb3 sd-netlink: make netlink_get_reply_callback_count() accept NULL 2025-09-19 15:33:17 +09:00
Yu Watanabe 114c4b95df firewall-util: remove iptables backend
As already announced by 5c68c51045,
let's remove iptables backend of firewall-util through libiptc.
2025-09-19 15:33:15 +09:00
Mike Yuan b6c8f0ec91 userdb: suppress creation of empty userdb dirs 2025-09-18 22:58:16 +02:00
Luca Boccassi defa0148b8 units: add missing Documentation=
The initrd units are described in the graphs in the bootup manpage,
so use that one for them.
2025-09-18 21:54:36 +01:00
Lennart Poettering 7d4b0df9f8 creds-util: don't reference superblocks when decrypting creds 2025-09-18 22:11:57 +02:00
Lennart Poettering 4be269563d core: if we cannot decode a TPM credential skip over it for ImportCredential=
let's skip over credentials we cannot decode when they are found with
ImportCredential=. When installing an OS on some disk and using that
disk on a different machine than assumed we'll otherwise end up with a
broken boot, because the credentials cannot be decoded when starting
systemd-firstboot. Let's handle this somewhat gracefully.

This leaves handling for LoadCredential=/SetCredential= as it is (i.e.
failure to decrypt results in service failure), because it is a lot more
explicit and focussed as opposed to ImportCredentials= which looks
everywhere, uses globs and so on and is hence very vague and unfocussed.

Fixes: #34740
2025-09-18 22:11:57 +02:00
Lennart Poettering ffd4b38096 creds: expose more errors as explicit varlink errors 2025-09-18 22:11:57 +02:00
Lennart Poettering 9be0a94b98 creds-util: tweak error code generation in decrypt_credential_and_warn() a bit, and add a comment listing it
Let's make some specific condition more recognizable via error codes of
their own, and in particular remove confusion between EREMOTE as
returned by tpm2_unseal() and by us.
2025-09-18 22:11:57 +02:00
Lennart Poettering bd610b2253 creds: modernize varlink server setup a bit
Let's make use of the userdata parameter of varlink_server_new(), and
split out the code into its own helper function.
2025-09-18 22:01:25 +02:00
Lennart Poettering c3b1aa6d73 acl-util: add new inode_type_can_acl() helper 2025-09-18 21:58:44 +02:00
Lennart Poettering 134749c1d0 chattr-util: add inode_type_can_chattr() helper 2025-09-18 21:58:00 +02:00
Lennart Poettering 74c10cfbeb sd-varlink: two small additions (#38994) 2025-09-18 21:34:09 +02:00
Lennart Poettering 86fd19af14 mountfsd: add recognizable error if we pass an fd with unexpected flags 2025-09-18 21:33:41 +02:00
Nick Rosbrook 9fe168a92c basic: validate timezones in get_timezones()
Depending on the packaging of tzdata, /usr/share/zoneinfo/tzdata.zi may
reference zones or links that are not actually present on the system.
E.g. on Debian and Ubuntu, there is a tzdata-legacy package that
contains "legacy" zones and links, but they are still referenced in
/usr/share/zoneinfo/tzdata.zi shipped by the main tzdata package.

Right now, get_timezoes() does not validate timezones when building the
list, which makes the following possible:

 $ timedatectl list-timezones | grep "US/Alaska"
 US/Alaska

 $ timedatectl set-timezone US/Alaska
 Failed to set time zone: Invalid or not installed time zone 'US/Alaska'

which feels buggy. Hence, simply validate timezones in get_timezones()
to avoid listing timezones that are not installed.
2025-09-18 21:33:24 +02:00
Lennart Poettering 818bd1dfa1 mountfsd: uncomment CapabilityBoundingSet= line
Since mountfsd was added in 702a52f4b5 the
caps bounding set line was commented. That's an accident. Fix that. (We
need to add a bunch of caps to the list).
2025-09-18 21:30:51 +02:00
Lennart Poettering 1c9500c2b7 units: explicitly reset TTY before running stuff on console
This adds TTYReset=yes to all units which run directly on the TTY. We
already had this in place for the gettys, but this adds it for the rest
that basically has StandardInput=tty + StandardOutput=tty set.

Originally, for these tools it wasn't necessary to reset the TTY,
because we after all already reset /dev/console very very early on once,
during PID1's early initialization, and hence there's no real reason to
do it again for these early boot services. But that's actually not
right, because since #36666 the TTY we reset from PID 1 is typically
/dev/console but the TTY those services are invoked on is typically the
resolved version of that, i.e. wherever that points. Now you might
think: if one is just an alias to the other, why does it matter to reset
this again? Well, because it's only a half-assed alias, and as it turns
out WIOCSWINSZ is not propagated from one to the other, i.e the terminal
dimesions we initialize for /dev/console don't propagate to whatever
that points to.

One option to address that would be to immediately propagate this down
ourselves (or to fix the kernel for it), but it felt safer to simply do
the reset again before the use, after all these one one-off services,
and there's no point in optimizing much here. Moreover, its probably
safer to give the guarantee that when the firstboot stuff (which after
all queries for pws to set) runs it definitely certainly guaranteed has
a properly reset terminal.
2025-09-18 21:30:31 +02:00
Mike Yuan 3b911434d6 TODO: drop completed entry 2025-09-18 20:25:15 +02:00
Mike Yuan 6b8dcb9853 codeql: taint setmntent() and getmntent() 2025-09-18 20:25:15 +02:00
Mike Yuan 873a70d28a mount-util: drop now unused _cleanup_endmntent_ 2025-09-18 20:25:15 +02:00
Mike Yuan 9d05015bb9 remount-fs: port to libmount parser 2025-09-18 20:25:15 +02:00
Mike Yuan 7ebb2b3349 remount-fs: minor coding style cleanups 2025-09-18 20:25:15 +02:00
Mike Yuan 69fa2b6303 cryptsetup: port from setmntent() to libmount parser 2025-09-18 20:25:14 +02:00