|
37 | 37 | # Operational Notes: |
38 | 38 | # ----------------- |
39 | 39 | # 1. First Boot (per component): |
40 | | -# - journal-fss-setup.service runs before systemd-journald |
| 40 | +# - journal-fss-setup.service runs after systemd-journald is ready |
41 | 41 | # - Generates sealing keys with configured seal interval |
| 42 | +# - Rotates journal to start using FSS keys immediately |
42 | 43 | # - Extracts verification key to cfg.keyPath/<hostname>/verification-key |
43 | 44 | # - Each component creates its own subdirectory with independent keys |
44 | 45 | # - CRITICAL: Backup all verification-keys to secure offline storage |
|
157 | 158 | exit 1 |
158 | 159 | fi |
159 | 160 |
|
| 161 | + # Rotate journal to start using FSS keys immediately |
| 162 | + # Per systemd documentation, rotation is required after --setup-keys |
| 163 | + # to create a new journal file that uses the FSS keys |
| 164 | + echo "Rotating journal to enable sealing..." |
| 165 | + if ! journalctl --rotate; then |
| 166 | + echo "Warning: Journal rotation failed - sealing may not start until next natural rotation" |
| 167 | + fi |
| 168 | +
|
160 | 169 | # Create sentinel file to prevent re-initialization |
161 | 170 | touch "$INIT_FILE" |
162 | 171 | chmod 0644 "$INIT_FILE" |
|
414 | 423 | ]; |
415 | 424 |
|
416 | 425 | # One-shot service to generate FSS keys on first boot |
| 426 | + # Runs after journald is ready, then rotates journal to enable sealing |
417 | 427 | systemd.services.journal-fss-setup = { |
418 | 428 | description = "Setup Forward Secure Sealing keys for systemd journal"; |
419 | 429 | documentation = [ "man:journalctl(1)" ]; |
420 | 430 |
|
421 | | - wantedBy = [ "sysinit.target" ]; |
422 | | - before = [ |
423 | | - "systemd-journald.service" |
424 | | - "systemd-journal-flush.service" |
425 | | - ]; |
426 | | - after = [ "local-fs.target" ]; |
| 431 | + wantedBy = [ "multi-user.target" ]; |
| 432 | + after = [ "systemd-journald.service" ]; |
| 433 | + wants = [ "systemd-journald.service" ]; |
427 | 434 |
|
428 | 435 | unitConfig = { |
429 | | - # Prevent implicit After=basic.target which creates ordering cycle |
430 | | - DefaultDependencies = false; |
431 | 436 | # Only run if not already initialized |
432 | 437 | ConditionPathExists = "!${cfg.keyPath}/initialized"; |
433 | | - # Ensure journal directory is ready and writable |
434 | | - ConditionPathIsReadWrite = "/var/log/journal"; |
435 | 438 | }; |
436 | 439 |
|
437 | 440 | serviceConfig = { |
|
441 | 444 | }; |
442 | 445 | }; |
443 | 446 |
|
444 | | - # Make journald sockets wait for FSS setup before starting |
445 | | - # This ensures FSS keys are configured before any journal entries are written. |
446 | | - # Adding After= to the socket units themselves is required because: |
447 | | - # - journald sockets have DefaultDependencies=no |
448 | | - # - Before= on our service doesn't create a dependency from socket to service |
449 | | - # - Only explicit After= on the socket creates proper ordering |
450 | | - systemd.sockets."systemd-journald" = { |
451 | | - after = [ "journal-fss-setup.service" ]; |
452 | | - wants = [ "journal-fss-setup.service" ]; |
453 | | - }; |
454 | | - |
455 | | - systemd.sockets."systemd-journald-dev-log" = { |
456 | | - after = [ "journal-fss-setup.service" ]; |
457 | | - wants = [ "journal-fss-setup.service" ]; |
458 | | - }; |
459 | | - |
460 | 447 | # Service to verify journal integrity |
461 | 448 | systemd.services.journal-fss-verify = { |
462 | 449 | description = "Verify systemd journal integrity using Forward Secure Sealing"; |
|
0 commit comments