swarm-bao-agent-pki: decide openbao's restart on the shared locale-independent compare
`swarm-bao-agent-pki` carried its own copy of the mtime-vs-start compare, with the same `stat -c %.6Y | tr -d .` read: on a comma-locale host the `-le` errored and, under `seal = "pkcs11"`, openbao was restarted on every run of the unit. The compare moves out of `refresh_unit` into `written_after_start` (0 newer, 1 not newer, 2 unreadable and logged at `err`), and both `refresh_unit` and the agent-pki unit call it. The agent-pki unit cannot call `refresh_unit` itself: it restarts with `restart`, not `try-restart`, runs a fail-closed check of the bundle between the compare and the restart, and under shamir prints the step instead of restarting. It acts only on 0, so an unreadable time skips the restart as `refresh_unit` does. `script-test-refresh-consumer` covers the three return codes in the agent-pki call shape; `module-eval-bao-basics` asserts both seal arms decide on that call and that no `%.6Y` read is left in the unit. Refs #5230
This commit is contained in:
parent
be7eaa8181
commit
8d554477ca
5 changed files with 67 additions and 24 deletions
|
|
@ -269,16 +269,26 @@ let
|
|||
{
|
||||
# openbao reads its client-CA file only at start, so picking up the
|
||||
# agent CA is a restart: automatic where the store unseals itself,
|
||||
# printed where a human has to. The shamir arm is the control.
|
||||
# printed where a human has to. The shamir arm is the control. Both
|
||||
# decide on the shared locale-independent compare
|
||||
# (../host-modules/lib/refresh-consumer.nix, run by
|
||||
# `script-test-refresh-consumer`) and act only on its 0.
|
||||
name = "the agent PKI unit restarts openbao under pkcs11 and only prints the step under shamir";
|
||||
ok =
|
||||
let
|
||||
restart = ''systemctl --machine="$machine" restart openbao.service'';
|
||||
compare = ''
|
||||
written_after_start openbao.service ${tlsDir}/listener-client-ca.pem --machine="$machine" || newer=$?
|
||||
'';
|
||||
p = baoPkcs11.systemd.services.swarm-bao-agent-pki.script;
|
||||
sh = baoShamir.systemd.services.swarm-bao-agent-pki.script;
|
||||
in
|
||||
lib.hasInfix restart p
|
||||
&& lib.hasInfix ''if [ "$written_us" -le "$started_us" ]; then'' p
|
||||
&& lib.all (s: lib.hasInfix compare s && lib.hasInfix ''if [ "$newer" != 0 ]; then'' s) [
|
||||
p
|
||||
sh
|
||||
]
|
||||
&& !(lib.hasInfix "%.6Y" p)
|
||||
&& !(lib.hasInfix restart sh)
|
||||
&& lib.hasInfix "# then unseal" sh;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue