Report which of fog.enrollsb's three exits was actually reached - #166
Open
mastacontrola wants to merge 1 commit into
Open
Report which of fog.enrollsb's three exits was actually reached#166mastacontrola wants to merge 1 commit into
mastacontrola wants to merge 1 commit into
Conversation
fog.enrollsb has three exits and every one of them ends with the same
argument-free `. /bin/fog.nonimgcomplete`, so from the server all three look
identical: the task completed. They are not remotely the same thing.
db the machine was in Setup Mode, `db` was written, it IS enrolled
trusted it already trusted this certificate; nothing was enrolled here, and
nothing observed how the trust got there
mok a request was STAGED. The machine is NOT enrolled and will not boot
with Secure Boot on until a human confirms it at MokManager
Recording the third as an enrolment is a lie an administrator acts on: they
turn Secure Boot on in firmware and the machine stops booting. So the outcome
is now reported by the only party that knows it, to the new
service/secureboot.report.php, along with the certificate fingerprint the task
already computes and prints. FOG stores that against the host as its enrolment
record -- an enrolment date alone says nothing once a certificate has rotated,
and FOG has PKI zones, a multi-server CA and certificates that expire.
Best-effort by design, and that is the half worth reading twice. The enrolment
has already happened by the time sbReport runs: a server too old to have the
endpoint answers 404, an unreachable one answers nothing, and in both cases
the machine is enrolled and the task must still complete. So sbReport never
calls handleError, always returns 0, and says on screen what did not happen --
in words that name the RECORDING as the failure, because "Secure Boot
enrolment failed" sends the next person to a firmware screen that is perfectly
fine.
sbState() is re-read at report time rather than reusing the value from the top
of the task, because the db path CHANGES the state it is reporting: writing
the PK is what leaves Setup Mode.
tests/checks/secureboot-enrolment-report.sh covers it, and every assertion in
it was made to go red by reintroducing the defect it exists to catch. Two of
them were not gates until that was done: the ordering case passed with a
report moved below its own completion, because the previous exit's report
satisfied it, and the argv case passed with the POST turned into a GET.
Server side: FOGProject/fogproject#1451, and
docs/adr/0029 there for the whole design.
Co-Authored-By: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Companion to FOGProject/fogproject#1451. That PR adds a per-host Secure Boot and enrolment ledger; this is the half only FOS can supply.
The problem
fog.enrollsbhas three exits and every one of them ends with the same argument-free. /bin/fog.nonimgcomplete, so from the server all three look identical — the task completed. They are not remotely the same thing:dbdbwas written, it is enrolledtrustedmokRecording the third as an enrolment is a lie an administrator acts on: they turn Secure Boot on in firmware and the machine stops booting.
What this does
Adds
sbReport()tosecureboot-funcs.shand calls it from each of the three exits, posting the outcome and the certificate fingerprint the task already computes and prints toservice/secureboot.report.php.The fingerprint is not decoration. An enrolment date alone goes stale in silence — FOG has PKI zones, a multi-server CA and certificates that expire, so "enrolled 2026-03-14" says nothing about whether the machine trusts what the server is serving today, which is the question an administrator actually has.
sbCertFingerprint()andFOGConfigurationPage::secureBoot()already produce the identical string, so the comparison is equality and there is no new computation on either side.sbState()is re-read at report time rather than reusing the value from the top of the task, because thedbpath changes the state it is reporting: writing the PK is what leaves Setup Mode.Best-effort by design
This is the half worth reading twice. The enrolment has already happened by the time
sbReportruns. A server too old to have the endpoint answers 404; an unreachable one answers nothing; in both cases the machine is enrolled and the task must still complete.So
sbReportnever callshandleError, always returns 0, and says on screen what did not happen — in words that name the recording as the failure. "Secure Boot enrolment failed" would send the next person to a firmware screen that is perfectly fine:Tests
New
tests/checks/secureboot-enrolment-report.sh, twelve cases, mirroring the sandbox-plus-stubbed-curl mechanism ofserver-post-reporting.sh. It pins:INPUT_POSTonly, so a call that lost its data argument would still reach a 200 and look fine;mokand neverdb— anchored on the whole call line, because a grep for the function name alone passes when the argument has been changed, and the argument is the entire point;Every assertion was made to go red by reintroducing the defect it exists to catch. Two of them were not gates until that was done, and both looked fine on a read-through:
sh tests/run-all.sh— 17 passed, 0 failed.Order
Merge fogproject#1451 first. Until the endpoint exists,
sbReportgets a 404 and prints its note; nothing else changes, and no task fails either way.🤖 Generated with Claude Code
https://claude.ai/code/session_01C2gFRQ3Khhx24FNYMZhW6N