Commit Graph
1081 Commits
Author SHA1 Message Date
Frantisek Sumsal 90f5d2a202 tree-wide: various fixlets suggested by Coccinelle 2026-03-05 10:27:58 +01:00
Frantisek Sumsal a8335fb91f tree-wide: use typed SD_JSON_BUILD_PAIR_* macros more 2026-03-05 10:27:58 +01:00
Mike Yuan ab7d40ff0c machine-varlink: reference the right struct in VARLINK_DISPATCH_MACHINE_LOOKUP_FIELDS
This practically shouldn't matter, as the layout for name
and pidref fields are identical for all the structs. But
let's get things right.
2026-03-05 08:56:34 +01:00
Mike Yuan e8c542981b machine-dbus: do not check for overlapping condition
Follow-up for c5e48e3a66

This also makes things in line with the varlink method.
2026-03-04 14:32:46 +01:00
Mike Yuan a521abbf27 machined: move declaration of manager_object to machined-dbus.h 2026-03-04 14:32:16 +01:00
Mike Yuan 08e4cf491a various: make bus objects static 2026-03-04 14:32:16 +01:00
Luca Boccassi e5a5656b55 machined: do not allow unprivileged users to shell into the root namespace via varlink
Forbid non-root from shelling into a machine that is running in
the root user namespace.

Follow-up for adaff8eb35
2026-03-04 13:03:44 +00:00
Lennart Poettering ec718b44a1 machined: add comment explaining access to machine objects a bit 2026-03-03 20:01:09 +01:00
Yu Watanabe 4b4eba1666 tree-wide: use _contains() rather than _get()/_find() 2026-03-02 23:10:22 +09:00
Michael Vogt 8471eca549 machine: switch CleanPool to SD_VARLINK_REQUIRES_MORE
The CleanPool requires --more to be set and checks that in
`vl_method_clean_pool`. By switching to SD_VARLINK_REQUIRES_MORE
this will automatically be handled and is more clear to
the varlink users.

Based on the comment from Lennart in
https://github.com/systemd/systemd/pull/40650#discussion_r2832378002
and the work done by Mike in 09388a6b9e (thanks!).
2026-02-20 18:01:08 +01:00
Daan De Meyer b6bdd540f9 machine: Fix cid passed to machine_add_from_params()
The default value is VMADDR_CID_ANY, not zero.
2026-02-19 15:17:10 +01:00
Daan De Meyer db1689e69c machined: Skip root user namespace check for user managers
You can register whatever process you want in the user machined instance
that is running in the same namespace as pid 1 as machined won't be allowed
to do anything privileged anyway that could be dangerous when running as a user
instance.

We have to skip the check as we user machined instances don't have
privileges to inspect pid1's user namespaces.
2026-02-18 19:22:14 +01:00
Daan De Meyer 051d228b1c tree-wide: Add some extra debug logging 2026-02-16 09:37:32 +01:00
Daan De Meyer 4f5d44ef53 tree-wide: Migrate to varlink_set_sentinel() 2026-02-11 14:25:36 +01:00
Yu Watanabe 4481c9ff65 machine: skip reading properties through DBus when not connected
When machined is started earlier than DBus service, the execution is
blocked by reading properties through DBus for a while. Let's return
earlier if the DBus connection is not ready.

Fixes issue reported in #40414.
2026-01-31 01:23:26 +09:00
Daan De Meyer e901e256d9 machined: Don't insist on 0:0 for the state directory
We now support running machined unprivileged, so don't pass in 0:0
as the uid/gid unconditionally but just use the UID/GID we're running
as.
2026-01-12 19:08:00 +01:00
Kai Lueke fd8a1deb0b sysext: Get verity user certs from given --root=
The verity user certs weren't looked up in the given --root= for
systemd-sysext which made it fail to set up extensions with a strict
image policy.
Look up verity user certs from inside the --root= when we operate on
images in it. The main use case where this matters is when the initrd
sets up the extensions for the final system and thus systemd-sysext
should do the same thing as it would do in the final system.
2026-01-05 06:53:50 +09:00
Daan De Meyer aec52c1e6e string-table: Introduce DECLARE_STRING_TABLE_LOOKUP() and friends
Let's introduce these for the following two reasons:
- Using them makes sure the parameter names match between declaration
  and definition (if both use the corresponding macros).
- They make sure developers can't forget the _const_ and _pure_
  attributes for the declarations.

This commit also includes some include sorting fixes
2026-01-02 04:05:45 +09:00
Daan De Meyer f9708c53aa Follow ups for #39806
We drop the optimization for verify_sigchld as the
check differs based on the options passed and the
extra syscalls are certainly not going to matter
compared to the cost of forking a child process.

Fixes #40166
2025-12-21 08:16:03 +01:00
Daan De Meyer 29d1df4b03 tree-wide: Remove unnecessary SIGCHLD blocking
Now that sd-event doesn't insist on blocking
SIGCHLD anymore when watching for process exit,
let's stop blocking SIGCHLD tree-wide where not
required anymore.
2025-12-20 15:50:47 +01:00
Daan De Meyer fbd276cb86 tree-wide: Use pidref_wait_for_terminate_and_check()
Let's use the pidref variants for waiting and
checking a process everywhere and get rid of the
non pidref variants.
2025-12-20 15:50:47 +01:00
Daan De MeyerandMike Yuan 8c007f68ff process-util: Migrate namespace_fork() to PidRef
Co-authored-by: Mike Yuan <me@yhndnzj.com>
2025-12-20 13:45:22 +01:00
Yu Watanabe 93378148d4 tree-wide: normalize comment style 2025-12-15 08:50:13 +09:00
Daan De Meyer 1075316a4b machine: Fix hardcoded /var/lib/machines paths 2025-12-08 14:56:39 +01:00
Zbigniew Jędrzejewski-Szmek 12391431c2 machined: add description to varlink server, unify error messages
manager_varlink_init_resolve_hook and manager_varlink_init_userdb are very
similar, but one didn't set a description and the other one had an error
message which didn't print the offending path.

Define constants for the paths, and also change other similar constants
to have slightly shorter names. (It's an "address" and "path", but we don't
need to have both parts in the name, esp. that it makes the name very long.)
2025-12-05 12:17:06 +01:00
Lennart Poettering 722dc73699 machined: in --user mode, restrict register access to our own UID, and that's it
This is a follow-up for 119d332d9c and
ensures the check only is applied to the system instance of machined. It
doesn't really apply to the per-user instance, because we never want to
permit differently privileged clients access anyway.

(The process_is_owned_by_uid() call might fail if invoked unpriv, hence
there's value in not calling it if machined runs in --user mode, it's
what makes machined actually work)
2025-12-02 13:34:20 +09:00
Daan De Meyer 6a9f0641cd tree-wide: Fix declaration/definition parameter name mismatches 2025-11-26 19:02:31 +09:00
Yu Watanabe caf7cb2737 SD_JSON_BUILD_PAIR() conversions with coccinelle script (#39858) 2025-11-26 16:35:35 +09:00
Daan De Meyer 9a6a8f35eb tree-wide: Small fixes for various clang-tidy warnings 2025-11-26 16:22:00 +09:00
Jelle van der Waa c12966c14f treewide: prefer using SD_JSON_BUILD_PAIR_* over SD_JSON_BUILD_PAIR()
Include a coccinelle script that patches this automatically.
2025-11-24 21:05:10 +01:00
Daan De Meyer 87fbd33372 clang-tidy: Fix all remaining misc-include-cleaner violations
- Remove unused includes
- Add common false positive headers to misc-include-cleaner.IgnoreHeaders
- Add IWYU pragma keep for uncommon false positive headers
2025-11-22 10:19:41 +01:00
Zbigniew Jędrzejewski-Szmek 5220bb8c3f meson: automatically add 'extract' to 'sources'
In all cases, everything that we list in 'extract', we also list in
'sources'. We can simplify things by automatically appending the first
list to the second.

In the listings, move 'extract' key right below 'sources', since now
they are both "sources", just with slightly different meanings.
2025-11-20 10:03:48 +09:00
Yu Watanabe a8156588fa cgroup-util: drop 'controller' argument from cg_get_path()
The argument is not used anymore. Let's drop it.
2025-11-17 21:31:50 +09:00
Yu Watanabe 5d397dc7f4 cgroup-util: drop 'controller' argument from cg_get_keyed_attribute() and cg_is_empty()
The argument is completely unused. Let's drop it.
2025-11-17 21:31:50 +09:00
Yu Watanabe b525a72f7b cgroup-util: drop cgroup v1 support from cg_pid_get_path()
We have dropped cgroup v1 support in v258. Let's drop legacy code.
Then, we can drop 'controller' argument from cg_pid_get_path() and
cg_pidref_get_path().
2025-11-17 21:30:29 +09:00
Yu Watanabe 5169b1c5a7 cgroup-show: drop 'controller' argument from show_cgroup() and show_cgroup_and_extra()
Nowadays these always take SYSTEMD_CGROUP_CONTROLLER as controller.
Let's drop it.

No functional change, just refactoring.
2025-11-17 21:30:29 +09:00
Lennart Poettering 3cd929f837 machined: implement resolve hook in machined
This basically implements nss-myhostname, but natively in
systemd-resolved, so that the logic becomes available also for clients
using the local DNS stub for resolution or the D-Bus or Varlink APIs.
2025-11-15 07:44:24 +01:00
Lennart Poettering 594352611b machine: minor refactoring, making machine_send_signal() invocations more readable 2025-11-15 07:44:24 +01:00
Luca Boccassi 555d878749 varlink: say which socket failed to bind in log message
Makes it a lot easier to debug failures
2025-11-15 10:02:10 +09:00
Yu Watanabe 7829c9cc48 discover-image: introduce bus_property_get_image_is_read_only() with BUS_DEFINE_PROPERTY_GET() macro
This also makes image_is_read_only() return bool.

Follow-up for ee327e086e.
2025-11-01 18:11:18 +09: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
Daan De Meyer b8ee7c2206 tree-wide: Various forward header cleanups
- Make sure forward headers have the iwyu pragma to always keep them
- Make sure we always include the daemon specific forward header
  instead of shared-forward.h
- Remove shared-forward.h include where the daemon specific forward
  header is already included
2025-10-17 21:11:23 +09:00
Daan De Meyer f102bc3e5f tree-wide: Introduce sd-forward.h and shared-forward.h headers
Let's not leak details from src/shared and src/libsystemd into
src/basic, even though you can't actually do anything useful with
just forward declarations from src/shared.

The sd-forward.h header is put in src/libsystemd/sd-common as we
don't have a directory for shared internal headers for libsystemd
yet.

Let's also rename forward.h to basic-forward.h to keep things
self-explanatory.
2025-10-16 17:00:29 +02:00
Luca Boccassi de2276cdcd Revert "machine: restrict register-machine action again"
Now that we have landed several fixes, this should be safe to do
again, so allow logged in users to register machines without
authentication prompts

This reverts commit 65badde82e.
2025-10-15 12:02:34 +02:00
David Tardon 188049d38c tree-wide: combine DUMP_STRING_TABLE() and return 2025-10-02 16:19:03 +02:00
Lennart Poettering d9c5566c0f machined: make image locking runtime scope aware, too
We cannot create an image lock in /run if we are unpriv, hence create it
in $XDG_RUNTIME_DIR instead.
2025-09-25 22:43:59 +02:00
Lennart Poettering 1966baf2d6 machinectl: add support for user-scoped operation 2025-09-25 22:43:59 +02:00
Lennart Poettering f5fa86f9f8 machined: allow running in --user mode 2025-09-25 22:43:59 +02:00
Lennart Poettering e1b3319b6c discover-image: support runtime scope also for .nspawn settings files and the pool dir
discover-image.[ch] largely already supports per-scope operations, let's
extend this however to also cover finding .nspawn settings files and
managing the pool dir.
2025-09-25 22:43:59 +02:00
Lennart Poettering b7f6bdbbd3 service-util: add generic parser for runtime scope 2025-09-25 22:43:59 +02:00