Commit Graph
10270 Commits
Author SHA1 Message Date
Daan De Meyer 004b7f1f7e elf-util: Add support for parsing dlopen metadata
Then we can add support for showing dlopen metadata to systemd-analyze.
2025-10-30 08:41:43 +01:00
Daan De Meyer 2988bba60f mount-util: Iterate mountinfo backwards when unmounting
Submounts will always be located further in the mountinfo file, so
when we're unmounting, iterating backwards is likely to be more
efficient than iterating forwards. It'll also reduce the amount of
EBUSY debug logging we'll get since we'll stop trying to unmount
parent mounts with submounts which will always fail with EBUSY.
2025-10-29 12:01:32 +01:00
Lennart Poettering a6146b250e machined: support image clone/rm operations unpriv, and make hidden images always read-only (#39408) 2025-10-27 17:06:26 +01:00
Yu Watanabe 85fb6ad573 meson: add all 'cflags' dependencies to libshared
This should not change any behavior in most common setups.
But, may be useful when headers are installed at non-default places.
2025-10-25 12:52:23 +09:00
Yu Watanabe 910e3843fd pwquality: drop 'sym_' prefix from cleanup function
This also drops unnecessary symbols in header.
2025-10-25 11:54:21 +09:00
Yu Watanabe 7d7b1755e9 passwdqc: drop 'sym_' prefix from cleanup function
This also drops unnecessary symbols in header.
2025-10-25 11:53:41 +09:00
Yu Watanabe 56b52c00e3 qrcode-util: drop 'sym_' prefix from cleanup function 2025-10-25 11:45:20 +09:00
Yu Watanabe 63649394cc pcre2-util: drop trivial pattern_free() wrapper 2025-10-25 11:43:00 +09:00
Yu Watanabe 8aadb82966 pcre2-util: drop 'sym_' prefix from cleanup functions 2025-10-25 11:28:30 +09:00
Yu Watanabe 76afd4dc4a elf-util: drop 'sym_' prefix from cleanup function 2025-10-25 11:26:39 +09:00
Yu Watanabe fc945d22d5 libarchive-util: drop 'sym_' prefix from cleanup functions 2025-10-25 11:25:19 +09:00
Yu Watanabe afb9b7c581 apparmor-util: drop 'sym_' prefix from cleanup functions 2025-10-25 11:21:12 +09:00
Yu Watanabe 744d0e4422 pkcs11-util: drop 'sym_' prefix from cleanup functions 2025-10-25 11:15:05 +09:00
Yu Watanabe d0520b1ee7 module-util: drop 'sym_' prefix from cleanup functions 2025-10-25 11:12:16 +09:00
Yu Watanabe 163a3990fa openssl-util: fix spurious indent 2025-10-25 10:40:43 +09:00
Yu Watanabe 73063abf24 openssl-util: drop unused functions
They were introduced by 5f163921e9, but
never used.
2025-10-25 10:26:49 +09:00
Daniel Hast 101dd41cb4 tree-wide: add basic validation of --background argument
Check whether the argument of the `--background` option of
`systemd-run`, `run0`, `systemd-nspawn`, `systemd-vmspawn`, and
`systemd-pty-forward` is either empty or looks like an ANSI color code,
and reject invalid values when parsing arguments.

We consider a string to look like an ANSI color code if it consists of
one or more sequences of ASCII digits separated by semicolons. This
permits every valid ANSI color code, and should reject anything that
results in garbled output.
2025-10-25 09:56:31 +09:00
Lennart Poettering 9d5fc235f4 discover-image: support clone + rm operation also unpriv 2025-10-24 17:51:00 +02:00
Lennart Poettering ee327e086e discover-image: imply that hidden images are read-only
Marking a whole directory tree OS image as read-only is difficult
privilege-wise, because so far we rely on the FS_IMMUTABLE_FL which is
not accessible to unpriv clients.

One fundamental place where we currently rely on marking images
read-only is for keeping pristine copies of the originally downloaded
image around, which we place in "hidden" image directories. This is
probably the most relevant usecase for the read-only flag. And moreover,
the only usecase for the hidden images are these read-only pristine
copies.

Hence, let's make this work reasonably in the unpriv case, and simply
imply the read-only flag for hidden images. This is strictly speaking a
change in behaviour, but effectively it shouldn't be, because for nspawn
containers that are executed we insist on names that are hostname
compatible, and hidden names aren't (because they start with a dot).
2025-10-24 17:51:00 +02:00
Lennart Poettering 502f7a2b80 rm-rf: make sure we can safely remove dirs we have no access to via rm_rf_at()
Previously, we'd first empty a dir, and then remove it. This works fine
as long as we have access to a dir. But in some cases (like for example
a foreign owned container tree) we might not have access to the dir, but
are still able to remove it (because it is empty, and in a dir we own).
Hence let's try that first. If it works, we do not need to enter the dir
(and thus fail).
2025-10-24 17:38:29 +02:00
Yu Watanabe 9b414a38fa tree-wide: drop unused libcap dependencies 2025-10-24 01:52:59 +09:00
Yu Watanabe a5962d3327 rereadpt: always update kernel partition tables from userspace in an incremental fashion (#39390)
Let's address #38672 comprehensively: let's avoid BLKRRPART as much as
we can, and always do careful userspace controlled, incremental updates
to the kernel partition tables.

This simply iterates through blkid's partition parsing, and turns it
into a BLKPG ioctls, adding, updating, removing partitions as necessary,
suppressing unnecessary changes. This has the major benefit that the
call becomes truly idempotent: if nothing changed then nothing is
removed/readed, like BLKRRPART is doing it.

This then ports over all code currently doing partition refreshing,
specifcially: udev, repart, and homed.

Fixes: #38672
2025-10-23 09:35:03 +09:00
Yu Watanabe 80297f75e1 Two minor id128-related cleanups (#39407)
Split out from #39210
2025-10-23 09:30:11 +09:00
Lennart Poettering e582484789 tree-wide: open block device locks in writable mode
udev's block device locking protocol has one pitfall not even the
example in the documentation got right so far (even though this is
explained in all detail above): udev's rescanning is only triggered when
an fd that is opened for writing is closed. This means that if a
separate locking fd is opened on a block device – one that is maintained
independently of the fd actually used for writing – it must be opened for
writing too, so that closing the lock definitely triggers a rescan. This
matters in cases where the lock fd is kept for longer than the fd used
for writing to disk. (Because otherwise udev might get the
IN_CLOSE_WRITE event, but when it tries to rescan will find the device
locked, and never retry because no IN_CLOSE_WRITE is triggred anymore.)

Let's fix that across the codebase, at 4 places:

1. in makefs (a lock fd is kept, and mkfs then invoked as child, which
   uses a different fd, and the lock fd is closed only once the child
   died)

2. in udevadm lock (embarassing!): which is intended to be used to wrap tools
   that modify disk contents, very similar to the makefs case. The lock
   is also kept until after the tool exited.

3. In storagetm: the kernel nvme-tcp layer writes to the device
   directly, we just keep a lock fd.

4. the example in BLOCK_DEVICE_LOCKING.md
2025-10-22 22:56:02 +02:00
Lennart Poettering aa47d8ade1 udev: switch over to rereadpt() rather than raw BLKRRPART
Fixes: #38672
2025-10-22 22:56:01 +02:00
Lennart Poettering 757887d01d rereadpt: implement userspace-based BLKRRPART re-implementation 2025-10-22 22:56:01 +02:00
Lennart Poettering 524ebfe28a blockdev-util: split out partition device node generation from dissect-util.c 2025-10-22 22:56:01 +02:00
Lennart Poettering bb45a893c2 blockdev-util: in blockdev_partscan_enabled() check if we are operating on block device first
The function makes no sense on any other type of fd, hence we better
check this explicitly.
2025-10-22 22:56:01 +02:00
Lennart Poettering a251345cf5 blockdev-util: rename BlockDeviceLookupFlag to plural
This is a flags type and a flag function argument, let's name it in
plural, because it allows many flags combinations. Internally, the
implementation already used plural, but let's fix the prototypes too.
2025-10-22 22:56:01 +02:00
DaanDeMeyer af0ae29714 machine-bind-user: Make home mount directory configurable 2025-10-22 16:42:50 +02:00
DaanDeMeyer 9aa6c30bbd machine-bind-user: Use machine in log messages instead of container 2025-10-22 16:42:50 +02:00
Zbigniew Jędrzejewski-Szmek e39cde9585 Disable abort in log_assert in libsystemd/libudev (#39307)
See the second commit for details.

I think we might want to apply the same treatment to nss and pam
modules. Asserting in such "plugin code" seems iffy. But this PR doesn't
change those in any way.
2025-10-22 14:48:14 +02:00
Mike Yuan 7d4e8f920b shared/bus-get-properties: use sizeof instead of hardcoded size in bus_property_get_id128()
Prompted by
https://github.com/systemd/systemd/pull/39210#discussion_r2404225907
2025-10-22 14:44:50 +02:00
Zbigniew Jędrzejewski-Szmek 0bb0316f5e Do not use "critical assert_return" in libsystemd or libudev
Previously, when compiled in developer mode, a call into libsystemd with
invalid parameters would result in an abort. This means that it's effectively
impossible to install such libsystemd in a normal system, since various
third-party programs may now abort. A shared library should generally never
abort or exit the calling program.

In python-systemd, the test suite calls into libsystemd, to check if the proper
return values are received and propagated through the Python wrappers.
Obviously with libsystemd compiled from git, the test suite now fails
in a nasty way.

So rework the code to set assert_return_is_critical similarly to how we handle
mempool enablement: the function that returns true is declared as a week
symbol, and we "opt in" by linking a file that provides the function in
libsystemd-shared. Effectively, libsystemd and libudev always have
assert_return_is_critical==false, and our binaries and modules enable it
conditionally.
2025-10-22 10:10:24 +02:00
Lennart Poettering 1be8caa6be importd: support unpacking tarballs to foreign UID range
When invoked unprivileged, let's use a transiently allocated userns, so
that we can properly untar UIDs/GIDs so that the trees appear owned by
the foreign UID/GID range.
2025-10-21 23:09:50 +02:00
Lennart Poettering d9c10bf1d2 importd: clean up how we determine image root in importd backends
Let's introduce a single helper that determines where to download images
to, taking all three primary parameters into account: the image class,
the runtime scope and whether to do runtime or persistency.

Then port everything over to this.

This not only cleans things up, but makes sure the importd backends
actually properly can deal with per-user downloads, as before we never
took the runtime scope into account for determining download location.
2025-10-21 23:09:50 +02:00
Lennart Poettering 570366b6e1 install-file: add flags to handle RO and syncing failures graceful
When operating in unprivileged mode we might not be able to execute the
necessary operations to make a disk image read-only (because
FS_IMMUTABEL_FL needs privs for example), and syncing (because for that
we might need to open the root inode, but that might not be possible
from the outside).

Let's deal with that by making these operation optional: if they work
great, if not they don't.
2025-10-21 23:09:50 +02:00
Lennart Poettering 69332065e2 copy: make copy_tree_at_full()'s 'to' parameter optional
Sometimes it's quite useful to pin a source dir via an fd, as well as a
target dir the same way, and then ask copy_tree_at_full() to copy the
contents from one to the other. Make this possible, by allowing 'to' be
NULL. (Previously, it had to be non-NULL, i.e. the function would always
create a new dir, no matter what.)

Note that we only support that for dir inodes.
2025-10-21 23:09:50 +02:00
Lennart Poettering 0a9e2e45f0 copy: optionally apply source inode's stat() when doing a merge copy 2025-10-21 23:09:50 +02:00
Lennart Poettering bcafa70974 nsresource: add constants for the only supported UID range size allocations
As requested: https://github.com/systemd/systemd/pull/39322#discussion_r2447366728
2025-10-21 23:09:50 +02:00
Lennart Poettering b3e5e00d45 dissect-image: explain one more error 2025-10-21 22:02:22 +09:00
Daan De Meyer cbbc7e51ec core: adding cgroup/invocationid lookups to io.systemd.Unit.List (#38032) 2025-10-20 17:15:34 +02:00
Yu Watanabe 97d38155db Several preparations for supporting new coredump interface (#39350) 2025-10-20 20:44:22 +09:00
Lennart Poettering 342084b035 loop-util: explain why we propagate discard_max_bytes from backing block device to loopback block device
Follow-up for: 29ee9c6fb7
2025-10-20 12:33:50 +01:00
Ivan Kruglov 6c2c2e0598 core: io.systemd.Unit.List can lookup by InvocationID 2025-10-20 03:58:53 -07:00
Ivan Kruglov 6b78d931cd core: io.systemd.Unit.List can lookup unit by CGroup 2025-10-20 03:58:39 -07:00
nkraetzschmar 29ee9c6fb7 loop-util: mirror discard limits from backing device 2025-10-20 12:49:39 +02:00
Daan De Meyer 9c3359f28a ptyfwd: Always prioritize $SYSTEMD_TINT_BACKGROUND
By giving priority to --background= we prevent users from opting
out of coloring if an explicit color is chosen by a tool wrapping
one of our own tools. Instead, let's give priority to the environment
variable, so that even if our tools are wrapped by another tool with
a different background, users can still opt out of coloring just by
setting the environment variable, which has a high chance of being
forwarded to the invocation of our own tools which makes it easy to
use to disable color tinting globally if requested by the user.
2025-10-20 12:20:35 +02:00
Ivan Kruglov 4ddd3fe1fb core: make name/pid lookup params use AND logic in io.systemd.Unit.List 2025-10-20 02:10:57 -07:00
Lennart Poettering e5dc5821ff dns-domain: make dns_name_change_suffix() work with an empty/null suffix 2025-10-20 10:35:23 +02:00