diff options
author | Bjoern Schiessle <schiessle@owncloud.com> | 2013-11-26 00:03:54 +0100 |
---|---|---|
committer | Bjoern Schiessle <schiessle@owncloud.com> | 2013-11-26 00:03:54 +0100 |
commit | 46dff0677d3eff1aa4da94865e82698229dd71e0 (patch) | |
tree | 91b96385b6a5725592bf68169f9d862b007bf14c /apps/files_encryption/lib/util.php | |
parent | acf74b24f24e1c2ea9e454a1c09f6bcf404f6627 (diff) | |
parent | 5310a5924b18849c85b482819c350d72a6d0c67c (diff) | |
download | nextcloud-server-46dff0677d3eff1aa4da94865e82698229dd71e0.tar.gz nextcloud-server-46dff0677d3eff1aa4da94865e82698229dd71e0.zip |
Merge branch 'master' into calc_version_size
Diffstat (limited to 'apps/files_encryption/lib/util.php')
-rw-r--r-- | apps/files_encryption/lib/util.php | 29 |
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); |