-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
fix: detect inadvertent overlapping config files that break things #49956
base: master
Are you sure you want to change the base?
Conversation
Fixes #32648 Detects when there are multiple config files and any of them other than the default `config.php` contain a `version` string: the telltale sign of an inadvertent `*.config.php` (such as a backup) existing in `config/` and creating a conflict (which breaks upgrades). Also refactors error message handling. Signed-off-by: Josh <[email protected]>
Also see #49926. |
} | ||
|
||
// Try to acquire a file lock | ||
if (!flock($filePointer, LOCK_SH)) { | ||
throw new \Exception(sprintf('Could not acquire a shared lock on the config file %s', $file)); | ||
http_response_code(500); |
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.
Use Http framework:
server/lib/public/AppFramework/Http.php
Line 253 in ce29068
public const STATUS_INTERNAL_SERVER_ERROR = 500; |
if (isset($CONFIG) && is_array($CONFIG)) { | ||
// try to detect unintentionally overlapping config files (which will break things like upgrades) | ||
if (isset($CONFIG['version']) && $file !== $this->configFilePath) { | ||
http_response_code(500); |
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.
Same here.
Summary
Addresses avoidable support matters (on the forum/etc) and invalid bug reports about updating/upgrading problems when people back up their
config.php
as something likeold.config.php
. This can create numerous problems (i.e. "Why are my config changes never taking effect?" and "Why does my Nextcloud keep saying it needs an upgrade after upgrading?").This PR detects when there are multiple config files and any of them (other than the default
config.php
) contain aversion
string. This is a telltale sign of an inadvertent*.config.php
(such as a backup) existing inconfig/
and creating a conflict.Since this is a Nextcloud Server managed parameter + the built-in updater doesn't even support multiple configuration files there is virtually zero chance this is a valid situation. So we consider it fatal.
PR also lightly enhances and refactors error message handling same area of code a bit:
Fatal error: Uncaught Error: Typed static property OC::$server must not be accessed before initialization in /[...]
alongside the actual error)basename
in all, not just most cases (to minimize exposure of unnecessary path details to unauthenticated users when seen via the web)TODO
Checklist