[Pkg-owncloud-commits] [owncloud] 31/70: Permit personal mount points to be used for sharing
David Prévot
taffit at moszumanska.debian.org
Thu Aug 21 17:40:02 UTC 2014
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to annotated tag v6.0.5RC1
in repository owncloud.
commit 82be3674c9699f793ff24cf391de7e7aa6142ca3
Author: Robin McCorkell <rmccorkell at karoshi.org.uk>
Date: Mon Apr 21 21:41:45 2014 +0100
Permit personal mount points to be used for sharing
An issue existed where `readData` used `OCP\User::getUser()` to get the user
for personal mount points, which worked in all situations apart from when a
personal mount point was used for sharing, so the return from `getUser()` is
not the user that owns the share. As such, any personal mount points would not
work correctly when shared.
`readData` and `writeData` have been changed from using a `$isPersonal`
boolean to using a `$user` string|null. `$isPersonal = false` can now be
written as `$user = NULL` (or left out in the case of `readData`), and
`$isPersonal = true` can be written as `$user = OCP\User::getUser()`.
Backport of abfd7ec from master
---
apps/files_external/lib/config.php | 36 ++++++++++++++++++------------------
1 file changed, 18 insertions(+), 18 deletions(-)
diff --git a/apps/files_external/lib/config.php b/apps/files_external/lib/config.php
index a20a2a0..c540001 100755
--- a/apps/files_external/lib/config.php
+++ b/apps/files_external/lib/config.php
@@ -186,7 +186,7 @@ class OC_Mount_Config {
}
// Load system mount points
- $mountConfig = self::readData(false);
+ $mountConfig = self::readData();
if (isset($mountConfig[self::MOUNT_TYPE_GLOBAL])) {
foreach ($mountConfig[self::MOUNT_TYPE_GLOBAL] as $mountPoint => $options) {
$options['options'] = self::decryptPasswords($options['options']);
@@ -223,7 +223,7 @@ class OC_Mount_Config {
}
// Load personal mount points
- $mountConfig = self::readData(true);
+ $mountConfig = self::readData($user);
if (isset($mountConfig[self::MOUNT_TYPE_USER][$user])) {
foreach ($mountConfig[self::MOUNT_TYPE_USER][$user] as $mountPoint => $options) {
$options['options'] = self::decryptPasswords($options['options']);
@@ -281,7 +281,7 @@ class OC_Mount_Config {
* @return array
*/
public static function getSystemMountPoints() {
- $mountPoints = self::readData(false);
+ $mountPoints = self::readData();
$backends = self::getBackends();
$system = array();
if (isset($mountPoints[self::MOUNT_TYPE_GROUP])) {
@@ -345,7 +345,7 @@ class OC_Mount_Config {
* @return array
*/
public static function getPersonalMountPoints() {
- $mountPoints = self::readData(true);
+ $mountPoints = self::readData(OCP\User::getUser());
$backends = self::getBackends();
$uid = OCP\User::getUser();
$personal = array();
@@ -437,7 +437,7 @@ class OC_Mount_Config {
'options' => self::encryptPasswords($classOptions))
)
);
- $mountPoints = self::readData($isPersonal);
+ $mountPoints = self::readData($isPersonal ? OCP\User::getUser() : NULL);
// Merge the new mount point into the current mount points
if (isset($mountPoints[$mountType])) {
if (isset($mountPoints[$mountType][$applicable])) {
@@ -449,7 +449,7 @@ class OC_Mount_Config {
} else {
$mountPoints[$mountType] = $mount;
}
- self::writeData($isPersonal, $mountPoints);
+ self::writeData($isPersonal ? OCP\User::getUser() : NULL, $mountPoints);
return self::getBackendStatus($class, $classOptions);
}
@@ -471,7 +471,7 @@ class OC_Mount_Config {
} else {
$mountPoint = '/$user/files/'.ltrim($mountPoint, '/');
}
- $mountPoints = self::readData($isPersonal);
+ $mountPoints = self::readData($isPersonal ? OCP\User::getUser() : NULL);
// Remove mount point
unset($mountPoints[$mountType][$applicable][$mountPoint]);
// Unset parent arrays if empty
@@ -481,20 +481,20 @@ class OC_Mount_Config {
unset($mountPoints[$mountType]);
}
}
- self::writeData($isPersonal, $mountPoints);
+ self::writeData($isPersonal ? OCP\User::getUser() : NULL, $mountPoints);
return true;
}
/**
* Read the mount points in the config file into an array
- * @param bool Personal or system config file
+ * @param string|null $user If not null, personal for $user, otherwise system
* @return array
*/
- private static function readData($isPersonal) {
+ private static function readData($user = NULL) {
$parser = new \OC\ArrayParser();
- if ($isPersonal) {
- $phpFile = OC_User::getHome(OCP\User::getUser()).'/mount.php';
- $jsonFile = OC_User::getHome(OCP\User::getUser()).'/mount.json';
+ if (isset($user)) {
+ $phpFile = OC_User::getHome($user).'/mount.php';
+ $jsonFile = OC_User::getHome($user).'/mount.json';
} else {
$datadir = \OC_Config::getValue("datadirectory", \OC::$SERVERROOT . "/data");
$phpFile = OC::$SERVERROOT.'/config/mount.php';
@@ -516,12 +516,12 @@ class OC_Mount_Config {
/**
* Write the mount points to the config file
- * @param bool Personal or system config file
- * @param array Mount points
+ * @param string|null $user If not null, personal for $user, otherwise system
+ * @param array $data Mount points
*/
- private static function writeData($isPersonal, $data) {
- if ($isPersonal) {
- $file = OC_User::getHome(OCP\User::getUser()).'/mount.json';
+ private static function writeData($user, $data) {
+ if (isset($user)) {
+ $file = OC_User::getHome($user).'/mount.json';
} else {
$datadir = \OC_Config::getValue("datadirectory", \OC::$SERVERROOT . "/data");
$file = $datadir . '/mount.json';
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud.git
More information about the Pkg-owncloud-commits
mailing list