1
0
mirror of https://github.com/systemd/systemd.git synced 2025-01-20 18:04:03 +03:00

70698 Commits

Author SHA1 Message Date
Lennart Poettering
9d2a292246 test: add integration test for Type=exec robustness
This tests for #30799, so that it does not return.
2024-01-19 16:51:55 +01:00
Lennart Poettering
8a69bf0c57 manager: order idle jobs
Let's put the run queue really the last spot, as we should only start
doing more work if we really have nothing else to do anymore.

Let's move the service watchdog after the rewatch PID logic for similar
logic: it will possibly result in new jobs being enqueued to stop
things, and we should really have done all other work first.
2024-01-19 16:46:28 +01:00
Lennart Poettering
90c40ea4bf manager: renumber priorities
no actual change, let's just make sure the priorities are densely
defined without "holes". Just to make this prettier and less surprising.
2024-01-19 16:46:28 +01:00
Lennart Poettering
f3a269a935 manager: process exec_fd (i.e. Type=exec) events before SIGCHLD events
We want to make sure we don't confuse the case "process started
successfully but then failed quickly" from the case "process failed to
start". Hence we need to make sure we take notice of Type=exec before we
bother with SIGCHLD.

Hence move EVENT_PRIORITY_EXEC_FD to the front. In fact, let's move it
even further up than SIGCHLD, i.e. before sd_notify() handling, so that
we don't end up processing service state change notifications before we
even considered that the service is properly started.

This also gives the cgroup OOM handling and the exec_fd handling
different priorities, to improve robustness of the system, we should act
quickly on OOM, and it doesn't matter if a service started succcessfully
if we have to act on OOM anyway.

This is based on Andrew Onyshchuk <andryk.rv@gmail.com> work here:

See: #30799
Fixes: #28304
2024-01-19 16:46:28 +01:00
Lennart Poettering
d42b61d279 core: maintain a single table with event source priorities
It's hard to oversee the assigned processing priorities of the various
event sources we have. Let's unify them in a table (an enum), where we
can have a single consisten look at them, and then reference the table
entries by expressive symbols.

This doesn#t change behaviour in any way, it just gives each priority a
nice label, but doesn't change any of the priorities.

Prompted by: #30799
2024-01-19 16:46:28 +01:00
Nick Rosbrook
6327d30224 test: skip a systemd-run test if unprivileged userns is restricted
With newer versions of AppArmor, unprivileged user namespace creation
may be restricted by default, in which case user manager instances will
not be able to apply PrivateUsers=yes, which is implied by
PrivateTmp=yes in this systemd-run invocation.
2024-01-19 10:21:57 -05:00
Antonio Alvarez Feijoo
08c0b6efd8
dissect: fix typo 2024-01-19 16:01:13 +01:00
Antonio Alvarez Feijoo
43aaa1b3d3
bash-completion: add missing options to systemd-dissect 2024-01-19 15:50:15 +01:00
Antonio Alvarez Feijoo
c13d9199d6
bash-completion: add missing options to systemd-cryptenroll 2024-01-19 15:49:52 +01:00
Yu Watanabe
fe0c684b34 network: fix typo
Follow-up for 406fde1a4d87eb43cbec0b86213bf78b02595c6b.
2024-01-19 23:28:03 +09:00
Lennart Poettering
eb47cb6986
Merge pull request #31012 from YHNdnzj/pam-systemd-session-busy
pam_systemd: always check if session is busy
2024-01-19 15:08:37 +01:00
Lennart Poettering
f145216005
Merge pull request #31013 from YHNdnzj/logind-modernization-split
logind: minor modernizations
2024-01-19 15:06:17 +01:00
Luca Boccassi
b26be60efc
Merge pull request #31009 from yuwata/network-route-convert-before-requesting
network/route: convert routes before requesting
2024-01-19 13:20:32 +00:00
Mike Yuan
ef9eb646e5
logind-dbus: use SESSION_IS_{SELF,AUTO} instead of SEAT_* for sessions 2024-01-19 20:12:31 +08:00
Mike Yuan
f6e4b1e0af
logind-user: use RET_GATHER more 2024-01-19 20:12:31 +08:00
Mike Yuan
2948803177
pam_systemd: always check if session is busy
We need to check for BUS_ERROR_SESSION_BUSY no matter
whether pidfd is used, i.e. after we retry with
CreateSession().
2024-01-19 20:08:39 +08:00
Mike Yuan
79f36b6415
pam_systemd: close pidfd after use 2024-01-19 20:08:39 +08:00
Clayton Craft
fb7a902aed boot: don't print error if device tree fixup protocol isn't supported
This isn't a failure we care about, and it's somewhat alarming to see a
red error message flash up on the display when booting, so this just
simply returns EFI_SUCCESS and skips printing the "error" altogether.
2024-01-19 11:43:19 +00:00
Luca Boccassi
0d2e660d84
Merge pull request #30956 from yuwata/nspawn-network-pass-wifi
nspawn: support passing wireless interface to container
2024-01-19 11:41:58 +00:00
Frantisek Sumsal
b9f880d528 journalctl: consider shut down namespaced sd-journald instance synced
If the namespaced systemd-journald instance was shut down due to
inactivity, we can consider it synchronized, so avoid throwing an error
in such case.

This should help with the random TEST-44-LOG-NAMESPACE fails where we
might try to sync the namespace just after it was shut down:

[    7.682941] H testsuite-44.sh[381]: + systemd-run --wait -p LogNamespace=foobaz echo 'hello world'
[    7.693916] H systemd-journald[389]: Failed to open /dev/kmsg, ignoring: Operation not permitted
[    7.693983] H systemd-journald[389]: Collecting audit messages is disabled.
[    7.725511] H systemd[1]: Started systemd-journald@foobar.service.
[    7.726496] H systemd[1]: Listening on systemd-journald-varlink@foobaz.socket.
[    7.726808] H systemd[1]: Listening on systemd-journald@foobaz.socket.
[    7.750774] H systemd[1]: Started run-u3.service.
[    7.795122] H systemd[1]: run-u3.service: Deactivated successfully.
[    7.842042] H testsuite-44.sh[390]: Running as unit: run-u3.service; invocation ID: 56380adeb36940a8a170d9ffd2e1e433
[    7.842561] H systemd[1]: systemd-journald-varlink@foobaz.socket: Deactivated successfully.
[    7.842762] H systemd[1]: Closed systemd-journald-varlink@foobaz.socket.
[    7.846394] H systemd[1]: systemd-journald@foobaz.socket: Deactivated successfully.
[    7.846566] H systemd[1]: Closed systemd-journald@foobaz.socket.
[    7.852983] H testsuite-44.sh[390]: Finished with result: success
[    7.852983] H testsuite-44.sh[390]: Main processes terminated with: code=exited/status=0
[    7.852983] H testsuite-44.sh[390]: Service runtime: 44ms
[    7.852983] H testsuite-44.sh[390]: CPU time consumed: 8ms
[    7.852983] H testsuite-44.sh[390]: Memory peak: 880.0K
[    7.852983] H testsuite-44.sh[390]: Memory swap peak: 0B
[    7.853785] H testsuite-44.sh[381]: + journalctl --namespace=foobar --sync
[    7.860095] H systemd-journald[389]: Received client request to sync journal.
[    7.862119] H testsuite-44.sh[381]: + journalctl --namespace=foobaz --sync
[    7.868381] H journalctl[396]: Failed to connect to /run/systemd/journal.foobaz/io.systemd.journal: Connection refused
[    7.871498] H systemd[1]: testsuite-44.service: Main process exited, code=exited, status=1/FAILURE
[    7.871642] H systemd[1]: testsuite-44.service: Failed with result 'exit-code'.
[    7.930772] H systemd[1]: Failed to start testsuite-44.service.
2024-01-19 11:41:34 +00:00
Yu Watanabe
cfe8975a37 network/route-nexthop: configure as a simple gateway when MultipathRoute= is specified only once
The kernel handles such configuration completely equivalent to the case
that Gateway= is specified.
2024-01-19 19:20:29 +09:00
Yu Watanabe
e217da1380 network/route: drop unnecessary ownership transfer
Let's free Route objects on the caller side.
2024-01-19 19:20:29 +09:00
Yu Watanabe
10b08b6790 network/route-nexthop: drop unnecessary link arguments
These arguments are unused now.
2024-01-19 19:20:29 +09:00
Yu Watanabe
5a18697d61 network/route: convert route before requesting
Previously,
1. use the passed Route object as is when a route is requested,
2. when the route becomes ready to configure, convert the Route object
   if necessary, to resolve outgoing interface name, and split multipath
   routes, and save them to the associated interfaces,
3. configure the route with the passed Route object.

However, there are several inconsistencies with what kernel does:
- The kernel does not merge nor split IPv4 multipath routes. However, we
  unconditionally split multipath routes to manage.
- The kernel does not set gateway or so to a route if it has nexthop ID.

Fortunately, I do not find any issues caused by the inconsistencies. But
for safety, let's manage routes in a consistent way with the kernel.

This makes,
1. when a route is requested, split IPv6 multipath routes, but keep IPv4
   multipath routes as is, and queue (possibly multiple) requests for
   the route.
2. when the route becomes ready to configure, resolve nexthop and interface
   name, and requeue request if necessary.
3. configure the (possibly split) route.

By using the logic,
- Now we manage routes in a mostly consistent way with the kernel.
- We can drop ConvertedRoutes object.
- Hopefully the code becomes much simpler.
2024-01-19 19:20:29 +09:00
Yu Watanabe
ed6a7148f4 network/route-nexthop: fix route_nexthop_copy()
Follow-up for 413ea20ab3d86b5bccf775da21a945327b3880c9.
2024-01-19 19:20:21 +09:00
Yu Watanabe
e8736fb6c9 test-13-NSPAWN: add more test case for passing network interfaces
- test interface renaming that conflicts with the current alternative
  network interface name,
- test passing wlan interfaces.
2024-01-19 19:06:19 +09:00
Yu Watanabe
1c3e5b4210 nspawn-network: support passing wireless interface to container
Closes #7873.
2024-01-19 19:06:12 +09:00
Yu Watanabe
326214bfa8 nspawn-network: also check alternative names
If the requested new name for a network interface is already assigned as a
alternative name, then it is not necessary to and cannot rename the
interface.
2024-01-19 19:05:27 +09:00
Yu Watanabe
38475cac6f nspawn-network: split out move_network_interface_one()
This also changes to use sd_device to get some attributes.
So, on moving interfaces back to the parent, we need to populate sysfs
associated to the client netns.
That may look redundant and complicated, but it makes later change
easier, and hopefully faster.
2024-01-19 19:05:26 +09:00
Yu Watanabe
cdd9988e43 nspawn-network: split out move_back_network_interfaces()
No functional change, just refactoring and preparation for later
commits.
2024-01-19 19:05:25 +09:00
Yu Watanabe
d926864073 sd-netlink: add policy for NL80211_ATTR_NETNS_FD 2024-01-19 15:06:08 +09:00
Yu Watanabe
6e931bc578 sd-netlink: introduce rtnl_rename_link() 2024-01-19 15:06:08 +09:00
Yu Watanabe
3e98379ec0 sd-device: introduce device_get_sysattr_u32() 2024-01-19 15:06:08 +09:00
Yu Watanabe
a3df693799 udev-util: introduce reset_cached_udev_availability() 2024-01-19 15:06:08 +09:00
Yu Watanabe
3f53332d4e namespace-util: introduce netns_acquire()
Similar to userns_acquire(), but for network namespace.
2024-01-19 15:06:08 +09:00
Yu Watanabe
387f39ea30 process-util: introduce FORK_NEW_NETNS for safe_fork()
Similar to FORK_NEW_MOUNTNS or FORK_NEW_USERNS.
2024-01-19 15:06:08 +09:00
Yu Watanabe
cb566b5d13 namespace-util: downgrade log level in userns_acquire()
On failure, the caller logs the error in LOG_ERR.
2024-01-19 15:06:08 +09:00
Yu Watanabe
d2881ef96e tree-wide: add short comments for namespace_open() and namespace_enter()
Also use -EBADF when unspecified.
2024-01-19 15:06:08 +09:00
Yu Watanabe
5178d4a77e namespace-util: rename arguments to prefix 'ret_'
Also reorder opening namespace fd to make it match with the order of the
arguments.
2024-01-19 15:06:08 +09:00
Antonio Alvarez Feijoo
f14686c1d2 Revert "man: add missing <cmdsynopsis> wrapper"
This reverts commit 35fc10756bc5302d2dff1c235f864fa23a6d8771.

Although DocBook 4.5 states that `cmdsynopsis` can be used within `term` [1],
and `term` within `varlistentry`, `man` does not display the list of commands
after this change. FWIW, `cmdsynopsis` is used tree-wide within `refsynopsisdiv`
only.

[1] https://tdg.docbook.org/tdg/4.5/term
2024-01-19 15:03:34 +09:00
Yu Watanabe
6504d41c63 network: use strdup_or_null() where appropriate 2024-01-19 14:53:51 +09:00
Black-Hole1
5a02a9adb2 virt: support detection of Apple Virtualization guests with cpuid
This is a supplement to #24419. On macOS Intel machines, detection needs to be done through cpuid.
In macOS, `dmi_vendors` detection is only applicable to M series.

Signed-off-by: Black-Hole1 <bh@bugs.cc>
2024-01-19 14:47:24 +09:00
Yu Watanabe
4abb8d7b0b
Merge pull request #30975 from yuwata/network-route-several-helper-functions
network/route: introduce several helper functions
2024-01-19 14:42:40 +09:00
Yu Watanabe
3babbdf632 network/route: introduce route_get_request()
No functional change, just refactoring and preparation for later
commits.
2024-01-19 10:23:14 +09:00
Yu Watanabe
2f542fc3d4 network: adjust nexthops of dynamic routes before requesting
No effective functionality is changed. Preparation for later commits.
2024-01-19 10:23:14 +09:00
Yu Watanabe
acc3fc9e5f network/route-nexthop: introduce route_adjust_nexthops() and route_nexthops_needs_adjust()
These are not used in this commit, but will be used later.
Preparation for later commits.
2024-01-19 10:23:14 +09:00
Yu Watanabe
413ea20ab3 network/route-nexthop: introduce route_nexthops_copy()
This also introduce an extra argument for route_dup(), but it is
currently unused, will be used later.

No functional change, just preparation for later commits.
2024-01-19 10:21:55 +09:00
Yu Watanabe
406fde1a4d network/route-nexthop: use RTA_MULTIPATH when weight is not zero
As we have no way to specify the weight of gateway without using
RTA_MULTIPATH.
2024-01-19 10:13:44 +09:00
Alberto Planas
4054e8128e Measure empty PK and KEK EFI vars
The OVMF UEFI firmware is measuring PK and KEK when secure boot is
disabled, and those variables are absent.  This can be checked via the
event log to see that there are extensions for PCR 7 associated with PK
and KEK events of type EV_EFI_VARIABLE_DRIVER_CONFIG.

When running the "lock-secureboot-policy" verb, pcrlock complains that
those variables are not found and refuse to generate the
240-secureboot-policy.pcrlock.d/generated.pcrlock file.

The "TCG PC Client Platform Firmware Profile Specification Version 1.05
Revision 23"[1] from May 7, 2021, in section "3.3.4.8 PCR[7] - Secure
Boot Policy Measurements", point 10.b:

If reading a UEFI variable returns UEFI_NOT_FOUND, platform firmware
SHALL measure the absence of the variable. The
UEFI_VARIABLE_DATA.VariableDataLength field MUST be set to zero and
UEFI_VARIABLE_DATA.VariableData field will have a size of zero.

This patch mark those variables to be marked as "synthesize empty",
generating the correct hash for those variables.

Signed-off-by: Alberto Planas <aplanas@suse.com>
2024-01-19 00:18:20 +00:00
Nick Cao
4be1fc8443 network: Add L3MasterDevice= into routing policy 2024-01-19 00:17:50 +00:00