Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow DB_PASSWORD with # character #429

Merged
merged 1 commit into from
Apr 6, 2024

Conversation

haydenseitz
Copy link
Contributor

@haydenseitz haydenseitz commented Apr 3, 2024

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-parsing

Proposed 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 in test/ environment on default branch:

  1. cd test
  2. Update .env with something like MYSQL_PASSWORD="asupersecretpassword-test#hash"
  3. Start compose stack: docker compose up -d
  4. View librenms web logs: docker compose logs -f librenms
  5. On a new database, migration scripts will fail with incorrect password error
  6. Verify that access to db container works with MYSQL_PASSWORD: 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, enter env("DB_PASSWORD")
  • lnms db

@CLAassistant
Copy link

CLAassistant commented Apr 3, 2024

CLA assistant check
All committers have signed the CLA.

Copy link
Member

@crazy-max crazy-max left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM thanks!

@crazy-max crazy-max merged commit fd34218 into librenms:master Apr 6, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants