fix(installer): stop resurrecting files FOG has dropped from management/other - #1346
Merged
Merged
Conversation
…nt/other
configureHttpd() does `rm -rf $webdirdest` and rebuilds from source, then
restores loose files from the pre-wipe backup of management/other/ -- the
directory an administrator's own files live in. Deciding "ours or theirs" was
done from a hardcoded list, `gpl-3.0.txt` and `index.php`.
That list is a second, hand-kept description of what the release ships, and it
drifted the first time FOG dropped a file it had been shipping there.
management/other/_variables.scss -- the Font Awesome 4 icon list the picker
used to read, dead since the FA7 migration -- was not on it, so every install
classified it as the administrator's and copied it back. It could never leave
an upgraded server, on any install, ever.
FOG owns three kinds of file in that directory and they need three different
answers, which is what the first attempt at this got wrong:
1. What this release ships. Asked of the source tree now, so it cannot drift
from what is actually shipped.
2. What FOG shipped there in the PAST and dropped. The source tree CANNOT
see these -- a file the release no longer ships is indistinguishable from
one the administrator put there -- so retirement is recorded in
retired_web_other, which is append-only. Add a name there in the same
commit that removes the file from packages/web.
3. ca.*, not shipped at all but minted into the directory by
_installCATrustAnchor(). Restoring the previous one over a freshly
generated CA hands the server a stale trust anchor -- the certificate
fog-client pins and iPXE is built against. Kept named, because there is
nothing to derive it from.
The source-tree test alone does NOT fix the reported symptom, and the test
below is what said so: with only that change, _variables.scss is still absent
from the source tree and still restored. Only (2) closes it.
tests/webroot-preserved-files.test.sh EXECUTES the loop against a fixture
rather than reading it -- a textual check passes on a loop that names the
right variables and gets the logic backwards, and the logic is the whole
change. It also pins that the decision is not made from a hand-kept list of
shipped files again, and that the ca.* exclusion survives being tidied away as
redundant.
Mutation-verified, four mutants, all killed:
- drop the retired list -> the dropped file is resurrected
- drop the source-tree test -> a shipped file is overwritten
- drop the ca.* exclusion -> the stale CA is restored
- invert the source-tree test -> shipped files overwritten and the
administrator's own file lost
Suite: 146 passed, 0 failed.
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.
Follow-up to #1344.
_variables.scsswas still on the live tree after aninstallfog.shrun, and this is why.What was happening
configureHttpd()doesrm -rf $webdirdestand rebuilds from source, so an upgrade genuinely gets the new release — then it restores loose files from the pre-wipe backup ofmanagement/other/, which is where an administrator's own files live (ca.cert.pem, a logo, whatever they put there).Deciding "ours or theirs" was done from a hardcoded list:
find .../management/other/ -maxdepth 1 -type f \ -not -name gpl-3.0.txt -a -not -name index.php -a -not -name 'ca.*'That list is a second, hand-kept description of what the release ships, and it drifted the first time FOG dropped a file it had been shipping there.
_variables.scss— the Font Awesome 4 icon list #1344 deleted — was not on it, so every install classified it as the administrator's and copied it back out of the backup. It could never leave an upgraded server, on any install, ever.Three kinds of FOG-owned file, three different answers
The first attempt at this got it wrong, and the test is what said so.
retired_web_other, which is append-only: add a name there in the same commit that removes the file frompackages/web.ca.*— not shipped in the tree at all, but minted into that directory by_installCATrustAnchor(). Restoring the previous one over a freshly generated CA hands the server a stale trust anchor: the certificatefog-clientpins and iPXE is built against. Kept named, because there is nothing to derive it from.The source-tree test alone does not fix the reported symptom. With only that change,
_variables.scssis still absent from the source tree and still restored. Only (2) closes it — that is why the retired list exists rather than being one more thing to remember.Pinned
tests/webroot-preserved-files.test.shexecutes the loop against a fixture rather than reading it — a textual check passes on a loop that names the right variables and gets the logic backwards, and the logic is the whole change. It also pins that the decision is not made from a hand-kept list of shipped files again, and that theca.*exclusion survives being tidied away as redundant.Mutation-verified, four mutants, all killed:
ca.*exclusionSuite: 146 passed, 0 failed. No root, no network, no FOG install needed to run it.
🤖 Generated with Claude Code
https://claude.ai/code/session_01XqpPXAk7bEm8huH9WkiGk6