From dabac5bf89685fb137536409e26d186ec58a94d4 Mon Sep 17 00:00:00 2001 From: Jim Date: Sun, 23 Aug 2020 22:41:19 +0200 Subject: [PATCH 1/2] Change timesync sync file, fixes #1012 --- include/tests_time | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/tests_time b/include/tests_time index eda41a6f..46db8d71 100644 --- a/include/tests_time +++ b/include/tests_time @@ -574,7 +574,7 @@ Register --test-no TIME-3185 --preqs-met "${PREQS_MET}" --weight L --network NO --category "security" --description "Check systemd-timesyncd synchronized time" - SYNCHRONIZED_FILE="/run/systemd/timesync/synchronized" + SYNCHRONIZED_FILE="/var/lib/systemd/timesync/clock" if [ ${SKIPTEST} -eq 0 ]; then if [ -e "${SYNCHRONIZED_FILE}" ]; then FIND=$(( $(date +%s) - $(${STATBINARY} -L --format %Y "${SYNCHRONIZED_FILE}") )) From 84fd612c912aa46129d00fea93cb81362df55843 Mon Sep 17 00:00:00 2001 From: Jim Date: Mon, 24 Aug 2020 17:59:06 +0200 Subject: [PATCH 2/2] Add check for other clock files for earlier systemd versions --- include/tests_time | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/include/tests_time b/include/tests_time index 46db8d71..3c5a8477 100644 --- a/include/tests_time +++ b/include/tests_time @@ -574,8 +574,17 @@ Register --test-no TIME-3185 --preqs-met "${PREQS_MET}" --weight L --network NO --category "security" --description "Check systemd-timesyncd synchronized time" - SYNCHRONIZED_FILE="/var/lib/systemd/timesync/clock" + SYNCHRONIZED_FILE="/run/systemd/timesync/synchronized" + if [ ${SKIPTEST} -eq 0 ]; then + # On earlier systemd versions (237), '/run/systemd/timesync/synchronized' does not exist, so use '/var/lib/systemd/timesync/clock' + if [ ! -e "${SYNCHRONIZED_FILE}" ]; then + SYNCHRONIZED_FILE="/var/lib/systemd/timesync/clock" + fi + # DynamicUser=yes moves the clock file to '/var/lib/private/systemd/timesync/clock' + if [ ! -e "${SYNCHRONIZED_FILE}" ]; then + SYNCHRONIZED_FILE="/var/lib/private/systemd/timesync/clock" + fi if [ -e "${SYNCHRONIZED_FILE}" ]; then FIND=$(( $(date +%s) - $(${STATBINARY} -L --format %Y "${SYNCHRONIZED_FILE}") )) # Check if last sync was more than 2048 seconds (= the default of systemd) ago