Commit Graph
52792 Commits
Author SHA1 Message Date
Lennart Poettering 09fbff57fc pid1: add GracefulOptions= setting to .mount units
This new setting can be used to specify mount options that shall only be
added to the mount option string if the kernel supports them.

This shall be used for adding "usrquota" to tmp.mount without breaking compat,
but is generally be useful.
2025-01-15 21:05:06 +01:00
Lennart Poettering f8214e2cca pam-systemd: introduce "user-light" session type, and make "background-light" the default for system users (#35987)
This implements one idea from #34988: default to "user-light" and
"background-light" for system users, so that the service manager is only
pulled in for sessions that likely need them, i.e. not cron jobs or ftp
logins.

This is a compat break to some degree, but I think a worthy one. I
updated the NEWS file to explain this.
2025-01-15 20:55:01 +01:00
Yu Watanabe e722fe74ca random-util: fix compilation error
Fixes the following error:
```
../src/basic/random-util.c: In function "fallback_random_bytes":
../src/basic/random-util.c:45:26: error: initializer-string for array of "char" is too long [-Werror=unterminated-string-initialization]
   45 |                 .label = "systemd fallback random bytes v1",
      |                          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
```
2025-01-15 20:24:30 +01:00
Lennart Poettering cc7300fc58 userdb: optionally parse numeric UIDs/GIDs where a username is expected
Let's move this logic from userdbctl into generic code so that we can
use it elsewhere.
2025-01-16 03:34:37 +09:00
Yu Watanabe b8980528c0 analyze: fix assignment of object_field
Prompted by #36000.
2025-01-16 03:34:11 +09:00
jane400 9e47199028 curl-util: use curl_getdate instead of implementing http spec
Available since curl 7.1, which is less than the version required in
meson.build

https://curl.se/libcurl/c/curl_getdate.html
2025-01-16 03:33:45 +09:00
Lennart Poettering 07b3556510 logind: improve log message we generate when a user logs in
Mention the session type and class both in the human readable string and
in the structured log.
2025-01-15 17:03:21 +01:00
Lennart Poettering ef5f72437e run0: allow explicit control of service manager activation for run0 sessions
This adds a new --lightweight=yes/no switch which allows controlling
whether the invoked service will have the service manager around or not.

Moreover, this changes that if the target user is root it will now
support to the lightweight mode, i.e. run0 towards root will no longer
pull in the service manager (a real tty login via getty still will
though!).

My thinking here is that quickly raising privileges via run0 probably
shouldn't be considered a proper login but just something short lived,
temporary for a single command or similar.
2025-01-15 17:03:21 +01:00
Lennart Poettering db320d97ca run: fire sd_notify("READY=1") when in service mode and the unit is properly started
Let's make sure systemd-run itself works nicely as a service that tells
the caller when it is ready.

Note that we don't fire the same message in scope mode, since in that
case want to leave sd_notify() handling to the invoked process.
2025-01-15 17:03:21 +01:00
Lennart Poettering cf8f6cd057 logind: introduce "user-light" session class
This new session class is to "user" what "background" is to
"background-light": it doesn't cause the per-user service manager to
start.

This new session class is now the default if no session class was
provided at session registration time and the following conditions hold:

1. The session is not graphical
2. The user is not a regular user (but not root)

Or in other words root and system users won't get a service manager
started automatically if they go through a PAM session as part of things
like cron or ftp. They will however still get one if they log in
graphically.

This changes behaviour a bit, but hopefully in OK was.

This also makes "background-light" for system users incl. root.

This addresses one of the ideas discussed in #34988.
2025-01-15 17:03:21 +01:00
Lennart Poettering a6ad410ffa logind: introduce macro for the last session class condition check
For all checks regarding the properties of sessoin classes we have
SESSION_CLASS_CAN_XYZ() style macros. Except for one. Convert that one
too.
2025-01-15 17:03:21 +01:00
Lennart Poettering 29f2057a20 pam-systemd: downgrade log message we handle gracefully to LOG_WARNING as per coding style 2025-01-15 17:03:21 +01:00
Lennart Poettering d2c7f8242b logind: register PAM sessions via Varlink instead of D-Bus (#35264)
This makes things a bit faster (because it cuts down a bit on
roundtrips) and prepares ground so that one day we can let logind run in
earlier boot already, making it a bit less special.

communication between logind and pid1 is still dbus only, hence there's
a lot of room for further improvement I guess.
2025-01-15 16:53:43 +01:00
wrvsrx 6013dee98d efivars: deal with uncommitted efi variables
Unfortunately kernel reports EOF if there's an inconsistency between efivarfs var list
and what's actually stored in firmware, c.f. #34304. A zero size env var is not allowed in
efi and hence the variable doesn't really exist in the backing store as long as it is zero
sized, and the kernel calls this "uncommitted". Hence we translate EOF back to ENOENT here,
as with kernel behavior before
https://github.com/torvalds/linux/commit/3fab70c165795431f00ddf9be8b84ddd07bd1f8f

If the kernel changes behaviour (to flush dentries on resume), we can drop
this at some point in the future. But note that the commit is 11
years old at this point so we'll need to deal with the current behaviour for
a long time.

Fix #34304.
2025-01-15 16:53:21 +01:00
Lennart Poettering fc6192f52b machine: introduce io.systemd.MachineImage.SetPoolLimit (#35953)
This PR introduces io.systemd.MachineImage.SetPoolLimit method which is
alternative to DBus's SetPoolLimit.

This is last function for org.freedesktop.machine1 Dbus interface
2025-01-15 16:52:24 +01:00
Lennart Poettering 76d2b8e281 nspawn: trivial scope reduction 2025-01-15 15:35:57 +00:00
Yu Watanabe 346ed75198 ptyfwd: fix wrong userdata passed to PTY forwarding
Fixes #35942.
2025-01-15 16:25:32 +01:00
Lennart Poettering b5a6f4c05b string-util: make strjoin() just a special case of strextend() (#36011)
This is split out of #36010, but makes a ton of sense on its own.
2025-01-15 13:25:08 +01:00
Lennart Poettering 3bcb650431 user-record-show: use word 'show' not 'dump' for helper call
The key functions and the file itself use the word "to show" here, this
helper should really stick to that nomenclature.
2025-01-15 13:24:17 +01:00
Lennart Poettering 7adafb0832 missing: add quotactl_fd() wrapper 2025-01-15 13:24:04 +01:00
Lennart Poettering f91f1eda08 bus-wait-for-jobs: fix table of service result codes (#35992) 2025-01-15 12:50:32 +01:00
Lennart Poettering 4582f8d7a5 pam-systemd: talk to logind via varlink
This makes sure we now use Varlink per default as transport for
allocating sessions.

This reduces the time it takes to do one run0 cycle by roughly ~10% on my
completely synthetic test setup (assuming the target user's service
manager is already started)

The D-Bus codepaths are kept in place for two reasons:
* To make upgrades easy
* If the user actually sets resource properties on the PAM session we
  fall back to the D-Bus codepaths, as we currently have no way to
  encode the scope properties in JSON, this is only supported for D-Bus
  serialization.

The latter should be revisited once it is possible to allocate a scope
unit from PID1 via varlink.
2025-01-15 11:58:49 +01:00
Lennart Poettering 2baca6c22b logind: add basic Varlink API
For now this only covers CreateSession() and ReleaseSession(), i.e. the
two operations pam_systemd cares about.
2025-01-15 11:56:47 +01:00
Ivan Kruglov 8342390161 machine: introduce io.systemd.MachineImage.SetPoolLimit 2025-01-15 02:47:58 -08:00
Ivan Kruglov efe47f5895 machine: use image_set_pool_limit() in dbus 2025-01-15 02:47:58 -08:00
Ivan Kruglov 42f2740aff shared: image_set_pool_limit() 2025-01-15 02:47:58 -08:00
Lennart Poettering fd3b7cf772 string-util: add a mechanism for strextend_with_separator() for specifying "ignore" arguments
in strv_new() we have STRV_IGNORE for skipping over an argument in the
argument list. Let's add the same to strextend_with_separator():

strextend_with_separator(&x, "foo", POINTER_MAX, "bar");

will result in "foobar" being appended to "x". (POINTER_MAX Which is
different from NULL, which terminates the argument list).

This is useful for ternary op situations.

(We should probably get rid of STRV_IGNORE and just use POINTER_MAX
everywhere directly, but that's for another time.)
2025-01-15 10:52:38 +01:00
Lennart Poettering 34467ffa3c string-util: make strjoin() just a special case of strextend()
The functions are very similar, let's make them the same. If the first
argument to strextend() is NULL instead of extending a string we'll
allocate a fresh one and return that.
2025-01-15 10:51:53 +01:00
Daan De Meyer 9a0776159b udev: several trivial fixlets (#36005)
split out of #35968.
2025-01-15 10:50:11 +01:00
Luca Boccassi af0a28854d meson: add udev/hwdb build aliases
Allows to do:

meson compile libudev udev hwdb
meson install --no-rebuild --tags libudev,udev,hwdb
2025-01-15 09:48:27 +00:00
Lennart Poettering a7620f5dd1 bus-wait-for-jobs: fix service result table
We were missing one service result (oom-kill), and the ratelimit one is
called differently. Correct that so that we generate proper log messages
for these cases.
2025-01-15 10:41:11 +01:00
Lennart Poettering 1d522f1a86 terminal-util: drop support for pre-TIOCGPTPEER kernels
Our minimum baseline is now far beyond 4.13, hence let's drop these
fallback paths.
2025-01-15 10:39:04 +01:00
Zbigniew Jędrzejewski-Szmek 69c9629da7 sysusers: emit audit events for user and group creation (#35957)
Background: Fedora/RHEL are switching to sysusers.d metadata for
creation of users and groups for system users defined by packages
(https://fedoraproject.org/wiki/Changes/RPMSuportForSystemdSysusers).
Packages carry sysusers files. During package installation, rpm calls an
program to execute on this config. This program may either be
/usr/lib/rpm/sysusers.sh which calls useradd/groupadd, or
/usr/bin/systemd-sysusers. To match the functionality provided by
useradd/groupadd from the shadow-utils project, systemd-sysusers must
emit audit events so that it provides a drop-in replacement.

systemd-sysuers will emit audit events AUDIT_ADD_USER/AUDIT_ADD_GROUP
when adding users and groups. The operation "names" are copied from
shadow-utils, so the format of the events that is generated on success
should be identical. On failure, things are more complicated. We write
the whole file at once, once, so we first generate "success" messages
for each entry, then we try to write the files, and if things fail, we
generate failure messages to all entries that we failed to write.
2025-01-15 10:36:07 +01:00
Zbigniew Jędrzejewski-Szmek 0dba7b5c6b core: use shared audit-fd wrappers
Two funcs are renamed to avoid naming conflict with the common
helper.
2025-01-15 10:35:28 +01:00
Zbigniew Jędrzejewski-Szmek 9c6afab6b6 sysusers: emit audit events for user and group creation
Background: Fedora/RHEL are switching to sysusers.d metadata for creation of
users and groups for system users defined by packages
(https://fedoraproject.org/wiki/Changes/RPMSuportForSystemdSysusers).
Packages carry sysusers files. During package installation, rpm calls an
program to execute on this config. This program may either be
/usr/lib/rpm/sysusers.sh which calls useradd/groupadd, or
/usr/bin/systemd-sysusers. To match the functionality provided by
useradd/groupadd from the shadow-utils project, systemd-sysusers must emit
audit events so that it provides a drop-in replacement.

systemd-sysuers will emit audit events AUDIT_ADD_USER/AUDIT_ADD_GROUP when
adding users and groups. The operation "names" are copied from shadow-utils in
Fedora (which has a patch to change them from the upstream version), so the
format of the events that is generated on success should be identical.

The helper code is shared between sysusers and utmp-wtmp. I changed the
audit_fd variable to be unconditional. This way we can avoid ugly iffdefery
every time the variable would be used. The cost is that 4 bytes of unused
storage might be present. This is negligible, and the compiler might even be
able to optimize that away if it inlines things.
2025-01-15 10:35:28 +01:00
Yu Watanabe 132a164d97 Follow-ups for recent namespace PRs (#35923) 2025-01-15 14:10:21 +09:00
Jeremy Linton 2572bf6a39 confidential-virt: add detection for aarch64 CCA
The arm confidential compute architecture (CCA) provides a platform design for
confidential VMs running in a new realm context.

This can be detected by the existence of a platform device exported for the
arm-cca-guest driver, which provides attestation services via the realm
services interface (RSI) to the Realm Management Monitor (RMM).

Like the other methods systemd uses to detect Confidential VM's, checking
the sysfs entry suggests that this is a confidential VM and should only be
used for informative purposes, or to trigger further attestation.

Like the s390 detection logic, the sysfs path being checked is not labeled
as ABI, and may change in the future. It was chosen because its
directly tied to the kernel's detection of the realm service interface rather
to the Trusted Security Module (TSM) which is what is being triggered by the
device entry. The TSM module has a provider string of 'arm-cca-guest' which
could also be used, but that (IMHO) doesn't currently provide any additional
benefit except that it can fail of the module isn't loaded.

More information can be found here:
https://developer.arm.com/documentation/den0125/0300

Signed-off-by: Jeremy Linton <jeremy.linton@arm.com>
2025-01-15 13:51:12 +09:00
Yu Watanabe 0363a45898 udev-rules: do not change maximum log level when running in test mode
When udev rules are being tested, log level specified by SYSTEMD_LOG_LEVEL=
environment variable should be honored, and should not be overridden by
the rules.
2025-01-15 11:50:22 +09:00
Yu Watanabe a75aeca78c udev-rules: replace 'type *func()' -> 'type* func()' 2025-01-15 11:48:11 +09:00
Yu Watanabe 22ca9406c4 udevadm-test: add missing oom check 2025-01-15 11:48:11 +09:00
Sea-Eun Lee 015a3b8cb1 oomd: support reloading configuration at runtime 2025-01-14 14:42:23 +01:00
Lennart Poettering 857ddc2e55 core: serialize API bus id and validate before deserializing bus tracks, plus several other bus util cleanups (#35970)
Follow-up for #35406
2025-01-14 14:39:58 +01:00
Lennart Poettering 4ba24c46b3 sysusers: some tweaks, mostly around chase() use (#35976) 2025-01-14 14:38:32 +01:00
Daan De Meyer 6309efbf31 dissect: Use COPY_MERGE
When copying a directory from or to an image, let's always merge
with existing directories instead of failing with "File Exists".

Fixes https://github.com/systemd/mkosi/issues/3342.
2025-01-14 11:13:25 +01:00
Lennart Poettering 5e35b6a5f7 lsm: improve logging about absence of lsm-bpf
In containers securityfs is typically not mounted. Our lsm-bpf code
so far detected this situation and claimed the kernel was lacking
lsm-bpf support. Which isn't quite true though, it might very well
support it. This made boots of systemd in systemd-nspawn a bit ugly,
because of the misleading log message at boot.

Let's improve things, and make clearer what is going on.
2025-01-14 09:53:56 +00:00
Mike Yuan 34f4b817f6 core/manager: restore bus track deserialization cleanup in manager_reload()
There's zero explanation why it got (spuriously) removed in
8402ca04d1a063c3d8a9e3d5c16df8bb8778ae98...
2025-01-13 23:08:35 +01:00
Aman Verma 9b10bc107f update-done: remove spurious trailing whitespace from MESSAGE. 2025-01-13 22:54:42 +01:00
Mike Yuan 1446e3c392 core: serialize API bus id and validate before deserializing bus tracks 2025-01-13 21:52:19 +01:00
Mike Yuan a9a8d2e12f bus-util: introduce bus_get_instance_id() 2025-01-13 21:52:19 +01:00
Mike Yuan af0e10354e core/manager: drop duplicate bus track deserialization
bus_init_api() now does this internally
(after 8402ca04d1).
2025-01-13 21:52:19 +01:00