Commit Graph
76765 Commits
Author SHA1 Message Date
Matteo Croce 9784ed760e timer: add unit tests for DeferReactivation
Create a unit test for systemd timer DeferReactivation config option.
The test works by creating a timer which fires every 5 seconds and
starts an unit which runs for 5 seconds.
With DeferReactivation=true, the timer must fire every 5+5 seconds,
instead of the 5 it fires normally.

As we need at least two timer runs to check if the delta is correct,
the test duration on success will be at least 20 seconds.
To be safe, the test script waits 35 seconds: this is enough to get
at least three runs but low enough to avoid clogging the CI.
2024-10-11 22:54:16 +02:00
Arthur ShauandMatteo Croce cc0ab8c810 timer: introduce DeferReactivation setting
By default, in instances where timers are running on a realtime schedule,
if a service takes longer to run than the interval of a timer, the
service will immediately start again when the previous invocation finishes.
This is caused by the fact that the next elapse is calculated based on
the last trigger time, which, combined with the fact that the interval
is shorter than the runtime of the service, causes that elapse to be in
the past, which in turn means the timer will trigger as soon as the
service finishes running.

This behavior can be changed by enabling the new DeferReactivation setting,
which will cause the next calendar elapse to be calculated based on when
the trigger unit enters inactivity, rather than the last trigger time.

Thus, if a timer is on an realtime interval, the trigger will always
adhere to that specified interval.
E.g. if you have a timer that runs on a minutely interval, the setting
guarantees that triggers will happen at *:*:00 times, whereas by default
this may skew depending on how long the service runs.

Co-authored-by: Matteo Croce <teknoraver@meta.com>
2024-10-11 22:54:16 +02:00
Yu Watanabe 632407c3e4 Merge pull request #34700 from yuwata/network-conf-parser
network: several cleanups for conf parsers
2024-10-12 05:22:11 +09:00
Matteo Croce 75355f22db report bpf_current_task_under_cgroup() errors to userspace
bpf_current_task_under_cgroup() returns 1 if the task is under the
specified cgroup, 0 if not, negative if an error happens.

Differentiate the 1 and -1 cases, and report to userspace when we got
and error.
An error like this is mostly unlikely, the only common one is that the
userspace doesn't populate the map, and the call returns -EAGAIN.

Tested by mocking the return value of bpf_current_task_under_cgroup():
    Enumeration completed
    enp1s0f0np0: Configuring with /etc/systemd/network/20-test.network.
    Sysctl monitor BPF returned error: Link number out of range
    Sysctl monitor BPF returned error: No CSI structure available
    Sysctl monitor BPF returned error: Invalid exchange
    Sysctl monitor BPF returned error: Exchange full
    Sysctl monitor BPF returned error: Invalid request code
    Sysctl monitor BPF returned error: Unknown error 58
    Sysctl monitor BPF returned error: Device not a stream
    Sysctl monitor BPF returned error: Timer expired
    Sysctl monitor BPF returned error: Machine is not on the network
    Sysctl monitor BPF returned error: Object is remote
    Sysctl monitor BPF returned error: Advertise error
2024-10-12 04:47:18 +09:00
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
Yu Watanabe 19931a6d8d network/route: use log_section_warning() more 2024-10-12 03:26:07 +09:00
Yu Watanabe a768478738 network/route: use generic [Route] section parser more 2024-10-12 03:26:07 +09:00
Yu Watanabe 571bb24123 network/route: use log_syntax_parse_error() more 2024-10-12 03:26:07 +09:00
Yu Watanabe 4daf605d87 network/route-nexthop: use generic [Route] section parser more 2024-10-12 03:26:07 +09:00
Yu Watanabe 70465e5b61 network/route-nexthop: use log_syntax_parse_error() 2024-10-12 03:26:06 +09:00
Yu Watanabe cf305c8458 network/route-metric: merge conf parsers for route metric
This introduces a generic [Route] section parser, then embed conf
parsers for route metric into it.
2024-10-12 03:26:06 +09:00
Yu Watanabe ff1f480c3b network/route-metric: use log_syntax_parse_error() 2024-10-12 03:26:06 +09:00
Yu Watanabe 1cbc8d9168 network/address: several cleanups for config_parse_address()
- make it accept an empty string,
- use config_parse_in_addr_prefix(),
- move null address checker to address_section_verify().

No functional change, just refactoring.
2024-10-12 03:26:06 +09:00
Yu Watanabe 5d15c7b19c network/address: warn but ignore Broadcast= setting for an IPv6 address
Previously, the below was refused and the IPv6 address would not assigned.
===
[Address]
Address=2001:db8:0:f101::15/64
Broadcast=192.168.0.255
===
However, in the following case, networkd warned about the broadcast
address would be ignored, and the IPv6 address would be configured.
===
[Address]
Broadcast=192.168.0.255
Address=2001:db8:0:f101::15/64
===
2024-10-12 03:26:06 +09:00
Yu Watanabe e58ec0dc90 network/address: use log_section_warning() more 2024-10-12 03:26:06 +09:00
Yu Watanabe f8a31c90cc network/routing-policy-rule: use in_addr_prefix for From= and To=
Also, this makes the settings parsed independently, and the
inconsistency will be checked in the section verifier.

No functional change, just refactoring.
2024-10-12 03:26:06 +09:00
Yu Watanabe 8cde9f6c5a conf-parser: introduce config_parse_in_addr_prefix()
It is not used currently, but will be used later.
2024-10-12 03:26:04 +09:00
Yu Watanabe c1316cd00d in-addr-util: rename in_addr_prefix_from_string_auto_internal() -> _full()
The function is also used in other source files. Hence, not internal.
No functional change, just refactoring.
2024-10-12 03:23:23 +09:00
Lucas Adriano Salles c2f3cb2676 hwdb: fix key toggle touchpad and programmable buttom for Positivo V142N (#34725) 2024-10-12 01:58:14 +09: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 3543456f84

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 a178ffdfcd
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 a6aa89122d
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
Daan De Meyer 0d0ecaab00 mkosi: Fix up ownership of testuser home directory on first boot
When building unprivileged, the testuser home directory ends up
owned by root:root because mkosi can't chown directories to other
owners when running unprivileged. So let's fix up the testuser
ownership on first boot with tmpfiles instead.
2024-10-11 11:35:02 +02:00
Daan De Meyer 40fadab195 Merge pull request #34707 from YHNdnzj/user-manager-reexec
core: fix STATUS=Ready for user manager; units/user@.service: issue daemon-reexec when notify-reloading
2024-10-11 11:34:24 +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