diff options
author | Thomas Müller <DeepDiver1975@users.noreply.github.com> | 2016-04-19 15:56:47 +0200 |
---|---|---|
committer | Thomas Müller <DeepDiver1975@users.noreply.github.com> | 2016-04-19 15:56:47 +0200 |
commit | 5b2ef92eb2931804057596c4ce9bac1920c4e5de (patch) | |
tree | a2706582c7b327f7b7ada20ff5a2a76bffc1465a /apps | |
parent | a86fd873d6102d4defeb4a7e4d4882685753a006 (diff) | |
parent | 50e20e531ea942d900c50b510c8c13a6a1dd1465 (diff) | |
download | nextcloud-server-5b2ef92eb2931804057596c4ce9bac1920c4e5de.tar.gz nextcloud-server-5b2ef92eb2931804057596c4ce9bac1920c4e5de.zip |
Merge pull request #24004 from owncloud/dont-transfer-files-to-not-ready-user
Introduce isReadyForUser and verify in file transfer ownership
Diffstat (limited to 'apps')
-rw-r--r-- | apps/encryption/lib/crypto/encryption.php | 13 | ||||
-rw-r--r-- | apps/encryption/lib/keymanager.php | 1 | ||||
-rw-r--r-- | apps/files/command/transferownership.php | 6 |
3 files changed, 20 insertions, 0 deletions
diff --git a/apps/encryption/lib/crypto/encryption.php b/apps/encryption/lib/crypto/encryption.php index 907a6437f5b..6eff66e72be 100644 --- a/apps/encryption/lib/crypto/encryption.php +++ b/apps/encryption/lib/crypto/encryption.php @@ -547,4 +547,17 @@ class Encryption implements IEncryptionModule { return $path; } + /** + * Check if the module is ready to be used by that specific user. + * In case a module is not ready - because e.g. key pairs have not been generated + * upon login this method can return false before any operation starts and might + * cause issues during operations. + * + * @param string $user + * @return boolean + * @since 9.1.0 + */ + public function isReadyForUser($user) { + return $this->keyManager->userHasKeys($user); + } } diff --git a/apps/encryption/lib/keymanager.php b/apps/encryption/lib/keymanager.php index 12fa5f92bd5..0accfb7900a 100644 --- a/apps/encryption/lib/keymanager.php +++ b/apps/encryption/lib/keymanager.php @@ -493,6 +493,7 @@ class KeyManager { */ public function userHasKeys($userId) { $privateKey = $publicKey = true; + $exception = null; try { $this->getPrivateKey($userId); diff --git a/apps/files/command/transferownership.php b/apps/files/command/transferownership.php index 6bf2fae6bdf..1f46efdde0d 100644 --- a/apps/files/command/transferownership.php +++ b/apps/files/command/transferownership.php @@ -97,6 +97,12 @@ class TransferOwnership extends Command { $output->writeln("<error>Unknown destination user $this->destinationUser</error>"); return; } + + // target user has to be ready + if (!\OC::$server->getEncryptionManager()->isReadyForUser($this->destinationUser)) { + $output->writeln("<error>The target user is not ready to accept files. The user has at least to be logged in once.</error>"); + return; + } $date = date('c'); $this->finalTarget = "$this->destinationUser/files/transferred from $this->sourceUser on $date"; |