aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files_encryption/lib/util.php
diff options
context:
space:
mode:
Diffstat (limited to 'apps/files_encryption/lib/util.php')
-rw-r--r--apps/files_encryption/lib/util.php29
1 files changed, 15 insertions, 14 deletions
diff --git a/apps/files_encryption/lib/util.php b/apps/files_encryption/lib/util.php
index 1af5e56e10b..b208a808bac 100644
--- a/apps/files_encryption/lib/util.php
+++ b/apps/files_encryption/lib/util.php
@@ -84,6 +84,8 @@ class Util {
$this->privateKeyPath =
'/owncloud_private_key/' . $this->userId . '.private.key'; // e.g. data/admin/admin.private.key
$this->isPublic = true;
+ // make sure that the owners home is mounted
+ \OC\Files\Filesystem::initMountPoints($GLOBALS['fileOwner']);
}
} else {
@@ -99,6 +101,8 @@ class Util {
$this->publicKeyDir . '/' . $this->userId . '.public.key'; // e.g. data/public-keys/admin.public.key
$this->privateKeyPath =
$this->encryptionDir . '/' . $this->userId . '.private.key'; // e.g. data/admin/admin.private.key
+ // make sure that the owners home is mounted
+ \OC\Files\Filesystem::initMountPoints($this->userId);
}
}
@@ -363,7 +367,7 @@ class Util {
// scanning every file like this
// will eat server resources :(
if (
- Keymanager::getFileKey($this->view, $this->userId, $relPath)
+ Keymanager::getFileKey($this->view, $relPath)
&& $isEncryptedPath
) {
@@ -468,22 +472,19 @@ class Util {
*/
public function isEncryptedPath($path) {
- // Disable encryption proxy so data retrieved is in its
- // original form
- $proxyStatus = \OC_FileProxy::$enabled;
- \OC_FileProxy::$enabled = false;
+ $relPath = Helper::getPathToRealFile($path);
- // we only need 24 byte from the last chunk
- $data = '';
- $handle = $this->view->fopen($path, 'r');
- if (is_resource($handle) && !fseek($handle, -24, SEEK_END)) {
- $data = fgets($handle);
+ if ($relPath === false) {
+ $relPath = Helper::stripUserFilesPath($path);
}
- // re-enable proxy
- \OC_FileProxy::$enabled = $proxyStatus;
+ $fileKey = Keymanager::getFileKey($this->view, $relPath);
- return Crypt::isCatfileContent($data);
+ if ($fileKey === false) {
+ return false;
+ }
+
+ return true;
}
@@ -1055,7 +1056,7 @@ class Util {
private function decryptKeyfile($filePath, $privateKey) {
// Get the encrypted keyfile
- $encKeyfile = Keymanager::getFileKey($this->view, $this->userId, $filePath);
+ $encKeyfile = Keymanager::getFileKey($this->view, $filePath);
// The file has a shareKey and must use it for decryption
$shareKey = Keymanager::getShareKey($this->view, $this->userId, $filePath);