Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

Remote database connection does not work with '$' in database username

  • SimonCropper
  • SimonCropper's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
5 years 3 months ago #179081 by SimonCropper
Hi Everyone,

This is as much a warning as a request for an explanation.

I have been trying the establish a remote MySQL / MariaDB connection for my LimeSurvey CE instance. LimeSurvey is on one machine (front-end) and the database on another (back-end).

We had an operational instance of limesurvey working when pointing to localhost - that is, when the database was on the same machine.

The minute we updated the config files to use a remote connection, no connection was made (all firewall setting were verified as being OK).

After quite a bit of effort we discovered that the problem was the user name. It included the charcater '$'.

So, if we had a MySQL user name 'abc$def' in the config file connection settings then the connection would not work. If we changed it to 'abcdef' it did (assuming the MySQL database has a user by that name). The inclusion of the '$' symbol was purely random and worked without any issues when the database was on the same machine.

The thing that got us thinking was when we tried to make a connection and 'abc'@somedomain.com was included in the error rather than 'abc$def'@somedomain.com. It appeared the connection was being made through the command line and the symbol $ was being treated as a macro substitution character - the variable 'def' was blank so the user name was truncated from 'abc$def' to 'abc'.

Anyway, can someone explain this? Does LimeSurvey use an external program to make remote connections via a command that is chained / piped thus explaining the abovementioned behaviour or am I misinterpreting what is happening?

Any feedback would be appreciated.

Cheers Simon

Cheers Simon
The topic has been locked.
  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
5 years 3 months ago #179137 by holch
my guess would be that LS is filtering the "$" as this symbol is used in the configuration file, see here:

github.com/LimeSurvey/LimeSurvey/blob/ma.../config-defaults.php

So I guess if your variables like the MySQL user would include $ this might be a problem for LS to work. But this is just a guess, I am not a developer.

I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.

The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
5 years 3 months ago #179141 by DenisChenu
LS don't really filter , see secure.php.net/manual/en/language.variables.basics.php

$ is a special character,

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
The topic has been locked.
  • SimonCropper
  • SimonCropper's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
5 years 3 months ago #179169 by SimonCropper
The puzzling thing is that when running on localhost LS worked fine. It was only when we moved the database to another machine that we had issues. This implies that a remote connection is made differently than a local connection but I can't find the point in the code that this occurs.

Cheers Simon
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
5 years 3 months ago #179175 by DenisChenu
Can you check application/config/config.php if you use ' or " for string here : github.com/LimeSurvey/LimeSurvey/blob/f7...sample-mysql.php#L29

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
The topic has been locked.
  • SimonCropper
  • SimonCropper's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
5 years 3 months ago #179222 by SimonCropper
I checked, and the connection string is surrounded by single inverted commas that same as your example.

Cheers Simon
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
5 years 3 months ago #179231 by DenisChenu
Can you activate debug mode (to 2) maybe we can find where this replacement is done (but i think it's a Yii issue, not a LS issue).

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
The topic has been locked.
  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
5 years 3 months ago #179272 by holch

but i think it's a Yii issue, not a LS issue

Which makes it a LS issue, if Yii comes with LS.

I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.

The topic has been locked.
  • SimonCropper
  • SimonCropper's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
5 years 3 months ago #179274 by SimonCropper
Thanks for the feedack. Unfortunately LS did not even appear in the browser until this error was resolved so turning on debug will be mute. This suggests that essential data needed to present LS in the browser is stored in the database. No database connection, no LS. The only way we discovered the issue was manually connecting to the server, which in itself suggests that it is a MySQL, the MySQL linux drivers or the connection routine used by Yii that is causing the problem.

Cheers Simon
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
5 years 3 months ago #179279 by DenisChenu

holch wrote:

but i think it's a Yii issue, not a LS issue

Which makes it a LS issue, if Yii comes with LS.

Yes, but more hard to fix …

And clearly, i'm sure if bug is reported , it was fixed by an update to manuel «don't use $ in sql username» :P

(and it's understandable since $ is a reserved caracter in PHP)

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose