bitnami / containers

Bitnami container images
https://bitnami.com
Other
3.29k stars 4.78k forks source link

[bitnami/matomo] Matomo initialisation fails to test database connection when there is # in the password #72352

Open artm opened 2 weeks ago

artm commented 2 weeks ago

Name and Version

bitnami/matomo:latest

What architecture are you using?

None

What steps will reproduce the bug?

  1. have a # in the database password
  2. have matomo initialize
  3. stop and remove the container, configuration is saved on the persistent volume
  4. start the container, the configuration is read from the persistent volume
  5. testing the database connection when "Trying to connect to the database server" is logged receive "ERROR 1045 (28000): Access denied for user 'matomo'@'xxxxxxx' (using password: YES)"

What is the expected behavior?

matomo restarts

What do you see instead?

"Could not connect to the database" in the log after several failed attempt

Additional information

this happens because ini-file get here fails to read a password containing # (everying from # on is thrown away)

dgomezleon commented 2 weeks ago

Hi @artm

Thank you for bringing this issue to our attention

This is a particular scenario. Apart from avoiding that character, I can see 3 workarounds:

What do you think? If you're interested in contributing a solution, we welcome you to create a pull request. The Bitnami team will review your submission and offer feedback. You can find the contributing guidelines here.

artm commented 2 weeks ago

Hi @dgomezleon

We have indeed regenerated the password without # as a workaround.

I think fixing ini-file is the correct solution. I would like to give it a try.

artm commented 2 weeks ago

I had a look at the utility and think there is no need to fix it. ini-file get supports a flag --ignore-inline-comments which fixes the problem.

artm commented 2 weeks ago

On the other hand, treating # (or ;) inside a quoted string as a comment marker is still wrong, so I'm still considering how much effort it would be to fix.

artm commented 2 weeks ago

In fact, the problem was reported earlier and partially solved: https://github.com/bitnami/ini-file/issues/7 The # and ; aren't treated as comment markers between backticks, but not double or single quotes

artm commented 2 weeks ago

I was wrong, that issue is different, it is about output of ini-file set using backticks as string markers. But my next finding was correct: the reader treats backticked strings correctly, but not double/single quotes.

dgomezleon commented 2 weeks ago

Thanks for your implication here.

I had a look at the utility and think there is no need to fix it. ini-file get supports a flag --ignore-inline-comments which fixes the problem.

I completely forgot that option. So to sum up a little bit. Would you consider adding the option for the container and create a separate issue/PR for ini-file repo if needed?

artm commented 2 weeks ago

sure!

I'm investigating the ini-file further, the actual ini file parsing is done by its dependency - https://github.com/go-ini/ini , I think the root cause is in that library, I'll go with my analysis.

In the mean time I'll add a workaround with --ignore-inline-comments to the matomo container.

artm commented 2 weeks ago

@dgomezleon is [./.vib/matomo/goss]() the setup for the tests? Are there some guidelines for writing the tests? And could I run matomo specific tests locally before submitting a PR?

dgomezleon commented 2 weeks ago

Hi @artm ,

Find here our testing guides for containers and charts. Note that our container testing is simpler than charts (something in our TODO list).