Skip to content

Conversation

@Morikko
Copy link
Contributor

@Morikko Morikko commented Nov 17, 2017

Issue: #6893

Fix:

  • HTTP status returned is 500 Internal Server Error
  • Add a hint message that the server can allow config file to be read only with "config_is_read_only" set to true.

Notes:

  • My new hint message use l10n but is not translated in any other language than English
  • A first check is done in lib/base.php with function checkConfig(), this one is handle completely.
  • A second one in lib/private/legacy/util.php with function checkServer. This one only check the folder. Thus, it can throw an error if config folder is not writable but config file is writable. Moreover, the http status returned was already 503.

Questions:

  • Should I change the http status returned with the second check to 500 ?
  • Should we open a new issue to correct the behavior of the second check to focus on the file instead of the folder ?

The http status code is now 500 Internal Server Error when config file
can't be written. #6893

Signed-off-by: Eric Masseran <rico.masseran@gmail.com>
If the config.php is not writable, print an error message: #6893
 - with HTTP status 500
 - Set config writable
 - Or set option to keep it read only

Signed-off-by: Eric Masseran <rico.masseran@gmail.com>
@codecov
Copy link

codecov bot commented Nov 17, 2017

Codecov Report

Merging #7205 into master will decrease coverage by 1.05%.
The diff coverage is 22.22%.

@@             Coverage Diff              @@
##             master    #7205      +/-   ##
============================================
- Coverage     51.91%   50.85%   -1.06%     
+ Complexity    25361    24541     -820     
============================================
  Files          1606     1584      -22     
  Lines         95311    93809    -1502     
  Branches       1394     1358      -36     
============================================
- Hits          49478    47704    -1774     
- Misses        45833    46105     +272
Impacted Files Coverage Δ Complexity Δ
lib/base.php 3.06% <0%> (+0.91%) 167 <0> (-1) ⬇️
lib/private/legacy/util.php 58.48% <100%> (+0.18%) 224 <0> (-16) ⬇️
apps/admin_audit/lib/Actions/GroupManagement.php 0% <0%> (-100%) 4% <0%> (ø)
...are/Security/Exceptions/AppNotEnabledException.php 0% <0%> (-100%) 1% <0%> (ø)
...ware/Security/Exceptions/NotConfirmedException.php 0% <0%> (-100%) 1% <0%> (ø)
apps/workflowengine/lib/Check/RequestUserAgent.php 0% <0%> (-96.43%) 10% <0%> (-4%)
apps/dav/lib/AppInfo/PluginManager.php 0% <0%> (-71.93%) 31% <0%> (ø)
apps/admin_audit/lib/Actions/AppManagement.php 0% <0%> (-66.67%) 3% <0%> (ø)
apps/files_sharing/lib/Helper.php 20.35% <0%> (-58.96%) 38% <0%> (+27%)
apps/comments/lib/Activity/Listener.php 23.52% <0%> (-56.87%) 10% <0%> (ø)
... and 668 more

lib/base.php Outdated
[ $urlGenerator->linkToDocs('admin-dir_permissions') ])
[ $urlGenerator->linkToDocs('admin-dir_permissions') ]) . '. '
. $l->t('Or, if you prefer to keep config.php file read only, set the option "config_is_read_only" to true in it. See %s',
[ $urlGenerator->linkToDocs('admin-config') ] )
Copy link
Member

@MorrisJobke MorrisJobke Nov 17, 2017

Choose a reason for hiding this comment

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

Could you fix the indentation of that and one below. We use tabs

Signed-off-by: Eric Masseran <rico.masseran@gmail.com>
lib/base.php Outdated
} else {

header('HTTP/1.1 500 Internal Server Error');
header('Status: 500 Internal Server Error');
Copy link
Member

@LukasReschke LukasReschke Nov 27, 2017

Choose a reason for hiding this comment

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

Go with http_response_code(500); instead.

Morikko and others added 2 commits November 29, 2017 19:59
@juliusknorr
Copy link
Member

@Morikko There is another check in lib/private/Config.php Could i ask you to adjust that as well? Otherwise the changes look good to me. 👍

@juliusknorr juliusknorr added 3. to review Waiting for reviews and removed 2. developing Work in progress labels Apr 18, 2018
@juliusknorr juliusknorr added this to the Nextcloud 14 milestone Apr 18, 2018
@juliusknorr juliusknorr requested a review from MorrisJobke April 18, 2018 10:07
@juliusknorr
Copy link
Member

My new hint message use l10n but is not translated in any other language than English

That is normal. Translations will be added though transifex after the PR is merged.

Should I change the http status returned with the second check to 500 ?

Yes, I'd say 500 makes more sense here.

Should we open a new issue to correct the behavior of the second check to focus on the file instead of the folder ?

Yes, we should probably consolidate all those config checks into one method that can then be used in the different places.

[ $urlGenerator->linkToDocs('admin-dir_permissions') ]) . '. '
. $l->t('Or, if you prefer to keep config.php file read only, set the option "config_is_read_only" to true in it. See %s',
[ $urlGenerator->linkToDocs('admin-config') ] )
);
Copy link
Member

Choose a reason for hiding this comment

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

Could you check the indentation of this, because it looks off. We usually use tabs for indenting lines. Beside that the changes look good 👍

Copy link
Member

@MorrisJobke MorrisJobke left a comment

Choose a reason for hiding this comment

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

Looks good except the one little nitpick.

@skjnldsv
Copy link
Member

@juliushaertl you broke the sign-off ^^

@MorrisJobke MorrisJobke added the stale Ticket or PR with no recent activity label Jun 19, 2018
@skjnldsv
Copy link
Member

@Morikko could you rebase and drop the unsigned merge pr?

@nextcloud-bot nextcloud-bot removed the stale Ticket or PR with no recent activity label Jun 26, 2018
MorrisJobke added a commit that referenced this pull request Jun 26, 2018
…instead of the actual resource

* found while reviewing #7205

Signed-off-by: Morris Jobke <hey@morrisjobke.de>
echo $l->t('See %s', [ $urlGenerator->linkToDocs('admin-config') ])."\n";
exit;
} else {
http_response_code(500);
Copy link
Member

Choose a reason for hiding this comment

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

I added this to the printErrorPage one in #9995

@MorrisJobke
Copy link
Member

Let me take this one and create a new PR out of this.

@MorrisJobke
Copy link
Member

@Morikko Sorry that we missed this for so long. I rebased your PR and squashed the commits into one (with you as Author). Thanks for this contribution and you are welcome to help out with other issues :)

See #9996 for the rebased version of this.

See https://github.com/nextcloud/server/issues?q=is%3Aopen+is%3Aissue+label%3A%22good+first+issue%22 for other good first issues ;)

Thanks a lot

@MorrisJobke MorrisJobke removed this from the Nextcloud 14 milestone Jun 26, 2018
MorrisJobke added a commit that referenced this pull request Jun 26, 2018
…instead of the actual resource

* found while reviewing #7205

Signed-off-by: Morris Jobke <hey@morrisjobke.de>
MorrisJobke added a commit that referenced this pull request Jun 26, 2018
…instead of the actual resource

* found while reviewing #7205
* allow to specify a special status code

Signed-off-by: Morris Jobke <hey@morrisjobke.de>
MorrisJobke added a commit that referenced this pull request Jun 26, 2018
…instead of the actual resource

* found while reviewing #7205
* allow to specify a special status code

Signed-off-by: Morris Jobke <hey@morrisjobke.de>
@Morikko
Copy link
Contributor Author

Morikko commented Jun 26, 2018

Thank you @MorrisJobke for merging this. I had started when I had more time few months ago. Now, I am still busy on some other projects to keep continuing.

MorrisJobke added a commit that referenced this pull request Jun 26, 2018
…instead of the actual resource

* found while reviewing #7205
* allow to specify a special status code

Signed-off-by: Morris Jobke <hey@morrisjobke.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3. to review Waiting for reviews enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants