diff options
Diffstat (limited to 'lib/private/Encryption')
14 files changed, 9 insertions, 51 deletions
diff --git a/lib/private/Encryption/DecryptAll.php b/lib/private/Encryption/DecryptAll.php index 3f6e4131d64..19bd2f81378 100644 --- a/lib/private/Encryption/DecryptAll.php +++ b/lib/private/Encryption/DecryptAll.php @@ -83,7 +83,6 @@ class DecryptAll { * @throws \Exception */ public function decryptAll(InputInterface $input, OutputInterface $output, $user = '') { - $this->input = $input; $this->output = $output; @@ -147,12 +146,10 @@ class DecryptAll { * @param string $user which users files should be decrypted, default = all users */ protected function decryptAllUsersFiles($user = '') { - $this->output->writeln("\n"); $userList = []; if ($user === '') { - $fetchUsersProgress = new ProgressBar($this->output); $fetchUsersProgress->setFormat(" %message% \n [%bar%]"); $fetchUsersProgress->start(); @@ -197,7 +194,6 @@ class DecryptAll { $progress->finish(); $this->output->writeln("\n\n"); - } /** @@ -208,7 +204,6 @@ class DecryptAll { * @param string $userCount */ protected function decryptUsersFiles($uid, ProgressBar $progress, $userCount) { - $this->setupUserFS($uid); $directories = []; $directories[] = '/' . $uid . '/files'; @@ -217,7 +212,7 @@ class DecryptAll { $content = $this->rootView->getDirectoryContent($root); foreach ($content as $file) { // only decrypt files owned by the user - if($file->getStorage()->instanceOfStorage('OCA\Files_Sharing\SharedStorage')) { + if ($file->getStorage()->instanceOfStorage('OCA\Files_Sharing\SharedStorage')) { continue; } $path = $root . '/' . $file['name']; @@ -299,5 +294,4 @@ class DecryptAll { \OC_Util::tearDownFS(); \OC_Util::setupFS($uid); } - } diff --git a/lib/private/Encryption/EncryptionWrapper.php b/lib/private/Encryption/EncryptionWrapper.php index 6389e996c1d..edbdc692b45 100644 --- a/lib/private/Encryption/EncryptionWrapper.php +++ b/lib/private/Encryption/EncryptionWrapper.php @@ -82,7 +82,6 @@ class EncryptionWrapper { ]; if (!$storage->instanceOfStorage(Storage\IDisableEncryptionStorage::class)) { - $user = \OC::$server->getUserSession()->getUser(); $mountManager = Filesystem::getMountManager(); $uid = $user ? $user->getUID() : null; @@ -119,5 +118,4 @@ class EncryptionWrapper { return $storage; } } - } diff --git a/lib/private/Encryption/Exceptions/DecryptionFailedException.php b/lib/private/Encryption/Exceptions/DecryptionFailedException.php index 5542082bf4d..048732d62a9 100644 --- a/lib/private/Encryption/Exceptions/DecryptionFailedException.php +++ b/lib/private/Encryption/Exceptions/DecryptionFailedException.php @@ -26,5 +26,4 @@ namespace OC\Encryption\Exceptions; use OCP\Encryption\Exceptions\GenericEncryptionException; class DecryptionFailedException extends GenericEncryptionException { - } diff --git a/lib/private/Encryption/Exceptions/EmptyEncryptionDataException.php b/lib/private/Encryption/Exceptions/EmptyEncryptionDataException.php index dd976b22bda..7a3be2a01bd 100644 --- a/lib/private/Encryption/Exceptions/EmptyEncryptionDataException.php +++ b/lib/private/Encryption/Exceptions/EmptyEncryptionDataException.php @@ -25,6 +25,5 @@ namespace OC\Encryption\Exceptions; use OCP\Encryption\Exceptions\GenericEncryptionException; -class EmptyEncryptionDataException extends GenericEncryptionException{ - +class EmptyEncryptionDataException extends GenericEncryptionException { } diff --git a/lib/private/Encryption/Exceptions/EncryptionFailedException.php b/lib/private/Encryption/Exceptions/EncryptionFailedException.php index 2b1672c2cb6..581d8fb7b56 100644 --- a/lib/private/Encryption/Exceptions/EncryptionFailedException.php +++ b/lib/private/Encryption/Exceptions/EncryptionFailedException.php @@ -25,6 +25,5 @@ namespace OC\Encryption\Exceptions; use OCP\Encryption\Exceptions\GenericEncryptionException; -class EncryptionFailedException extends GenericEncryptionException{ - +class EncryptionFailedException extends GenericEncryptionException { } diff --git a/lib/private/Encryption/Exceptions/EncryptionHeaderToLargeException.php b/lib/private/Encryption/Exceptions/EncryptionHeaderToLargeException.php index 3a9b8d6d33d..c44ea9d7db0 100644 --- a/lib/private/Encryption/Exceptions/EncryptionHeaderToLargeException.php +++ b/lib/private/Encryption/Exceptions/EncryptionHeaderToLargeException.php @@ -26,9 +26,7 @@ namespace OC\Encryption\Exceptions; use OCP\Encryption\Exceptions\GenericEncryptionException; class EncryptionHeaderToLargeException extends GenericEncryptionException { - public function __construct() { parent::__construct('max header size exceeded'); } - } diff --git a/lib/private/Encryption/Exceptions/ModuleAlreadyExistsException.php b/lib/private/Encryption/Exceptions/ModuleAlreadyExistsException.php index c9da35d9c5d..824dce48007 100644 --- a/lib/private/Encryption/Exceptions/ModuleAlreadyExistsException.php +++ b/lib/private/Encryption/Exceptions/ModuleAlreadyExistsException.php @@ -34,5 +34,4 @@ class ModuleAlreadyExistsException extends GenericEncryptionException { public function __construct($id, $name) { parent::__construct('Id "' . $id . '" already used by encryption module "' . $name . '"'); } - } diff --git a/lib/private/Encryption/Exceptions/ModuleDoesNotExistsException.php b/lib/private/Encryption/Exceptions/ModuleDoesNotExistsException.php index 841ead4ac16..24192e6e8d6 100644 --- a/lib/private/Encryption/Exceptions/ModuleDoesNotExistsException.php +++ b/lib/private/Encryption/Exceptions/ModuleDoesNotExistsException.php @@ -26,5 +26,4 @@ namespace OC\Encryption\Exceptions; use OCP\Encryption\Exceptions\GenericEncryptionException; class ModuleDoesNotExistsException extends GenericEncryptionException { - } diff --git a/lib/private/Encryption/Exceptions/UnknownCipherException.php b/lib/private/Encryption/Exceptions/UnknownCipherException.php index eb16f9c2fbc..7a8bd76d936 100644 --- a/lib/private/Encryption/Exceptions/UnknownCipherException.php +++ b/lib/private/Encryption/Exceptions/UnknownCipherException.php @@ -26,5 +26,4 @@ namespace OC\Encryption\Exceptions; use OCP\Encryption\Exceptions\GenericEncryptionException; class UnknownCipherException extends GenericEncryptionException { - } diff --git a/lib/private/Encryption/File.php b/lib/private/Encryption/File.php index 578fdeea5e6..13879c02cdc 100644 --- a/lib/private/Encryption/File.php +++ b/lib/private/Encryption/File.php @@ -124,5 +124,4 @@ class File implements \OCP\Encryption\IFile { return ['users' => $uniqueUserIds, 'public' => $public]; } - } diff --git a/lib/private/Encryption/Keys/Storage.php b/lib/private/Encryption/Keys/Storage.php index f71017bc4aa..2030f26f8f5 100644 --- a/lib/private/Encryption/Keys/Storage.php +++ b/lib/private/Encryption/Keys/Storage.php @@ -188,7 +188,6 @@ class Storage implements IStorage { * @return string */ protected function constructUserKeyPath($encryptionModuleId, $keyId, $uid) { - if ($uid === null) { $path = $this->root_dir . '/' . $this->encryption_base_dir . '/' . $encryptionModuleId . '/' . $keyId; } else { @@ -206,7 +205,6 @@ class Storage implements IStorage { * @return string */ private function getKey($path) { - $key = ''; if ($this->view->file_exists($path)) { @@ -250,7 +248,6 @@ class Storage implements IStorage { * @return string */ private function getFileKeyDir($encryptionModuleId, $path) { - list($owner, $filename) = $this->util->getUidAndFilename($path); // in case of system wide mount points the keys are stored directly in the data directory @@ -271,7 +268,6 @@ class Storage implements IStorage { * @return boolean */ public function renameKeys($source, $target) { - $sourcePath = $this->getPathToKeys($source); $targetPath = $this->getPathToKeys($target); @@ -294,7 +290,6 @@ class Storage implements IStorage { * @return boolean */ public function copyKeys($source, $target) { - $sourcePath = $this->getPathToKeys($source); $targetPath = $this->getPathToKeys($target); @@ -375,5 +370,4 @@ class Storage implements IStorage { } } } - } diff --git a/lib/private/Encryption/Manager.php b/lib/private/Encryption/Manager.php index 52fc23de947..f160a16a995 100644 --- a/lib/private/Encryption/Manager.php +++ b/lib/private/Encryption/Manager.php @@ -84,7 +84,6 @@ class Manager implements IManager { * @return bool true if enabled, false if not */ public function isEnabled() { - $installed = $this->config->getSystemValue('installed', false); if (!$installed) { return false; @@ -101,7 +100,6 @@ class Manager implements IManager { * @throws ServiceUnavailableException */ public function isReady() { - if ($this->isKeyStorageReady() === false) { throw new ServiceUnavailableException('Key Storage is not ready'); } @@ -137,7 +135,6 @@ class Manager implements IManager { * @throws Exceptions\ModuleAlreadyExistsException */ public function registerEncryptionModule($id, $displayName, callable $callback) { - if (isset($this->encryptionModules[$id])) { throw new Exceptions\ModuleAlreadyExistsException($id, $displayName); } @@ -213,7 +210,6 @@ class Manager implements IManager { $message = 'No default encryption module defined'; throw new Exceptions\ModuleDoesNotExistsException($message); } - } /** @@ -260,7 +256,6 @@ class Manager implements IManager { * @return bool */ protected function isKeyStorageReady() { - $rootDir = $this->util->getKeyStorageRoot(); // the default root is always valid @@ -275,6 +270,4 @@ class Manager implements IManager { return false; } - - } diff --git a/lib/private/Encryption/Update.php b/lib/private/Encryption/Update.php index f5128abd0b0..beb76a223b7 100644 --- a/lib/private/Encryption/Update.php +++ b/lib/private/Encryption/Update.php @@ -41,7 +41,7 @@ class Update { /** @var \OC\Encryption\Util */ protected $util; - /** @var \OC\Files\Mount\Manager */ + /** @var \OC\Files\Mount\Manager */ protected $mountManager; /** @var \OC\Encryption\Manager */ @@ -70,7 +70,6 @@ class Update { File $file, $uid ) { - $this->view = $view; $this->util = $util; $this->mountManager = $mountManager; @@ -133,13 +132,13 @@ class Update { public function postRename($params) { $source = $params['oldpath']; $target = $params['newpath']; - if( + if ( $this->encryptionManager->isEnabled() && dirname($source) !== dirname($target) ) { - list($owner, $ownerPath) = $this->getOwnerPath($target); - $absPath = '/' . $owner . '/files/' . $ownerPath; - $this->update($absPath); + list($owner, $ownerPath) = $this->getOwnerPath($target); + $absPath = '/' . $owner . '/files/' . $ownerPath; + $this->update($absPath); } } @@ -169,7 +168,6 @@ class Update { * @throws Exceptions\ModuleDoesNotExistsException */ public function update($path) { - $encryptionModule = $this->encryptionManager->getEncryptionModule(); // if the encryption module doesn't encrypt the files on a per-user basis @@ -192,5 +190,4 @@ class Update { $encryptionModule->update($file, $this->uid, $usersSharing); } } - } diff --git a/lib/private/Encryption/Util.php b/lib/private/Encryption/Util.php index 937a77bca7a..a5414a66796 100644 --- a/lib/private/Encryption/Util.php +++ b/lib/private/Encryption/Util.php @@ -38,7 +38,6 @@ use OCP\IConfig; use OCP\IUser; class Util { - const HEADER_START = 'HBEGIN'; const HEADER_END = 'HEND'; const HEADER_PADDING_CHAR = '-'; @@ -89,7 +88,6 @@ class Util { \OC\User\Manager $userManager, \OC\Group\Manager $groupManager, IConfig $config) { - $this->ocHeaderKeys = [ self::HEADER_ENCRYPTION_MODULE_KEY ]; @@ -179,7 +177,6 @@ class Util { $result[] = $c->getPath(); } } - } return $result; @@ -226,7 +223,6 @@ class Util { * @throws \BadMethodCallException */ public function getUidAndFilename($path) { - $parts = explode('/', $path); $uid = ''; if (count($parts) > 2) { @@ -241,7 +237,6 @@ class Util { $ownerPath = implode('/', array_slice($parts, 2)); return [$uid, Filesystem::normalizePath($ownerPath)]; - } /** @@ -254,18 +249,16 @@ class Util { $extension = pathinfo($path, PATHINFO_EXTENSION); if ($extension === 'part') { - $newLength = strlen($path) - 5; // 5 = strlen(".part") $fPath = substr($path, 0, $newLength); // if path also contains a transaction id, we remove it too $extension = pathinfo($fPath, PATHINFO_EXTENSION); - if(substr($extension, 0, 12) === 'ocTransferId') { // 12 = strlen("ocTransferId") + if (substr($extension, 0, 12) === 'ocTransferId') { // 12 = strlen("ocTransferId") $newLength = strlen($fPath) - strlen($extension) -1; $fPath = substr($fPath, 0, $newLength); } return $fPath; - } else { return $path; } @@ -372,7 +365,6 @@ class Util { // detect user specific folders if ($this->userManager->userExists($root[1]) && in_array($root[2], $this->excludedPaths)) { - return true; } } @@ -408,5 +400,4 @@ class Util { public function getKeyStorageRoot() { return $this->config->getAppValue('core', 'encryption_key_storage_root', ''); } - } |