eBPF-based security platform
systemd: bound the timer services and upgrade after a failed update
Daniel Borkmannf13c8b7347ec
diff --git a/systemd/shirudo-bpm-repo-update.service.in b/systemd/shirudo-bpm-repo-update.service.inindex b5e85247..b3a2833f 100644--- a/systemd/shirudo-bpm-repo-update.service.in+++ b/systemd/shirudo-bpm-repo-update.service.in@@ -9,6 +9,9 @@ RequiresMountsFor=/etc/shirudo/bpm /var/lib/shirudo[Service]Type=oneshot+TimeoutStartSec=30minEnvironmentFile=-/etc/shirudo/bpm/environment-ExecStart=@bindir@/shirudo bpm repo update+# One unreachable registry fails the update; the upgrade still runs+# from what the others refreshed.+ExecStart=-@bindir@/shirudo bpm repo updateExecStart=@bindir@/shirudo bpm upgradediff --git a/systemd/shirudo-bpm-tree-sync.service.in b/systemd/shirudo-bpm-tree-sync.service.inindex ab2b726a..9259fa19 100644--- a/systemd/shirudo-bpm-tree-sync.service.in+++ b/systemd/shirudo-bpm-tree-sync.service.in@@ -9,5 +9,6 @@ RequiresMountsFor=/etc/shirudo/bpm /var/lib/shirudo[Service]Type=oneshot+TimeoutStartSec=30minEnvironmentFile=-/etc/shirudo/bpm/environmentExecStart=@bindir@/shirudo bpm tree syncdiff --git a/systemd/shirudo-keepalive.service.in b/systemd/shirudo-keepalive.service.inindex 3c643c3e..48b3cba0 100644--- a/systemd/shirudo-keepalive.service.in+++ b/systemd/shirudo-keepalive.service.in@@ -7,5 +7,6 @@ After=shirudo.service[Service]Type=oneshot+TimeoutStartSec=2minEnvironmentFile=-/etc/shirudo/map-export.envExecStart=@bindir@/shirudo status --otel --include-systemdiff --git a/systemd/shirudo-map-export.service.in b/systemd/shirudo-map-export.service.inindex f82c0b22..8273f63b 100644--- a/systemd/shirudo-map-export.service.in+++ b/systemd/shirudo-map-export.service.in@@ -8,5 +8,6 @@ ConditionPathExists=/run/shirudo/bpffs/lsm_link[Service]Type=oneshot+TimeoutStartSec=5minEnvironmentFile=-/etc/shirudo/map-export.envExecStart=@bindir@/shirudo upatch map --alldiff --git a/testing/bpm/t0019-bpm-repo-update.sh b/testing/bpm/t0019-bpm-repo-update.shindex 90af645b..d6499d7b 100755--- a/testing/bpm/t0019-bpm-repo-update.sh+++ b/testing/bpm/t0019-bpm-repo-update.sh@@ -28,6 +28,13 @@ test_expect_success 'BPM repository refresh service runs update before upgrade'"$(cat "$WORK/bpm-upgrade-line")"'+test_expect_success 'the BPM services have a start timeout' '+ for u in bpm-repo-update bpm-tree-sync; do+ grep -q "^TimeoutStartSec=" ../systemd/shirudo-$u.service.in ||+ return 1+ done+'+test_expect_success 'BPM repository refresh timer runs at boot and every minute' 'grep -q "^OnBootSec=0s$" \../systemd/shirudo-bpm-repo-update.timer &&@@ -51,7 +58,7 @@ test_expect_success 'target install resolves and stages the BPM refresh unit' 'systemdunitdir=/usr/lib/systemd/system install-target \>"$WORK/target.plan") &&- grep -q "^ExecStart=/opt/shirudo/bin/shirudo bpm repo update$" \+ grep -q "^ExecStart=-/opt/shirudo/bin/shirudo bpm repo update$" \"$GENERATED_BPM" &&grep -q "^ExecStart=/opt/shirudo/bin/shirudo bpm upgrade$" \"$GENERATED_BPM" &&diff --git a/testing/otel/t0017-systemd-map-export.sh b/testing/otel/t0017-systemd-map-export.shindex c71faa80..ccdc8cbc 100755--- a/testing/otel/t0017-systemd-map-export.sh+++ b/testing/otel/t0017-systemd-map-export.sh@@ -21,6 +21,13 @@ test_expect_success 'map export service runs the configured batch exporter' '../../systemd/shirudo-map-export.service.in'+test_expect_success 'the exporter services have a start timeout' '+ for u in map-export keepalive; do+ grep -q "^TimeoutStartSec=" ../../systemd/shirudo-$u.service.in ||+ return 1+ done+'+test_expect_success 'map export timer waits five seconds between runs' 'grep -q "^OnBootSec=5s$" ../../systemd/shirudo-map-export.timer &&grep -q "^OnUnitInactiveSec=5s$" \