diff options
author | Bjoern Schiessle <schiessle@owncloud.com> | 2015-07-24 12:24:18 +0200 |
---|---|---|
committer | Bjoern Schiessle <schiessle@owncloud.com> | 2015-08-30 19:00:03 +0200 |
commit | 289e9130f35334a6f0cffcedee82da7d9f5082d0 (patch) | |
tree | 6330cd354add9962f3a1ec8c84aa0482b826df82 /lib/private/encryption/manager.php | |
parent | 045f8cc97101521cafd664faf7b8f24ea9e88451 (diff) | |
download | nextcloud-server-289e9130f35334a6f0cffcedee82da7d9f5082d0.tar.gz nextcloud-server-289e9130f35334a6f0cffcedee82da7d9f5082d0.zip |
make system root of key storage configurable
Diffstat (limited to 'lib/private/encryption/manager.php')
-rw-r--r-- | lib/private/encryption/manager.php | 53 |
1 files changed, 46 insertions, 7 deletions
diff --git a/lib/private/encryption/manager.php b/lib/private/encryption/manager.php index 1e0a065e25a..c004dfda0d9 100644 --- a/lib/private/encryption/manager.php +++ b/lib/private/encryption/manager.php @@ -25,14 +25,12 @@ namespace OC\Encryption; +use OC\Encryption\Keys\Storage; use OC\Files\Filesystem; -use OC\Files\Storage\Shared; -use OC\Files\Storage\Wrapper\Encryption; use OC\Files\View; -use OC\Search\Provider\File; +use OC\ServiceUnavailableException; use OCP\Encryption\IEncryptionModule; use OCP\Encryption\IManager; -use OCP\Files\Mount\IMountPoint; use OCP\IConfig; use OCP\IL10N; use OCP\ILogger; @@ -51,16 +49,26 @@ class Manager implements IManager { /** @var Il10n */ protected $l; + /** @var View */ + protected $rootView; + + /** @var Util */ + protected $util; + /** * @param IConfig $config * @param ILogger $logger * @param IL10N $l10n + * @param View $rootView + * @param Util $util */ - public function __construct(IConfig $config, ILogger $logger, IL10N $l10n) { + public function __construct(IConfig $config, ILogger $logger, IL10N $l10n, View $rootView, Util $util) { $this->encryptionModules = array(); $this->config = $config; $this->logger = $logger; $this->l = $l10n; + $this->rootView = $rootView; + $this->util = $util; } /** @@ -82,7 +90,8 @@ class Manager implements IManager { /** * check if new encryption is ready * - * @return boolean + * @return bool + * @throws ServiceUnavailableException */ public function isReady() { // check if we are still in transit between the old and the new encryption @@ -94,6 +103,11 @@ class Manager implements IManager { $this->logger->warning($warning); return false; } + + if ($this->isKeyStorageReady() === false) { + throw new ServiceUnavailableException('Key Storage is not ready'); + } + return true; } @@ -221,6 +235,31 @@ class Manager implements IManager { \OC::$server->getGroupManager(), \OC::$server->getConfig() ); - \OC\Files\Filesystem::addStorageWrapper('oc_encryption', array($util, 'wrapStorage'), 2); + Filesystem::addStorageWrapper('oc_encryption', array($util, 'wrapStorage'), 2); } + + + /** + * check if key storage is ready + * + * @return bool + */ + protected function isKeyStorageReady() { + + $rootDir = $this->util->getKeyStorageRoot(); + + // the default root is always valid + if ($rootDir === '') { + return true; + } + + // check if key storage is mounted correctly + if ($this->rootView->file_exists($rootDir . '/' . Storage::KEY_STORAGE_MARKER)) { + return true; + } + + return false; + } + + } |