Commit Graph

844 Commits

Author SHA1 Message Date
Lennart Poettering
25ff515b39 sd-varlink: make our internal Varlink API public as sd-varlink.[ch]
It's time. sd-json was already done earlier in this cycle, let's now
make sd-varlink public too.

This is mostly just a search/replace job of epical proportions.

I left some functions internal (mostly IDL handling), and I turned some
static inline calls into regular calls.
2024-07-16 11:57:32 +02:00
Zbigniew Jędrzejewski-Szmek
28f1f1a5e6 Drop support for nscd
nscd is known to be racy [1] and it was already deprecated and later dropped in
Fedora a while back [1,2]. We don't need to support obsolete stuff in systemd,
and the cache in systemd-resolved provides a better solution anyway.

We announced the plan to drop nscd in d44934f378.

[1] https://fedoraproject.org/wiki/Changes/DeprecateNSCD
[2] https://fedoraproject.org/wiki/Changes/RemoveNSCD

The option is kept as a stub without any effect to make the transition easier.
2024-06-28 18:51:56 +02:00
Luca Boccassi
8e6d95846b Merge pull request #33491 from keszybz/allow-interactive-auth-in-inhibit
Allow interactive auth in inhibit
2024-06-26 23:01:22 +02:00
Zbigniew Jędrzejewski-Szmek
a8c3ed5f13 Rename spawn-ask-password-agent.c to just ask-password-agent.c
The functions in the file were *not* using the spawn prefix,
and the prefix seems completely unnecessary.
2024-06-26 15:04:06 +02:00
Zbigniew Jędrzejewski-Szmek
1b919ca4db Rename spawn-polkit-agent.c to just polkit-agent.c
The functions in the file were *not* using the spawn prefix,
and the prefix seems completely unnecessary.
2024-06-26 15:04:06 +02:00
Luca Boccassi
f8f06462e5 Merge pull request #33042 from poettering/machined-unpriv
machined: unprivileged machine registration
2024-06-24 20:45:37 +02:00
Lennart Poettering
f98e821cda machined: support allocating a scope for machines if needed via varlink
On dbus we have two apis: one for registering a new machne when the
client already has a cgroup (RegisterMachine()) and one where it doesn't
and machined shall create it (CreateMachine()).

Let's add the same for the varlink api. To simplify things we just
implement it via a boolean flag to the existign RegisterMachine()
varlink call, since the differences are mostly minor otherwise.
2024-06-21 17:38:23 +02:00
Lennart Poettering
38a7666df3 machined: allow unprivileged registration of VMs/containers
Now that we have a concept of unprivileged VMs and containers, let's
allow unprivileged clients to register with machined too – subject to
Polkit permissions.
2024-06-21 17:38:23 +02:00
Lennart Poettering
1c7642a3b7 machined: add simple varlink API for listing machines 2024-06-21 17:28:16 +02:00
Lennart Poettering
1762c2c045 machined: watch leader PID's lifetime via pidfd
If we have a pidfd, we might as well track the machine's leader PID's
lifetime, and enqueue the machine for a GC run.

(This is similar to what we are already doing for logind's session
leaders)
2024-06-20 22:51:24 +02:00
Lennart Poettering
9b27811d49 machined: GC machines during runtime too
One major omission in machine's logic so far was that the GC was only
run at startup and on the check-idle timeout, which is really slow.

Let's make this more like the GC logic in homed or logind: make sure we
run it in a close-by event loop cycle.
2024-06-20 22:49:57 +02:00
Lennart Poettering
be5bee2a13 tree-wide: port over to new builder apis 2024-06-19 22:50:02 +02:00
Zbigniew Jędrzejewski-Szmek
ff3f29537c various: move ptr indicator to return value 2024-06-19 16:37:12 +02:00
Zbigniew Jędrzejewski-Szmek
bfd5a0687f various: move const ptr indicator to return value 2024-06-19 16:28:28 +02:00
Zbigniew Jędrzejewski-Szmek
cd2fb04960 Fix confusion between killer and prey
"who" is the entity doing the killing, "whom" is the target.
Follow-up for 4ccde410a3.
2024-06-19 16:22:23 +02:00
Lennart Poettering
4db747b0dd machined: use bus_message_read_id128() at one more place 2024-06-15 01:19:31 +01:00
Luca Boccassi
78fb0ca46d Merge pull request #33325 from poettering/vsock-ret-optional
socket-util: make return parameter for socket_address_parse_vsock() o…
2024-06-15 00:45:28 +01:00
Lennart Poettering
0870654241 machined: use pidref instead of just pid when determining unit of pid when registering machine 2024-06-14 13:26:30 +02:00
Lennart Poettering
92a6f21484 machined: prefer pinning clients via pidfd when creating machine, rather than PID 2024-06-14 13:26:30 +02:00
Lennart Poettering
4198ff4c6a machined: modernize method_create_or_register_machine() return parameter naming 2024-06-14 13:24:52 +02:00
Lennart Poettering
cb869969d1 machined: initialize CID of '.host' pseudo-machine to 1 (i.e. the loopback vsock address) 2024-06-14 11:13:36 +02:00
Lennart Poettering
d3be2a75ae sd-json: rename SD_JSON_SAFE → SD_JSON_STRICT
The flag is fairly generic these days and just selects a slightly
stricter validation, with details depending on the selected dispatch
function. Hence, let's give it more precise name, in particular one that
mirrors the SD_JSON_RELAXED flag nicely (which does the opposite:
relaxes parsing)
2024-06-12 18:42:44 +02:00
Lennart Poettering
309a747fa6 libsystemd: turn json.[ch] into a public API
This is preparation for making our Varlink API a public API. Since our
Varlink API is built on top of our JSON API we need to make that public
first (it's a nice API, but JSON APIs there are already enough, this is
purely about the Varlink angle).

I made most of the json.h APIs public, and just placed them in
sd-json.h. Sometimes I wasn't so sure however, since the underlying data
structures would have to be made public too. If in doubt I didn#t risk
it, and moved the relevant API to src/libsystemd/sd-json/json-util.h
instead (without any sd_* symbol prefixes).

This is mostly a giant search/replace patch.
2024-06-12 18:42:22 +02:00
Lennart Poettering
f2eb7716d0 json: merge json_dispatch_path() + json_dispatch_absolute_path()
The functions more or less do the same thing. Merge them.

This makes json_dispatch_path() the common resulting implementation. it
learnt:

1. Will reset the path to NULL if specified as null in JSON
2. Depending on the JSON_SAFE flag will insist on normalized path or not

With this the two implementations are identical, except for the
differences now toggable via JSON_SAFE flag
2024-06-12 18:39:03 +02:00
Lennart Poettering
ec8bbd8adb tree-wide: never consider service idle if polkit authentication is still pending
Let's be correct on this.
2024-06-11 23:17:38 +01:00
Lennart Poettering
7c1a1aa42c machined: downgrade warning if we cannot drop ref to systemd unit if disconnected from bus
if machined exits while a machine is still running, we'll issue the
UnrefUnit() call on the unit. This quite likely will fail if during
shutdown the bus connection is already down. But that's no reason to
warn at all, since the ref count will implicitly be dropped if our side
disappears from the bus. Hence, downgrade to LOG_DEBUG in case of
connection problems.
2024-05-28 15:05:11 +02:00
Yu Watanabe
3b1b2d4e3d machine: fix use-after-free in Rename() DBus method
Fixes a bug introduced by 1ddb263d21.

Note, this requires the previous two commits, and cannot backport without them.

Note, before the previous commit, the use-after-free could be triggered
only by Rename() DBus method, and could not by RenameImage(), as we did not
cache Image object when RenameImage() method is called. And machinectl
always uses RenameImage(). Hence, the issue could be triggered only when
Rename() DBus method is explicitly called by e.g. busctl.

With the previous commit, the Image object passed to the function is
always cached. Hence, the issue could be triggered even with machinectl
command, and this fix is important.
2024-05-20 01:03:14 +09:00
Yu Watanabe
c6aeb9b596 machine: also acquire Image object from cache when a dbus method in the main interface is called
Previously, Image objects were only cached when reading properties or
methods in the org.freedesktop.machine1.Image interface are called.

This makes that, when a method in the main interface (org.freedesktop.machine1)
for an image is called, also acquire the Image object from the cache,
and if not cached, create Image object and put into the cache, like we
do for org.freedesktop.machine1.Image.

Otherwise, if some properties of an image are updated by methods in the main
interface, e.g. MarkImageReadOnly(), the changes do not applied to the cached
Image object, and subsequent read of proerties through the interface for the
image, e.g. ReadOnly property, may provide outdated values.

Follow-up for 1ddb263d21.

Fixes #32888.
2024-05-20 01:03:14 +09:00
Yu Watanabe
6d917da140 machine: split out manager_acquire_image() from image_object_find()
Preparation for the next commit. No functional change.
2024-05-20 01:03:14 +09:00
Lennart Poettering
ddbfc4d17e machined: return recognizable error when we try to register the same machine name twice 2024-05-13 12:25:22 -06:00
Lennart Poettering
13d6c5de41 varlink: rename vsockCid → vSockCid field 2024-05-14 00:49:45 +08:00
Yu Watanabe
8ac0810f6c logs-show: drop uid argument from add_matches_for_user_units()
It is always equivalent to getuid(). Let's call getuid() in the
function instead.
2024-05-10 09:35:24 +09:00
Sam Leonard
5b44c81ff8 machined: add varlink interface for registering machines
This commit adds the new varlink interface io.systemd.Machine at
/run/systemd/machine/io.systemd.Machine with a single method Register

It supports all combinations of RegisterMachine[WithSSH,WithNetwork] all
under the same method.
2024-05-08 11:54:31 +01:00
Sam Leonard
1f815bf164 machined: add GetMachineSSHInfo method
Also adds three properties:
- VsockCid: the VSOCK CID of the VM
- SshAddress: the address of the VM in a format SSH can connect to
- SshPrivateKeyPath: the path to the SSH private key to use to connect
  to the VM.

GetMachineSSHInfo is essentially a convenience method to query both the
SshAddress and SshPrivateKeyPath properties at once.
2024-05-08 09:56:42 +01:00
Sam Leonard
885317f1ab machined: split manager linking out of machine_new into machine_link 2024-05-08 09:52:15 +01:00
Sam Leonard
71a15f37af machined: expose machine_freep in machine.h 2024-05-08 09:52:15 +01:00
Daan De Meyer
132f6cfcfe machine: Add PIDFDs= fallback
In some environments, systemd-machined might not be restarted on
downgrade. For safety, let's add the usual PIDFDs= fallback here
as well.
2024-04-29 22:56:49 +02:00
Sam Leonard
c9e89db860 machined: fix invalid edge case in machine_new 2024-04-22 22:37:05 +02:00
Mike Yuan
8e1a1caa9c Merge pull request #31886 from DaanDeMeyer/logind
logind: Add fallback for when the PIDFDs= property is not available
2024-03-24 19:19:12 +08:00
Daan De Meyer
66b574b0a2 tree-wide: Add allow_pidfd argument to bus_append_scope_pidref() 2024-03-22 17:03:35 +01:00
Mike Yuan
7312b0397c machinectl: minor modernization, use FOREACH_ARRAY
Prompted by 237bbec117
2024-03-22 01:54:31 +08:00
Zbigniew Jędrzejewski-Szmek
237bbec117 machinectl: use strdup_to() and move cleanup out of the loop
It doesn't matter much, but it seems nicer to call va_end() just
once.
2024-03-20 15:18:21 +01:00
Matteo Croce
3fc72d5413 dynamically load compression libraries
Dynamically load liblz4, libzstd and liblzma with dlopen().
This helps to reduce the size of the initrd image when these libraries
are not really needed.
2024-03-05 12:37:21 +01:00
Zbigniew Jędrzejewski-Szmek
c5c619502b machinectl: add -P 2024-03-04 16:12:23 +04:00
Lennart Poettering
0068131bf5 Merge pull request #31507 from poettering/import-modernize
importd: various modernizations
2024-03-01 23:42:32 +01:00
Lennart Poettering
8157cc0e3e bus-util: add generic parser for extracting id128 values from bus messages 2024-03-01 22:37:38 +01:00
Lennart Poettering
8ce438bb71 machinectl: chainload importctl for relevant verbs
Now that "importctl" exists, let's chainload it from machinectl for the
relevant verbs so that we only have a single implementation of the
logic.
2024-03-01 22:25:42 +01:00
Lennart Poettering
3c1053ff27 machinectl: mention -V in --help text
Follow-up for f82dcc3fc3
2024-03-01 22:24:19 +01:00
Sam Leonard
f82dcc3fc3 machinectl: support vmspawn as a backend 2024-02-28 17:49:00 +00:00
Lennart Poettering
db7136ec73 signal-util: imply sentinel -1 in sigprocmask_many() + sigset_add_many() args list 2024-02-23 09:35:12 -08:00