2011-11-19 11:56:40 +01:00
< ? php
2021-04-26 12:33:36 +02:00
declare ( strict_types = 1 );
2011-11-19 11:56:40 +01:00
/**
2016-07-21 17:07:57 +02:00
* @ copyright Copyright ( c ) 2016 , ownCloud , Inc .
2016-10-31 11:07:54 +01:00
* @ copyright Copyright ( c ) 2016 , Lukas Reschke < lukas @ statuscode . ch >
2016-07-21 17:07:57 +02:00
*
2016-05-26 19:56:05 +02:00
* @ author Arthur Schiwon < blizzz @ arthur - schiwon . de >
2017-11-06 15:56:42 +01:00
* @ author Bjoern Schiessle < bjoern @ schiessle . org >
2019-12-03 19:57:53 +01:00
* @ author Christoph Wurst < christoph @ winzerhof - wurst . at >
2016-05-26 19:56:05 +02:00
* @ author Frank Karlitschek < frank @ karlitschek . de >
2019-12-03 19:57:53 +01:00
* @ author Georg Ehrke < oc . list @ georgehrke . com >
2021-06-04 21:52:51 +02:00
* @ author J0WI < J0WI @ users . noreply . github . com >
2016-07-21 17:07:57 +02:00
* @ author Joas Schilling < coding @ schilljs . com >
2020-12-16 14:54:15 +01:00
* @ author Julius Härtl < jus @ bitgrid . net >
2016-05-26 19:56:05 +02:00
* @ author Lukas Reschke < lukas @ statuscode . ch >
2015-03-26 11:44:34 +01:00
* @ author Morris Jobke < hey @ morrisjobke . de >
2016-07-21 18:13:36 +02:00
* @ author Robin Appelman < robin @ icewind . nl >
2017-11-06 15:56:42 +01:00
* @ author Roeland Jago Douma < roeland @ famdouma . nl >
2015-06-25 11:43:55 +02:00
* @ author Steffen Lindner < mail @ steffen - lindner . de >
2015-03-26 11:44:34 +01:00
* @ author Thomas Müller < thomas . mueller @ tmit . eu >
* @ author Victor Dubiniuk < dubiniuk @ owncloud . com >
2020-12-16 14:54:15 +01:00
* @ author Vincent Petry < vincent @ nextcloud . com >
2015-03-26 11:44:34 +01:00
*
* @ license AGPL - 3.0
*
* This code is free software : you can redistribute it and / or modify
* it under the terms of the GNU Affero General Public License , version 3 ,
* as published by the Free Software Foundation .
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU Affero General Public License for more details .
*
* You should have received a copy of the GNU Affero General Public License , version 3 ,
2019-12-03 19:57:53 +01:00
* along with this program . If not , see < http :// www . gnu . org / licenses />
2015-03-26 11:44:34 +01:00
*
2011-11-19 11:56:40 +01:00
*/
2013-07-06 17:00:00 +02:00
namespace OC ;
2014-07-24 17:18:54 +02:00
2021-10-01 16:40:25 +02:00
use OC\App\AppManager ;
2021-01-03 15:28:31 +01:00
use OC\DB\Connection ;
2017-06-01 16:56:34 +02:00
use OC\DB\MigrationService ;
2022-08-22 17:59:26 +02:00
use OC\DB\MigratorExecuteSqlEvent ;
2013-07-06 17:00:00 +02:00
use OC\Hooks\BasicEmitter ;
Add code integrity check
This PR implements the base foundation of the code signing and integrity check. In this PR implemented is the signing and verification logic, as well as commands to sign single apps or the core repository.
Furthermore, there is a basic implementation to display problems with the code integrity on the update screen.
Code signing basically happens the following way:
- There is a ownCloud Root Certificate authority stored `resources/codesigning/root.crt` (in this PR I also ship the private key which we obviously need to change before a release :wink:). This certificate is not intended to be used for signing directly and only is used to sign new certificates.
- Using the `integrity:sign-core` and `integrity:sign-app` commands developers can sign either the core release or a single app. The core release needs to be signed with a certificate that has a CN of `core`, apps need to be signed with a certificate that either has a CN of `core` (shipped apps!) or the AppID.
- The command generates a signature.json file of the following format:
```json
{
"hashes": {
"/filename.php": "2401fed2eea6f2c1027c482a633e8e25cd46701f811e2d2c10dc213fd95fa60e350bccbbebdccc73a042b1a2799f673fbabadc783284cc288e4f1a1eacb74e3d",
"/lib/base.php": "55548cc16b457cd74241990cc9d3b72b6335f2e5f45eee95171da024087d114fcbc2effc3d5818a6d5d55f2ae960ab39fd0414d0c542b72a3b9e08eb21206dd9"
},
"certificate": "-----BEGIN CERTIFICATE-----MIIBvTCCASagAwIBAgIUPvawyqJwCwYazcv7iz16TWxfeUMwDQYJKoZIhvcNAQEF\nBQAwIzEhMB8GA1UECgwYb3duQ2xvdWQgQ29kZSBTaWduaW5nIENBMB4XDTE1MTAx\nNDEzMTcxMFoXDTE2MTAxNDEzMTcxMFowEzERMA8GA1UEAwwIY29udGFjdHMwgZ8w\nDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBANoQesGdCW0L2L+a2xITYipixkScrIpB\nkX5Snu3fs45MscDb61xByjBSlFgR4QI6McoCipPw4SUr28EaExVvgPSvqUjYLGps\nfiv0Cvgquzbx/X3mUcdk9LcFo1uWGtrTfkuXSKX41PnJGTr6RQWGIBd1V52q1qbC\nJKkfzyeMeuQfAgMBAAEwDQYJKoZIhvcNAQEFBQADgYEAvF/KIhRMQ3tYTmgHWsiM\nwDMgIDb7iaHF0fS+/Nvo4PzoTO/trev6tMyjLbJ7hgdCpz/1sNzE11Cibf6V6dsz\njCE9invP368Xv0bTRObRqeSNsGogGl5ceAvR0c9BG+NRIKHcly3At3gLkS2791bC\niG+UxI/MNcWV0uJg9S63LF8=\n-----END CERTIFICATE-----",
"signature": "U29tZVNpZ25lZERhdGFFeGFtcGxl"
}
```
`hashes` is an array of all files in the folder with their corresponding SHA512 hashes (this is actually quite cheap to calculate), the `certificate` is the certificate used for signing. It has to be issued by the ownCloud Root Authority and it's CN needs to be permitted to perform the required action. The `signature` is then a signature of the `hashes` which can be verified using the `certificate`.
Steps to do in other PRs, this is already a quite huge one:
- Add nag screen in case the code check fails to ensure that administrators are aware of this.
- Add code verification also to OCC upgrade and unify display code more.
- Add enforced code verification to apps shipped from the appstore with a level of "official"
- Add enfocrced code verification to apps shipped from the appstore that were already signed in a previous release
- Add some developer documentation on how devs can request their own certificate
- Check when installing ownCloud
- Add support for CRLs to allow revoking certificates
**Note:** The upgrade checks are only run when the instance has a defined release channel of `stable` (defined in `version.php`). If you want to test this, you need to change the channel thus and then generate the core signature:
```
➜ master git:(add-integrity-checker) ✗ ./occ integrity:sign-core --privateKey=resources/codesigning/core.key --certificate=resources/codesigning/core.crt
Successfully signed "core"
```
Then increase the version and you should see something like the following:
![2015-11-04_12-02-57](https://cloud.githubusercontent.com/assets/878997/10936336/6adb1d14-82ec-11e5-8f06-9a74801c9abf.png)
As you can see a failed code check will not prevent the further update. It will instead just be a notice to the admin. In a next step we will add some nag screen.
For packaging stable releases this requires the following additional steps as a last action before zipping:
1. Run `./occ integrity:sign-core` once
2. Run `./occ integrity:sign-app` _for each_ app. However, this can be simply automated using a simple foreach on the apps folder.
2015-11-03 20:26:06 +01:00
use OC\IntegrityCheck\Checker ;
2022-08-22 17:59:26 +02:00
use OC\Repair\Events\RepairAdvanceEvent ;
use OC\Repair\Events\RepairErrorEvent ;
use OC\Repair\Events\RepairFinishEvent ;
use OC\Repair\Events\RepairInfoEvent ;
use OC\Repair\Events\RepairStartEvent ;
use OC\Repair\Events\RepairStepEvent ;
use OC\Repair\Events\RepairWarningEvent ;
2015-02-17 12:00:39 +01:00
use OC_App ;
2023-11-23 10:22:34 +01:00
use OCP\App\IAppManager ;
use OCP\EventDispatcher\Event ;
use OCP\EventDispatcher\IEventDispatcher ;
use OCP\HintException ;
use OCP\IConfig ;
use OCP\ILogger ;
use OCP\Util ;
2021-02-01 14:56:56 +01:00
use Psr\Log\LoggerInterface ;
2013-07-06 17:00:00 +02:00
2011-11-19 11:56:40 +01:00
/**
2013-07-08 21:13:23 +02:00
* Class that handles autoupdating of ownCloud
2013-07-06 17:00:00 +02:00
*
* Hooks provided in scope \OC\Updater
* - maintenanceStart ()
* - maintenanceEnd ()
* - dbUpgrade ()
* - failure ( string $message )
2011-11-19 11:56:40 +01:00
*/
2013-07-06 17:00:00 +02:00
class Updater extends BasicEmitter {
2021-04-16 14:26:43 +02:00
/** @var LoggerInterface */
2013-07-06 17:00:00 +02:00
private $log ;
2016-11-11 14:36:17 +01:00
2015-02-17 12:00:39 +01:00
/** @var IConfig */
2014-12-09 23:13:38 +01:00
private $config ;
2013-07-06 17:00:00 +02:00
Add code integrity check
This PR implements the base foundation of the code signing and integrity check. In this PR implemented is the signing and verification logic, as well as commands to sign single apps or the core repository.
Furthermore, there is a basic implementation to display problems with the code integrity on the update screen.
Code signing basically happens the following way:
- There is a ownCloud Root Certificate authority stored `resources/codesigning/root.crt` (in this PR I also ship the private key which we obviously need to change before a release :wink:). This certificate is not intended to be used for signing directly and only is used to sign new certificates.
- Using the `integrity:sign-core` and `integrity:sign-app` commands developers can sign either the core release or a single app. The core release needs to be signed with a certificate that has a CN of `core`, apps need to be signed with a certificate that either has a CN of `core` (shipped apps!) or the AppID.
- The command generates a signature.json file of the following format:
```json
{
"hashes": {
"/filename.php": "2401fed2eea6f2c1027c482a633e8e25cd46701f811e2d2c10dc213fd95fa60e350bccbbebdccc73a042b1a2799f673fbabadc783284cc288e4f1a1eacb74e3d",
"/lib/base.php": "55548cc16b457cd74241990cc9d3b72b6335f2e5f45eee95171da024087d114fcbc2effc3d5818a6d5d55f2ae960ab39fd0414d0c542b72a3b9e08eb21206dd9"
},
"certificate": "-----BEGIN CERTIFICATE-----MIIBvTCCASagAwIBAgIUPvawyqJwCwYazcv7iz16TWxfeUMwDQYJKoZIhvcNAQEF\nBQAwIzEhMB8GA1UECgwYb3duQ2xvdWQgQ29kZSBTaWduaW5nIENBMB4XDTE1MTAx\nNDEzMTcxMFoXDTE2MTAxNDEzMTcxMFowEzERMA8GA1UEAwwIY29udGFjdHMwgZ8w\nDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBANoQesGdCW0L2L+a2xITYipixkScrIpB\nkX5Snu3fs45MscDb61xByjBSlFgR4QI6McoCipPw4SUr28EaExVvgPSvqUjYLGps\nfiv0Cvgquzbx/X3mUcdk9LcFo1uWGtrTfkuXSKX41PnJGTr6RQWGIBd1V52q1qbC\nJKkfzyeMeuQfAgMBAAEwDQYJKoZIhvcNAQEFBQADgYEAvF/KIhRMQ3tYTmgHWsiM\nwDMgIDb7iaHF0fS+/Nvo4PzoTO/trev6tMyjLbJ7hgdCpz/1sNzE11Cibf6V6dsz\njCE9invP368Xv0bTRObRqeSNsGogGl5ceAvR0c9BG+NRIKHcly3At3gLkS2791bC\niG+UxI/MNcWV0uJg9S63LF8=\n-----END CERTIFICATE-----",
"signature": "U29tZVNpZ25lZERhdGFFeGFtcGxl"
}
```
`hashes` is an array of all files in the folder with their corresponding SHA512 hashes (this is actually quite cheap to calculate), the `certificate` is the certificate used for signing. It has to be issued by the ownCloud Root Authority and it's CN needs to be permitted to perform the required action. The `signature` is then a signature of the `hashes` which can be verified using the `certificate`.
Steps to do in other PRs, this is already a quite huge one:
- Add nag screen in case the code check fails to ensure that administrators are aware of this.
- Add code verification also to OCC upgrade and unify display code more.
- Add enforced code verification to apps shipped from the appstore with a level of "official"
- Add enfocrced code verification to apps shipped from the appstore that were already signed in a previous release
- Add some developer documentation on how devs can request their own certificate
- Check when installing ownCloud
- Add support for CRLs to allow revoking certificates
**Note:** The upgrade checks are only run when the instance has a defined release channel of `stable` (defined in `version.php`). If you want to test this, you need to change the channel thus and then generate the core signature:
```
➜ master git:(add-integrity-checker) ✗ ./occ integrity:sign-core --privateKey=resources/codesigning/core.key --certificate=resources/codesigning/core.crt
Successfully signed "core"
```
Then increase the version and you should see something like the following:
![2015-11-04_12-02-57](https://cloud.githubusercontent.com/assets/878997/10936336/6adb1d14-82ec-11e5-8f06-9a74801c9abf.png)
As you can see a failed code check will not prevent the further update. It will instead just be a notice to the admin. In a next step we will add some nag screen.
For packaging stable releases this requires the following additional steps as a last action before zipping:
1. Run `./occ integrity:sign-core` once
2. Run `./occ integrity:sign-app` _for each_ app. However, this can be simply automated using a simple foreach on the apps folder.
2015-11-03 20:26:06 +01:00
/** @var Checker */
private $checker ;
2017-11-24 10:27:58 +01:00
/** @var Installer */
private $installer ;
2015-09-29 14:35:32 +02:00
private $logLevelNames = [
0 => 'Debug' ,
1 => 'Info' ,
2 => 'Warning' ,
3 => 'Error' ,
4 => 'Fatal' ,
];
2016-04-11 13:19:22 +02:00
public function __construct ( IConfig $config ,
2023-11-23 10:22:34 +01:00
Checker $checker ,
? LoggerInterface $log ,
Installer $installer ) {
2013-07-06 17:00:00 +02:00
$this -> log = $log ;
2014-12-09 23:13:38 +01:00
$this -> config = $config ;
Add code integrity check
This PR implements the base foundation of the code signing and integrity check. In this PR implemented is the signing and verification logic, as well as commands to sign single apps or the core repository.
Furthermore, there is a basic implementation to display problems with the code integrity on the update screen.
Code signing basically happens the following way:
- There is a ownCloud Root Certificate authority stored `resources/codesigning/root.crt` (in this PR I also ship the private key which we obviously need to change before a release :wink:). This certificate is not intended to be used for signing directly and only is used to sign new certificates.
- Using the `integrity:sign-core` and `integrity:sign-app` commands developers can sign either the core release or a single app. The core release needs to be signed with a certificate that has a CN of `core`, apps need to be signed with a certificate that either has a CN of `core` (shipped apps!) or the AppID.
- The command generates a signature.json file of the following format:
```json
{
"hashes": {
"/filename.php": "2401fed2eea6f2c1027c482a633e8e25cd46701f811e2d2c10dc213fd95fa60e350bccbbebdccc73a042b1a2799f673fbabadc783284cc288e4f1a1eacb74e3d",
"/lib/base.php": "55548cc16b457cd74241990cc9d3b72b6335f2e5f45eee95171da024087d114fcbc2effc3d5818a6d5d55f2ae960ab39fd0414d0c542b72a3b9e08eb21206dd9"
},
"certificate": "-----BEGIN CERTIFICATE-----MIIBvTCCASagAwIBAgIUPvawyqJwCwYazcv7iz16TWxfeUMwDQYJKoZIhvcNAQEF\nBQAwIzEhMB8GA1UECgwYb3duQ2xvdWQgQ29kZSBTaWduaW5nIENBMB4XDTE1MTAx\nNDEzMTcxMFoXDTE2MTAxNDEzMTcxMFowEzERMA8GA1UEAwwIY29udGFjdHMwgZ8w\nDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBANoQesGdCW0L2L+a2xITYipixkScrIpB\nkX5Snu3fs45MscDb61xByjBSlFgR4QI6McoCipPw4SUr28EaExVvgPSvqUjYLGps\nfiv0Cvgquzbx/X3mUcdk9LcFo1uWGtrTfkuXSKX41PnJGTr6RQWGIBd1V52q1qbC\nJKkfzyeMeuQfAgMBAAEwDQYJKoZIhvcNAQEFBQADgYEAvF/KIhRMQ3tYTmgHWsiM\nwDMgIDb7iaHF0fS+/Nvo4PzoTO/trev6tMyjLbJ7hgdCpz/1sNzE11Cibf6V6dsz\njCE9invP368Xv0bTRObRqeSNsGogGl5ceAvR0c9BG+NRIKHcly3At3gLkS2791bC\niG+UxI/MNcWV0uJg9S63LF8=\n-----END CERTIFICATE-----",
"signature": "U29tZVNpZ25lZERhdGFFeGFtcGxl"
}
```
`hashes` is an array of all files in the folder with their corresponding SHA512 hashes (this is actually quite cheap to calculate), the `certificate` is the certificate used for signing. It has to be issued by the ownCloud Root Authority and it's CN needs to be permitted to perform the required action. The `signature` is then a signature of the `hashes` which can be verified using the `certificate`.
Steps to do in other PRs, this is already a quite huge one:
- Add nag screen in case the code check fails to ensure that administrators are aware of this.
- Add code verification also to OCC upgrade and unify display code more.
- Add enforced code verification to apps shipped from the appstore with a level of "official"
- Add enfocrced code verification to apps shipped from the appstore that were already signed in a previous release
- Add some developer documentation on how devs can request their own certificate
- Check when installing ownCloud
- Add support for CRLs to allow revoking certificates
**Note:** The upgrade checks are only run when the instance has a defined release channel of `stable` (defined in `version.php`). If you want to test this, you need to change the channel thus and then generate the core signature:
```
➜ master git:(add-integrity-checker) ✗ ./occ integrity:sign-core --privateKey=resources/codesigning/core.key --certificate=resources/codesigning/core.crt
Successfully signed "core"
```
Then increase the version and you should see something like the following:
![2015-11-04_12-02-57](https://cloud.githubusercontent.com/assets/878997/10936336/6adb1d14-82ec-11e5-8f06-9a74801c9abf.png)
As you can see a failed code check will not prevent the further update. It will instead just be a notice to the admin. In a next step we will add some nag screen.
For packaging stable releases this requires the following additional steps as a last action before zipping:
1. Run `./occ integrity:sign-core` once
2. Run `./occ integrity:sign-app` _for each_ app. However, this can be simply automated using a simple foreach on the apps folder.
2015-11-03 20:26:06 +01:00
$this -> checker = $checker ;
2017-11-24 10:27:58 +01:00
$this -> installer = $installer ;
2015-05-20 17:06:00 +02:00
}
2013-07-06 17:00:00 +02:00
/**
* runs the update actions in maintenance mode , does not upgrade the source files
2014-02-28 11:59:30 +01:00
* except the main . htaccess file
2014-06-05 16:19:24 +02:00
*
* @ return bool true if the operation succeeded , false otherwise
2013-07-06 17:00:00 +02:00
*/
2021-04-26 12:33:36 +02:00
public function upgrade () : bool {
2016-11-24 16:33:05 +01:00
$this -> logAllEvents ();
2016-04-27 10:51:02 +02:00
2018-04-25 15:22:28 +02:00
$logLevel = $this -> config -> getSystemValue ( 'loglevel' , ILogger :: WARN );
2015-09-29 14:35:32 +02:00
$this -> emit ( '\OC\Updater' , 'setDebugLogLevel' , [ $logLevel , $this -> logLevelNames [ $logLevel ] ]);
2018-04-25 15:22:28 +02:00
$this -> config -> setSystemValue ( 'loglevel' , ILogger :: DEBUG );
2015-09-29 14:35:32 +02:00
2019-02-06 17:08:41 +01:00
$wasMaintenanceModeEnabled = $this -> config -> getSystemValueBool ( 'maintenance' );
2015-05-19 10:27:53 +02:00
2020-04-10 14:19:56 +02:00
if ( ! $wasMaintenanceModeEnabled ) {
2015-05-19 10:27:53 +02:00
$this -> config -> setSystemValue ( 'maintenance' , true );
$this -> emit ( '\OC\Updater' , 'maintenanceEnabled' );
}
2014-06-10 11:47:27 +02:00
2019-04-04 23:32:00 +02:00
// Clear CAN_INSTALL file if not on git
if ( \OC_Util :: getChannel () !== 'git' && is_file ( \OC :: $configDir . '/CAN_INSTALL' )) {
if ( ! unlink ( \OC :: $configDir . '/CAN_INSTALL' )) {
$this -> log -> error ( 'Could not cleanup CAN_INSTALL from your config folder. Please remove this file manually.' );
}
}
2023-04-05 12:50:08 +02:00
$installedVersion = $this -> config -> getSystemValueString ( 'version' , '0.0.0' );
2015-12-18 15:26:54 +01:00
$currentVersion = implode ( '.' , \OCP\Util :: getVersion ());
2018-06-26 16:35:38 +02:00
2020-03-26 09:30:18 +01:00
$this -> log -> debug ( 'starting upgrade from ' . $installedVersion . ' to ' . $currentVersion , [ 'app' => 'core' ]);
2014-02-18 16:26:37 +01:00
2015-06-23 10:03:27 +02:00
$success = true ;
2014-06-10 11:47:27 +02:00
try {
$this -> doUpgrade ( $currentVersion , $installedVersion );
2016-11-09 09:10:32 +01:00
} catch ( HintException $exception ) {
2021-04-16 14:26:43 +02:00
$this -> log -> error ( $exception -> getMessage (), [
'exception' => $exception ,
]);
2020-03-26 09:30:18 +01:00
$this -> emit ( '\OC\Updater' , 'failure' , [ $exception -> getMessage () . ': ' . $exception -> getHint ()]);
2016-11-09 09:10:32 +01:00
$success = false ;
2014-06-10 11:47:27 +02:00
} catch ( \Exception $exception ) {
2021-04-16 14:26:43 +02:00
$this -> log -> error ( $exception -> getMessage (), [
'exception' => $exception ,
]);
2020-03-26 09:30:18 +01:00
$this -> emit ( '\OC\Updater' , 'failure' , [ get_class ( $exception ) . ': ' . $exception -> getMessage ()]);
2015-06-23 10:03:27 +02:00
$success = false ;
2014-06-10 11:47:27 +02:00
}
2020-03-26 09:30:18 +01:00
$this -> emit ( '\OC\Updater' , 'updateEnd' , [ $success ]);
2015-05-19 10:27:53 +02:00
2020-04-10 14:19:56 +02:00
if ( ! $wasMaintenanceModeEnabled && $success ) {
2015-05-19 10:27:53 +02:00
$this -> config -> setSystemValue ( 'maintenance' , false );
$this -> emit ( '\OC\Updater' , 'maintenanceDisabled' );
} else {
$this -> emit ( '\OC\Updater' , 'maintenanceActive' );
}
2015-06-23 10:03:27 +02:00
2015-09-29 14:35:32 +02:00
$this -> emit ( '\OC\Updater' , 'resetLogLevel' , [ $logLevel , $this -> logLevelNames [ $logLevel ] ]);
$this -> config -> setSystemValue ( 'loglevel' , $logLevel );
2016-05-23 10:09:22 +02:00
$this -> config -> setSystemValue ( 'installed' , true );
2015-09-29 14:35:32 +02:00
2015-06-23 10:03:27 +02:00
return $success ;
2014-06-10 11:47:27 +02:00
}
2015-08-30 16:21:55 +02:00
/**
* Return version from which this version is allowed to upgrade from
*
2017-01-20 17:47:45 +01:00
* @ return array allowed previous versions per vendor
2015-08-30 16:21:55 +02:00
*/
2021-04-26 12:33:36 +02:00
private function getAllowedPreviousVersions () : array {
2015-08-30 16:21:55 +02:00
// this should really be a JSON file
require \OC :: $SERVERROOT . '/version.php' ;
2015-10-09 13:46:59 +02:00
/** @var array $OC_VersionCanBeUpgradedFrom */
2017-02-10 06:24:24 +01:00
return $OC_VersionCanBeUpgradedFrom ;
2015-08-30 16:21:55 +02:00
}
2016-07-22 14:44:00 +02:00
/**
* Return vendor from which this version was published
*
* @ return string Get the vendor
*/
2021-04-26 12:33:36 +02:00
private function getVendor () : string {
2016-07-22 14:44:00 +02:00
// this should really be a JSON file
require \OC :: $SERVERROOT . '/version.php' ;
/** @var string $vendor */
return ( string ) $vendor ;
}
2014-09-18 17:45:30 +02:00
/**
* Whether an upgrade to a specified version is possible
* @ param string $oldVersion
* @ param string $newVersion
2017-01-20 17:47:45 +01:00
* @ param array $allowedPreviousVersions
2014-09-18 17:45:30 +02:00
* @ return bool
*/
2021-04-26 12:33:36 +02:00
public function isUpgradePossible ( string $oldVersion , string $newVersion , array $allowedPreviousVersions ) : bool {
2017-01-20 17:47:45 +01:00
$version = explode ( '.' , $oldVersion );
$majorMinor = $version [ 0 ] . '.' . $version [ 1 ];
$currentVendor = $this -> config -> getAppValue ( 'core' , 'vendor' , '' );
2017-05-17 11:18:43 +02:00
// Vendor was not set correctly on install, so we have to white-list known versions
2020-09-25 12:04:11 +02:00
if ( $currentVendor === '' && (
isset ( $allowedPreviousVersions [ 'owncloud' ][ $oldVersion ]) ||
isset ( $allowedPreviousVersions [ 'owncloud' ][ $majorMinor ])
)) {
2018-01-19 14:10:29 +01:00
$currentVendor = 'owncloud' ;
2020-12-09 10:10:51 +01:00
$this -> config -> setAppValue ( 'core' , 'vendor' , $currentVendor );
2017-05-17 11:18:43 +02:00
}
2017-01-20 17:47:45 +01:00
if ( $currentVendor === 'nextcloud' ) {
return isset ( $allowedPreviousVersions [ $currentVendor ][ $majorMinor ])
&& ( version_compare ( $oldVersion , $newVersion , '<=' ) ||
2023-04-05 12:50:08 +02:00
$this -> config -> getSystemValueBool ( 'debug' , false ));
2016-07-22 14:44:00 +02:00
}
2017-01-20 17:47:45 +01:00
// Check if the instance can be migrated
2017-05-17 11:18:43 +02:00
return isset ( $allowedPreviousVersions [ $currentVendor ][ $majorMinor ]) ||
isset ( $allowedPreviousVersions [ $currentVendor ][ $oldVersion ]);
2014-09-18 17:45:30 +02:00
}
2014-06-10 11:47:27 +02:00
/**
* runs the update actions in maintenance mode , does not upgrade the source files
* except the main . htaccess file
*
* @ param string $currentVersion current version to upgrade to
* @ param string $installedVersion previous version from which to upgrade from
*
2014-09-18 17:45:30 +02:00
* @ throws \Exception
2014-06-10 11:47:27 +02:00
*/
2021-04-26 12:33:36 +02:00
private function doUpgrade ( string $currentVersion , string $installedVersion ) : void {
2014-09-18 17:45:30 +02:00
// Stop update if the update is over several major versions
2017-01-20 17:47:45 +01:00
$allowedPreviousVersions = $this -> getAllowedPreviousVersions ();
if ( ! $this -> isUpgradePossible ( $installedVersion , $currentVersion , $allowedPreviousVersions )) {
2015-08-30 16:21:55 +02:00
throw new \Exception ( 'Updates between multiple major versions and downgrades are unsupported.' );
2014-09-18 17:45:30 +02:00
}
2015-02-19 02:15:21 +01:00
// Update .htaccess files
try {
Setup :: updateHtaccess ();
Setup :: protectDataDirectory ();
} catch ( \Exception $e ) {
throw new \Exception ( $e -> getMessage ());
2014-02-28 11:59:30 +01:00
}
2014-03-14 13:03:18 +01:00
// create empty file in data dir, so we can later find
// out that this is indeed an ownCloud data directory
// (in case it didn't exist before)
2023-04-05 12:50:08 +02:00
file_put_contents ( $this -> config -> getSystemValueString ( 'datadirectory' , \OC :: $SERVERROOT . '/data' ) . '/.ocdata' , '' );
2014-03-14 13:03:18 +01:00
2014-06-10 11:47:27 +02:00
// pre-upgrade repairs
2022-08-22 17:59:26 +02:00
$repair = new Repair ( Repair :: getBeforeUpgradeRepairSteps (), \OC :: $server -> get ( \OCP\EventDispatcher\IEventDispatcher :: class ), \OC :: $server -> get ( LoggerInterface :: class ));
2014-06-10 11:47:27 +02:00
$repair -> run ();
2014-02-18 16:26:37 +01:00
2016-09-21 15:12:00 +02:00
$this -> doCoreUpgrade ();
2014-06-10 11:47:27 +02:00
2016-09-21 15:12:00 +02:00
try {
// TODO: replace with the new repair step mechanism https://github.com/owncloud/core/pull/24378
Setup :: installBackgroundJobs ();
} catch ( \Exception $e ) {
throw new \Exception ( $e -> getMessage ());
2013-07-06 17:00:00 +02:00
}
2013-11-26 14:12:48 +01:00
2016-09-21 15:12:00 +02:00
// update all shipped apps
2017-04-23 22:10:17 +02:00
$this -> checkAppsRequirements ();
2016-09-21 15:12:00 +02:00
$this -> doAppUpgrade ();
2014-06-04 16:40:53 +02:00
2017-05-02 10:08:16 +02:00
// Update the appfetchers version so it downloads the correct list from the appstore
\OC :: $server -> getAppFetcher () -> setVersion ( $currentVersion );
2023-03-29 16:34:53 +02:00
/** @var AppManager $appManager */
2021-10-01 16:40:25 +02:00
$appManager = \OC :: $server -> getAppManager ();
2016-09-21 15:12:00 +02:00
// upgrade appstore apps
2021-10-01 16:40:25 +02:00
$this -> upgradeAppStoreApps ( $appManager -> getInstalledApps ());
$autoDisabledApps = $appManager -> getAutoDisabledApps ();
2021-10-15 14:16:08 +02:00
if ( ! empty ( $autoDisabledApps )) {
$this -> upgradeAppStoreApps ( array_keys ( $autoDisabledApps ), $autoDisabledApps );
}
2016-02-23 10:31:11 +01:00
2016-09-21 15:12:00 +02:00
// install new shipped apps on upgrade
$errors = Installer :: installShippedApps ( true );
foreach ( $errors as $appId => $exception ) {
/** @var \Exception $exception */
2021-04-16 14:26:43 +02:00
$this -> log -> error ( $exception -> getMessage (), [
'exception' => $exception ,
'app' => $appId ,
]);
2016-09-21 15:12:00 +02:00
$this -> emit ( '\OC\Updater' , 'failure' , [ $appId . ': ' . $exception -> getMessage ()]);
}
2014-06-04 16:40:53 +02:00
2016-09-21 15:12:00 +02:00
// post-upgrade repairs
2022-08-22 17:59:26 +02:00
$repair = new Repair ( Repair :: getRepairSteps (), \OC :: $server -> get ( \OCP\EventDispatcher\IEventDispatcher :: class ), \OC :: $server -> get ( LoggerInterface :: class ));
2016-09-21 15:12:00 +02:00
$repair -> run ();
2014-07-23 23:38:17 +02:00
2016-09-21 15:12:00 +02:00
//Invalidate update feed
2022-08-22 15:58:50 +02:00
$this -> config -> setAppValue ( 'core' , 'lastupdatedat' , '0' );
Add code integrity check
This PR implements the base foundation of the code signing and integrity check. In this PR implemented is the signing and verification logic, as well as commands to sign single apps or the core repository.
Furthermore, there is a basic implementation to display problems with the code integrity on the update screen.
Code signing basically happens the following way:
- There is a ownCloud Root Certificate authority stored `resources/codesigning/root.crt` (in this PR I also ship the private key which we obviously need to change before a release :wink:). This certificate is not intended to be used for signing directly and only is used to sign new certificates.
- Using the `integrity:sign-core` and `integrity:sign-app` commands developers can sign either the core release or a single app. The core release needs to be signed with a certificate that has a CN of `core`, apps need to be signed with a certificate that either has a CN of `core` (shipped apps!) or the AppID.
- The command generates a signature.json file of the following format:
```json
{
"hashes": {
"/filename.php": "2401fed2eea6f2c1027c482a633e8e25cd46701f811e2d2c10dc213fd95fa60e350bccbbebdccc73a042b1a2799f673fbabadc783284cc288e4f1a1eacb74e3d",
"/lib/base.php": "55548cc16b457cd74241990cc9d3b72b6335f2e5f45eee95171da024087d114fcbc2effc3d5818a6d5d55f2ae960ab39fd0414d0c542b72a3b9e08eb21206dd9"
},
"certificate": "-----BEGIN CERTIFICATE-----MIIBvTCCASagAwIBAgIUPvawyqJwCwYazcv7iz16TWxfeUMwDQYJKoZIhvcNAQEF\nBQAwIzEhMB8GA1UECgwYb3duQ2xvdWQgQ29kZSBTaWduaW5nIENBMB4XDTE1MTAx\nNDEzMTcxMFoXDTE2MTAxNDEzMTcxMFowEzERMA8GA1UEAwwIY29udGFjdHMwgZ8w\nDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBANoQesGdCW0L2L+a2xITYipixkScrIpB\nkX5Snu3fs45MscDb61xByjBSlFgR4QI6McoCipPw4SUr28EaExVvgPSvqUjYLGps\nfiv0Cvgquzbx/X3mUcdk9LcFo1uWGtrTfkuXSKX41PnJGTr6RQWGIBd1V52q1qbC\nJKkfzyeMeuQfAgMBAAEwDQYJKoZIhvcNAQEFBQADgYEAvF/KIhRMQ3tYTmgHWsiM\nwDMgIDb7iaHF0fS+/Nvo4PzoTO/trev6tMyjLbJ7hgdCpz/1sNzE11Cibf6V6dsz\njCE9invP368Xv0bTRObRqeSNsGogGl5ceAvR0c9BG+NRIKHcly3At3gLkS2791bC\niG+UxI/MNcWV0uJg9S63LF8=\n-----END CERTIFICATE-----",
"signature": "U29tZVNpZ25lZERhdGFFeGFtcGxl"
}
```
`hashes` is an array of all files in the folder with their corresponding SHA512 hashes (this is actually quite cheap to calculate), the `certificate` is the certificate used for signing. It has to be issued by the ownCloud Root Authority and it's CN needs to be permitted to perform the required action. The `signature` is then a signature of the `hashes` which can be verified using the `certificate`.
Steps to do in other PRs, this is already a quite huge one:
- Add nag screen in case the code check fails to ensure that administrators are aware of this.
- Add code verification also to OCC upgrade and unify display code more.
- Add enforced code verification to apps shipped from the appstore with a level of "official"
- Add enfocrced code verification to apps shipped from the appstore that were already signed in a previous release
- Add some developer documentation on how devs can request their own certificate
- Check when installing ownCloud
- Add support for CRLs to allow revoking certificates
**Note:** The upgrade checks are only run when the instance has a defined release channel of `stable` (defined in `version.php`). If you want to test this, you need to change the channel thus and then generate the core signature:
```
➜ master git:(add-integrity-checker) ✗ ./occ integrity:sign-core --privateKey=resources/codesigning/core.key --certificate=resources/codesigning/core.crt
Successfully signed "core"
```
Then increase the version and you should see something like the following:
![2015-11-04_12-02-57](https://cloud.githubusercontent.com/assets/878997/10936336/6adb1d14-82ec-11e5-8f06-9a74801c9abf.png)
As you can see a failed code check will not prevent the further update. It will instead just be a notice to the admin. In a next step we will add some nag screen.
For packaging stable releases this requires the following additional steps as a last action before zipping:
1. Run `./occ integrity:sign-core` once
2. Run `./occ integrity:sign-app` _for each_ app. However, this can be simply automated using a simple foreach on the apps folder.
2015-11-03 20:26:06 +01:00
2016-09-21 15:12:00 +02:00
// Check for code integrity if not disabled
2020-04-10 14:19:56 +02:00
if ( \OC :: $server -> getIntegrityCodeChecker () -> isCodeCheckEnforced ()) {
2016-09-21 15:12:00 +02:00
$this -> emit ( '\OC\Updater' , 'startCheckCodeIntegrity' );
$this -> checker -> runInstanceVerification ();
$this -> emit ( '\OC\Updater' , 'finishedCheckCodeIntegrity' );
2014-06-04 16:40:53 +02:00
}
2014-07-24 17:18:54 +02:00
2016-09-21 15:12:00 +02:00
// only set the final version if everything went well
$this -> config -> setSystemValue ( 'version' , implode ( '.' , Util :: getVersion ()));
$this -> config -> setAppValue ( 'core' , 'vendor' , $this -> getVendor ());
2014-07-24 17:18:54 +02:00
}
2021-04-26 12:33:36 +02:00
protected function doCoreUpgrade () : void {
2015-10-21 09:17:38 +02:00
$this -> emit ( '\OC\Updater' , 'dbUpgradeBefore' );
2017-06-01 16:56:34 +02:00
// execute core migrations
2021-01-03 15:28:31 +01:00
$ms = new MigrationService ( 'core' , \OC :: $server -> get ( Connection :: class ));
2017-07-05 14:44:24 +02:00
$ms -> migrate ();
2014-07-24 17:18:54 +02:00
$this -> emit ( '\OC\Updater' , 'dbUpgrade' );
}
2015-02-03 19:02:25 +01:00
/**
* upgrades all apps within a major ownCloud upgrade . Also loads " priority "
* ( types authentication , filesystem , logging , in that order ) afterwards .
*
* @ throws NeedsUpdateException
*/
2021-04-26 12:33:36 +02:00
protected function doAppUpgrade () : void {
2014-07-24 17:18:54 +02:00
$apps = \OC_App :: getEnabledApps ();
2023-04-12 12:34:38 +02:00
$priorityTypes = [ 'authentication' , 'extended_authentication' , 'filesystem' , 'logging' ];
2015-02-03 19:02:25 +01:00
$pseudoOtherType = 'other' ;
2020-03-26 09:30:18 +01:00
$stacks = [ $pseudoOtherType => []];
2014-07-24 17:18:54 +02:00
foreach ( $apps as $appId ) {
2015-02-03 19:02:25 +01:00
$priorityType = false ;
foreach ( $priorityTypes as $type ) {
2020-04-10 14:19:56 +02:00
if ( ! isset ( $stacks [ $type ])) {
2020-03-26 09:30:18 +01:00
$stacks [ $type ] = [];
2015-02-03 19:02:25 +01:00
}
2018-02-17 15:22:00 +01:00
if ( \OC_App :: isType ( $appId , [ $type ])) {
2015-02-03 19:02:25 +01:00
$stacks [ $type ][] = $appId ;
$priorityType = true ;
break ;
}
}
if ( ! $priorityType ) {
$stacks [ $pseudoOtherType ][] = $appId ;
}
}
2021-01-08 12:27:51 +01:00
foreach ( array_merge ( $priorityTypes , [ $pseudoOtherType ]) as $type ) {
$stack = $stacks [ $type ];
2015-02-03 19:02:25 +01:00
foreach ( $stack as $appId ) {
if ( \OC_App :: shouldUpgrade ( $appId )) {
2023-05-31 21:13:58 +02:00
$this -> emit ( '\OC\Updater' , 'appUpgradeStarted' , [ $appId , \OCP\Server :: get ( IAppManager :: class ) -> getAppVersion ( $appId )]);
2015-02-03 19:02:25 +01:00
\OC_App :: updateApp ( $appId );
2023-05-31 21:13:58 +02:00
$this -> emit ( '\OC\Updater' , 'appUpgrade' , [ $appId , \OCP\Server :: get ( IAppManager :: class ) -> getAppVersion ( $appId )]);
2015-02-03 19:02:25 +01:00
}
2020-04-10 14:19:56 +02:00
if ( $type !== $pseudoOtherType ) {
2015-02-03 19:02:25 +01:00
// load authentication, filesystem and logging apps after
// upgrading them. Other apps my need to rely on modifying
// user and/or filesystem aspects.
2017-03-14 01:07:41 +01:00
\OC_App :: loadApp ( $appId );
2015-02-03 19:02:25 +01:00
}
2014-07-24 17:18:54 +02:00
}
}
}
2015-02-17 12:00:39 +01:00
/**
* check if the current enabled apps are compatible with the current
* ownCloud version . disable them if not .
* This is important if you upgrade ownCloud and have non ported 3 rd
* party apps installed .
2015-06-28 11:25:28 +02:00
*
* @ throws \Exception
2015-02-17 12:00:39 +01:00
*/
2021-09-30 10:42:35 +02:00
private function checkAppsRequirements () : void {
2015-02-24 12:51:55 +01:00
$isCoreUpgrade = $this -> isCodeUpgrade ();
2015-02-17 12:00:39 +01:00
$apps = OC_App :: getEnabledApps ();
2018-02-19 10:28:41 +01:00
$version = implode ( '.' , Util :: getVersion ());
2017-08-01 18:57:00 +02:00
$appManager = \OC :: $server -> getAppManager ();
2015-02-17 12:00:39 +01:00
foreach ( $apps as $app ) {
2020-11-26 16:44:20 +01:00
// check if the app is compatible with this version of Nextcloud
2022-05-12 17:08:54 +02:00
$info = $appManager -> getAppInfo ( $app );
2020-04-10 14:19:56 +02:00
if ( $info === null || ! OC_App :: isAppCompatible ( $version , $info )) {
2017-08-01 18:57:00 +02:00
if ( $appManager -> isShipped ( $app )) {
2016-11-02 09:40:10 +01:00
throw new \UnexpectedValueException ( 'The files of the app "' . $app . '" were not correctly replaced before running the update' );
}
2021-09-30 10:42:35 +02:00
$appManager -> disableApp ( $app , true );
2020-03-26 09:30:18 +01:00
$this -> emit ( '\OC\Updater' , 'incompatibleAppDisabled' , [ $app ]);
2015-02-17 12:00:39 +01:00
}
}
}
2015-02-24 12:51:55 +01:00
2015-06-28 11:25:28 +02:00
/**
* @ return bool
*/
2021-04-26 12:33:36 +02:00
private function isCodeUpgrade () : bool {
2023-04-05 12:50:08 +02:00
$installedVersion = $this -> config -> getSystemValueString ( 'version' , '0.0.0' );
2016-09-21 15:12:00 +02:00
$currentVersion = implode ( '.' , Util :: getVersion ());
2015-02-24 12:51:55 +01:00
if ( version_compare ( $currentVersion , $installedVersion , '>' )) {
return true ;
}
return false ;
}
2015-03-13 12:16:16 +01:00
2015-06-28 11:25:28 +02:00
/**
2021-10-15 14:16:08 +02:00
* @ param array $apps
* @ param array $previousEnableStates
2015-06-28 11:25:28 +02:00
* @ throws \Exception
*/
2021-10-15 14:16:08 +02:00
private function upgradeAppStoreApps ( array $apps , array $previousEnableStates = []) : void {
foreach ( $apps as $app ) {
2015-10-09 13:44:30 +02:00
try {
2017-05-11 20:35:17 +02:00
$this -> emit ( '\OC\Updater' , 'checkAppStoreAppBefore' , [ $app ]);
2017-11-24 10:41:51 +01:00
if ( $this -> installer -> isUpdateAvailable ( $app )) {
2016-10-31 11:07:54 +01:00
$this -> emit ( '\OC\Updater' , 'upgradeAppStoreApp' , [ $app ]);
2017-11-24 10:27:58 +01:00
$this -> installer -> updateAppstoreApp ( $app );
2015-10-09 13:44:30 +02:00
}
2017-05-11 20:35:17 +02:00
$this -> emit ( '\OC\Updater' , 'checkAppStoreApp' , [ $app ]);
2018-02-15 16:49:42 +01:00
2021-10-15 14:16:08 +02:00
if ( ! empty ( $previousEnableStates )) {
2018-02-15 16:49:42 +01:00
$ocApp = new \OC_App ();
2021-11-11 13:56:42 +01:00
if ( ! empty ( $previousEnableStates [ $app ]) && is_array ( $previousEnableStates [ $app ])) {
2021-10-15 14:16:08 +02:00
$ocApp -> enable ( $app , $previousEnableStates [ $app ]);
2021-10-01 16:40:25 +02:00
} else {
$ocApp -> enable ( $app );
}
2018-02-15 16:49:42 +01:00
}
2015-10-09 13:44:30 +02:00
} catch ( \Exception $ex ) {
2021-04-16 14:26:43 +02:00
$this -> log -> error ( $ex -> getMessage (), [
'exception' => $ex ,
]);
2015-03-13 12:16:16 +01:00
}
}
}
2016-04-19 15:36:11 +02:00
2021-04-26 12:33:36 +02:00
private function logAllEvents () : void {
2016-11-24 16:33:05 +01:00
$log = $this -> log ;
2022-08-22 17:59:26 +02:00
/** @var IEventDispatcher $dispatcher */
$dispatcher = \OC :: $server -> get ( IEventDispatcher :: class );
$dispatcher -> addListener (
2022-08-22 16:56:01 +02:00
MigratorExecuteSqlEvent :: class ,
2022-08-23 14:57:00 +02:00
function ( MigratorExecuteSqlEvent $event ) use ( $log ) : void {
2022-08-22 16:56:01 +02:00
$log -> info ( get_class ( $event ) . ': ' . $event -> getSql () . ' (' . $event -> getCurrentStep () . ' of ' . $event -> getMaxStep () . ')' , [ 'app' => 'updater' ]);
2016-11-24 16:33:05 +01:00
}
2022-08-22 16:56:01 +02:00
);
2016-11-24 16:33:05 +01:00
2022-08-23 14:57:00 +02:00
$repairListener = function ( Event $event ) use ( $log ) : void {
2022-08-22 17:59:26 +02:00
if ( $event instanceof RepairStartEvent ) {
$log -> info ( get_class ( $event ) . ': Starting ... ' . $event -> getMaxStep () . ' (' . $event -> getCurrentStepName () . ')' , [ 'app' => 'updater' ]);
} elseif ( $event instanceof RepairAdvanceEvent ) {
$desc = $event -> getDescription ();
if ( empty ( $desc )) {
$desc = '' ;
}
2022-08-25 16:26:31 +02:00
$log -> info ( get_class ( $event ) . ': ' . $desc . ' (' . $event -> getIncrement () . ')' , [ 'app' => 'updater' ]);
2022-08-22 17:59:26 +02:00
} elseif ( $event instanceof RepairFinishEvent ) {
$log -> info ( get_class ( $event ), [ 'app' => 'updater' ]);
} elseif ( $event instanceof RepairStepEvent ) {
$log -> info ( get_class ( $event ) . ': Repair step: ' . $event -> getStepName (), [ 'app' => 'updater' ]);
} elseif ( $event instanceof RepairInfoEvent ) {
$log -> info ( get_class ( $event ) . ': Repair info: ' . $event -> getMessage (), [ 'app' => 'updater' ]);
} elseif ( $event instanceof RepairWarningEvent ) {
$log -> warning ( get_class ( $event ) . ': Repair warning: ' . $event -> getMessage (), [ 'app' => 'updater' ]);
} elseif ( $event instanceof RepairErrorEvent ) {
$log -> error ( get_class ( $event ) . ': Repair error: ' . $event -> getMessage (), [ 'app' => 'updater' ]);
2016-11-24 16:33:05 +01:00
}
};
2022-08-22 17:59:26 +02:00
$dispatcher -> addListener ( RepairStartEvent :: class , $repairListener );
$dispatcher -> addListener ( RepairAdvanceEvent :: class , $repairListener );
$dispatcher -> addListener ( RepairFinishEvent :: class , $repairListener );
$dispatcher -> addListener ( RepairStepEvent :: class , $repairListener );
$dispatcher -> addListener ( RepairInfoEvent :: class , $repairListener );
$dispatcher -> addListener ( RepairWarningEvent :: class , $repairListener );
$dispatcher -> addListener ( RepairErrorEvent :: class , $repairListener );
2016-11-24 16:33:05 +01:00
2020-04-09 13:53:40 +02:00
$this -> listen ( '\OC\Updater' , 'maintenanceEnabled' , function () use ( $log ) {
2016-11-24 16:33:05 +01:00
$log -> info ( '\OC\Updater::maintenanceEnabled: Turned on maintenance mode' , [ 'app' => 'updater' ]);
});
2020-04-09 13:53:40 +02:00
$this -> listen ( '\OC\Updater' , 'maintenanceDisabled' , function () use ( $log ) {
2016-11-24 16:33:05 +01:00
$log -> info ( '\OC\Updater::maintenanceDisabled: Turned off maintenance mode' , [ 'app' => 'updater' ]);
});
2020-04-09 13:53:40 +02:00
$this -> listen ( '\OC\Updater' , 'maintenanceActive' , function () use ( $log ) {
2016-11-24 16:33:05 +01:00
$log -> info ( '\OC\Updater::maintenanceActive: Maintenance mode is kept active' , [ 'app' => 'updater' ]);
});
2020-04-09 13:53:40 +02:00
$this -> listen ( '\OC\Updater' , 'updateEnd' , function ( $success ) use ( $log ) {
2016-11-24 16:33:05 +01:00
if ( $success ) {
$log -> info ( '\OC\Updater::updateEnd: Update successful' , [ 'app' => 'updater' ]);
} else {
$log -> error ( '\OC\Updater::updateEnd: Update failed' , [ 'app' => 'updater' ]);
}
});
2020-04-09 13:53:40 +02:00
$this -> listen ( '\OC\Updater' , 'dbUpgradeBefore' , function () use ( $log ) {
2016-11-24 16:33:05 +01:00
$log -> info ( '\OC\Updater::dbUpgradeBefore: Updating database schema' , [ 'app' => 'updater' ]);
});
2020-04-09 13:53:40 +02:00
$this -> listen ( '\OC\Updater' , 'dbUpgrade' , function () use ( $log ) {
2016-11-24 16:33:05 +01:00
$log -> info ( '\OC\Updater::dbUpgrade: Updated database' , [ 'app' => 'updater' ]);
});
2020-04-09 13:53:40 +02:00
$this -> listen ( '\OC\Updater' , 'incompatibleAppDisabled' , function ( $app ) use ( $log ) {
2016-11-24 16:33:05 +01:00
$log -> info ( '\OC\Updater::incompatibleAppDisabled: Disabled incompatible app: ' . $app , [ 'app' => 'updater' ]);
});
2020-04-09 13:53:40 +02:00
$this -> listen ( '\OC\Updater' , 'checkAppStoreAppBefore' , function ( $app ) use ( $log ) {
2021-11-15 14:34:09 +01:00
$log -> debug ( '\OC\Updater::checkAppStoreAppBefore: Checking for update of app "' . $app . '" in appstore' , [ 'app' => 'updater' ]);
2017-05-11 20:35:17 +02:00
});
2020-04-09 13:53:40 +02:00
$this -> listen ( '\OC\Updater' , 'upgradeAppStoreApp' , function ( $app ) use ( $log ) {
2017-05-11 20:35:17 +02:00
$log -> info ( '\OC\Updater::upgradeAppStoreApp: Update app "' . $app . '" from appstore' , [ 'app' => 'updater' ]);
});
2020-04-09 13:53:40 +02:00
$this -> listen ( '\OC\Updater' , 'checkAppStoreApp' , function ( $app ) use ( $log ) {
2021-11-15 14:34:09 +01:00
$log -> debug ( '\OC\Updater::checkAppStoreApp: Checked for update of app "' . $app . '" in appstore' , [ 'app' => 'updater' ]);
2016-11-24 16:33:05 +01:00
});
$this -> listen ( '\OC\Updater' , 'appSimulateUpdate' , function ( $app ) use ( $log ) {
$log -> info ( '\OC\Updater::appSimulateUpdate: Checking whether the database schema for <' . $app . '> can be updated (this can take a long time depending on the database size)' , [ 'app' => 'updater' ]);
});
$this -> listen ( '\OC\Updater' , 'appUpgradeStarted' , function ( $app ) use ( $log ) {
$log -> info ( '\OC\Updater::appUpgradeStarted: Updating <' . $app . '> ...' , [ 'app' => 'updater' ]);
});
$this -> listen ( '\OC\Updater' , 'appUpgrade' , function ( $app , $version ) use ( $log ) {
$log -> info ( '\OC\Updater::appUpgrade: Updated <' . $app . '> to ' . $version , [ 'app' => 'updater' ]);
});
2020-04-09 13:53:40 +02:00
$this -> listen ( '\OC\Updater' , 'failure' , function ( $message ) use ( $log ) {
2016-11-24 16:33:05 +01:00
$log -> error ( '\OC\Updater::failure: ' . $message , [ 'app' => 'updater' ]);
});
2020-04-09 13:53:40 +02:00
$this -> listen ( '\OC\Updater' , 'setDebugLogLevel' , function () use ( $log ) {
2016-11-24 16:33:05 +01:00
$log -> info ( '\OC\Updater::setDebugLogLevel: Set log level to debug' , [ 'app' => 'updater' ]);
});
2020-04-09 13:53:40 +02:00
$this -> listen ( '\OC\Updater' , 'resetLogLevel' , function ( $logLevel , $logLevelName ) use ( $log ) {
2016-11-24 16:33:05 +01:00
$log -> info ( '\OC\Updater::resetLogLevel: Reset log level to ' . $logLevelName . '(' . $logLevel . ')' , [ 'app' => 'updater' ]);
});
2020-04-09 13:53:40 +02:00
$this -> listen ( '\OC\Updater' , 'startCheckCodeIntegrity' , function () use ( $log ) {
2016-11-24 16:33:05 +01:00
$log -> info ( '\OC\Updater::startCheckCodeIntegrity: Starting code integrity check...' , [ 'app' => 'updater' ]);
});
2020-04-09 13:53:40 +02:00
$this -> listen ( '\OC\Updater' , 'finishedCheckCodeIntegrity' , function () use ( $log ) {
2016-11-24 16:33:05 +01:00
$log -> info ( '\OC\Updater::finishedCheckCodeIntegrity: Finished code integrity check' , [ 'app' => 'updater' ]);
});
}
2013-07-06 17:00:00 +02:00
}