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

Handle misconfigured config directory and file permissions #1415

Closed
anonymous-matomo-user opened this issue Jun 8, 2010 · 6 comments
Closed
Labels
Bug For errors / faults / flaws / inconsistencies etc.
Milestone

Comments

@anonymous-matomo-user
Copy link

Hi,

this time I have a solution. So, in the Piwik_Config::init() method, the is_readable($this->pathIniFileUserConfig) is made after the attempt to read the config file. I think the code should be swapped to look like this:

if(!is_readable($this->pathIniFileUserConfig))
        {
            die("The configuration file {$this->pathIniFileUserConfig} has not been found.");
        }
        $this->defaultConfig = new Piwik_Config_Ini($this->pathIniFileDefaultConfig, null, true);

Also note that I've placed a die instead of throwing an exception. The exception was silent, and no error where displayed about the config not found.

And then, many critical error were occuring because the config was missing. So a die() statement looked like useful at this place as we don't want the excecution to continue.

@robocoder
Copy link
Contributor

Sorry, what problem is this a solution for?

The exception is used to launch the installer. (See core/FrontController.php)

@anonymous-matomo-user
Copy link
Author

the is_readable() is made after the attempt to read the config file.

... the file is read before knowing if you can read it. In my case, you couldn't (file doesn't exist), so an uncatched exception was thrown.

@robocoder
Copy link
Contributor

Can you post a stacktrace for this code path?

Normally, this is caught by core/FrontController, which then launches the installer.

@anonymous-matomo-user
Copy link
Author

No, I cannot really do it, as I've fixed the code on my installation & I'm configured & I've desactivated XDebug as the site is now in production.

But just try to remove your config file, you should reproduce the bug.

And even without reproducing, just look at the "logic" behind the code:
Read a file, and then check if it's readable... what's the point ?

@robocoder
Copy link
Contributor

I see.

The patch is wrong, but I'm testing a fix now. Thanks.

@robocoder
Copy link
Contributor

(In [2290]) fixes #1415 - prettier error messages for misconfigurations

tested all possible combinations:

  • config/ directory not readable
  • config/global.ini.php not readable (but exists)
  • config/global.ini.php doesn't exist
  • config/global.ini.php empty
  • config/global.ini.php exists and:
    • config/config.ini.php not readable (but exists)
    • config/config.ini.php doesn't exist; triggers installer
    • config/config.ini.php empty
  • config/global.ini.php and config/config.ini.php both exist; normal

@anonymous-matomo-user anonymous-matomo-user added this to the Piwik 0.6.3 milestone Jul 8, 2014
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug For errors / faults / flaws / inconsistencies etc.
Projects
None yet
Development

No branches or pull requests

2 participants