Closed MBlagui closed 10 years ago
What config file are you speaking of? Very convoluted writing.
I assume Me.B is referring to the db.cnf file as seen here ( https://github.com/sentora/sentora-core/blob/master/cnf/db.php)
On 19 November 2014 08:46, Rakhmanov notifications@github.com wrote:
What config file are you speaking of? Very convoluted writing.
— Reply to this email directly or view it on GitHub https://github.com/sentora/sentora-core/issues/64#issuecomment-63608369.
Can really this to be done ? If I understand well:
I know there are a number of ways this can be achieved eg. with variables in the PHP.ini file and environmental variables but to be honest these are all very dangerous... eg if someone can create a PHP script they only then need to call the environmental variables eg. echo getenv('mysql_root_pass') to get the result etc. of use phpinfo() function to return all PHP vars - I'm sure that if having the DB settings in a PHP include file was really all that bad then other, much larger projects such as Wordpress etc. would have implemented something different by now!
Maybe I'm missing something but I've worked with PHP for a very long time and I'm racking my brains at the moment to work out what the 'solution' here would be (one that is actually water-tight from all directions as there are pros and cons for all the alternatives that I've been thinking oft!)
Maybe I should Goolge lol!
On 19 November 2014 14:10, Pascal Peyremorte notifications@github.com wrote:
Can really this to be done ? If I understand well:
- you want that this file is not reachable in case of hack of the panel.
- it must be reachable in order to use the panel. These two points seems me to be mutually exclusive.
— Reply to this email directly or view it on GitHub https://github.com/sentora/sentora-core/issues/64#issuecomment-63644600.
If someone has access to your php files on server its too late to worry about mysql root password.
Bobby is correct, using an include file IS the safest way of calling DB info and is the standard for ALL php/mysql sites around the world-why re-invent the wheel? Although, most of them use something like this to lock it down:
if (stristr(htmlentities($_SERVER['PHP_SELF']), 'config.php')) { Header('Location: index.php'); die(); }
If the file is accessed directly it will die and redirect them to the index.php
The test proposed by @TGates71 is even not required because the whole directory cnf is protected by a "deny from all" (apache 2.2) or "require all denied" (apache 2.4) placed in httpd.conf file (line 24)
Except if @MBlagui was thinking to something different, all is correct and nothing more can be done. I'll close this issue.
As a side note, the above could be added as a secondary protection just in case a panel user screws up their deny statement (which I am sure will happen from time to time LOL)
My point here was:
M B
Remove mysql root off config file and place it a file that only hook will access.
Goal in case of panel direct hack Mysql root won't be exposed.