allow DB_PASSWORD with # character #429
Merged
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.
Problem
When using MYSQL_PASSWORD that contains
#
character, the entrypoint scripts write the/opt/librenms/.env
file in a way that Laravel will interpret as a comment. Source: https://laravel.com/docs/5.8/upgrade#environment-variable-parsingProposed solution
In the
03-config.sh
entrypoint file, wrap the DB_PASSWORD entry in the/opt/librenms/.env
in double quotes. This allows Laravel (and underlying phpdotenv package) to handle the#
correctly.Test steps
Even when quoting the value of
MYSQL_PASSWORD
in the docker compose.env
, the value gets written to the/opt/librenms/.env
file without quotes. You can confirm intest/
environment on default branch:test
.env
with something likeMYSQL_PASSWORD="asupersecretpassword-test#hash"
docker compose up -d
docker compose logs -f librenms
docker compose exec db mysql -u librenms -p
Repeat test steps on this PR branch and database migrations should pass. Some other helpful commands to check DB_PASSWORD while in the librenms web container:
cat .env
lnms tinker
-> in new prompt, enterenv("DB_PASSWORD")
lnms db