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

Config file is checked multiple times with different checks #13104

Closed
LukasReschke opened this issue Jan 5, 2015 · 2 comments
Closed

Config file is checked multiple times with different checks #13104

LukasReschke opened this issue Jan 5, 2015 · 2 comments

Comments

@LukasReschke
Copy link
Member

LukasReschke commented Jan 5, 2015

From owncloud-archive/documentation#731 (comment):


Oh fun, oh fun.

What happens here is that our awesome code-base has the "is config writable check" in at least three different places and the logic is all different - yay.

  1. A check in lib/private/config.php whether the file config/config.php exists (

    core/lib/private/config.php

    Lines 172 to 178 in c36bac3

    if(!is_resource ($filePointer)) {
    $url = \OC_Helper::linkToDocs('admin-dir_permissions');
    throw new HintException(
    "Can't write into config directory!",
    'This can usually be fixed by '
    .'<a href="' . $url . '" target="_blank">giving the webserver write access to the config directory</a>.');
    }
    )
  2. A check in lib/base.php whether the file config/config.php is writable or the read-only mode is set (

    core/lib/base.php

    Lines 198 to 216 in 891474b

    // Check if config is writable
    $configFileWritable = is_writable($configFilePath);
    if (!$configFileWritable && !OC_Helper::isReadOnlyConfigEnabled()
    || !$configFileWritable && \OCP\Util::needUpgrade()) {
    if (self::$CLI) {
    echo $l->t('Cannot write into "config" directory!')."\n";
    echo $l->t('This can usually be fixed by giving the webserver write access to the config directory')."\n";
    echo "\n";
    echo $l->t('See %s', array(\OC_Helper::linkToDocs('admin-dir_permissions')))."\n";
    exit;
    } else {
    OC_Template::printErrorPage(
    $l->t('Cannot write into "config" directory!'),
    $l->t('This can usually be fixed by '
    . '%sgiving the webserver write access to the config directory%s.',
    array('<a href="'.\OC_Helper::linkToDocs('admin-dir_permissions').'" target="_blank">', '</a>'))
    );
    }
    }
    )
  3. A check in lib/private/util.php which checks whether the config directory is writable. The even more funny thing here is that this code path is only called for new sessions, thus all existing sessions will work happily but as soon as you start a new one things will explode.(

    core/lib/private/util.php

    Lines 509 to 516 in aec79b0

    if (!is_writable(OC::$configDir) or !is_readable(OC::$configDir)) {
    $errors[] = array(
    'error' => $l->t('Cannot write into "config" directory'),
    'hint' => $l->t('This can usually be fixed by '
    . '%sgiving the webserver write access to the config directory%s.',
    array('<a href="' . \OC_Helper::linkToDocs('admin-dir_permissions') . '" target="_blank">', '</a>'))
    );
    }
    )

For the sake of having an usable documentation I'd say that we adjust the documentation for now and in the future unify these insane checks somehow in core - but that is unrelated… No need to have them at three different places and also no need to be different everywhere. Especially the third check is really some magic voodoo which abuses the session storage totally ;-)


Related to #11843

@MorrisJobke
Copy link
Contributor

see also #13736

@PVince81
Copy link
Contributor

PVince81 commented Mar 1, 2016

Did we make any progress here, even small ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants