Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Show a more specific error message if config file is not writable #11663
Show a more specific error message if config file is not writable #11663
Changes from all commits
e44ff03
7b7d9fe
ac1d3e6
845cce5
60c1fd1
59fac23
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While I understand the intention of this PR, trying to print a page when config has an error is a bad idea. This will try to load SCSS stuff which might also fail to be written, etc, and then you end up with a blank page instead of message which at least gives you a hint what is wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would
!is_file($this->configFilePath) && !touch($this->configFilePath)
work? I guess when either directory or file is not writabletouch
will fail anyway?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think so 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Technically you are correct,
touch
will fail, but when it fails it fails with a PHP Notice generated. I tried to prevent this by first making sure the touch wouldn't fail due to missing write permissions. Another problem is thattouch
can succeed if the file exists and the current user is the owner of the file but has no write permissions, check https://stackoverflow.com/a/990893 for more information about this.On further testing I also noticed that we should first
touch
and then check foris_writable
because for a non existing fileis_writable
also returnsfalse
, see 5b2cf3cThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just found this. Just wondering is these function broken? I guess when config not writable there should be an error.
server/lib/base.php
Lines 233 to 268 in 40d185e
PhpStorm tells me that
!$configFileWritable && !OC_Helper::isReadOnlyConfigEnabled() || !$configFileWritable && \OCP\Util::needUpgrade()
may not work as expected.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There seems to be a config parameter
config_is_read_only
which can be set totrue
if the config file is intentionally not writable, so I guess there shouldn't always be an error if the config file is not writable.I guess PhpStorm is reporting this because there are no parentheses to clarify the intended order/grouping of those statements, but it seems to do the right thing. At least it makes sense to me, it goes into the if (displaying an error) if either the config file is not writable and not configured to be readonly or if the config file is not writable but an upgrade should be done (which would need to alter the config file).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it makes sense to add a check "is directory writable" to the function above? What do you think is the current check to late? I guess your check is executed much earlier.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if I understand, where exactly would you suggest adding a check 'is directory writable' and how would that help?
I'm not sure if
checkConfig
is called too late, 'my check' is called a bit earlier inbase.php
viaself::initSession()
which might try to create aconfig.php
to set an instance ID. But I don't know if changing the order would be better or not. I guess it wouldn't really matter, we just would have to changecheckConfig
a bit.checkConfig
is usingOC_Template::printErrorPage
which as I already found out in #11663 (comment) tries to do some DB queries which of course can fail if there is no config.php with some DB settings.But as 'my check' is running before that it shouldn't happen because otherwise it wouldn't even get that far to call
checkConfig
.