diff options
Diffstat (limited to 'apps/encryption/lib')
-rw-r--r-- | apps/encryption/lib/crypto/encryption.php | 6 | ||||
-rw-r--r-- | apps/encryption/lib/util.php | 42 |
2 files changed, 47 insertions, 1 deletions
diff --git a/apps/encryption/lib/crypto/encryption.php b/apps/encryption/lib/crypto/encryption.php index 1a05277e20d..d1140ce7cde 100644 --- a/apps/encryption/lib/crypto/encryption.php +++ b/apps/encryption/lib/crypto/encryption.php @@ -378,6 +378,12 @@ class Encryption implements IEncryptionModule { * @return boolean */ public function shouldEncrypt($path) { + if ($this->util->shouldEncryptHomeStorage() === false) { + $storage = $this->util->getStorage($path); + if ($storage->instanceOfStorage('\OCP\Files\IHomeStorage')) { + return false; + } + } $parts = explode('/', $path); if (count($parts) < 4) { return false; diff --git a/apps/encryption/lib/util.php b/apps/encryption/lib/util.php index a162dcde305..62c9dc6dc5f 100644 --- a/apps/encryption/lib/util.php +++ b/apps/encryption/lib/util.php @@ -94,12 +94,41 @@ class Util { $recoveryMode = $this->config->getUserValue($uid, 'encryption', 'recoveryEnabled', - 0); + '0'); return ($recoveryMode === '1'); } /** + * check if the home storage should be encrypted + * + * @return bool + */ + public function shouldEncryptHomeStorage() { + $encryptHomeStorage = $this->config->getAppValue( + 'encryption', + 'encryptHomeStorage', + '1' + ); + + return ($encryptHomeStorage === '1'); + } + + /** + * check if the home storage should be encrypted + * + * @param bool $encryptHomeStorage + */ + public function setEncryptHomeStorage($encryptHomeStorage) { + $value = $encryptHomeStorage ? '1' : '0'; + $this->config->setAppValue( + 'encryption', + 'encryptHomeStorage', + $value + ); + } + + /** * check if master key is enabled * * @return bool @@ -157,4 +186,15 @@ class Util { return $owner; } + /** + * get storage of path + * + * @param string $path + * @return \OC\Files\Storage\Storage + */ + public function getStorage($path) { + $storage = $this->files->getMount($path)->getStorage(); + return $storage; + } + } |