Merge pull request #6858 from owncloud/fix-setupfs-only-for-existing-users-master

OC_Util::setupFS($user) will create a data dir for the given string - no...
This commit is contained in:
Thomas Müller 2014-01-21 07:36:30 -08:00
commit 3a17220c9f
8 changed files with 35 additions and 5 deletions

View File

@ -34,6 +34,7 @@ if (empty($_POST['dirToken'])) {
// resolve reshares
$rootLinkItem = OCP\Share::resolveReShare($linkItem);
OCP\JSON::checkUserExists($rootLinkItem['uid_owner']);
// Setup FS with owner
OC_Util::tearDownFS();
OC_Util::setupFS($rootLinkItem['uid_owner']);

View File

@ -6,6 +6,7 @@ if (OC::$CLI) {
if (count($argv) === 2) {
$file = $argv[1];
list(, $user) = explode('/', $file);
OCP\JSON::checkUserExists($owner);
OC_Util::setupFS($user);
$view = new \OC\Files\View('');
/**

View File

@ -39,6 +39,7 @@ if(!isset($linkedItem['uid_owner']) || !isset($linkedItem['file_source'])) {
$rootLinkItem = OCP\Share::resolveReShare($linkedItem);
$userId = $rootLinkItem['uid_owner'];
OCP\JSON::checkUserExists($rootLinkItem['uid_owner']);
\OC_Util::setupFS($userId);
\OC\Files\Filesystem::initMountPoints($userId);
$view = new \OC\Files\View('/' . $userId . '/files');

View File

@ -44,6 +44,7 @@ if (version_compare($installedVersion, '0.3', '<')) {
$shareType = OCP\Share::SHARE_TYPE_USER;
$shareWith = $row['uid_shared_with'];
}
OCP\JSON::checkUserExists($row['uid_owner']);
OC_User::setUserId($row['uid_owner']);
//we need to setup the filesystem for the user, otherwise OC_FileSystem::getRoot will fail and break
OC_Util::setupFS($row['uid_owner']);

View File

@ -43,10 +43,10 @@ if (isset($_GET['t'])) {
$shareOwner = $linkItem['uid_owner'];
$path = null;
$rootLinkItem = OCP\Share::resolveReShare($linkItem);
$fileOwner = $rootLinkItem['uid_owner'];
if (isset($fileOwner)) {
if (isset($rootLinkItem['uid_owner'])) {
OCP\JSON::checkUserExists($rootLinkItem['uid_owner']);
OC_Util::tearDownFS();
OC_Util::setupFS($fileOwner);
OC_Util::setupFS($rootLinkItem['uid_owner']);
$path = \OC\Files\Filesystem::getPath($linkItem['file_source']);
}
}

View File

@ -64,6 +64,20 @@ class OC_JSON{
}
}
/**
* Check is a given user exists - send json error msg if not
* @param string $user
*/
public static function checkUserExists($user) {
if (!OCP\User::userExists($user)) {
$l = OC_L10N::get('lib');
OCP\JSON::error(array('data' => array('message' => $l->t('Unknown user'))));
exit;
}
}
/**
* Check if the user is a subadmin, send json error msg if not
*/

View File

@ -51,6 +51,10 @@ class OC_Util {
self::$rootMounted = true;
}
if ($user != '' && !OCP\User::userExists($user)) {
return false;
}
//if we aren't logged in, there is no use to set up the filesystem
if( $user != "" ) {
\OC\Files\Filesystem::addStorageWrapper(function($mountPoint, $storage){

View File

@ -167,7 +167,7 @@ class JSON {
* @return string json formatted string if not admin user.
*/
public static function checkAdminUser() {
return(\OC_JSON::checkAdminUser());
\OC_JSON::checkAdminUser();
}
/**
@ -177,4 +177,12 @@ class JSON {
public static function encode($data) {
return(\OC_JSON::encode($data));
}
/**
* Check is a given user exists - send json error msg if not
* @param string $user
*/
public static function checkUserExists($user) {
\OC_JSON::checkUserExists($user);
}
}