1
0
mirror of https://github.com/systemd/systemd.git synced 2025-02-18 21:57:48 +03:00

51428 Commits

Author SHA1 Message Date
Yu Watanabe
b950a8acd8
Merge pull request #34720 from YHNdnzj/extra-fds-followup
core: several follow-ups for ExtraFileDescriptors
2024-10-12 04:46:51 +09:00
Daan De Meyer
8b8668b9e7 systemd-update-helper: Show executed commands if debug logging is enabled 2024-10-11 19:30:04 +01:00
Mike Yuan
8e66f42b06
core/service: add missing serialization for extra fds 2024-10-11 18:22:24 +02:00
Mike Yuan
32af4dd80f
core/service: use array rather than list for extra fds, limit max number
Follow-up for 3543456f84ec2e83e07b6c9bf2b3a1c5d30241d8

I don't think list is particularly useful here. The passed fds are
constant for the lifetime of service, and with this commit we track
the number of extra fds in a dedicated var anyway.
2024-10-11 18:22:19 +02:00
Mike Yuan
6286f213f5
core/service: use LIST_HEAD where appropriate 2024-10-11 18:21:09 +02:00
Mike Yuan
407bfa0db6
time-util: use saturate_add for usec_add() 2024-10-11 18:21:09 +02:00
Lennart Poettering
d00dd3d3c0
Merge pull request #34717 from anonymix007/fundamental-boot-changes
Fundamental and boot changes for multi-dt UKIs
2024-10-11 17:55:06 +02:00
Mike Yuan
8c9c8e304e
shared/bus-util: re-break comment, insert missing newline before case
Follow-up for a178ffdfcd9d25886a6e563a0fbd9929852e85c4
2024-10-11 15:30:04 +02:00
Daan De Meyer
051441e559
Merge pull request #34686 from DaanDeMeyer/bus-fallback
Make sure bus_connect_transport_systemd() actually connects to the private manager bus
2024-10-11 15:16:54 +02:00
anonymix007
33af044178 fundamental: Add EFI_GUID userspace definition 2024-10-11 15:23:54 +03:00
anonymix007
beb41e3948 boot: Add log_info and log_debug 2024-10-11 15:23:54 +03:00
anonymix007
4ef4781ff8 boot: Add smbios_populate_raw_info
This function will be used to gather information for DeviceTree matching
2024-10-11 15:23:54 +03:00
anonymix007
dd6a37e335 boot: Move smbios-related functions to a separate file 2024-10-11 15:23:53 +03:00
anonymix007
1fcdf22573 boot: Add xcalloc and xcalloc_multiply 2024-10-11 14:37:30 +03:00
anonymix007
5faaac27fd boot: Add EFI_STATUS_IS_ERROR macro 2024-10-11 14:37:30 +03:00
anonymix007
53443e8176 boot: Add bswap_{16,32} 2024-10-11 14:37:30 +03:00
anonymix007
60c75a2a41 boot: Add be32toh 2024-10-11 14:37:30 +03:00
Lennart Poettering
8caae05174
Merge pull request #34718 from poettering/efi-smbios-tweak
efi: minor tweaks to smbios parsing
2024-10-11 13:34:13 +02:00
Lennart Poettering
1fef1773c0
Merge pull request #34703 from poettering/pidref-varlink
Serialize "PidRef" in a reasonable way in Varlink interfaces
2024-10-11 13:33:44 +02:00
Lennart Poettering
373c810e04
Merge pull request #34681 from ikruglov/ikruglov/io-systemd-Machine-post-merge-review
machine: address post-merge review #34623
2024-10-11 12:15:56 +02:00
Lennart Poettering
d693c483a2 seccomp: allowlist uretprobe() syscall
This is a new syscall provided by the kernel used to implement faster
uprobes. It's not supposed to be called by userspace, but only by kernel
generated uprobe code.

It should be fine to allow this, as the kernel authenticates the
invocation itself, and we shouldn't break compat with things.

Note that this allowlisting is not sufficient to make ureprobe() work.
libseccomp must be tought the syscall too, but this can happen
independently.

Fixes: #34615
2024-10-11 11:57:40 +02:00
Lennart Poettering
62f0d851a8 smbios: make code more readable by introducing a "limit" pointer 2024-10-11 11:54:04 +02:00
Lennart Poettering
b7c544c759 smbios: move validation of SMBIOS table sizes fully into get_smbios_table()
We do half a validation currently ourselves (i.e. check the header fits
into the rest of the data), and leave the other half to the
caller (i.e. check the table fits into the rest of the data).

get_smbios_table() is changed to accept the minimum object size and
validates it before returning a table.

Based on a discussion with @anonymix007.
2024-10-11 11:54:02 +02:00
Daan De Meyer
d94e85c227 stdio-bridge: Use customized log message for forwarding bus
Let's more clearly indicate that we failed to set up the server
which forwards messages from the remote client to the local bus
instead of logging a generic bus client message.
2024-10-11 11:35:02 +02:00
Daan De Meyer
b066b68353 stdio-bridge: Use bus_log_connect_error() 2024-10-11 11:35:02 +02:00
Daan De Meyer
a178ffdfcd bus-util: Move geteuid() check out of bus_connect_system_systemd()
Let's move this check to bus_connect_transport_systemd() so that
bus_connect_system_systemd() will only ever connect to the manager
private manager bus instance and fail otherwise.
2024-10-11 11:35:02 +02:00
Daan De Meyer
a339495b1d bus-util: Drop fallback to system/user bus if manager bus doesn't work
We have various callsites that explicitly need the manager bus and
won't work with the system bus, like daemon-reexec and friends which
can't properly wait until the operation has finished unless using the
manager bus.

If we silently fall back to the system bus for these operations, we
can end up with rather hard to debug issues so let's remove the fallback
as it was added back in 2013 in a6aa89122d2fa5e811a72200773068c13bfffea2
without a clear explanation of why it was needed (I expect as a fallback
if kdbus wasn't available but that's not a thing anymore these days).
2024-10-11 11:35:02 +02:00
Daan De Meyer
ec9fd0d4f5 update-utmp: Make reconnect logic more robust
We might also fail to connect to the private manager bus itself if
the daemon-reexec is still ongoing, so let's handle that as well by
retrying on ECONNREFUSED.
2024-10-11 11:35:02 +02:00
Lennart Poettering
755cb018c9 machined: also take new ProcessId structure when registering processes 2024-10-11 10:48:07 +02:00
Lennart Poettering
0fc530d157 machined: make List() varlink method return a full pidref JSON object for leader
This new call has not been released yet, hence we can still change the
encoding of the "leader" field.
2024-10-11 10:48:07 +02:00
Lennart Poettering
1eb8a560a6 json: add builder/dispatcher for PidRef → JSON and back
So far, at the one place we sent a PID over Varlink we did so as a
simple numeric pid_t value. That's of course is racy, since classic PIDs
are recycled too eagerly.

Let's address that, by passing around JSON objects distantly resembling our
PidRef structure. Note that this JSON object does *not* contain the
pidfd, however, but just the pidfd inode number if known.

I originally planned to include the pidfd in some direct form, but I
figured that's not really the best idea, since we always need a
side-channel of some form for that (i.e. AF_UNIX/SCM_RIGHTS), but we
should be able to report about PIDs even without that.

Moreover, while sending the pid number and pidfd id around should always
be OK to do, it's a lot more problematic to always send a pidfd around,
since that implies that fd passing is on and it is OK to install fds
remotely in some IPC peers fd table. For example, when doing a wild dump
of service manager service state we really shouldn't end up with a bunch
of fds installed in our client's fd table.

Hence, all in all I think it is cleaner to define a structure carrying
pid number and pidfd inode id, wich is passed directly as JSON. And then
optionally, in a separate field also pass around a pidfd where it makes
sense.

Note that sending around pidfds is not that beneficial anymore if we
have the pidfd inode id, because we can always securely and reliably get
a pidfd back from a pair of pid + inode id: first we do pidfd_open() on
the pid, and then we check if it is really the right one by comparing
.st_ino after fstat().

This logic is implemented gracefully: if for some reason pidfd/pidfd
inode nrs are not available (too old kernel), we'll fall back to plain
PID numbers.

The dispatching logic knows two distinct levels of validation of the
provided PID data: if SD_JSON_STRICT is specified we'll acquire a pidfd
for the PID, thus verifying it currently exists and failing if it
doesn't. If the flag is not set, well just store the provided info
as-is, will try to acquire a pidfd for it, but not fail if we cannot.
Both modes are important in different contexts.

Also note that in addition to the pidfd inode nr we always store the
current boot ID of the system in the JSON object, since only the
combination of pidfd inode nr and boot ID of the system really is a
world-wide unique reference to a process.

When dispatching a JSON pid field we operate somewhat gracefully: we
either support the triplet structure of pid, pid inode nr, boot id, or
we accept a simple classic UNIX pid.
2024-10-11 10:48:07 +02:00
Lennart Poettering
47bbcfff06 varlink-idl: introduce c/.h file for common varlink IDL structures
Some structures we'll use in various varlink interfaces, move them to a
common .c/.h file. For now this is only the dual timestamp object, but
there will be more soon.
2024-10-11 10:41:06 +02:00
Lennart Poettering
44fd4548b5 macro: add voffsetof() helper, that operates like offsetof() but on variables 2024-10-11 10:41:06 +02:00
Lennart Poettering
b71ac3e509 test: also dump varlink IDL for Machine interface in the test 2024-10-11 10:41:06 +02:00
Daan De Meyer
2d0af8bc35 rpm/systemd-update-helper: Use systemctl reload to reexec/reload user managers
Let's always use systemctl reload to reexec and reload user managers
now that it always implies a reexec. This moves all the job management
logic to pid 1 instead of bash and reduces the complexity of the logic
as we remove systemd-run, pam and systemd-stdio-bridge from the equation.
2024-10-11 10:36:08 +02:00
Mike Yuan
155098a702 core/manager-serialize: drop serialization for Manager.ready_sent
This field indicates whether READY=1 has been sent to
the service manager/supervisor. Whenever we reload/reexec/soft-reboot,
manager_send_reloading() always resets it to false first,
so that READY=1 is sent after reloading finishes. Hence
we utterly get "false" at all times. Kill it.
2024-10-11 10:36:08 +02:00
Mike Yuan
da81a10865 core/manager: still send out STATUS=Ready for user manager
This effectively reverts 37d15cd132f3a8a0bf42fb252c1604e804171ff2.

The offending commit wrongly assumed that the second READY=1
notification is for system scope only, but it also serves the purpose
of flushing out previous STATUS= containing user unit job status.
2024-10-11 10:36:05 +02:00
Yu Watanabe
ba8d48be64 sd-netlink: introduce two more _get_family()
Then, use them in sd_rtnl_message_get_family().
2024-10-11 02:53:00 +09:00
Yu Watanabe
9b8cb789dd sd-netlink,network: rename functions and RoutingPolicyRule.type
To make them consistent to the netlink message header.
No functional change, just refactoring.
2024-10-11 02:52:58 +09:00
Yu Watanabe
2bc1d78345 sd-netlink: introduce macros to define sd_rtnl_message setters and getters 2024-10-11 02:52:26 +09:00
Yu Watanabe
2fcaeaaaf6 sd-netlink: make size verifier in sd_netlink_message_read_xyz() stricter
Also, fill remaining output buffer with zero, for safety.
2024-10-11 02:38:16 +09:00
Yu Watanabe
768237e73a sd-netlink: shorten sd_netlink_message_read_string_strdup() a bit 2024-10-11 02:38:16 +09:00
Yu Watanabe
ae298c938b sd-netlink: various cleanups
- use uint8_t, uint16_t, and so on, rather than unsigned char, unsigned
  short, and so on, respectively,
- rename output parameters to ret or ret_xyz,
- add several missing assertions.
2024-10-11 02:38:16 +09:00
Jörg Behrmann
e9984357ad ukify: Fix systemd-measure detection in tests
Fixes: 206fa93c854e3d5c94e56da9b53e107245f31503
2024-10-10 15:59:33 +02:00
Ivan Kruglov
d8aefe88c8 machine: use sd_json_dispatch_pid() in varlink code 2024-10-10 13:40:45 +02:00
Ivan Kruglov
dafd44de4f sd-json: add sd_json_dispatch_pid() 2024-10-10 13:40:45 +02:00
Ivan Kruglov
f6cb4d4afb machine: switch to use PidRef when lookup machine by pid in dbus and varlink interfaces
This commit includes adding introduce manager_get_machine_by_pidref() as a replacement for manager_get_machine_by_pid()
and moving surrounding code to utilise PidRef.
2024-10-10 13:40:45 +02:00
Ivan Kruglov
45a20e41df machine: use sd_json_dispatch_signal() in varlink code 2024-10-10 13:40:45 +02:00
Ivan Kruglov
729fbe78df sd-json: add sd_json_dispatch_signal() 2024-10-10 13:40:45 +02:00
Ivan Kruglov
18897460cf machine: remove redundant else if lookup_machine_by_name_or_pid() 2024-10-10 12:34:45 +02:00