diff options
author | Lukas Reschke <lukas@owncloud.com> | 2015-03-16 11:28:23 +0100 |
---|---|---|
committer | Lukas Reschke <lukas@owncloud.com> | 2015-03-25 16:04:41 +0100 |
commit | 5f044ebf1bc6f45acec2e79dc05185acd0405f42 (patch) | |
tree | 8bc8797ef55588d3aab1b160acb3e2f5576d460f /lib/repair | |
parent | 13904a7f8979a87492ac765e05017eb1e4b69588 (diff) | |
download | nextcloud-server-5f044ebf1bc6f45acec2e79dc05185acd0405f42.tar.gz nextcloud-server-5f044ebf1bc6f45acec2e79dc05185acd0405f42.zip |
Add wrapper for Guzzle
Diffstat (limited to 'lib/repair')
-rw-r--r-- | lib/repair/updatecertificatestore.php | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/lib/repair/updatecertificatestore.php b/lib/repair/updatecertificatestore.php new file mode 100644 index 00000000000..e1f6be45ef9 --- /dev/null +++ b/lib/repair/updatecertificatestore.php @@ -0,0 +1,77 @@ +<?php +/** + * @author Lukas Reschke + * @copyright 2015 Lukas Reschke lukas@owncloud.com + * + * This file is licensed under the Affero General Public License version 3 or + * later. + * See the COPYING-README file. + */ + +namespace OC\Repair; + +use OC\Files\View; +use OC\Hooks\BasicEmitter; +use OC\RepairStep; +use OC\Server; +use OCP\IConfig; + +/** + * Class UpdateCertificateStore rewrites the user specific certificate store after + * an update has been performed. This is done because a new root certificate file + * might have been added. + * + * @package OC\Repair + */ +class UpdateCertificateStore extends BasicEmitter implements RepairStep { + /** + * FIXME: The certificate manager does only allow specifying the user + * within the constructor. This makes DI impossible. + * @var Server + */ + protected $server; + /** @var IConfig */ + protected $config; + + /** + * @param Server $server + * @param IConfig $config + */ + public function __construct(Server $server, + IConfig $config) { + $this->server = $server; + $this->config = $config; + } + + /** {@inheritDoc} */ + public function getName() { + return 'Update user certificate stores with new root certificates'; + } + + /** {@inheritDoc} */ + public function run() { + $rootView = new View(); + $dataDirectory = $this->config->getSystemValue('datadirectory', null); + if(is_null($dataDirectory)) { + throw new \Exception('No data directory specified'); + } + + $pathToRootCerts = '/files_external/rootcerts.crt'; + + foreach($rootView->getDirectoryContent('', 'httpd/unix-directory') as $fileInfo) { + $uid = trim($fileInfo->getPath(), '/'); + if($rootView->file_exists($uid . $pathToRootCerts)) { + // Delete the existing root certificate + $rootView->unlink($uid . $pathToRootCerts); + + /** + * FIXME: The certificate manager does only allow specifying the user + * within the constructor. This makes DI impossible. + */ + // Regenerate the certificates + $certificateManager = $this->server->getCertificateManager($uid); + $certificateManager->createCertificateBundle(); + } + } + } +} |