Skip to content
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

Configuration randomly cleared #11070

Closed
stefan-niedermann opened this issue Sep 14, 2014 · 46 comments
Closed

Configuration randomly cleared #11070

stefan-niedermann opened this issue Sep 14, 2014 · 46 comments

Comments

@stefan-niedermann
Copy link

i'm using OC 7.0.2 since it is released, without any problem.

Suddenly it can not remember its admin account or any other - it shows me the init-screen, but i have already much data and files on it.

do you know something about what could cause such an issue? i did not manually manipulate files or database.

I'm running php 5.3, mysql on debian (shared hoster, so it's difficult to get more detailled information). i have 2 mounted ftps (which worked till yet without problems).

i hope you have any idea.

bildschirmfoto vom 2014-09-14 12 05 54

@stefan-niedermann
Copy link
Author

The only content in my config/config.php seems to be

<?php
$CONFIG = array (
  'instanceid' => 'oca212f9132c',
);

is there any chance i can restore my setup if i find a backup of the config file? would it be possible to restore the data without the config file? i think a problem could be the salt, it's stored in this file, isn't it?

@PVince81
Copy link
Contributor

@stefan-niedermann that's very weird.
The screen you're seeing is the install screen, so obviously your admin password will not work there.

The config.php is not supposed to be empty.
You should be able to restore it from your backups.

Can you post your owncloud.log ? I hope there are any clues why the config was emptied.

@PVince81
Copy link
Contributor

To clarify: just restore the config.php from your backup. This should give you back access.

@stefan-niedermann
Copy link
Author

To clarify: just restore the config.php from your backup. This should give you back access.

I found a backup and replacing the file with my backup worked very well.

I have no idea what cleared the config.php-file. i can provide you my log-file, but only on private way (e.g. email). the log is 4,5 mb big, so i don't have hope you will find any information (i already read it). there are many errors, but they are "normal" because my shared hoster provides only a very old php-version.

i would be fine with closing this issue - it's your choice if you want to try to figgure out what happend, i will help you.

@LukasReschke
Copy link
Member

I'd be very interested in the log file and the webservers' access log (if available) - can you drop me a mail (lukas@owncloud.com) with it? - Thanks!

@stefan-niedermann
Copy link
Author

I sent you an email. webservers' access log is deleted every day - i don't have it anymore.
I experimented with the new "Turn Off Code Checker"-App (to install the music app) - i think it writes a flag in the config.php file - maybe this could cause the issue?

@LukasReschke
Copy link
Member

This is very unlikely. I'll dig into your log. Thanks!

@MTRichards MTRichards added this to the 2014-sprint-05-next milestone Sep 15, 2014
@bantu
Copy link

bantu commented Sep 16, 2014

@LukasReschke and I believe that this is likely caused by a race condition while two concurrent processes write out the config.php file.
If that is the case, this can be solved by turning the config file into a file that is only written once and is then read only as has been suggested multiple times before. Actual application configuration can then be stored in the database.

@PVince81
Copy link
Contributor

As @bantu I also suspect a race condition.
I remember seeing a similar report in the past but we weren't able to trace the part that would overwrite the file.

@bantu in the short term can this be achieved with file locking of some sorts ? (flock)

@LukasReschke LukasReschke changed the title [OC 7.0.2] OC does not remember its administrator account Configuration randomly cleared Sep 16, 2014
@stefan-niedermann
Copy link
Author

WTF it happened again? oO I'm using OC now for years, but two times the same heavy error within 10 days?!
I will disable the "Turn Off Code Checker"-App. I hope this will help.

@PVince81
Copy link
Contributor

DAmn, misclicked

@PVince81 PVince81 reopened this Sep 23, 2014
@PVince81
Copy link
Contributor

Can we add configuration locking ? At least a write lock ?

@LukasReschke
Copy link
Member

@MTRichards Can you please rerate this? - "Medium" seems a little bit low for something that may trigger data loss.

@PVince81
Copy link
Contributor

"data loss" as in "forgot to save the config.php and lost the password salt".

@schiesbn are the private keys encrypted with the user's password directly or the hashed password ?

@Silkeyway
Copy link

This issue is happening for me too, lost the file 4 times in the last 24 hours.
@PVince81 - I managed to emergency-recover my installation while I had no access to my backed-up config.php by moving the password salt and salted admin password from the database and config.php of the remains of another old unused installation over to my 7.0.2 installation. File access is possible.

Steps to reproduce

  1. Just set up ownCloud 7.0.2 as fresh installation, and used it.

Expected behaviour

Can't specify. Just logging in and using the installation.

Actual behaviour

The installation becomes fully unusable due to the config.php file being reduced to only setting the instanceid for the config array. Every other information is lost. Couldn't find a specific cause for this.

Server configuration

(this is a custom installation on a hosting service (all-inkl.com), info as obtained from phpinfo(); )

Operating system: Linux dd32126 3.2.0-64-generic #97-Ubuntu SMP Wed Jun 4 22:04:21 UTC 2014 x86_64

Web server: Apache

Database: MySQL 5.5.35-nmm2-log - (Ubuntu)

PHP version: 5.4.32-nmm1

ownCloud version: 7.0.2 (stable)

Updated from an older ownCloud or fresh install: Fresh install

List of activated apps: Activity, Calendar, Contacts, Deleted Files, Documents, Encryption, First Run Wizard, Full Text Search, Mail Template Editor, PDF Viewer, Pictures, Share Files, Text Editor, Updater, Versions, Video Viewer, News, Turn Off App Codechecker

The content of config/config.php:

Before:

<?php
$CONFIG = array (
  'instanceid' => '...',
  'passwordsalt' => '...',
  'trusted_domains' => 
  array (
    ...
  ),
  'datadirectory' => '...',
  'dbtype' => 'mysql',
  'version' => '7.0.2.1',
  'dbname' => '...',
  'dbhost' => 'localhost',
  'dbtableprefix' => 'oc_',
  'dbuser' => '...',
  'dbpassword' => '...',
  'installed' => true,
  'appcodechecker' => false,
  'loglevel' => '0',
  'overwritehost' => '...',
  'overwriteprotocol' => 'https',
  'overwritewebroot' => '...',
  'overwritecondaddr' => '^...$',
);

After:

<?php
$CONFIG = array (
  'instanceid' => '...',
);

(left out spaces '...' for privacy, hope it's okay that way)

Are you using external storage, if yes which one: none

Are you using encryption: yes

Client configuration

Browser: Firefox 32 for Ubuntu / Firefox 32 Windows

Operating system: Lubuntu 14.04 / Windows 7

Logs

Web server error log

Could not yet obtain it in original, support told me there's nothing there to be seen.

ownCloud log (data/owncloud.log)

Can't identify anything related, this is all that's been happening all day:

Error   PHP Cannot modify header information - headers already sent at .../owncloud/lib/private/appframework/app.php#68 2014-09-24T07:05:58+00:00
Error   PHP Cannot modify header information - headers already sent at .../owncloud/lib/private/appframework/app.php#64 2014-09-24T07:05:58+00:00
Error   PHP Cannot modify header information - headers already sent at .../owncloud/lib/private/appframework/app.php#60 2014-09-24T07:05:58+00:00

Browser log

happens without browser interaction

@LukasReschke
Copy link
Member

Seems really to be a race condition which we also observed without the "Turn Off App Codechecker" app. - So we have to fix this.

Proposal:

Short-term: Let's remove the "Turn Off App Code Checker" app \cc @Raydiation
Mid-term: Add a file lock on the config - I guess this would make sense.

@LukasReschke
Copy link
Member

Code of the turn off app code checker app (app.php):

<?php
if (\OCP\Config::getSystemValue('appcodechecker') !== false) {
    \OCP\Config::setSystemValue('appcodechecker', false);
}

@BernhardPosselt
Copy link
Contributor

I'm happy that my app was able to discover this really obscure bug :)

Shortterm goal should be a file lock which is 1 line of code since the bug severity IMO is pretty high. Please get this in before 7.0.3

@LukasReschke
Copy link
Member

@craigpg @MTRichards FYI ^

@BernhardPosselt
Copy link
Contributor

@BernhardPosselt
Copy link
Contributor

Pass this as the third parameter for file_put_contents https://github.com/owncloud/core/blob/master/lib/private/config.php#L172: LOCK_EX

@BernhardPosselt
Copy link
Contributor

LukasReschke added a commit that referenced this issue Sep 25, 2014
This adds a file lock to the config in hope that this prevents race conditions as reported in #11070

Testplan:

- [ ] Delete config.php and make it read-only => Error is thrown that it is not writeable
- [ ] Installation still works
- [ ] Changing config settings works (i.e. using the SMTP config switches in the administration menu)
- [ ] Your PC didn't blow up
- [ ] Installing the news app and the "Disable AppCode checker" app did not destroy your installation
@LukasReschke LukasReschke mentioned this issue Sep 25, 2014
5 tasks
@LukasReschke
Copy link
Member

@stefan-niedermann @jcpro It would be totally awesome if you could test if the changes in #11303 would help in your case.

@stefan-niedermann Please keep the "Disable Appcode Checker App" enabled for this. Thanks!

@jcpro
Copy link

jcpro commented Sep 25, 2014

I don't know what you mean by that, I don't see a Disable Appcode Checker App.

@LukasReschke
Copy link
Member

Yeah - that was only meant for Stefan. In your case it would be sufficient if you would apply my changes and report back whether nothing exploded :)

@stefan-niedermann
Copy link
Author

@LukasReschke i will test this patch, but i'm not sure how to reproduce the scenario, so i can only copy the new files and see if it might happen again...

@LukasReschke
Copy link
Member

Yeah. That would be cool - race conditions are nearly impossible to properly reproduce.

Thank you!

@craigpg craigpg modified the milestones: 2014-sprint-05-current, 2014-sprint-04 Sep 29, 2014
LukasReschke added a commit that referenced this issue Sep 30, 2014
This adds a file lock to the config in hope that this prevents race conditions as reported in #11070

Testplan:

- [ ] Delete config.php and make it read-only => Error is thrown that it is not writeable
- [ ] Installation still works
- [ ] Changing config settings works (i.e. using the SMTP config switches in the administration menu)
- [ ] Your PC didn't blow up
- [ ] Installing the news app and the "Disable AppCode checker" app did not destroy your installation

Only skip the main config

Otherwise read only additional configs might not be processed

Test on tmpdir
@LukasReschke
Copy link
Member

Potential fix merged with #11303

Please report back if the failure persists despite using this patch.

LukasReschke added a commit that referenced this issue Oct 1, 2014
This adds a file lock to the config in hope that this prevents race conditions as reported in #11070

Testplan:

- [ ] Delete config.php and make it read-only => Error is thrown that it is not writeable
- [ ] Installation still works
- [ ] Changing config settings works (i.e. using the SMTP config switches in the administration menu)
- [ ] Your PC didn't blow up
- [ ] Installing the news app and the "Disable AppCode checker" app did not destroy your installation

Only skip the main config

Otherwise read only additional configs might not be processed

Test on tmpdir
@BernhardPosselt
Copy link
Contributor

from the docs
On some operating systems flock() is implemented at the process level. When using a multithreaded server API like ISAPI you may not be able to rely on flock() to protect files against other PHP scripts running in parallel threads of the same server instance!

you may want to mention that in the admin docs that this feature is unsupported

@LukasReschke
Copy link
Member

@carlaschroder For our IIS docs - I don't care too much about IIS myself TBH

@BernhardPosselt
Copy link
Contributor

other than that looks solid, just took another stab at the php docs and this seems to be the way to go

@carlaschroder
Copy link

I am baffled and lost. What feature is unsupported, and what docs? I do admin and user, so if it's a dev doc you want someone who knows what they're doing. Which is not me :)

@BernhardPosselt
Copy link
Contributor

@carlaschroder its admin docs :) basically running owncloud on ISAPI should be pointed out as unsupported

@LukasReschke
Copy link
Member

What feature is unsupported, and what docs? I do admin and user, so if it's a dev doc you want someone who knows what they're doing. Which is not me :)

Well, just write that PHP and Windows together are bad and you should use Linux if possible ;-)

@carlaschroder
Copy link

@LukasReschke, I love it. I could consolidate all the Windows pages into one line.

@carlaschroder
Copy link

PR here re: documenting that ISAPI is not supported owncloud-archive/documentation#587

@lock lock bot locked as resolved and limited conversation to collaborators Aug 15, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests