Skip to content

Show error message if config file is not readable - #185

Merged
LukasReschke merged 1 commit into
masterfrom
fix-permission-issue
Jun 21, 2016
Merged

Show error message if config file is not readable#185
LukasReschke merged 1 commit into
masterfrom
fix-permission-issue

Conversation

@MorrisJobke

Copy link
Copy Markdown
Member

cc @adsworth@Mar1u5 @williambargent @LukasReschke@schiessle

@MorrisJobkeMorrisJobke added bug 3. to review Waiting for reviews labels Jun 21, 2016
@MorrisJobkeMorrisJobke added this to the Nextcloud Next milestone Jun 21, 2016
@MorrisJobke

MorrisJobke commented Jun 21, 2016

Copy link
Copy Markdown
MemberAuthor

@adsworth the stable9 patch looks like this (because of some refactoring this patch doesn't apply to stable9)

diff --git a/lib/private/config.php b/lib/private/config.php
index 368dafd..2a21cd6 100644
--- a/lib/private/config.php+++ b/lib/private/config.php@@ -184,10 +184,11 @@ class Config {
// Include file and merge config
foreach ($configFiles as $file) {
- $filePointer = file_exists($file) ? fopen($file, 'r') : false;+ $fileExistsAndIsReadable = file_exists($file) && is_readable($file);+ $filePointer = $fileExistsAndIsReadable ? fopen($file, 'r') : false;
if($file === $this->configFilePath &&
- $filePointer === false &&- @!file_exists($this->configFilePath)) {+ $filePointer === false) {
// Opening the main config might not be possible, e.g. if the wrong
// permissions are set (likely on a new installation)
continue;

Comment threadlib/private/Config.php Outdated
if($file === $this->configFilePath &&
$filePointer === false &&
@!file_exists($this->configFilePath)) {
!$fileExistsAndIsReadable) {

@schiessleschiessleJun 21, 2016

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems to be redundant, if $fileExistsAndIsReadable is false, then $filePointer is already false, see https://github.com/nextcloud/server/pull/185/files#diff-e8ccb791da0aa95230141afcf200336dR188

Btw, the old check didn't checked if the config file exists but if the "configFilePath" exists. Don't know in which cases this makes a difference.

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Btw, the old check didn't checked if the config file exists but if the "configFilePath" exists.

$file === $this->configFilePath ;)

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested your proposal and also thought about it and you are correct :) I fixed it

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Btw, the old check didn't checked if the config file exists but if the "configFilePath" exists.

$file === $this->configFilePath ;)

This just check if $file equals $this->configFilePath.

The old check evaluated the if-statement to false if $this->configFilePath exists but fopen() returned false. The new check would evaluate the if-statement to true.

But I believe that this is just a theoretical difference. I don't see how this should make a difference and also tested it.

* when the config file is not writable there is a error message shown
* same happens now if the config file is not readable
* fixes#180
@MorrisJobke
MorrisJobkeforce-pushed the fix-permission-issue branch from 3409440 to 191a6c6CompareJune 21, 2016 09:25
@LukasReschke

Copy link
Copy Markdown
Member

LGTM

@schiessle

Copy link
Copy Markdown
Member

tested, LGTM

@LukasReschke
LukasReschke merged commit 097cba8 into masterJun 21, 2016
@LukasReschke
LukasReschke deleted the fix-permission-issue branch June 21, 2016 10:14
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3. to reviewWaiting for reviewsbug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

white screen if webserver has no read access to config.php

3 participants

@MorrisJobke@LukasReschke@schiessle