Repository navigation
Force the admin password from CM_INITIAL_ADMIN_PASS on every boot - #24
Merged
Merged
Conversation
Upstream scripts/docker/create_superuser.py only acts when no superuser exists. Every VFB instance boots by restoring a *.pgsql dump that already contains superusers, so that check always fails and CM_INITIAL_ADMIN_PASS is silently ignored - the admin password is whatever the dump happened to carry. It has therefore never been applied to any seeded instance, and the passwords have drifted apart (l1em no longer matches the others). Postgres data lives inside the container and only /backup persists, so a manual correction is wiped on the next recreate. Reapplying on boot is the only durable fix. modify_superuser.py now reads CM_INITIAL_ADMIN_USER/CM_INITIAL_ADMIN_PASS instead of carrying a hardcoded password hash, and is idempotent: it writes only when the password or the staff/active flags actually differ, and is a no-op when the variable is unset or the user does not exist. init.sh invokes it in the background, since catmaid-entry.sh never returns, polling for up to 10 minutes while the fixture loads and the database comes up. Loaders are unaffected - they start from an empty /backup, so upstream create_superuser.py already applies the variable correctly there.
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.
Upstream
scripts/docker/create_superuser.pyonly acts when no superuser exists:Every VFB instance boots by restoring a
*.pgsqldump that already containssuperusers, so that check always fails and
CM_INITIAL_ADMIN_PASSis silentlyignored — the admin password is whatever the dump happened to carry. The
passwords have consequently drifted apart (l1em no longer matches the others).
This is a repair, not a new feature.
init.shused to force the password,but the code could never have worked:
A missing line break made that
cdwith two arguments, which fails, and the&&-chain meant nothing after it ran. It was removed in 40aaeae ("removingforced password set", 2021) rather than fixed. It also relied on virtualenvwrapper
and a fixed
sleep 2m.Postgres data lives inside the container and only
/backuppersists, so a manualcorrection is wiped on the next recreate. Reapplying on boot is the only durable
fix.
modify_superuser.pynow readsCM_INITIAL_ADMIN_USER/CM_INITIAL_ADMIN_PASSinstead of carrying a hardcoded password hash, and is idempotent: it writes only
when the password or the staff/active flags actually differ, and is a no-op when
the variable is unset or the user does not exist.
init.shinvokes it in the background, sincecatmaid-entry.shnever returns,polling for up to 10 minutes while the fixture loads and the database comes up.
It uses the current venv at
/home/envrather than virtualenvwrapper.Loaders are unaffected: they start from an empty
/backup, so upstreamcreate_superuser.pyalready applies the variable correctly there.Tested against a fixture: retries without hanging when the database never comes
up, applies immediately when ready, recovers when it arrives late, and does not
delay
catmaid-entry.sh.