summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjörn Schießle <schiessle@owncloud.com>2013-05-23 20:30:07 +0200
committerBjörn Schießle <schiessle@owncloud.com>2013-05-23 20:30:07 +0200
commita9ebf2aabe0297e2bd02a07018d6bac3b2de65c6 (patch)
treea5ace50319d4d16266e326d9662f7e3cb27ea1a1
parentcb79169cf54bfc9d7c79422ebf118717acf9d980 (diff)
downloadnextcloud-server-a9ebf2aabe0297e2bd02a07018d6bac3b2de65c6.tar.gz
nextcloud-server-a9ebf2aabe0297e2bd02a07018d6bac3b2de65c6.zip
fix public link share if a user is logged in
-rwxr-xr-xapps/files_encryption/lib/keymanager.php19
-rw-r--r--apps/files_encryption/lib/session.php4
-rw-r--r--apps/files_encryption/lib/util.php16
3 files changed, 32 insertions, 7 deletions
diff --git a/apps/files_encryption/lib/keymanager.php b/apps/files_encryption/lib/keymanager.php
index ddd8f0ad6e2..58c1d4b24ad 100755
--- a/apps/files_encryption/lib/keymanager.php
+++ b/apps/files_encryption/lib/keymanager.php
@@ -237,10 +237,15 @@ class Keymanager
}
$util = new Util($view, \OCP\User::getUser());
- list($owner, $filename) = $util->getUidAndFilename($filePath);
- $filePath_f = ltrim($filename, '/');
- $keyfilePath = '/' . $owner . '/files_encryption/keyfiles/' . $filePath_f . '.key';
+ if ($util->isPublic()) {
+ $keyfilePath = $util->getKeyfilePath() . $filePath . '.key';
+ } else {
+ list($owner, $filename) = $util->getUidAndFilename($filePath);
+ $filePath_f = ltrim($filename, '/');
+
+ $keyfilePath = '/' . $owner . '/files_encryption/keyfiles/' . $filePath_f . '.key';
+ }
$proxyStatus = \OC_FileProxy::$enabled;
\OC_FileProxy::$enabled = false;
@@ -447,9 +452,13 @@ class Keymanager
//here we need the currently logged in user, while userId can be a different user
$util = new Util($view, \OCP\User::getUser());
- list($owner, $filename) = $util->getUidAndFilename($filePath);
+ if ($util->isPublic()) {
+ $shareKeyPath = $util->getSharekeyPath() . $filePath . '.' . $userId . '.shareKey';
+ } else {
+ list($owner, $filename) = $util->getUidAndFilename($filePath);
+ $shareKeyPath = \OC\Files\Filesystem::normalizePath('/' . $owner . '/files_encryption/share-keys/' . $filename . '.' . $userId . '.shareKey');
+ }
- $shareKeyPath = \OC\Files\Filesystem::normalizePath('/' . $owner . '/files_encryption/share-keys/' . $filename . '.' . $userId . '.shareKey');
if ($view->file_exists($shareKeyPath)) {
$result = $view->file_get_contents($shareKeyPath);
diff --git a/apps/files_encryption/lib/session.php b/apps/files_encryption/lib/session.php
index 8425cedd99f..86f56e56766 100644
--- a/apps/files_encryption/lib/session.php
+++ b/apps/files_encryption/lib/session.php
@@ -84,7 +84,9 @@ class Session
}
- if (\OCP\USER::getUser() === false) {
+ if (\OCP\USER::getUser() === false ||
+ (isset($_GET['service']) && $_GET['service'] == 'files' &&
+ isset($_GET['t']))) {
// Disable encryption proxy to prevent recursive calls
$proxyStatus = \OC_FileProxy::$enabled;
\OC_FileProxy::$enabled = false;
diff --git a/apps/files_encryption/lib/util.php b/apps/files_encryption/lib/util.php
index 784d74bd759..e327c3403bb 100644
--- a/apps/files_encryption/lib/util.php
+++ b/apps/files_encryption/lib/util.php
@@ -129,7 +129,9 @@ class Util
$this->recoveryKeyId = \OC_Appconfig::getValue('files_encryption', 'recoveryKeyId');
// if we are anonymous/public
- if ($this->userId === false) {
+ if ($this->userId === false ||
+ (isset($_GET['service']) && $_GET['service'] == 'files' &&
+ isset($_GET['t']))) {
$this->userId = $this->publicShareKeyId;
// only handle for files_sharing app
@@ -1491,4 +1493,16 @@ class Util
$this->recoverAllFiles('/', $privateKey);
}
+
+ public function isPublic() {
+ return $this->isPublic;
+ }
+
+ public function getKeyfilePath() {
+ return $this->keyfilesPath;
+ }
+
+ public function getSharekeyPath() {
+ return $this->shareKeysPath;
+ }
}