Commit Graph
10653 Commits
Author SHA1 Message Date
Luca Boccassi cd45d803c3 discover-image: restore compatibility with C9S and overlayfs directories
5817c73391 broke compatibility with
CentOS 9 and overlayfs directories, the following fails with -EOPTNOTSUPP:

mount -t overlay overlay -o lowerdir=/tmp/app1:/tmp/rootdir /tmp/overlay
portablectl attach --copy=symlink --now --runtime /tmp/overlay app1

name_to_handle_at() fails both with and without AT_HANDLE_MNT_ID_UNIQUE.

Restore the fallback to path_get_mnt_id_at() that was removed.
Fixes TEST-29-PORTABLE.directory

Follow-up for 5817c73391
2026-02-09 19:39:51 +00:00
Luca Boccassi e67b008fa3 journald: set a lower size limit for FDs from unpriv processes
Unprivileged processes can send 768M in a FD-based message to journald,
which will be malloc'ed in one go, likely causing memory issues.
Set the limit for unprivileged users to 24M.

Allow coredumps as an exception, since we always allowed storing
up to the 768M max core files in the journal.

Reported on yeswehack.com as #YWH-PGM9780-48
2026-02-09 13:51:59 +01:00
Mike Yuan b026cb94ae path-util: unify path_extract_filename/directory into path_split_prefix_filename() (#40608) 2026-02-09 11:03:14 +01:00
Daan De Meyer 7d4ea41bd1 bootctl parts of installer PR (#40447)
This contains the "bootctl install" related work from the #38764 split
out, but also includes the preparatory work already split out into
#40446.

I'll rebase this PR once the prep work is merged.

This has a simple CI test already, and has docs
2026-02-09 09:46:39 +01:00
Mike Yuan cc9a9d6a15 tree-wide: use path_split_prefix_filename() where appropriate 2026-02-09 09:07:15 +01:00
Mike Yuan 3788ec1b4a snapshot-util: include shared-forward.h 2026-02-09 09:05:44 +01:00
Matteo Croce c1bf450fa0 oomd: implement a prekill varlink event
When a cgroup is selected for termination, send varlink messages
to hooks registered in `/run/systemd/oomd.prekill-hooks/`.
oomd waits up to `PreKillHookTimeoutSec=` seconds for response
before proceeding with the kill.
2026-02-09 02:05:57 +01:00
Lennart Poettering 5276ef1548 udev: Introduce uaccess for remote graphical sessions (#38516)
When systemd is compiled with group-render-mode=0660, only the active
seat gets access to the render devices through uaccess. Remote desktop
sessions like gnome-remote-desktop would be left with no hardware
rendering, because those sessions are not associated with a seat.

We solve the issue by granting uaccess to specifically tagged devices on
session start, if the session is marked with
XDG_SESSION_EXTRA_DEVICE_ACCESS.

udev-builtin-uaccess is refactored to grant multiple users access to a
device, taking into account the device's seat and all the active
EXTRA_DEVICE_ACCESS sessions.
2026-02-08 21:41:21 +01:00
Yu Watanabe 1f3b407307 daemon-util: downgrade log level on ECONNREFUSED and friends
This partially reverts 36c557f7d4, which
introduced notify_remove_fd() that logs in LOG_DEBUG. However,
notify_remove_fd_warn() is still called other library functions, e.g.
notify_push_fd(), and produces warning message about the failure in
removing fd from fdstore on shutdown.

During shutdown process, we get the following logs:
```
systemd-udevd[370]: Failed to send notify message to '/run/systemd/notify': Connection refused
systemd-udevd[370]: Failed to remove file descriptor "config-serialization" from the store, ignoring: Connection refused
systemd-udevd[370]: Failed to send notify message to '/run/systemd/notify': Connection refused
systemd-udevd[370]: Failed to push serialization fd to service manager: Connection refused
```
Here, the 1st, 3rd, and 4th messages are in LOG_DEBUG, but the 2nd one
was in LOG_WARNING before this commit, and this makes it also in LOG_DEBUG.

Follow-up for 472404aca5.
2026-02-07 00:15:33 +01:00
Lennart Poettering a537c5e4b8 bootctl: add comments emphasizing that certain functions do not touch the file read pointer 2026-02-06 23:17:02 +01:00
Lennart Poettering 9b29d38c33 bootctl: return recognizable Varlink error when we cannot determine the boot entry token
When running "bootctl install" on an empty --root= dir, we don't know
which token to use, and the operation will fail. Make sure to return an
explicit error about this.

This introduces a recognizable low-level error for this (EUNATCH), and
then turns this into a recognizable Varlink error.

(I made sure that the old low-level error EINVAL wasn't load-bearing,
and it is safe to change this.)
2026-02-06 23:16:50 +01:00
Lennart Poettering aea76373b2 bootctl: add Install() varlink API
Fixes: #11221
2026-02-06 23:15:49 +01:00
Alessandro Astone 5a198ad6f8 udev: Grant sessions access to devices tagged with xaccess
Grant access to devices tagged with "xaccess" on session start, if the session
was created with XDG_SESSION_EXTRA_DEVICE_ACCESS=1.

udev-builtin-uaccess is refactored to grant multiple users access to a device,
taking into account the device's seat and all the active EXTRA_DEVICE_ACCESS
sessions.
2026-02-06 16:20:18 +01:00
Alessandro Astone 87840e144b login: Add XDG_SESSION_EXTRA_DEVICE_ACCESS variable for additional access
A session created with XDG_SESSION_EXTRA_DEVICE_ACCESS will be granted
additional powers.
Exactly which powers are granted is going to be defined by udevd.
2026-02-06 16:20:18 +01:00
Yu Watanabe 5f815d6fa1 metrics: fix typo
Follow-up for fd73cd6c91.
2026-02-06 15:20:28 +09:00
Lennart Poettering 823054d079 pcrextend: fix varlink API to match what we actually take
(Change test case slightly, to ensure we don't regress on this)
2026-02-06 15:08:51 +09:00
Mike Yuan 10072d8be4 various: use xstatx() 2026-02-05 14:14:40 +01:00
Mike Yuan 5817c73391 mountpoint-util: rework name_to_handle_at() unique mount id handling
name_to_handle_at_try_unique_mntid_fid() in its current form is
ill-designed for various reasons:

* AT_HANDLE_FID requires file system support, while unique mount id
  is a VFS concept hence is always available if supported. Hence
  the fallback for AT_HANDLE_MNT_ID_UNIQUE should be independent
  of fid.
* The request for AT_HANDLE_MNT_ID_UNIQUE can be identified via
  specifying ret_unique_mnt_id, no need for opening up the control
  to caller (and currently the function simply doesn't handle
  mismatch between ret params and flags).
* The caller cannot realistically differentiate whether the returned
  mount id is actually unique.
* The path_get_unique_mnt_id() fallback did not handle AT_SYMLINK_FOLLOW.

Let's instead move the statx() fallback into name_to_handle_at_loop()
directly, and revamp interaction of ret_mnt_id/ret_unique_mnt_id:
if both are set, it indicates that the caller can handle both, hence
set what we have and return 0/1 for whether we managed to acquire
the unique one.

The !ret_handle && ret_mnt_id logic is removed. Let's not rely on
undocumented bizaare behavior and it's unused anyways.
path_get_mnt_id_at() exists for a reason...
2026-02-05 14:14:40 +01:00
Mike Yuan 3065bc80cb shared/find-esp: STATX_MNT_ID is no longer needed as we rely on _ATTR_MOUNT_ROOT
Follow-up for a98a6eb95c
2026-02-05 14:14:39 +01:00
Mike Yuan 7dc7cc02fb portable-util: drop spurious -ENXIO check for xdg_user_config_dir()
Unlike $XDG_RUNTIME_DIR the user config dir has a default
value, hence -ENXIO is not really expected.
2026-02-05 14:14:38 +01:00
Zbigniew Jędrzejewski-Szmek e047394797 [metrics] Introduce metrics API (#39202)
See the [design
doc](https://github.com/systemd/systemd/issues/38023#issue-3192567450)
by @ikruglov

This PR introduces the metrics API framework, adds some basic system
wide/per unit/service metrics, and a basic CLI. The PR is broken into
two commits as described below.

### Deviations from the original design
- Introduced top level field "object" for ease of filtering. Instead of
having `fields: { unit: "foo", unit_type: "service" }`, we now have
`object: foo.service` as the top level field.


### First commit

The first commit includes:
- Metrics API definitions
- Code to set up the varlink server
- The describe method which shows all the metrics families
- The list method which lists all the metrics
- Type definitions related to MetricFamily
- Common code to build json objects

### Second commit
The second commit adds some basic metrics, a basic CLI (systemd-report)
which
lists the metrics, and integration tests.

**System wide metrics:**
- units_by_type_total
- units_by_state_total

**Two per unit metrics:**
- unit_active_state
- unit_load_state

**A service state metric:**
- nrestarts

### Sample outputs

**units_by_type_total**:

```
{
        "name" : "io.systemd.Manager.units_by_type_total",
        "value" : 52,
        "fields" : {
                "type" : "target"
        }
}
{
        "name" : "io.systemd.Manager.units_by_type_total",
        "value" : 82,
        "fields" : {
                "type" : "device"
        }
}
{
        "name" : "io.systemd.Manager.units_by_type_total",
        "value" : 2,
        "fields" : {
                "type" : "automount"
        }
}
```
**units_by_state_total**:
```
{
        "name" : "io.systemd.Manager.units_by_state_total",
        "value" : 216,
        "fields" : {
                "state" : "active"
        }
}
{
        "name" : "io.systemd.Manager.units_by_state_total",
        "value" : 0,
        "fields" : {
                "state" : "reloading"
        }
}
{
        "name" : "io.systemd.Manager.units_by_state_total",
        "value" : 120,
        "fields" : {
                "state" : "inactive"
        }
}
```
**unit_active_state**:
```
{
        "name" : "io.systemd.Manager.unit_active_state",
        "object" : "multi-user.target",
        "value" : "active"
}
{
        "name" : "io.systemd.Manager.unit_active_state",
        "object" : "systemd-sysusers.service",
        "value" : "inactive"
}
```
**unit_load_state**:
```
{
        "name" : "io.systemd.Manager.unit_load_state",
        "object" : "multi-user.target",
        "value" : "loaded"
}

```
**nrestarts**:
```
{
        "name" : "io.systemd.Manager.nrestarts",
        "object" : "user@0.service",
        "value" : 0
}
{
        "name" : "io.systemd.Manager.nrestarts",
        "object" : "user-runtime-dir@0.service",
        "value" : 0
}
```
2026-02-04 16:31:55 +01:00
gvenugo3 cf27c70d70 networkd-json: add human-readable address strings for IP addresses
Add JSON_BUILD_PAIR_IN_ADDR_WITH_STRING, JSON_BUILD_PAIR_IN6_ADDR_WITH_STRING,
and JSON_BUILD_PAIR_IN4_ADDR_WITH_STRING macros (plus _NON_NULL variants) that
emit both the binary address array and a human-readable string representation.

For example, an address field now emits both:
  "Address": [192, 168, 1, 1]
  "AddressString": "192.168.1.1"

This improves usability of the JSON/Varlink output for debugging and tooling
that consumes networkd state.

Updated networkd-json.c to use these new macros for addresses, neighbors,
nexthops, routes, routing policy rules, DNS servers, NTP servers, SIP servers,
domains, DHCPv6 prefixes, and link-local addresses.

Also updated the Varlink interface definitions to include the new string fields.
2026-02-04 10:34:30 +01:00
Lennart Poettering 13d82876f5 sysext: Skip refresh if no changes are found (#39980)
When the extensions for the final system are already set up from the
    initrd we should avoid disrupting the boot process with the remount
    (which currently isn't atomic) and the daemon reload for
systemd-confext and systemd-sysext. Similarly, when sysupdate ran and
updated extensions it's best to avoid the remount and daemon reload if
    no changes are found.
    To do this, encode the current extension state in more detail than
    before where only the names of the extensions where encoded in the
overlay mount. This can also be used to provide more details about the
    extension origin in "systemd-sysext status (--json=)". During the
refresh add a check whether the old state matches the new state and in
    this case skip the refresh unless the user provides a flag to always
    refresh. Besides the extension name and the resolved path the best
method for identification is the verity hash but that is not available
for plain image files or directories. Therefore, also include data to
check for file/directory replacements. The creation/modification times
are not always real on reproducible images or extracted archive content.
    The file handle together with the unique mount ID is the next best
identifier we can use when we have no verity hash. Fall back to an inode
when we get no handle. With the creation/modification time and the path
this should be good enough. Using a unique mount ID is important (with
a fallback to the regular non-unique mount ID) instead of st_dev because
    st_dev gets reused too easily, e.g., by a loop device mount and the
mount ID helps to catch this. For the mount ID to be valid it has to be
resolved before we enter the new mount namespace. Thus, it gets provided
    by the image dissect logic and handed over to the sysext subprocess
    which runs in a new mount namespace.
    Luckily, we can rule out online modification of directories or image
files because this is anyway not well supported with overlay mounts, so
we don't do a file checksum nor do we recurse into a directory to look
    for the most recently touched files.  But, as said, with the
    always-refresh flag one can force a reload.
2026-02-04 10:30:10 +01:00
Yu Watanabe 89591e04a2 resolvectl: re-implement normal status output using varlink (#40529)
Currently, `resolvectl status` (and other status commands like
`resolvectl dns $iface`) uses varlink when asked to print JSON, but uses
dbus otherwise. This PR re-implements the regular status output to use
varlink instead of dbus.

This both simplifies the `resolvectl status` code, and is an incremental
step in replacing dbus usage with varlink throughout `resolvectl`.

The first several commits move `dns-configuration.[ch]` from
`src/network/wait-online` to `src/shared`, and complete the JSON
dispatching so that all fields are available in a concrete type. The
next few commits re-implement global, link, and delegate status output.
Finally, the last commits consolidate and simplify the status logic
since varlink and the `DNSConfiguration` type can be used in all cases.
2026-02-04 15:47:02 +09:00
Yu Watanabe 5a35a6d9d4 vmspawn: add --ephemeral (#40505)
This PR implements --ephemeral for vmspawn in the same way as nspawn.

Note that this does not support snapshots for --extra-drives.
2026-02-04 11:43:22 +09:00
Kai Lueke 23115eeaf1 sysext: Skip refresh if no changes are found
When the extensions for the final system are already set up from the
initrd we should avoid disrupting the boot process with the remount
(which currently isn't atomic) and the daemon reload for
systemd-confext and systemd-sysext. Similarly, when sysupdate ran and
updated extensions it's best to avoid the remount and daemon reload if
no changes are found.
To do this, encode the current extension state in more detail than
before where only the names of the extensions where encoded in the
overlay mount. This can also be used to provide more details about the
extension origin in "systemd-sysext status (--json=)". During the
refresh add a check whether the old state matches the new state and in
this case skip the refresh unless the user provides a flag to always
refresh. Besides the extension name and the resolved path the best
method for identification is the verity hash but that is not available
for plain image files or directories. Therefore, also include data to
check for file/directory replacements. The creation/modification times
are not always real on reproducible images or extracted archive content.
The file handle together with the unique mount ID is the next best
identifier we can use when we have no verity hash. Fall back to an inode
when we get no handle. With the creation/modification time and the path
this should be good enough. Using a unique mount ID is important (with
a fallback to the regular non-unique mount ID) instead of st_dev because
st_dev gets reused too easily, e.g., by a loop device mount and the
mount ID helps to catch this. For the mount ID to be valid it has to be
resolved before we enter the new mount namespace. Thus, it gets provided
by the image dissect logic and handed over to the sysext subprocess
which runs in a new mount namespace.
Luckily, we can rule out online modification of directories or image
files because this is anyway not well supported with overlay mounts, so
we don't do a file checksum nor do we recurse into a directory to look
for the most recently touched files.  But, as said, with the
always-refresh flag one can force a reload.
2026-02-04 00:05:24 +01:00
Nick Rosbrook 7bfc82bf5a dns-configuration: use OrderedSet for servers and domains
This only has a small effect, which mostly matters for generating status
output. It ensures that the order of servers and domains displayed
matches the order they are stored on the daemon side, which keeps the
new resolvectl output consistent with the old.
2026-02-03 15:07:41 -05:00
Nick Rosbrook 8894f29a4e dns-configuration: add DNSSEC support boolean to DNSConfiguration
This is one of several commits to dispatch all fields of the
DNSConfiguration JSON.
2026-02-03 15:07:41 -05:00
Nick Rosbrook d9757721ab dns-configuration: add in_addr_union field to DNSServer type
This makes it easier to use DNSServer with helpers from in-addr-util.h.
2026-02-03 15:07:41 -05:00
Nick Rosbrook 8731d33b58 dns-configuration: dispatch delegate name to DNSConfiguration
This is one of several commits to dispatch all fields of the
DNSConfiguration JSON.
2026-02-03 15:07:41 -05:00
Nick Rosbrook 3afb9c20b6 dns-configuration: dispatch scopes to DNSConfiguration
This is one of several commits to dispatch all fields of the
DNSConfiguration JSON.

Introduce a DNSScope type, and all required JSON dispatching helpers.
2026-02-03 15:07:41 -05:00
Nick Rosbrook e90180f50c dns-configuration: dispatch resolv conf mode to DNSConfiguration
This is one of several commits to dispatch all fields of the
DNSConfiguration JSON.
2026-02-03 15:07:41 -05:00
Nick Rosbrook 4a8f4efd44 dns-configuration: dispatch negative trust anchors to DNSConfiguration
This is one of several commits to dispatch all fields of the
DNSConfiguration JSON.
2026-02-03 15:07:41 -05:00
Nick Rosbrook d3b60567d7 dns-configuration: dispatch fallback servers to DNSConfiguration
This is one of several commits to dispatch all fields of the
DNSConfiguration JSON.
2026-02-03 15:07:41 -05:00
Nick Rosbrook fb0bd15d15 dns-configuration: dispatch all protocol modes to DNSConfiguration
This is one of several commits to dispatch all fields of the
DNSConfiguration JSON.
2026-02-03 15:07:41 -05:00
Nick Rosbrook 271f7630a2 shared: move wait-online's dns-configuration.[ch] to shared 2026-02-03 15:07:41 -05:00
Nick Rosbrook 9b2f263f30 resolve: add DNSConfiguration field to indicate DNSSEC support
The varlink API is currently missing the "DNSSEC supported" field, which
is required for to re-implement the existing resolvectl status output
with varlink instead of dbus.

Add this field to DNSConfiguration.
2026-02-03 15:07:41 -05:00
Yu Watanabe 503a788332 Introduce name_to_handle_at_u64() helper function and use it for getting pidfd ID and cgroup ID (#40500) 2026-02-04 04:37:07 +09:00
Yu Watanabe 06432cca43 Portabled capsule fixes (#40427) 2026-02-04 02:53:16 +09:00
Yu Watanabe f37931bd78 tree-wide: replace cg_{fd,path}_get_cgroupid() with {fd,path}_to_handle_u64() 2026-02-04 02:45:17 +09:00
Daan De Meyer ae6dcaff0d portable: Don't refuse copying out instance of template that exists
There's no reason to refuse copying out capsule@abc.service even if
capsule@.service already exists on the host, so let's optionally not
search for templates if we can't find an instance when looking up
units and use it in portabled.
2026-02-03 15:03:51 +01:00
Daan De Meyer 4d388536ee tree-wide: Allow running capsules as any user
For many use cases DynamicUser= just doesn't cut it. Specifically lots
of stuff wants to run as root. Let's support this use case by relaxing
our checks for capsules a bit.
2026-02-03 15:00:32 +01:00
Luca Boccassi 75cb25c0b9 firstboot/homectl: hide plymouth splashscreen when asking questions
When plymouth is enabled, the screen gets all garbled when firstboot
runs and asks questions. Disable the splash screen, but only when
actually asking questions.
2026-02-03 13:21:03 +01:00
Mike Yuan c27d1b3eec ssh-generator: follow symlink when searching for sshd@.service
unit_file_exists() currently does not follow symlinks, as it is
mainly used to test whether the unit (of any install state)
has been seen under search dirs. However, in ssh-generator
we should search for and honor whatever the distro ships,
which might be an alias or linked externally.
2026-02-03 08:17:34 +09:00
Yu Watanabe ab8603d26b Fixes for ask-password (#40549) 2026-02-03 07:48:13 +09:00
Yaping Li fd73cd6c91 [metrics] Introduce metrics API framework
This commit introduces the shared code for the metrics API framework:

- Metrics API definitions
- Code to set up the varlink server
- The describe method which shows all the metrics families
- The list method which lists all the metrics
- Type definitions related to MetricFamily
- Common code to build json objects
2026-02-02 08:03:48 -08:00
Zbigniew Jędrzejewski-Szmek 65f72f5dbb ask-password: remove files in /run when query is aborted
Because of the missing 'goto', if the query was aborted, we
would leave behind the ask.* ini file.
2026-02-02 15:16:23 +01:00
Antonio Alvarez Feijoo 5327755f8b discover-image: fix typo in log message 2026-02-02 22:24:28 +09:00
Michael Vogt 96dd2df514 nspawn: extract snapshot creation into new shared helper
This commit extracts the creation of the snapshot for
nspawn into a shared helper. Its not a lot of code but its
subtle so having a single place seems beneficial.

While extracting the snapshot code got tweaked/simplified based
on the feedback from Yu (many thanks!).

With that we can simplify the snapshot delete and error handling
as well. The shared helper is then going to be used by vmspawn
when it also gets the --ephemeral option.
2026-02-02 09:04:37 +01:00
Yu Watanabe c3540c80a5 bus-unit-util: convert StandardInputText to StandardInputData
Fixes #40527.
2026-01-31 06:41:57 +09:00