Commit Graph
58040 Commits
Author SHA1 Message Date
DaanDeMeyer ef155c909a dissect: Make --mount/--unmount/--with work unprivileged
Let's check for CAP_SYS_ADMIN instead of root for these, and make
unmounting more graceful if we can't access the backing loop device
because of permission issues. This allows mounting and unmounting images
from an unprvileged mount namespace. The actual files in the image will
end up owned by nobody:nobody because we'll be in an unprivileged user
namespace, but assuming the directory permissions are not too strict, this
still allows interacting with the image in useful ways.
2026-02-12 09:43:07 +01:00
DaanDeMeyer fe0114db8e dissect: Fix wrong errno passed to log message 2026-02-12 09:43:07 +01:00
DaanDeMeyer a0a4e9d7d2 dissect: Fix segmentation fault if loop device is not provided 2026-02-12 09:43:07 +01:00
DaanDeMeyer 53d1d6e49c dissect: Fix logging in (with) 2026-02-12 09:43:07 +01:00
DaanDeMeyer 09e38c2709 dissect: Don't use private userns for --copy-to/--copy-from
These actions interact with the host. The former needs privileges to
write into the image, the latter needs privileges to write on the host.
Neither will have the privileges required if the image is attached under
a private userns, hence, don't use one.
2026-02-12 09:43:07 +01:00
Daan De Meyer 9f01cffc39 bootctl: Drop SD_VARLINK_NULLABLE from ListBootEntries IDL
9e10f3a7e8 changed the implementation
to report an error instead of an empty object but the IDL was not
adjusted. Let's fix that.
2026-02-11 14:25:36 +01:00
Daan De Meyer 4f5d44ef53 tree-wide: Migrate to varlink_set_sentinel() 2026-02-11 14:25:36 +01:00
Daan De Meyer dc28940745 resolve: Make sure we free varlink subscription sets 2026-02-11 14:24:03 +01:00
Daan De Meyer c0696f1f5d sd-varlink: Introduce varlink_set_sentinel()
Streaming methods which are not used as a continuous subscription but
instead only send a series of objects all end up with the same workaround
to be able to figure out when to send sd_varlink_reply() or sd_varlink_notify().
Let's generalize this in sd-varlink itself.

Let's introduce the concept of a sentinel, which is a reply that will be sent
by sd-varlink if no other reply was queued by a method callback. The sentinel
is configured with varlink_set_sentinel(). If a sentinel is configured,
sd_varlink_reply() can be used more than once in streaming methods to queue
multiple values to stream to the client. The last queued reply is not sent
until the callback finishes. When the callback finishes, the last reply is
sent without "continues: more". If no reply was queued, the sentinel is sent.

This always using only sd_varlink_reply() in such streaming methods and
leaves sd_varlink_notify() available solely for continuous subscription
streaming methods, where we never use sd_varlink_reply() and instead disconnect
when the server exits.
2026-02-11 14:24:03 +01:00
Daan De Meyer 22f1d5a625 sd-varlink: Move code around
Preparation for next commits
2026-02-11 14:24:03 +01:00
Daan De Meyer edc1515cf8 varlink-unit: Coding style cleanups 2026-02-11 14:24:03 +01:00
Yaping Li a0f2d74cba Metrics: Refactor to drop usage of strv
This addresses Daan's feedback on #39202
2026-02-11 12:43:28 +01:00
Mike Yuan 48c1393bfb terminal-util: also protect from empty /sys/class/tty/tty0/active 2026-02-10 22:21:53 +01:00
Mike Yuan a01cf5b2e0 terminal-util: handle the case where no system console is active
/dev/console might have no backing driver, in which case
/sys/class/tty/console/active is empty. Unlike get_kernel_consoles()
resolve_dev_console() currently proceeds with empty devnode,
resulting in setup_input() -> acquire_terminal() emitting -EISDIR
as we're trying to open /dev/. Let's catch this and report -ENXIO.
2026-02-10 22:04:02 +01:00
Lennart Poettering 8b736d94cd bootctl: decouple "list", "unlink", "cleanup"
These operations to quite different things, they just share 2 common
funcs. Let's split them out into separate files.

This also splits up verb_list() into separate calls for the three
operations. This actually fixes issues, as for status/list we want
"unpriv" ESP discovery logic, but for the other two we really should
have privileged discovery logic.

This is preparation for adding "bootctl link" later, but this makes
sense either way, I am sure.
2026-02-10 19:43:04 +00:00
Luca Boccassi 6cf5581af8 sysupdate: Split update into acquire and install verbs (#40236)
Using roughly the approach described in
https://gitlab.gnome.org/GNOME/gnome-software/-/merge_requests/2004#note_2145880.
Basically, copying in-progress downloads to a file/partition with a
predictable prefix, and then moving to a predictable ‘pending’ prefix
when ready to install.

Helps: https://github.com/systemd/systemd/issues/34814
2026-02-10 13:11:52 +00:00
Luca Boccassi b6defb8f84 bootctl: install tweaks (#40622) 2026-02-10 13:04:48 +00:00
Kai Lüke eefb46c83b repart: Discard only once
The indirect discard in mkfs.btrfs on the loop device mapped to the
region on disk can hang and fail the first-boot creation of the rootfs.
Since there already is a discard done we anyway don't need to do it
twice. This might help for most cases to avoid the failure in
mkfs.btrfs.
Keep track if the direct discard worked and then skip the mkfs.btrfs
discard if it did. This still leaves the case where mkfs.btrfs can hang
when the direct discard couldn't succeed and mkfs.btrfs tries again but
since the conditions are rather the same it might be that this case is
not easy to trigger. If the problem still shows up and the kernel won't
be fixed soon we can still disable the mkfs discard for at least btrfs.
2026-02-10 13:09:33 +01:00
Lennart Poettering 51480b56c8 bootctl: rearrange if branches in vl_method_install() 2026-02-10 11:56:26 +01:00
Lennart Poettering 10268261a8 bootctl: toughen fd validation in Install() handler
Let's also check the fd flags. Just in case.
2026-02-10 11:56:26 +01:00
Lennart Poettering 7f204857e1 bootctl: fix varlink IDL for rootDirectory field 2026-02-10 11:56:26 +01:00
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
nikstur 14519d7dfa meson: guard symlinks in sysconfdir behind install_sysconfidr
Symlinks to files inside sysconfdir are now only installed if
ìnstall_sysconfdir=true (which is the default).

If sshconfdir,sshdconfdir,shellprofiledir are not inside sysconfdir and
install_sysconfidr=false, these symlinks are still installed to the
configured directory.
2026-02-09 16:52:53 +01:00
Philip Withnall 779ed358f2 test: Add basic tests for path_split_prefix_filename()
These aren’t anything comprehensive, but provide some basic assurances
that it’s working correctly. In particular, they test its behaviour when
*both* the prefix and filename components are requested.

Split out from the original version of this function which was part
of #40236.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2026-02-09 16:26:40 +01: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
Philip Withnall e6e8efcffb sysupdate: Add some more debug output
Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2026-02-09 12:05:15 +00:00
Philip Withnall 3bc9208435 sysupdate: Add acquire and install verbs
These expose the two parts of ‘update’, so that update sets can be
acquired (downloaded) and installed (applied) in separate actions at
different times. For example, this could allow a load of update sets to
be acquired when online, and later applied when offline.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
Helps: https://github.com/systemd/systemd/issues/34814
2026-02-09 12:05:10 +00:00
Philip Withnall cf7cccf2f7 sysupdate: Split the update verb into two parts internally
An ‘acquire’ (download) part, and an ‘install’ (apply) part.

Following commits will expose these as separate verbs and D-Bus methods,
but this commit is the one which rearranges the internals.

If doing an ‘install’, a mirror version of the ‘acquire’ has to happen
first to make sure the transfer’s internal state is correct.

‘Acquire’ can require an internet connection, but ‘install’ will always
work with `--offline` specified.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
Helps: https://github.com/systemd/systemd/issues/34814
2026-02-09 12:05:05 +00:00
Philip Withnall 594d0345fa sysupdate: Add partial/pending flags to UpdateSet
This commit adds the flags and some basic formatting/printing of them.
Following commits will integrate them into the update/acquire/install
logic.

`UPDATE_PARTIAL` is set if any of the instances in the `UpdateSet` are
partial, i.e. have been partially downloaded.

`UPDATE_PENDING` is set if any of the instances in the `UpdateSet` are
pending, i.e. have been acquired (downloaded) but not yet installed.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
Helps: https://github.com/systemd/systemd/issues/34814
2026-02-09 12:05:01 +00:00
Philip Withnall ba9687adef sysupdate: Factor out temporary path computation for transfers
This helper function will be reused in a following commit.

This introduces no functional changes.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
Helps: https://github.com/systemd/systemd/issues/34814
2026-02-09 12:04:52 +00:00
Philip Withnall adcc03a0c0 sysupdate: Vacuum partial/pending instances first
Modify the vacuum implementation to preferentially vacuum partial or
pending transfers first (unless protected) as they are meant to be
fairly transitory, and ones which are hanging around have probably been
forgotten about and/or are out of date.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
Helps: https://github.com/systemd/systemd/issues/34814
2026-02-09 12:03:59 +00:00
Philip Withnall 48fff6a27a sysupdate: Implement acquire and install steps for transfers
Instead of using a random temporary path for file transfers, use a
predictable one which indicates whether the transfer is partially
complete or pending installation. Similarly for partitions.

This is another step towards being able to split the ‘update’ step into
‘acquire’ and ‘install’.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
Helps: https://github.com/systemd/systemd/issues/34814
2026-02-09 12:03:47 +00:00
Philip Withnall edf7679faf sysupdate: Factor out a vacuum helper function
This will be reused in an upcoming commit.

This commit introduces no functional changes.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
Helps: https://github.com/systemd/systemd/issues/34814
2026-02-09 11:54:45 +00:00
Philip Withnall fdc661116d sysupdate: Allow instances to be partial or pending
If we allow target instances to be partial or pending, we can build on
top of this to allow updates to be split into two phases: ‘acquire’ (which
takes an available source instance and copies it (temporarily partial) to
a pending target instance; and ‘install’ (which takes a pending target
instance and installs it as an installed target instance).

This commit introduces a file/directory and partition prefix naming
scheme to identify partial and pending instances.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
Helps: https://github.com/systemd/systemd/issues/34814
2026-02-09 11:54:40 +00:00
Philip Withnall ec10efa1a1 sysupdate: Split context_apply() into acquire and install steps
This introduces no functional changes at the moment, but will be used in
upcoming commits.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
Helps: https://github.com/systemd/systemd/issues/34814
2026-02-09 11:54:25 +00:00
Lennart Poettering 775f04293d kernel-install refactorings (#40610)
This contains the first two commits from #38764. While @daandemeyer
convinced me to base systemd-sysinstall on a new "bootctl link" rather
than "kernel-install", I think the refactorings I prepped as part of the
original work still make a lot of sense on their own, and I hope I
didn't do them for /dev/null.
2026-02-09 11:54:36 +01:00
Lennart Poettering 7ae2329198 tree-wide: symlink well-known Varlink service entry point sockets into /run/varlink/registry/ (#40590)
This is generally useful, but is particularly useful in context of
https://github.com/mvo5/varlink-proxy-rs which can expose a set of local
Varlink services via a HTTP bridge. The idea is that the sockets linked
into /run/varlink/registry/ are candidates for being exposed like that.

/cc @mvo5
2026-02-09 11:54:15 +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
Zbigniew Jędrzejewski-Szmek df8747806b Two cleanups (#40587) 2026-02-09 11:02:41 +01:00
Zbigniew Jędrzejewski-Szmek 25860000b6 Fix wording in two places
Noticed this while going through the stable series…
Also update location after 97318131fd.
2026-02-09 11:01:15 +01:00
Lennart Poettering 607152c742 varlinkctl: add 'list-registry' command 2026-02-09 10:54:17 +01:00
Lennart Poettering 3e4fca7489 chase: add new flag CHASE_MUST_BE_SOCKET
Just like CHASE_MUST_BE_DIRECTORY and CHASE_MUST_BE_REGULAR, but test if
the inode is a socket.
2026-02-09 10:44:47 +01:00
Lennart Poettering c0ee33f48f stat-util: add stat_verify_socket() helper 2026-02-09 10:44:47 +01:00
Lennart Poettering 2557f78c07 mountfsd: do not cross mount boundaries when looking for parent of foreign UID range owned dirs
This is primarily paranoia: it might be possible for unpriv users to set
up mount hierarchies in unexpected ways when using userns. Hence let's
make protections more rigid: when looking for a parent dir of a foreign
UID owned dir tree, refuse to cross mount boundaries.
2026-02-09 10:33:01 +01:00
Lennart Poettering f5a7247afb stat-util: add statx_verify_directory() helper, similar to stat_verify_directory() but for statx 2026-02-09 10:33:01 +01:00
Lennart Poettering 780f15ee7d mountpoint-util: use xstatx() a bit more 2026-02-09 10:33:01 +01:00
Lennart Poettering 2c756c6964 dirent-util: use xstatx_full() some more 2026-02-09 10:33:01 +01:00
Zbigniew Jędrzejewski-Szmek 15777d6d5c report: many smaller clean-ups/tweaks to systemd-report (#40598)
/cc @keszybz
2026-02-09 10:28:29 +01:00
Lennart Poettering cfee2c1900 kernel-install: allocate "Context" object only in verb_xyz() functions, not already in run()
We soon want to add a Varlink interface to this, but that means that the
various paramaters for the Context object will be sourced from a Varlink
message not from the command line. Hence split apart the parsing logic
so that we alway parse the command line into arg_xyz first, and then,
inside the verb_abc() calls copy the data from there into the Context
object.

This matches a similar pattern in bootctl.
2026-02-09 10:21:16 +01:00
Lennart Poettering 533afe86c3 kernel-install: rework in preparation for varlink
This reworks things a bit, so that the "Context" object can later be
allocated for each Varlink call separately. For example we define a
more precise CONTEXT_NULL that invalidates truly all fields, so that we
can discern "defaults" from "unspecified" later on.

Other minor rearrangements too
2026-02-09 10:21:16 +01:00