aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjoern Schiessle <schiessle@owncloud.com>2013-11-20 23:23:23 +0100
committerBjoern Schiessle <schiessle@owncloud.com>2013-11-20 23:23:23 +0100
commitb9c18d16fe67f71015d1a233e2716bc7c0812140 (patch)
treef3c570ddbdd288eb9c216ea5d4bebd02c980bff4
parente11afd306608798a8ba9138cae70e9ab283c490d (diff)
downloadnextcloud-server-b9c18d16fe67f71015d1a233e2716bc7c0812140.tar.gz
nextcloud-server-b9c18d16fe67f71015d1a233e2716bc7c0812140.zip
make sure that we always use the correct user id
-rwxr-xr-xapps/files_encryption/lib/keymanager.php18
-rw-r--r--apps/files_encryption/lib/stream.php12
-rw-r--r--apps/files_encryption/lib/util.php2
3 files changed, 21 insertions, 11 deletions
diff --git a/apps/files_encryption/lib/keymanager.php b/apps/files_encryption/lib/keymanager.php
index 8d3e72b422b..b207b1437ba 100755
--- a/apps/files_encryption/lib/keymanager.php
+++ b/apps/files_encryption/lib/keymanager.php
@@ -125,8 +125,8 @@ class Keymanager {
$proxyStatus = \OC_FileProxy::$enabled;
\OC_FileProxy::$enabled = false;
- //here we need the currently logged in user, while userId can be a different user
- $util = new Util($view, \OCP\User::getUser());
+ $userId = Helper::getUser($path);
+ $util = new Util($view, $userId);
list($owner, $filename) = $util->getUidAndFilename($path);
// in case of system wide mount points the keys are stored directly in the data directory
@@ -225,7 +225,8 @@ class Keymanager {
$trimmed = ltrim($path, '/');
- $util = new Util($view, \OCP\User::getUser());
+ $userId = Helper::getUser($path);
+ $util = new Util($view, $userId);
if($util->isSystemWideMountPoint($path)) {
$keyPath = '/files_encryption/keyfiles/' . $trimmed;
@@ -322,8 +323,10 @@ class Keymanager {
// $shareKeys must be an array with the following format:
// [userId] => [encrypted key]
- // Here we need the currently logged in user, while userId can be a different user
- $util = new Util($view, \OCP\User::getUser());
+
+ $userId = Helper::getUser($path);
+
+ $util = new Util($view, $userId);
list($owner, $filename) = $util->getUidAndFilename($path);
@@ -441,8 +444,9 @@ class Keymanager {
$proxyStatus = \OC_FileProxy::$enabled;
\OC_FileProxy::$enabled = false;
- //here we need the currently logged in user, while userId can be a different user
- $util = new Util($view, \OCP\User::getUser());
+ $userId = Helper::getUser($filePath);
+
+ $util = new Util($view, $userId);
list($owner, $filename) = $util->getUidAndFilename($filePath);
diff --git a/apps/files_encryption/lib/stream.php b/apps/files_encryption/lib/stream.php
index 393c133d765..2497e56e898 100644
--- a/apps/files_encryption/lib/stream.php
+++ b/apps/files_encryption/lib/stream.php
@@ -92,10 +92,14 @@ class Stream {
$this->session = new \OCA\Encryption\Session($this->rootView);
- $this->privateKey = $this->session->getPrivateKey($this->userId);
+ $this->privateKey = $this->session->getPrivateKey();
- $util = new Util($this->rootView, \OCP\USER::getUser());
+ $userId = Helper::getUser($path);
+ $util = new Util($this->rootView, $userId);
+
+ // need to get the userId once more from util, because now this can be the
+ // public share key ID
$this->userId = $util->getUserId();
// rawPath is relative to the data directory
@@ -509,7 +513,9 @@ class Stream {
// Check if OC sharing api is enabled
$sharingEnabled = \OCP\Share::isEnabled();
- $util = new Util($this->rootView, $this->userId);
+ $userId = Helper::getUser($this->rawPath);
+
+ $util = new Util($this->rootView, $userId);
// Get all users sharing the file includes current user
$uniqueUserIds = $util->getSharingUsersArray($sharingEnabled, $this->relPath, $this->userId);
diff --git a/apps/files_encryption/lib/util.php b/apps/files_encryption/lib/util.php
index ce3d253cc93..1e8b852fb31 100644
--- a/apps/files_encryption/lib/util.php
+++ b/apps/files_encryption/lib/util.php
@@ -69,7 +69,7 @@ class Util {
$this->userFilesDir =
'/' . $userId . '/' . $this->fileFolderName; // TODO: Does this need to be user configurable?
$this->publicKeyDir = '/' . 'public-keys';
- $this->encryptionDir = '/' . $this->userId . '/' . 'files_encryption';
+ $this->encryptionDir = '/' . $userId . '/' . 'files_encryption';
$this->keyfilesPath = $this->encryptionDir . '/' . 'keyfiles';
$this->shareKeysPath = $this->encryptionDir . '/' . 'share-keys';
$this->publicKeyPath =