-
Notifications
You must be signed in to change notification settings - Fork 2.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
Migrate config.php to proper config format or move config to DB #11843
Comments
Related to #9713 |
To keep backwards-compatibility:
That way we would not need to worry about migration too much and could easily make it a read-only file. |
JSON sounds nice. 😉 |
I'd vote for JSON over YAML as well - JSON can be read/written with PHP without further components - YAML would need an additional component like symfony/yaml
We could provide console commands for this purpose as well as an config editing page if necessary - the console should be enough from my pov
What we need to keep in mind with this approach is that we carefully need to analyse config settings which belong to the server and which belong to the system. e.g. the version number in config.php is bound to the server and not to the system. But anyway - I'd vote for tiny steps and go for the json approach first |
The configfile format could be change of needed. I´m actually not sure if JSON is a format that provides the optimal readability for users. So not sure about that. |
Well, RW on PHP file is bad, RW on a JSON file is not that bad ;-) If we want to have RO config files we could go with the alternative approach suggested by me:
We would in this case be able to make the config RO after installation. - This would have the advantage that a wrongly configured webserver will not by accident leak the So, there are a lot of possibilities to solve this ;-) |
tl;dr: Still dataloss when using IIS and ownCloud. Switching to another config format would fix that and increase security. I discussed this with @PVince81 on IRC a little bit since this is in my opinion quite an important decision that we need at some point to do. Doing this properly can increase the system hardening for ownCloud installations enormously and shouldn’t be neglected. For example the recent Local file inclusion in core (oC-SA-2014-018) wouldn’t have been possible to exploit in most environments. But this is not the only reason to consider changing to a read-only config and moving settings to the DB: We still have a very critical bug when running ownCloud with IIS which pretty certainly lead to data-loss or even worse people stealing personal data. It is the good old: “Race-condition when reading and writing config and then borking everything resulting in complete configuration loss and an angry mob that wants to lynch us developers”-bug. What makes this even more worse is that then an attacker might be able to reinstall the ownCloud instance. Our users are trusting us with one of their most important stuff: Their data. Our goal is to protect those data and such bugs are really bad for that. Sure, there might be a way to fix this issue but fixing and debugging this for *NIX systems took already a lot of time and I’m pretty sure fixing this might just lead us into other bugs. I see the point that sysadmins might want to be able to modify the settings with an editor such as vim directly in What I am suggesting is:
We could even do this on an evolutionary base, such as migrating every single setting on it’s own. From my point of view this would offer us the following advantages:
First steps would be to progressively move every setting one by one to the new settings table (or oc_appconfig). |
Just putting this in here:
|
"Contra: Not that easy to modify configuration values with a terminal." is a non-issue. You should have console commands for that anyway. You probably also have to flush a cache or two when making changes. See e.g. https://github.com/phpbb/phpbb/tree/develop-ascraeus/phpBB/phpbb/console/command/config Edit: DeepDiver already mentioned that. |
As a follow up to how config values are stored: The config API should be changed for a better support of default values. Specifically, repeating config value defaults all over the code is pointless. There should be one file holding default values as defined by ownCloud and then there should be one file for user specific values that may overwrite the defaults. This way default values can be easily changed with software updates without having to think or care about changes made by the user. As far as I remember the Symfony config component supports all of that, so I would recommend just using that or at least looking into it. http://symfony.com/doc/current/components/config/index.html |
Bug report about IIS and config: #12263 |
Another bug report about NFS and the config: #12300 (Please note that flock is not supported on NFS to my knowledge) |
Work-around for @DeepDiver1975 which allows a read-only config is at #12419 … - Still requires a long-term fix aka "moving settings to the database". |
From a deployment perspective having a minimal config is desirable. Optimally, only the db config should be necessary. The rest should be stored in the db. This makes administration of several web servers a lot easier, because only the db connection needs to be specified. Then the file would contain maybe five settings related to the database. We could go so far as to only store the DSN (Data Source Name) in a config file: http://doctrine.readthedocs.org/en/latest/en/manual/introduction-to-connections.html Something like |
Hmmm. In my opinion everything that is "system configuration" should be in the config file. this makes automatic deployment and setup, remote configuration, config diff and other things a lot easier. This is best practices for most unix services for a long time. |
The alternative would be to only have read-only values in the config.php and move all read-write settings to the database. This means that everything that can be configured in the admin page (ex: mail settings) must go to the database. This would solve the overwrite issue. Or if we still want to go the "everything in the DB except the DB settings" route, then we can provide a CLI tool I'm not sure it is worth to spend an additional man-month to try and fight against (the absence of) windows proper file locking... that man-month could be spent to implement the suggestion above. |
and then if you really want the config settings updates to auto-deploy to the DB, you could have process that observes that "configfilewithupdatesettings" whenever it has changed and use that CLI tool to auto-import them, which gives you almost the same admin experience you had before. |
For most of the configuration setting they are fine to stay in the config file as we have it today as they are basic system setup and will not change during regular operations. With a few exception they are already kind of read-only. Issues start as soon as we write to the config file - e.g. because of the admin changes some setting in the admin page. On the other hand in a single web server setup (which is the most common setup in the the non-enterprise world) changing the config via the web is almost required because accessing the files on the web server might not be that easy (thinking about web hosters where one gets ftp access only). This is a circumstance we need to have an answer to. Proposal:
Furthermore we closely review any write operations to the system config and reevaluate if this is the right approach. |
I'd love to see a read-only configuration file that I can template with a config management tool like Ansible. I would say that some of the stuff in the config file should only be in the config file, and some should only be in the database. Like the data dir path would only be in the file, while the mail settings would be in the db. Installs would have the user make the file rw, then ro after the install was complete. |
With overwrite.cli.url we need a writable .htaccess too. 9.0.1 offers shortend URLs by means of adding a rewrite rule to .htaccess like this
This feature needs a review for improved hardening. |
@butonic @DeepDiver1975 reopen the discussion about having a read-only config.php and move all non-database options to the database ? |
absolutly ➕ 💯 |
➕ 💯 for readonly config cc @cdamken @felixboehm @pako81 @michaelstingl @dercorn @kawohl @CaptionF @RealRancor @tflidd |
cc @pmaier1 |
|
9.2? |
even if the whole thing isn't complete by 9.2, we can still start working on first migrating the read-write settings. |
Hi, This "copy/paste/adapt" thing is the point. If the conf must be stored inside the DB, won't it be more difficult for the admin, to set the config options for his apps ? A JSON file or a YAML file could be an alternative to the php one, but a file seems very usefull IMHO. |
A file needs to be transferred to every webserver in a scaleout, while the db is just there. |
@ppaysant there is a command |
@ppaysant to give more context, the reason for this idea is because currently ownCloud also updates config.php which requires this file to be writable. The idea is to have at least all read-write settings in the database and the read-only ones could stay in config.php if needed. |
This was fixed for 9.1 |
backlog for now, need to schedule time for this |
Classic case of too long didn't read … 😝 I vote for JSON because JavaScript!! |
Currently the ownCloud config is stored within
config/config.php
within a PHP array, the files has to be r/w.While this is a pragmatic solution there are several problems with that:
From a security PoV it is desirable to make the whole ownCloud folder read-only, if an attacker gained read-only access to the FS he cannot escalate his privileges further. (which might be handy in combination with the server-side encryption app)
Furthermore, using PHP to store the config means that an attacker can execute any arbitrary PHP code as soon as he gained full FS access of the ownCloud folder.
Therefore I'd recommend one of the following approaches:
The text was updated successfully, but these errors were encountered: