Skip to content

Commit 92fa532

Browse files
juliuskoskelabrianmcgillion
authored andcommitted
logging: fix FSS setup idempotency, journal rotation, and test timer detection
Remove ConditionPathExists guard from setup service so it can re-run on boot to write fss-config on existing deployments where the file was never created. Add one-time journal rotation after FSS key setup to move pre-FSS entries to archive, fixing EBADMSG ("Bad message") during verification. Add systemctl cat fallback to test 6 for timer detection in microVMs where list-unit-files may not show the timer. Signed-off-by: Julius Koskela <julius.koskela@unikie.com>
1 parent c584e08 commit 92fa532

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

modules/common/logging/fss.nix

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,12 @@ let
125125
# Write config pointer so test scripts can discover KEY_DIR without hostname
126126
echo "$KEY_DIR" > "/var/log/journal/$MACHINE_ID/fss-config"
127127
chmod 0644 "/var/log/journal/$MACHINE_ID/fss-config"
128+
# One-time rotation to move pre-FSS entries to archive (fixes "Bad message")
129+
if [ ! -f "/var/log/journal/$MACHINE_ID/fss-rotated" ]; then
130+
echo "Rotating journal to ensure clean FSS state..."
131+
journalctl --rotate 2>/dev/null || true
132+
touch "/var/log/journal/$MACHINE_ID/fss-rotated"
133+
fi
128134
exit 0
129135
fi
130136
@@ -168,6 +174,9 @@ let
168174
echo "Warning: Journald restart failed - sealing may not be active"
169175
fi
170176
177+
# Rotate so active journal starts clean with FSS (pre-FSS entries become archive)
178+
journalctl --rotate 2>/dev/null || true
179+
171180
# Create sentinel file to prevent re-initialization
172181
touch "$INIT_FILE"
173182
chmod 0644 "$INIT_FILE"
@@ -176,6 +185,8 @@ let
176185
echo "$KEY_DIR" > "/var/log/journal/$MACHINE_ID/fss-config"
177186
chmod 0644 "/var/log/journal/$MACHINE_ID/fss-config"
178187
188+
touch "/var/log/journal/$MACHINE_ID/fss-rotated"
189+
179190
echo "Forward Secure Sealing initialization complete"
180191
echo "Sealing key: $FSS_KEY_FILE"
181192
echo "Verification key: $KEY_DIR/verification-key (if extracted)"
@@ -438,11 +449,6 @@ in
438449
after = [ "systemd-journald.service" ];
439450
wants = [ "systemd-journald.service" ];
440451

441-
unitConfig = {
442-
# Only run if not already initialized
443-
ConditionPathExists = "!${cfg.keyPath}/initialized";
444-
};
445-
446452
serviceConfig = {
447453
Type = "oneshot";
448454
RemainAfterExit = true;

tests/logging/test_scripts/fss-test.nix

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,12 @@ writeShellApplication {
222222
else
223223
warn "journal-fss-verify.timer exists but is not active"
224224
fi
225+
elif systemctl cat journal-fss-verify.timer &>/dev/null; then
226+
if systemctl is-active --quiet journal-fss-verify.timer; then
227+
pass "journal-fss-verify.timer is active"
228+
else
229+
pass "journal-fss-verify.timer exists"
230+
fi
225231
else
226232
warn "journal-fss-verify.timer not found"
227233
fi

0 commit comments

Comments
 (0)