Systemd/src
Filipe Brandenburger 26698337f3 timer: Adjust calendar timers based on monotonic timer instead of realtime
When the RTC time at boot is off in the future by a few days, OnCalendar=
timers will be scheduled based on the time at boot. But if the time has been
adjusted since boot, the timers will end up scheduled way in the future, which
may cause them not to fire as shortly or often as expected.

Update the logic so that the time will be adjusted based on monotonic time.
We do that by calculating the adjusted manager startup realtime from the
monotonic time stored at that time, by comparing that time with the realtime
and monotonic time of the current time.

Added a test case to validate this works as expected. The test case creates a
QEMU virtual machine with the clock 3 days in the future. Then we adjust the
clock back 3 days, and test creating a timer with an OnCalendar= for every 15
minutes. We also check the manager startup timestamp from both `systemd-analyze
dump` and from D-Bus.

Test output without the corresponding code changes that fix the issue:

  Timer elapse outside of the expected 20 minute window.
    next_elapsed=1594686119
    now=1594426921
    time_delta=259198

With the code changes in, the test passes as expected.
2020-07-15 09:23:09 +02:00
..
ac-power
activate
analyze analyze: make testing ConditionPathExistsGlob= work 2020-07-14 14:59:18 +02:00
ask-password
backlight backlight: read current backlight brightness from 'actual_brightness' attribute 2020-06-30 22:19:21 +09:00
basic Merge pull request #16424 from keszybz/cap-bpf-compat 2020-07-11 13:35:34 +02:00
binfmt binfmt: also unregister binfmt entries from unit 2020-04-23 17:14:45 +02:00
boot sd-boot: Add small comments after device-specific key macros 2020-06-18 15:57:11 +02:00
busctl bus: use bus_log_parse_error to print message 2020-07-12 06:33:48 +09:00
cgls log: introduce log_parse_environment_cli() and log_setup_cli() 2020-06-24 16:49:26 +02:00
cgroups-agent
cgtop log: introduce log_parse_environment_cli() and log_setup_cli() 2020-06-24 16:49:26 +02:00
core timer: Adjust calendar timers based on monotonic timer instead of realtime 2020-07-15 09:23:09 +02:00
coredump coredump: use log_error_errno() where appropriate 2020-06-25 15:03:13 +02:00
cryptsetup tree-wide: avoid some loaded terms 2020-06-25 09:00:19 +02:00
debug-generator
delta log: introduce log_parse_environment_cli() and log_setup_cli() 2020-06-24 16:49:26 +02:00
detect-virt log: introduce log_parse_environment_cli() and log_setup_cli() 2020-06-24 16:49:26 +02:00
dissect dissect/nspawn: add support for dm-verity root hash signature 2020-06-25 08:45:21 +01:00
environment-d-generator
escape log: introduce log_parse_environment_cli() and log_setup_cli() 2020-06-24 16:49:26 +02:00
firstboot firstboot: add option to turn off welcome text display 2020-07-07 11:20:42 +02:00
fsck
fstab-generator fstab-generator: introduce an helper to write extra dependencies specified via the mount options 2020-07-01 16:35:13 +02:00
fuzz fuzz-udev-rules: -ENOBUFS should be accepted too 2020-06-25 08:51:21 +02:00
getty-generator
gpt-auto-generator dissect: support single-filesystem verity images with external verity hash 2020-06-09 12:19:21 +01:00
hibernate-resume
home Merge pull request #16385 from JackFangXN/master 2020-07-08 12:12:29 +02:00
hostname shared: split out code that maps properties to local structs 2020-06-30 15:09:35 +02:00
hwdb Make failures of mac_selinux_init() fatal 2020-06-23 19:10:07 +02:00
id128 table use table_log_print_error() instead of table_log_show_error 2020-07-08 15:16:52 +08:00
import shared: split out property get helpers 2020-06-30 15:10:17 +02:00
initctl initctl: use _cleanup_ and run() 2020-07-02 17:12:23 +02:00
journal journald: minor wording tweak in message 2020-07-07 12:14:41 +02:00
journal-remote various daemons: emit Stopping... notification before destructing the manager object 2020-07-02 17:12:23 +02:00
kernel-install kernel-install: extend --help 2020-06-05 16:34:05 +02:00
libsystemd basic/capability-util: let cap_last_cap() return unsigned integer 2020-07-10 16:55:24 +02:00
libsystemd-network all: fix minor typos 2020-07-07 18:52:49 +09:00
libudev tree-wide: avoid some loaded terms 2020-06-25 09:00:19 +02:00
locale shared: split out code that maps properties to local structs 2020-06-30 15:09:35 +02:00
login Merge pull request #16385 from JackFangXN/master 2020-07-08 12:12:29 +02:00
machine table use table_log_print_error() instead of table_log_show_error 2020-07-08 15:16:52 +08:00
machine-id-setup
modules-load
mount table use table_log_print_error() instead of table_log_show_error 2020-07-08 15:16:52 +08:00
network bus: use bus_log_parse_error to print message 2020-07-12 06:33:48 +09:00
notify Introduce sd_notify_barrier 2020-05-01 03:22:47 +05:30
nspawn Merge pull request #15891 from bluca/host_os_release 2020-07-08 23:52:13 +02:00
nss-myhostname tree-wide: use "hostname" spelling everywhere 2020-04-21 16:58:04 +02:00
nss-mymachines shared: actually move all BusLocator related calls to bus-locator.c 2020-06-30 15:09:19 +02:00
nss-resolve shared: actually move all BusLocator related calls to bus-locator.c 2020-06-30 15:09:19 +02:00
nss-systemd userdb: replace recursion lock 2020-06-23 17:24:24 +02:00
partition repart: include more relevant information in the warning message, fix test 2020-07-13 03:43:26 +09:00
path sd-path: drop "-dir" and "-path" suffixes from path enums 2020-05-28 23:54:35 +02:00
portable Merge pull request #15891 from bluca/host_os_release 2020-07-08 23:52:13 +02:00
pstore Merge pull request #16057 from keszybz/resolvectl-sorted-no-nta 2020-06-04 11:30:14 +09:00
quotacheck
random-seed random-util: add common helper random_write_entropy() for crediting entropy to the kernel's pool 2020-06-24 15:33:27 +02:00
rc-local-generator
remount-fs
reply-password
resolve bus: use bus_log_parse_error to print message 2020-07-12 06:33:48 +09:00
rfkill
run shared: split out code that maps properties to local structs 2020-06-30 15:09:35 +02:00
run-generator
shared shared: fix error handling in make_inaccessible_nodes 2020-07-11 21:25:39 +02:00
shutdown shutdown: fix spacing in shutdown error message 2020-05-05 10:23:47 +02:00
sleep sleep: one spelling unification 2020-07-07 10:02:02 +02:00
socket-proxy socket-proxy: use structured initialization in one place 2020-06-24 10:38:15 +02:00
stdio-bridge tree-wide: check POLLNVAL everywhere 2020-06-10 08:57:31 +02:00
sulogin-shell
sysctl journalctl,elsewhere: make sure --file=foo fails with sane error msg if foo is not readable 2020-05-19 15:26:51 +02:00
system-update-generator
systemctl table use table_log_print_error() instead of table_log_show_error 2020-07-08 15:16:52 +08:00
systemd udevadm: beef up deprecation log warning 2020-07-14 14:57:19 +02:00
sysusers Make failures of mac_selinux_init() fatal 2020-06-23 19:10:07 +02:00
sysv-generator sysv-generator: reduce scope of variables 2020-06-24 10:38:15 +02:00
test Merge pull request #16340 from keszybz/var-tmp-readonly 2020-07-14 19:59:48 +02:00
time-wait-sync
timedate bus: use bus_log_parse_error to print message 2020-07-12 06:33:48 +09:00
timesync various daemons: emit Stopping... notification before destructing the manager object 2020-07-02 17:12:23 +02:00
tmpfiles tree-wide: avoid some loaded terms 2020-06-25 09:00:19 +02:00
tty-ask-password-agent tree-wide: check POLLNVAL everywhere 2020-06-10 08:57:31 +02:00
udev udevadm: beef up deprecation log warning 2020-07-14 14:57:19 +02:00
update-done Make failures of mac_selinux_init() fatal 2020-06-23 19:10:07 +02:00
update-utmp initctl,update-utmp: define iterator variable in loop 2020-07-02 17:12:23 +02:00
user-sessions Make failures of mac_selinux_init() fatal 2020-06-23 19:10:07 +02:00
userdb Merge pull request #16385 from JackFangXN/master 2020-07-08 12:12:29 +02:00
vconsole
veritysetup veritysetup: add support for dm-verity root hash signature 2020-06-25 08:44:49 +01:00
version tree-wide: spellcheck using codespell 2020-04-16 18:00:40 +02:00
volatile-root tree-wide: add size limits for tmpfs mounts 2020-05-13 00:37:18 +02:00
xdg-autostart-generator xdg-autostart: ignore all empty entries in multi-string entries 2020-07-07 14:02:16 +02:00