summaryrefslogtreecommitdiffstats
path: root/apps/encryption
diff options
context:
space:
mode:
authorBjoern Schiessle <bjoern@schiessle.org>2017-07-17 13:13:27 +0200
committerBjoern Schiessle <bjoern@schiessle.org>2017-07-20 11:40:17 +0200
commit473824fa061af2d28f75f194c4a6588ba5ce3701 (patch)
tree17049d047831d019dfdf31e202635926e6b46600 /apps/encryption
parent20a6b22db6d5751ebb11ad30cfd29498ef04a9fa (diff)
downloadnextcloud-server-473824fa061af2d28f75f194c4a6588ba5ce3701.tar.gz
nextcloud-server-473824fa061af2d28f75f194c4a6588ba5ce3701.zip
make sure that we always have a owner
Signed-off-by: Bjoern Schiessle <bjoern@schiessle.org>
Diffstat (limited to 'apps/encryption')
-rw-r--r--apps/encryption/lib/Crypto/Encryption.php21
1 files changed, 17 insertions, 4 deletions
diff --git a/apps/encryption/lib/Crypto/Encryption.php b/apps/encryption/lib/Crypto/Encryption.php
index d62235a4528..1f8c8a8012e 100644
--- a/apps/encryption/lib/Crypto/Encryption.php
+++ b/apps/encryption/lib/Crypto/Encryption.php
@@ -60,7 +60,7 @@ class Encryption implements IEncryptionModule {
/** @var string */
private $user;
- /** @var string */
+ /** @var array */
private $owner;
/** @var string */
@@ -139,6 +139,7 @@ class Encryption implements IEncryptionModule {
$this->decryptAll = $decryptAll;
$this->logger = $logger;
$this->l = $il10n;
+ $this->owner = [];
$this->useMasterPassword = $util->isMasterKeyEnabled();
}
@@ -177,7 +178,6 @@ class Encryption implements IEncryptionModule {
$this->path = $this->getPathToRealFile($path);
$this->accessList = $accessList;
$this->user = $user;
- $this->owner = $this->util->getOwner($path);
$this->isWriteOperation = false;
$this->writeCache = '';
@@ -284,7 +284,7 @@ class Encryption implements IEncryptionModule {
}
}
- $publicKeys = $this->keyManager->addSystemKeys($this->accessList, $publicKeys, $this->owner);
+ $publicKeys = $this->keyManager->addSystemKeys($this->accessList, $publicKeys, $this->getOwner($path));
$encryptedKeyfiles = $this->crypt->multiKeyEncrypt($this->fileKey, $publicKeys);
$this->keyManager->setAllFileKeys($this->path, $encryptedKeyfiles);
}
@@ -413,7 +413,7 @@ class Encryption implements IEncryptionModule {
}
}
- $publicKeys = $this->keyManager->addSystemKeys($accessList, $publicKeys, $this->owner);
+ $publicKeys = $this->keyManager->addSystemKeys($accessList, $publicKeys, $this->getOwner($path));
$encryptedFileKey = $this->crypt->multiKeyEncrypt($fileKey, $publicKeys);
@@ -563,6 +563,19 @@ class Encryption implements IEncryptionModule {
}
/**
+ * get owner of a file
+ *
+ * @param string $path
+ * @return string
+ */
+ protected function getOwner($path) {
+ if (!isset($this->owner[$path])) {
+ $this->owner[$path] = $this->util->getOwner($path);
+ }
+ return $this->owner[$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