Commit Graph
9756 Commits
Author SHA1 Message Date
Yu Watanabe d117687ab3 sd-bus: rename internal structs and enums
This renames e.g. struct bus_body_part -> BusMessageBodyPart to
follow our usual coding style. Also, several struct and enum
declarations are moved to relevant headers.
Also, this introduces bus-forward.h.
2025-05-28 09:52:28 +02:00
Mike Yuan d87f943596 bus-print-properties: drop *CPUShares formatter 2025-05-28 00:19:26 +02:00
Nick Rosbrook 906145d53f shared: add optional error parameter in bus_print_all_properties()
While here, remove the unused found_properties parameter.

This is preparation for another commit.
2025-05-28 04:40:08 +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
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 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 98fc46f2a6 logind,machined: expose bus properties for leader PID fd ids, too 2025-05-27 10:23:36 +02: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 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 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 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
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
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
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
Daan De Meyer f1ee656d4d tree-wide: Handle EINVAL as not supported for chattr_xxx()
F2FS returns EINVAL from FS_IOC_SETFLAGS when trying to set
FS_NOCOW_FL. Let's handle this by treating EINVAL as not supported.
While we're at it, make sure we use ERRNO_IS_IOCTL_NOT_SUPPORTED()
across the tree instead of ERRNO_IS_NOT_SUPPORTED() when calling any
of the chattr_xxx() functions.

Fixes #37593
2025-05-26 21:59:08 +02:00
Mike Yuan 180341e732 basic,shared: mark eligible functions with _pure_/_const_
Following the recent witch hunt done to static inline functions
I figure we should at least give the compiler some more hint
on optimizations.
2025-05-26 20:26:58 +02:00
Mike Yuan fae687ec2b shared/bitmap: minor modernizations 2025-05-26 20:24:47 +02:00
Daan De Meyer dbef7bcf29 shared: Followups for #37575 2025-05-25 03:28:50 +09:00
Jelle van der Waa 79d70bb282 killall: correct argument comment 2025-05-24 17:13:39 +02:00
Jelle van der Waa 03722d7120 tpm2-util: rename 'policy' -> 'pcrlock_policy'
Follow the used argument comment naming.
2025-05-24 17:13:39 +02:00
Jelle van der Waa d7bf63bcad creds-util: correct argument comment 2025-05-24 17:13:39 +02:00
Jelle van der Waa 457ce7d94a machine-id-setup: correct argument comments 2025-05-24 16:58:56 +02:00
Jelle van der Waa 3f0a9665d9 dissect-image: rename 'dest' -> 'where'
Consistently name dissect_image_mount*.
2025-05-24 16:58:55 +02:00
Daan De Meyer 69a283c5f2 shared: Clean up includes
Split out of #37344.
2025-05-24 14:00:44 +02:00
Mike Yuan 4108529d3e core: renames in io.systemd.Manager (#37582)
1. rename sources to follow `core/varlink-*` patter per @YHNdnzj's
comment in
https://github.com/systemd/systemd/pull/35098#issuecomment-2876509919
2. camelCase Context/Runtime in varlink spec. Varlink fields are
camelCase unless well defined config names.
2025-05-23 17:46:26 +02:00
Yu Watanabe 2c1cc93840 hostname: add hardware family, sku and version (#36956)
Add support for the hardware family, SKU (Stock-Keeping Unit) and
version. The values are read from the file /etc/machine-info or DMI as
fallback.

The entries are useful to provide an unified interface to collect detail
hardware information. The /etc/machine-info entries enable embedded
devices without UEFI support to provide the information via a common
interface.

Fixes: #31134
2025-05-23 23:17:01 +09:00
Ivan Kruglov 9ffa967413 core: lowercase Context/Runtime
Varlink fields are camelCase unless well defined config names.
2025-05-23 06:32:49 -07:00
Daan De Meyer 5ea01af240 meson: Use .inc for generated code meant to be included in other files
These files use the .h extension but are not standalone so let's not
make it appear like they are proper headers and instead use the .inc
extension.
2025-05-22 11:25:29 +02:00
Stefan Herbrechtsmeier 29a352e8c1 hostname: add hardware version
Add support for the hardware version. The version describes a distinct
version of compatibility hardware. The value is read from the file
/etc/machine-info or DMI as fallback.

The integration provides an unified interface to collect detail hardware
information. The /etc/machine-info entry enables embedded devices
without UEFI support to read the information from a custom store.
2025-05-22 09:00:14 +02:00
Stefan Herbrechtsmeier 79e9fb68a3 hostname: add hardware Stock-Keeping Unit
Add support for the hardware Stock-Keeping Unit (SKU). The SKU describes
a distinct type of hardware for sale, purchase or inventory management.
The value is read from the file /etc/machine-info or DMI as fallback.

The integration provides an unified interface to collect detail hardware
information. The /etc/machine-info entry enables embedded devices
without UEFI support to read the information from a custom store.
2025-05-22 09:00:14 +02:00
Daan De Meyer 54f3008a1e pretty-print: Add missing fileio.h include
LONG_LINE_MAX comes from fileio.h and is used in pretty-print.h so
pretty-print.h should include it.
2025-05-21 23:53:40 +09:00
Daan De Meyer cdd5fac068 tree-wide: Include <libaudit.h> via libaudit-util.h
Let's keep the ifdeffery for the include in one place.
2025-05-21 14:05:56 +02:00
Daan De Meyer 9f23910935 tests: Move implementation of DEFINE_HEX_PTR() into source file
Otherwise we have to add a hexdecoct.h include to tests.h which we
want to avoid.
2025-05-21 13:59:18 +02:00
Daan De Meyer 9f74f56f36 test-tables: Pass enum type to test_table() as well
clang-include-cleaner has a hard time figuring out unused includes
with all the macro string concatentation we're doing in test_table().
Let's help it out a little by also passing the enum type into test_table().

While technically not needed, this makes the tests a bit more self-descriptive
and not really much more verbose so it feels like a good chance regardless,
even if the primary purpose is to help clang-include-cleaner figure out
used and unused includes.
2025-05-21 13:24:42 +02:00
Yu Watanabe ef27ebab08 Clean up more includes (#37527)
Split out of #37344
2025-05-21 19:43:39 +09:00
Jelle van der Waa d0ae0e4f07 pretty-print: correct argument comment 2025-05-21 10:50:25 +02:00
Jelle van der Waa d8b9f67e67 treewide: fix header file definitions 2025-05-21 10:50:25 +02:00
Daan De Meyer 7a30bc9ad6 shared: Introduce conf-parser-forward.h
conf-parser.h pulls in a lot of other headers as needed by all the
macros it defines. We can't easily move the implementations of these
macro to conf-parser.c, so let's instead introduce conf-parser-forward.h
with just the stuff in it needed by other header files.

We'll make use of this when cleaning up includes to only include the
minimal parts of conf-parser.h that are required by other headers without
pulling in the kitchen sink.
2025-05-21 10:49:42 +02:00
Daan De Meyer fa34123c35 test: Clean up includes
To make sure everything still compiles, we add a preliminary include
of forward.h to tests.h to make sure it is included in every test source
file. We'll clean up the tests.h includes in a later commit.

We also add a <errno.h> include to errno-list.h to keep test-errno-list.c
compiling. It'll be removed again when we clean up includes in src/basic.

Split out of #37344.
2025-05-21 10:49:42 +02:00
Daan De Meyer 4cb9717bdc pcre2-util: Make sure PatternCompileCase enum is named 2025-05-21 10:37:18 +02:00
Daan De Meyer 1fda0f4cae Various meson improvements (#37510) 2025-05-20 13:44:33 +02:00
Luca Boccassi 6946eed3fa core: Also refresh confext extensions when reloading notify-reload service (#33995)
`ExtensionImages=` and `ExtensionDirectories=` now let you specify
vpick-named extensions; however, since they just get set up once when
the service is started, you can't see newer versions without restarting
the service entirely. Here, also reload confext extensions when you
reload a service. This allows you to deploy a new version of some
configuration and have it picked up at reload time without interruption
to your workload.

Right now, we would only reload confext extensions and leave the sysext
ones behind, since it didn't seem prudent to swap out what is likely
program code at reload. This is made possible by only going for the
`SYSTEMD_CONFEXT_HIERARCHIES` overlays (which only contains `/etc`).

This PR:
- Adjusts `service.c` to also refresh extensions when needed. 
- Adds integration tests to check that a confext reload actually
occurred.
- Adds to the `systemd.exec` man pages to document this behavior.

This is a follow up to #24864 and #31364. Thank you to @bluca and
@goenkam for help in getting this up.
2025-05-20 11:27:34 +01:00
Daan De Meyer d86fead481 meson: Rework clang-tidy integration to be done via unit tests
Instead of using run-clang-tidy.py with its own scheduling, let's
just gather a list of source files ourselves and then use that to
add a unit test for each source file that runs clang-tidy on the
source file.

We also add a bit of logic to run clang-tidy on most header files
as well for extra coverage. This uncovered various header files that
were not standalone so this commit also includes fixes to make sure
the clang-tidy tests are all green.

We can also use this in a later commit to run clang-include-cleaner
on each source file in the same way.
2025-05-20 10:29:59 +02:00
maia x.andLuca Boccassi dfdeb0b1cb core: reload confexts when reloading notify-reload services
`ExtensionImages=` and `ExtensionDirectories=` now let you specify
vpick-named extensions; however, since they just get set up once when
the service is started, you can't see newer versions without restarting
the service entirely.  Here, also reload confext extensions when you
reload a service. This allows you to deploy a new version of some
configuration and have it picked up at reload time without interruption
to your workload.

Right now, we would only reload confext extensions and leave the sysext
ones behind, since it didn't seem prudent to swap out what is likely
program code at reload. This is made possible by only going for the
`SYSTEMD_CONFEXT_HIERARCHIES` overlays (which only contains `/etc`).

Implementation wise, this uses the new kernel API and two collaborating
child processes under the host & child namespaces in order to gather the
right FDs needed:

  - (1) In child, set up the extension images and directories in a slave
	mountns, and obtain their FDs.
  - (2) Fork into a grandchild under target process namespace, and do a
        "fake" unmount to obtain the FD of the underlying target folder
	say /etc).
  - (3) In the child again, set up new overlay under host NS rights.

We do not want to do I/O heavy jobs inline in PID1 blocking the state
machine, so add separate async states to handle this case.

Co-authored-by: Luca Boccassi <luca.boccassi@gmail.com>
2025-05-19 13:36:21 +01:00