Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Handle misconfigured config directory and file permissions #1415

Closed
anonymous-piwik-user opened this Issue · 6 comments

2 participants

@anonymous-piwik-user

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

Sorry, what problem is this a solution for?

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

@anonymous-piwik-user

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

Can you post a stacktrace for this code path?

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

@anonymous-piwik-user

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

I see.

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

@robocoder

(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-piwik-user anonymous-piwik-user added this to the Piwik 0.6.3 milestone
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.