owncloud / updater

GNU Affero General Public License v3.0
27 stars 19 forks source link

Update to 8.0.2: Cannot redeclare class OC\Security\SecureRandom #86

Closed dreamerworks closed 9 years ago

dreamerworks commented 9 years ago

Got stuck on step 3 "replace". Admin log entry said: "Cannot redeclare class OC\Security\SecureRandom at /MY_WWW_PATH/owncloud/lib/private/security/securerandom.php#24"


Edit by @LukasReschke: A workaround can be found at https://github.com/owncloud/updater/issues/86#issuecomment-99187323

Edit by @VicDeo: And final fix is https://github.com/owncloud/updater/issues/86#issuecomment-85592285

karlitschek commented 9 years ago

@VicDeo @LukasReschke any idea? hint: I just activated the updater for 8.0.2 5min ago

LukasReschke commented 9 years ago

Update from 8.0.0 to 8.0.2 works for me locally here. Can you please fill-out the issue template? Thanks.

https://raw.githubusercontent.com/owncloud/core/master/issue_template.md

VicDeo commented 9 years ago

Tried my production 7.0.4 instance

Here is your backup: /home/vhosts/xxx/data/updater_backup/7.0.4.2-8c142e41 All done. Click to the link below to start database upgrade. Proceed

Without a full report I can only guess that PHP script has been killed by timeout in the middle of replacing process

karlitschek commented 9 years ago

puuuh. Thanks guys :-) heartbeatrateisdroppingbelow200

geiseri commented 9 years ago

i am seeing random failures along the way. i think it could be a combination of timeout on my VPS and the download timeout. is there a way to instigate this update from the occ without needed to mv && upgrade manually?

LukasReschke commented 9 years ago

"random failures along the way" – can you please clarify what you mean with that?

VicDeo commented 9 years ago

I caught https://github.com/owncloud/core/issues/13999 (fixed by removing old contacts and calendar apps) but this is another story. 8.0 runs smoothly so far

LukasReschke commented 9 years ago

Another report at https://github.com/owncloud/core/issues/14797 but without issue template I have no idea ;-)

dreamerworks commented 9 years ago

I know it's closed. Only now I saw the template thing, sorry, next time I'll try to do it properly. When the error occurs, the updater page places a link to open an issue and I saw no mention there to a template one should adhere. Just to say that I had "Options -Indexes" after removing it, deleting all backups and trying again, it worked. Thanks

dcanali commented 9 years ago

Still can't manage to solve this issue, see my issue template: http://davidecanali.com/dl/oc_update.txt

dcrdev commented 9 years ago

Also experiencing this issue.

LukasReschke commented 9 years ago

Do you have some OpCache installed such as APC?

SirWesthoff commented 9 years ago

Steps to reproduce

The error raised when trying to update from 8.0 to 8.0.2 using the owncloud Updater app.

Expected behaviour

Tell us what should happen

Update to version 8.0.2.0

Actual behaviour

Tell us what happens instead

updater is stuck at step 3.Replace with error: Server error. Please check web server log file for details

Tried several times but with no success. Backup files are generated in the updater_backup directory: Sicherungen

Sicherungverzeichnis: /.../updater_backup/

Sicherung Abgeschlossen am
8.0.0.7-1d5bdf09 March 11 2015 15:31:49
8.0.0.7-25b2a165 March 11 2015 15:42:29
8.0.0.7-ce5adbb3 March 11 2015 15:38:11

Server configuration

Operating system: Ubuntu Server 14.04.2 LTS

Web server: Apache/2.4.12 (Ubuntu)

Database: MySQL Server 5.5.41-0ubuntu0.14.04.1

PHP version: PHP 5.6.6-1+deb.sury.org~trusty+1 (cli) (built: Feb 20 2015 11:22:10) Copyright (c) 1997-2015 The PHP Group Zend Engine v2.6.0, Copyright (c) 1998-2015 Zend Technologies with XCache v3.2.0, Copyright (c) 2005-2014, by mOo with Zend OPcache v7.0.4-dev, Copyright (c) 1999-2015, by Zend Technologies with XCache Optimizer v3.2.0, Copyright (c) 2005-2014, by mOo with XCache Cacher v3.2.0, Copyright (c) 2005-2014, by mOo with XCache Coverager v3.2.0, Copyright (c) 2005-2014, by mOo

ownCloud version: (see ownCloud admin page)

ownCloud 8.0 (stable)

Updated from an older ownCloud or fresh install: Fresh installed 8.0.0

List of activated apps: Activity 1.2.0 Bookmarks 0.4 Calendar 0.6.4 Contacts 0.3.0.18 Deleted files 0.6.2 Documents 0.9.0 External Sites 1.2 External storage support 0.2.3 External user support 0.4 File Locking First Run Wizard 1.1 Full Text Search 0.6.0 Mail Template Editor 0.1 PDF Viewer 0.7 Pictures 0.6.0 Provisioning API 0.2 Share Files 0.6.0 Text Editor 0.4 Video Viewer 0.1.3 WebDAV user backend 1.1.0.1

The content of config/config.php: <?php $CONFIG = array ( 'instanceid' => 'passwordsalt' => 'secret' => 'trusted_domains' => array ( 0 => 1 => 'datadirectory' => 'overwrite.cli.url' => 'dbtype' => 'mysql', 'version' => '8.0.0.7', 'dbname' => 'dbhost' => 'localhost', 'dbtableprefix' => 'dbuser' => 'dbpassword' => 'installed' => true, 'forcessl' => true, 'forceSSLforSubdomains' => true, 'loglevel' => 1, 'mail_smtpmode' => 'smtp', 'mail_smtpsecure' => 'ssl', 'mail_from_address' => 'mail_domain' => 'mail_smtpauthtype' => 'LOGIN', 'mail_smtpauth' => 1, 'mail_smtphost' => 'mail_smtpport' => '465', 'mail_smtpname' => 'mail_smtppassword' => );

Are you using encryption: yes/no

yes, HTTPS enforced

Are you using an external user-backend, if yes which one: LDAP/ActiveDirectory/Webdav/...

no

LDAP configuration (delete this part if not used)

no LDAP

Client configuration

Browser:

tried both Firefox 36 and Chromium 37

Operating system:

Ubuntu 12.04 & Windows 8.1

Logs

Web server error log

empty, only very old entries

ownCloud log (data/owncloud.log)

{"reqId":"7ab48523641d0a17c77e357434249063","remoteAddr":"93.232.7.124","app":"PHP","message":"Cannot redeclare class OC\Security\SecureRandom at \/var\/www\/html\/lib\/private\/security\/securerandom.php#24","level":3,"time":"2015-03-11T15:32:10+00:00"} {"reqId":"3325a555d65a4046e1bd3213107085fc","remoteAddr":"93.232.7.124","app":"PHP","message":"Cannot redeclare class OC\Security\SecureRandom at \/var\/www\/html\/lib\/private\/security\/securerandom.php#24","level":3,"time":"2015-03-11T15:38:24+00:00"} {"reqId":"e596f738eaf287643b2b6c3698416f2d","remoteAddr":"93.232.7.124","app":"PHP","message":"Cannot redeclare class OC\Security\SecureRandom at \/var\/www\/html\/lib\/private\/security\/securerandom.php#24","level":3,"time":"2015-03-11T15:42:47+00:00"}

LukasReschke commented 9 years ago

Can you run a MD5 over all files in the ownCloud directory (excluding data and config)? – Alternatively upload the application source code somewhere for us.

Looks like it crashed in the middle somewhere while replacing stuff.

dcrdev commented 9 years ago

I don't think I have APC enabled:

My phpinfo output: http://goo.gl/uswY27

MD5 Hashes of Owncloud Directory: http://goo.gl/tlCRDb

geiseri commented 9 years ago

@LukasReschke i tried to run the upgrade via the updater 4 times. twice it failed in the backup part. then it kept failing in the '"Cannot redeclare class OC\Security\SecureRandom at /home/lof/webapps/wploflabs/cloud/lib/private/security/securerandom.php#24''' Honestly I blame the slow filesystem writes on my VPS. If file operations take too long I have seen php fail.

CliffMitchell commented 9 years ago

I just hit exactly the same problem trying to upgrade to 8.0.2 ffrom 8.0.

ghost commented 9 years ago

Exactly same log and issue like heartsaver at here :( I run my instance on rather great specs (Duo Core 2.1 GHz, 4 GB RAM, only 2 users). Also tried via wired LAN. So to me, the problem doesn't seem to be a slow server performance.

ghost commented 9 years ago

Found a solution, wait a sec

ghost commented 9 years ago

My update from 8.0 to 8.0.2 worked after this. Can someone check this for a long term solution?

dcrdev commented 9 years ago

That fix didn't work for me.. Still getting the same error in the log.

I am now getting a new debug message: Exception: {"Message":"No basic authentication headers were found","Code":0,"Trace":"#0

dogsbody commented 9 years ago

I too am getting this error and cannot upgrade from 8.0.0 to 8.0.2

As well as...

Cannot redeclare class OC\Security\SecureRandom at /home/.sites/106/site15/web/lib/private/security/securerandom.php#24"

... I am also getting...

file_exists(): open_basedir restriction in effect. File(/dev/urandom) is not within the allowed path(s): (/var/lib/php/session/:/home/sites/xyz.example.com:/usr/sausalito/configs/php/:/tmp/:/home/.sites/106/site15/) at /home/.sites/106/site15/web/3rdparty/ircmaxell/random-lib/lib/RandomLib/Source/URandom.php#57

... and as one other person reported I am now getting this debug error too...

Exception: {"Message":"No basic authentication headers were found","Code":0,"Trace":"#0 \/home\/.sites\/106\/site15\/web\/lib\/private\/connector\/sabre\/auth.php(123): Sabre\\DAV\\Auth\\Backend\\AbstractBasic->authenticate(Object(OC_Connector_Sabre_Server), 'ownCloud')\n#1 \/home\/.sites\/106\/site15\/web\/lib\/private\/connector\/sabre\/auth.php(103): OC_Connector_Sabre_Auth->auth(Object(OC_Connector_Sabre_Server), 'ownCloud')\n#2 \/home\/.sites\/106\/site15\/web\/3rdparty\/sabre\/dav\/lib\/Sabre\/DAV\/Auth\/Plugin.php(108): OC_Connector_Sabre_Auth->authenticate(Object(OC_Connector_Sabre_Server), 'ownCloud')\n#3 [internal function]: Sabre\\DAV\\Auth\\Plugin->beforeMethod('PROPFIND', 'Dropbox')\n#4 \/home\/.sites\/106\/site15\/web\/3rdparty\/sabre\/dav\/lib\/Sabre\/DAV\/Server.php(433): call_user_func_array(Array, Array)\n#5 \/home\/.sites\/106\/site15\/web\/3rdparty\/sabre\/dav\/lib\/Sabre\/DAV\/Server.php(455): Sabre\\DAV\\Server->broadcastEvent('beforeMethod', Array)\n#6 \/home\/.sites\/106\/site15\/web\/3rdparty\/sabre\/dav\/lib\/Sabre\/DAV\/Server.php(214): Sabre\\DAV\\Server->invokeMethod('PROPFIND', 'Dropbox')\n#7 \/home\/.sites\/106\/site15\/web\/apps\/files\/appinfo\/remote.php(61): Sabre\\DAV\\Server->exec()\n#8 \/home\/.sites\/106\/site15\/web\/remote.php(54): require_once('\/home\/.sites\/10...')\n#9 {main}","File":"\/home\/.sites\/106\/site15\/web\/3rdparty\/sabre\/dav\/lib\/Sabre\/DAV\/Auth\/Backend\/AbstractBasic.php","Line":73}

Thank you in advance.

LukasReschke commented 9 years ago

file_exists(): open_basedir restriction in effect. File(/dev/urandom) is not within the allowed path(s): (/var/lib/php/session/:/home/sites/stash.dogsbodyhosting.net:/usr/sausalito/configs/php/:/tmp/:/home/.sites/106/site15/) at /home/.sites/106/site15/web/3rdparty/ircmaxell/random-lib/lib/RandomLib/Source/URandom.php#57

That is interesting. This has been fixed with the 8.0.2 release, so somehow it is still using the old code. Mhm…

...

LukasReschke commented 9 years ago

Got access to some affected system, stacktrace:

[Thu Mar 12 15:24:45 2015] [error] [client 77.58.106.23] PHP Fatal error:  Cannot redeclare class OC\\Security\\SecureRandom in /var/www/owncloud/lib/private/security/securerandom.php on line 24, referer: https://cloud.xyz.com/owncloud/index.php/apps/updater/update.php
[Thu Mar 12 15:24:45 2015] [error] [client 77.58.106.23] PHP Stack trace:, referer: https://cloud.xyz.com/owncloud/index.php/apps/updater/update.php
[Thu Mar 12 15:24:45 2015] [error] [client 77.58.106.23] PHP   1. {main}() /var/www/owncloud/index.php:0, referer: https://cloud.xyz.com/owncloud/index.php/apps/updater/update.php
[Thu Mar 12 15:24:45 2015] [error] [client 77.58.106.23] PHP   2. OC::handleRequest() /var/www/owncloud/index.php:36, referer: https://cloud.xyz.com/owncloud/index.php/apps/updater/update.php
[Thu Mar 12 15:24:45 2015] [error] [client 77.58.106.23] PHP   3. OC\\Route\\Router->match() /var/www/owncloud/lib/base.php:763, referer: https://cloud.xyz.com/owncloud/index.php/apps/updater/update.php
[Thu Mar 12 15:24:45 2015] [error] [client 77.58.106.23] PHP   4. call_user_func() /var/www/owncloud/lib/private/route/router.php:250, referer: https://cloud.xyz.com/owncloud/index.php/apps/updater/update.php
[Thu Mar 12 15:24:45 2015] [error] [client 77.58.106.23] PHP   5. __lambda_func() /var/www/owncloud/lib/private/route/router.php:250, referer: https://cloud.xyz.com/owncloud/index.php/apps/updater/update.php
[Thu Mar 12 15:24:45 2015] [error] [client 77.58.106.23] PHP   6. require_once() /var/www/owncloud/lib/private/route/route.php(135) : runtime-created function:1, referer: https://cloud.xyz.com/owncloud/index.php/apps/updater/update.php
[Thu Mar 12 15:24:45 2015] [error] [client 77.58.106.23] PHP   7. OCA\\Updater\\Updater::update() /var/www/owncloud/apps/updater/ajax/update.php:27, referer: https://cloud.xyz.com/owncloud/index.php/apps/updater/update.php
[Thu Mar 12 15:24:45 2015] [error] [client 77.58.106.23] PHP   8. OCA\\Updater\\Location->update() /var/www/owncloud/apps/updater/lib/updater.php:44, referer: https://cloud.xyz.com/owncloud/index.php/apps/updater/update.php
[Thu Mar 12 15:24:45 2015] [error] [client 77.58.106.23] PHP   9. OCA\\Updater\\Location->finalize() /var/www/owncloud/apps/updater/lib/location.php:53, referer: https://cloud.xyz.com/owncloud/index.php/apps/updater/update.php
[Thu Mar 12 15:24:45 2015] [error] [client 77.58.106.23] PHP  10. OCA\\Updater\\App::log() /var/www/owncloud/apps/updater/lib/location.php:62, referer: https://cloud.xyz.com/owncloud/index.php/apps/updater/update.php
[Thu Mar 12 15:24:45 2015] [error] [client 77.58.106.23] PHP  11. OCP\\Util::writeLog() /var/www/owncloud/apps/updater/lib/app.php:58, referer: https://cloud.xyz.com/owncloud/index.php/apps/updater/update.php
[Thu Mar 12 15:24:45 2015] [error] [client 77.58.106.23] PHP  12. OC_Log::write() /var/www/owncloud/lib/public/util.php:82, referer: https://cloud.xyz.com/owncloud/index.php/apps/updater/update.php
[Thu Mar 12 15:24:45 2015] [error] [client 77.58.106.23] PHP  13. call_user_func() /var/www/owncloud/lib/private/legacy/log.php:50, referer: https://cloud.xyz.com/owncloud/index.php/apps/updater/update.php
[Thu Mar 12 15:24:45 2015] [error] [client 77.58.106.23] PHP  14. OC\\Log->info() /var/www/owncloud/lib/private/legacy/log.php:50, referer: https://cloud.xyz.com/owncloud/index.php/apps/updater/update.php
[Thu Mar 12 15:24:45 2015] [error] [client 77.58.106.23] PHP  15. OC\\Log->log() /var/www/owncloud/lib/private/log.php:120, referer: https://cloud.xyz.com/owncloud/index.php/apps/updater/update.php
[Thu Mar 12 15:24:45 2015] [error] [client 77.58.106.23] PHP  16. call_user_func() /var/www/owncloud/lib/private/log.php:157, referer: https://cloud.xyz.com/owncloud/index.php/apps/updater/update.php
[Thu Mar 12 15:24:45 2015] [error] [client 77.58.106.23] PHP  17. OC_Log_Owncloud::write() /var/www/owncloud/lib/private/log.php:157, referer: https://cloud.xyz.com/owncloud/index.php/apps/updater/update.php
[Thu Mar 12 15:24:45 2015] [error] [client 77.58.106.23] PHP  18. OC_Request::getRequestID() /var/www/owncloud/lib/private/log/owncloud.php:71, referer: https://cloud.xyz.com/owncloud/index.php/apps/updater/update.php
[Thu Mar 12 15:24:45 2015] [error] [client 77.58.106.23] PHP  19. OC\\Server->getSecureRandom() /var/www/owncloud/lib/private/request.php:52, referer: https://cloud.xyz.com/owncloud/index.php/apps/updater/update.php
[Thu Mar 12 15:24:45 2015] [error] [client 77.58.106.23] PHP  20. OC\\AppFramework\\Utility\\SimpleContainer->query() /var/www/owncloud/lib/private/server.php:594, referer: https://cloud.xyz.com/owncloud/index.php/apps/updater/update.php
[Thu Mar 12 15:24:45 2015] [error] [client 77.58.106.23] PHP  21. Pimple\\Container->offsetGet() /var/www/owncloud/lib/private/appframework/utility/simplecontainer.php:91, referer: https://cloud.xyz.com/owncloud/index.php/apps/updater/update.php
[Thu Mar 12 15:24:45 2015] [error] [client 77.58.106.23] PHP  22. OC\\Server->OC\\{closure}() /var/www/owncloud/3rdparty/pimple/pimple/src/Pimple/Container.php:112, referer: https://cloud.xyz.com/owncloud/index.php/apps/updater/update.php
[Thu Mar 12 15:24:45 2015] [error] [client 77.58.106.23] PHP  23. OC\\Autoloader->load() /var/www/owncloud/3rdparty/pimple/pimple/src/Pimple/Container.php:0, referer: https://cloud.xyz.com/owncloud/index.php/apps/updater/update.php
[Thu Mar 12 15:24:45 2015] [error] [client 77.58.106.23] PHP  24. require_once() /var/www/owncloud/lib/autoloader.php:114, referer: https://cloud.xyz.com/owncloud/index.php/apps/updater/update.php
LukasReschke commented 9 years ago

Seems not to be a timeout or memory issue. Increased both values to very high values and still the same failure…

LukasReschke commented 9 years ago

READ THIS POST FOR A WORKAROUND

I really do have problems to reproduce this locally on my test environments, I even copied the same php.ini settings etc.

Edit by VicDeo Workaround is not recommended Please use fix from here https://github.com/owncloud/updater/issues/86#issuecomment-99187323

@VicDeo Can you please take-over from here? – I don't really know what would cause this and really have other things on my backlog. This bug is really real and needs to get fixed somehow :see_no_evil:

LukasReschke commented 9 years ago

@fcturner @heartsaver @dcanali @CliffMitchell Could you try if that workaround works for you as well? The applications' source code can be found in /apps/

LukasReschke commented 9 years ago

If it still does not work please try to install xdebug and take a look at the ownCloud log as well as the PHP error log file (mostly /var/log/apache2/errorlog) and post any relevant output.

dcanali commented 9 years ago

Awesome, commenting out that line solved the problem for me :) Thank you @LukasReschke

LukasReschke commented 9 years ago

One naive guess for the cause could that the folks experiencing this error are using some kind of slow / cached FS and thus the overwrite process is not yet finished.

Other explanation might be that the autoloader runs havoc somehow…

Notice that the instance where I debugged this does not have a user-cache or APC installed.

dcrdev commented 9 years ago

Commenting that line out hasn't helped for me, still getting: Cannot redeclare class OC\Security\SecureRandom at /xxx/xxx/xxx/htdocs/cloud/lib/private/security/securerandom.php#24

I commented that line out in my existing install and in the 8.0.2 zip.

Also looking at my apache logs, I'm seeing this: [mpm_prefork:error] [pid 6566] AH00161: server reached MaxRequestWorkers setting

That particular setting is set to 150 - which should be more than adequate, shouldn't it?

TecJon commented 9 years ago

Same problem as OP here.

sebader commented 9 years ago

Same problem for me. Changing stringutils.php does not work for me.

LukasReschke commented 9 years ago

I don't know who said you should change stringutils.php - that will work not at all and only introduce other more critical security bugs.

Please try the changes suggested at https://github.com/owncloud/updater/issues/86#issuecomment-78503941

sebader commented 9 years ago

oh, nevermind :/ I got confused with the one above... This one acutally works. Thanks!

dcrdev commented 9 years ago

As stated #86 didn't work for me...

I'm assuming I'm not missing something: http://pastebin.com/FhRXDtKN

I don't want to, but if worst comes to worst, can I do a manual update?

LukasReschke commented 9 years ago

@dcrdev Please open a new bug report then as yours seems to have another root cause.

That said, a manual update should work, yes.

TecJon commented 9 years ago

@LukasReschke #86 solved it but only to go one step further. Not sure if related.

Upgrade DB produces "CSRF attack. Connection will be closed."
And after continuing: "This ownCloud instance is currently being updated, which may take a while. This page will refresh itself when the ownCloud instance is available again. Contact your system administrator if this message persists or appeared unexpectedly. Thank you for your patience."

No web server error log.

OC log:

{"reqId":"2f1a8d6b8e9a9a3153058917dcb53ed4","remoteAddr":"xx.xxx.xxx.xxx","app":"index","message":"Exception: {\"Message\":\"\",\"Code\":0,\"Trace\":\"#0 \/var\/www\/owncloud\/lib\/private\/app.php(77): OC_App::loadApp('files_sharing')\n#1 \/var\/www\/owncloud\/lib\/private\/util.php(75): OC_App::loadApps(Array)\n#2 \/var\/www\/owncloud\/lib\/base.php(766): OC_Util::setupFS()\n#3 \/var\/www\/owncloud\/index.php(36): OC::handleRequest()\n#4 {main}\",\"File\":\"\/var\/www\/owncloud\/lib\/private\/app.php\",\"Line\":96}","level":4,"time":"2015-03-12T18:49:50+00:00"}

LukasReschke commented 9 years ago

That is an unrelated error that 8.0.3 will fix, meanwhile please try disabling the maintenance mode manually in your config file and try to re-update the instance. It should work then.

TecJon commented 9 years ago

Already tried to disable it manually. Unfortunately didn't change anything.

LukasReschke commented 9 years ago

Interesting. Can you open a new bug report as well? I'll investigate this tomorrow. It's already after 20:00 here.

TecJon commented 9 years ago

@LukasReschke Can be found here https://github.com/owncloud/updater/issues/92

Huster-at-github commented 9 years ago

Thanks, https://github.com/owncloud/updater/issues/86#issuecomment-78503941 worked for me!

ghost commented 9 years ago

Had the same problem https://github.com/owncloud/updater/issues/86#issuecomment-78503941 worked for me, too!

casparflintstone commented 9 years ago

I have the same issue - mod updater.php #86 does not work OwnCloud 8.0.1->8.0.2 Ubuntu Linux 14.04.2

[Fri Mar 13 10:40:53.937107 2015] [unixd:alert] pid 394Invalid argument: AH02156: setgid: unable to set group id to Group 4294967295 [Fri Mar 13 10:21:17.094460 2015] [:error] [pid 30645] [client 192.168.1.39:16975] PHP Fatal error: Cannot redeclare class OC\Security\SecureRandom in /var/www/owncloud/lib/private/security/securerandom.php on line 24, referer: https://192.168.1.63/index.php/apps/updater/update.php [Fri Mar 13 10:41:52.002315 2015] [unixd:alert] pid 497Invalid argument: AH02156: setgid: unable to set group id to Group 4294967295

1337sup3rh4x0r commented 9 years ago

Thank you, the #86 (comment) worked for me too!

farandag commented 9 years ago

Thanks, #86 worked for me too!

rsevat commented 9 years ago

Thanks, 86 also worked for me.

casparflintstone commented 9 years ago

86: only line 62 commented out worked fine (/ & /)

RaphaelSalique commented 9 years ago

Thanks, the #86 worked for me too