Commit Graph
54983 Commits
Author SHA1 Message Date
Yu Watanabe 7dde00ca57 network/link: update state file when master ifindex is changed
If master ifindex is non-zero, then the carrier state and operational
state of the interface may be the enslaved state.
As the operational state is saved in link state file, and read by
wait-online, we need to update the state file when the master ifindex is
changed.
2025-05-28 04:38:56 +09:00
Yu Watanabe f44b20b7b6 network/link: ENODATA from reading IFLA_MASTER when an interface has no master
When an interface leaved from the master interface, then reading
IFLA_MASTER attribute causes ENODATA. When the interface was previously
enslaved to another interface, we need to remove reference to the
interface from the previous master interface.

This is especially important when
```
ip link set dev eth0 nomaster
```
is called.

Fixes a bug introduced by 0d411b7f8f (v249).
Fixes #37629.
2025-05-28 04:38:56 +09:00
Yu Watanabe ae6420c923 cgroup-util: minor cleanups (#37630) 2025-05-28 02:19:21 +09:00
Yu Watanabe b6278c1937 bpf-program: check if a trivial BPF program can be created and loaded
Re-introduce the check dropped by
ec3c5cfac7,
ad446c8ceb.

For some reasons, if we are running on LXC, even if bpf_program_supported()
returned true, but bpf_program_load_kernel() failed:
```
Attaching device control BPF program to cgroup /system.slice/test-bpf-devices-875b406d56ac7bc3.scope/186c411f6e991777 failed: Operation not permitted
src/test/test-bpf-devices.c:31: Assertion failed: Expected "r" to succeed, but got error: Operation not permitted
```
2025-05-27 17:24:33 +01:00
Jan Vaclav a8a39e23bb in-addr-util: use s6_addr* macros everywhere
Currently, the code in in-addr-util.c uses a mix of accessing the
in6_u members directly, as well as using the s6_addr* macros.
Let's unify it so that the s6_addr macros are used everwhere.
2025-05-27 22:33:57 +09:00
Mike Yuan a941822d1c cgroup-util: assert on attribute for cg_{get,set}_attribute()
It makes zero sense to ever perform IO operations on cgroup dirs.
2025-05-27 14:31:06 +02:00
Mike Yuan 606ef91a40 cgroup-util: make cg_get_attribute_as_bool() return 0/1 directly
As with getenv_bool() and getxattr_at_bool(), to match
our usual style.
2025-05-27 14:28:08 +02:00
Mike Yuan 7b4022bdb0 cgroup-util: rename cg_get_xattr_malloc -> cg_get_xattr
This is not a trivial wrapper around user-created-buffer-based
syscall, so do not use _malloc suffix. Most of our functions
return an internally allocated buffer and this one's not special.
2025-05-27 14:28:08 +02:00
Daan De Meyer c5d7a2d000 basic,shared: mark eligible functions with _pure_/_const_ (#37623) 2025-05-27 14:24:30 +02:00
Zbigniew Jędrzejewski-Szmek 976295bf8b repart: Copy fs-verity status for CopyFiles= (#35401)
When populating a filesytem with CopyFiles=, we first copy the files to
a temporary directory. Make sure we use the (new) COPY_FS_VERITY flag
when doing that copy so that the `mkfs` that we invoke can see the files
with fs-verity enabled.

Closes #35352
2025-05-27 14:01:05 +02:00
Daan De Meyer 4793dbc56e core: introduce io.systemd.Unit.List (first PR) (#37432) 2025-05-27 12:42:11 +02:00
Lennart Poettering 5c5934c62d mountfsd: add ability to create dir owned by foreign UID range in unpriv $HOME (#37616) 2025-05-27 12:20:05 +02:00
Lennart Poettering b4c2e2b970 varlinkctl: optionally push fds to server 2025-05-27 10:41:52 +02:00
Lennart Poettering 0261fe571b mountfsd: add call for creating a foreign UID owned dir in dir owned by caller
In order to fully support unpriv containers placed in directories owned
by the foreign UID range, below some unpriv user $HOME, we need to away
to actually create these hierarchies in the first place.

Let's add a method call for that. It takes a dir fd, then validates that
its ownership matches the client's identity, and then creates a subdir,
chown()ing it to the foreign UID range. It then returns an fd to the
result.

The result could then be passed to MountDirectory() in order to get a
mount which can then be populated by some code running in a dynamic
userns.
2025-05-27 10:41:52 +02:00
Lennart Poettering cb062410ec sd-json: add json_dispatch_const_filename()
json_dispatch_const_filename() is to json_dispatch_filename() what json_dispatch_const_path() is to json_dispatch_path().
2025-05-27 10:37:11 +02:00
Lennart Poettering 48764e2e58 machine: fix log message, doesn't have to be scope unit, can by any 2025-05-27 10:27:37 +02:00
Lennart Poettering ca02f658e0 machine: rework machine_gc()
Let's check the leader alive state, and let's log about dbus errors.
This mimics (but is not quite identical to) what we do these days in
logind for GC'ing user sessions.
2025-05-27 10:27:37 +02:00
Lennart Poettering 0c38bc6227 machine: shorten code 2025-05-27 10:23:36 +02:00
Lennart Poettering ee5622f9f0 machine: as safety precaution also check parsed machine name 2025-05-27 10:23:36 +02:00
Lennart Poettering 6981e465a7 machine: also save/restore vsock CID properly 2025-05-27 10:23:36 +02:00
Lennart Poettering 320b370ab3 machine: modernizations of serializing/deserializing netif data 2025-05-27 10:23:36 +02:00
Lennart Poettering 20babd6038 machine: save/restore machine leader pidfdid 2025-05-27 10:23:36 +02:00
Lennart Poettering 4b9c918431 machine: use the correct escaping calls for machine metadata 2025-05-27 10:23:36 +02:00
Lennart Poettering b8396f1102 machine: properly remove unit name symlink on removal 2025-05-27 10:23:36 +02:00
Lennart Poettering a4dc3b16d9 machine: port machined state files to fopen_tmpfile_linkable()
Similar to the erlier commit for logind, switch to a more modern way to
write the state files.
2025-05-27 10:23:36 +02:00
Lennart Poettering 0c18c0deee machine: insist in a valid root directory 2025-05-27 10:23:36 +02:00
Lennart Poettering 98fc46f2a6 logind,machined: expose bus properties for leader PID fd ids, too 2025-05-27 10:23:36 +02:00
Ivan Kruglov e3fee4519f core: break line after sd_json_buildo( in varlink-manager.c 2025-05-27 01:16:56 -07:00
Ivan Kruglov dd14c3eab1 test: simple tests for io.systemd.Unit varlink interface 2025-05-27 01:16:56 -07:00
Ivan Kruglov d2a8dbabf5 core: add basic lookup by name/pidref in io.systemd.Unit.List 2025-05-27 01:16:56 -07:00
Ivan Kruglov 2af33c3d1e json: add unit tests for json_dispatch_const_unit_name() 2025-05-27 01:16:56 -07:00
Ivan Kruglov 643622f850 json: json_dispatch_const_unit_name() 2025-05-27 01:16:56 -07:00
Ivan Kruglov c5ff8283b0 core: Unit Runtime in io.systemd.Unit.List method 2025-05-27 01:16:42 -07:00
Ivan Kruglov 472abf7bec core: skeleton for io.system.Unit interface and io.systemd.Unit.List method 2025-05-27 01:15:34 -07:00
Allison Karlitskaya eef63efcc3 repart: add 'fsverity' flag for CopyFiles= lines
We currently pass the CopyFlags that we use to populate the temporary
directory in the form of a constant at each of the copy_tree_at() call
sites.  De-duplicate that and move it into the `CopyFilesLine` struct,
initializing it from the parser.

Add our first non-constant flag: `fsverity=`.  This can be set to `off`
(the default) or `copy`, in which case we copy the fs-verity state from
the source files.

This arrangement is amenable to the introduction of more flags to
`CopyFiles=` lines, if we want to add them in the future.

Update the `repart.d(5)` manpage.

Closes #35352

Signed-off-by: Allison Karlitskaya <allison.karlitskaya@redhat.com>
2025-05-27 09:26:02 +02:00
Allison Karlitskaya 80f00d67ad repart: Collect CopyFiles= lines into structs
We currently convert the source:target pairs of the `CopyFiles=` lines
in `repart.d` files into a pairwise strv.  This works great if the only
thing that can be specified is a source and a target, but we're about to
add a flags field.

Let's start by making this a bit more explicit: we now turn each
`CopyFiles=` line into a `CopyFilesLine` struct.  We keep an array of
those in the `Partition` now, instead of the strv.

So far this is a whole lot of added complexity for nothing, but it's
necessary for the next step.

Signed-off-by: Allison Karlitskaya <allison.karlitskaya@redhat.com>
2025-05-27 09:26:02 +02:00
Allison Karlitskaya a46bb37710 mkfs-util: add fsverity option to make_filesystem()
Add an fsverity flag to MkfsFlags and use it to pass the `-O verity`
option when creating an ext4 or f2fs filesystem: they share the same
argument for this.

The only other filesystem that currently supports fs-verity is btrfs and
it doesn't require a flag to be enabled when creating the filesystem.

Nothing uses this yet.

Signed-off-by: Allison Karlitskaya <allison.karlitskaya@redhat.com>
2025-05-27 09:26:02 +02:00
Allison Karlitskaya d89283b48e mkfs-util: turn quiet/discard to a flags field
Add a new `MakeFilesystemFlags` enum and use it to replace the existing
`quiet` and `discard` booleans on `make_filesystem()`.

Update the callers.  While we're doing that, consolidate some duplicated
logic in systemd-repart.

Signed-off-by: Allison Karlitskaya <allison.karlitskaya@redhat.com>
2025-05-27 09:26:02 +02:00
Allison Karlitskaya c69598a3ab mkfs-util: rename a local variable
Change 'flags' to 'fork_flags' in preparation for using 'flags' as an
argument in the next commit.

Signed-off-by: Allison Karlitskaya <allison.karlitskaya@redhat.com>
2025-05-27 09:26:02 +02:00
Allison Karlitskaya fdc5f9e844 test: add a testcase for copy_tree() and fs-verity 2025-05-27 09:25:57 +02:00
Allison Karlitskaya 56a279a7f7 copy: add support for copying fs-verity status
Add a new member to CopyFlags to request copying of fs-verity status.

If copying of fs-verity is requested then we query the descriptor from
each regular file.  If it has one, we use it to setup fs-verity on the
destination, using the same parameters.

Signatures don't seem to be a particularly well-loved (or used) feature
of fs-verity and we don't bother to query them here.  Support for that
could be added later, if desired.

This change means that, with the correct combination of flags, we might
end up calling `fsync()` on a read-only file descriptor.  This is
permitted by POSIX and supported on Linux.

Nothing uses this yet.

Signed-off-by: Allison Karlitskaya <allison.karlitskaya@redhat.com>
2025-05-27 08:08:34 +02:00
Mike Yuan 7f436569c1 fs-util: prefer linkat(AT_EMPTY_PATH) over /proc/self/fd/ shenanigans
The permission check got relaxed in kernel v6.10, so let's
switch the fallback order around.

This also effectively reverts 94d94f0c0a,
as I just realized that link_fd() involves multiple paths and
we can't tell which one tripped ENOENT...
2025-05-27 12:19:22 +09:00
Yu Watanabe f67b2a06bf cgroup-util: drop handcrafted cg_is_empty(), always check cgroup.events populated field (#37624) 2025-05-27 10:41:56 +09:00
Lennart Poettering 5b759bf5fd homed: generate proper error if we cannot create mountpoint for homedir
Let's make this easier to debug. (When this failed for me due to disk
full it took me a bit to figure out what was going on.)
2025-05-27 10:10:03 +09:00
Yu Watanabe 5c606fb33e udevadm-info: update error messages (#37619) 2025-05-27 10:08:24 +09:00
Mike Yuan b823f7bb6a cgroup-util: remove now unused cg_read_event()
cg_get_keyed_attribute() is a more generic version of this,
and cg_is_empty_recursive() was the only user of this function,
which got converted in the previous commit.
2025-05-26 22:59:48 +02:00
Mike Yuan c3f900770d cgroup-util: drop handcrafted cg_is_empty(), always check cgroup.events populated field
This effectively renames cg_is_empty_recursive() to cg_is_empty().
Note that all existing code calls the former and not the latter,
hence with cgv1 support being dropped it's trivial to consult
cgroup.events directly for populated state everywhere.

Additionally, use more generic cg_get_keyed_attribute() helper
rather than cg_read_event().
2025-05-26 22:59:48 +02:00
Dusty Mabe bdd852a199 src/core/manager.c: log preset activity on first boot
This gives us a little more information about what units were enabled
or disabled on that first boot and will be useful for OS developers
tracking down the source of unit state.

An example with this enabled looks like:

```
NET: Registered PF_VSOCK protocol family
systemd[1]: Applying preset policy.
systemd[1]: Unit /etc/systemd/system/dnsmasq.service is masked, ignoring.
systemd[1]: Unit /etc/systemd/system/systemd-repart.service is masked, ignoring.
systemd[1]: Removed '/etc/systemd/system/sockets.target.wants/systemd-resolved-monitor.socket'.
systemd[1]: Removed '/etc/systemd/system/sockets.target.wants/systemd-resolved-varlink.socket'.
systemd[1]: Created symlink '/etc/systemd/system/multi-user.target.wants/var-mnt-workdir.mount' → '/etc/systemd/system/var-mnt-workdir.mount'.
systemd[1]: Created symlink '/etc/systemd/system/multi-user.target.wants/var-mnt-workdir\x2dtmp.mount' → '/etc/systemd/system/var-mnt-workdir\x2dtmp.mount'.
systemd[1]: Created symlink '/etc/systemd/system/afterburn-sshkeys.target.requires/afterburn-sshkeys@core.service' → '/usr/lib/systemd/system/afterburn-sshkeys@.service'.
systemd[1]: Created symlink '/etc/systemd/system/sockets.target.wants/systemd-resolved-varlink.socket' → '/usr/lib/systemd/system/systemd-resolved-varlink.socket'.
systemd[1]: Created symlink '/etc/systemd/system/sockets.target.wants/systemd-resolved-monitor.socket' → '/usr/lib/systemd/system/systemd-resolved-monitor.socket'.
systemd[1]: Populated /etc with preset unit settings.
```

Considering it only happens on first boot and not on every boot I think
the extra information is worth the extra verbosity in the logs just for
that boot.
2025-05-27 05:53:36 +09:00
Lennart Poettering 61d3133706 polkit: reword 'Interactive authentication required' error
I guess the current wording of "Interactive authentication required." is
hard to grok for many users. Let's try to reword this, and say
explicitly:

1. That this is a form of "access denied" error
2. That interactive auth could remedy this
3. But that the client disabled interactive auth

I think these are the three primary elements the error msg needs to
convey. I tried to distill this in a short error string with this.

Fixes: #2081
2025-05-27 05:52:38 +09:00
Mike Yuan 879952a853 core/cgroup: CGRuntime.cgroup_path indicates whether the cg is still alive
so drop redundant checks in attr getters. Memory and IO accounting
functions already follow this pattern.
2025-05-26 22:51:58 +02:00