Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
die_coolen_jungs
our_own_cloud_project
Commits
7ecd2207
Commit
7ecd2207
authored
Nov 04, 2014
by
Robin Appelman
Browse files
Setup shared mounts for the correct user when setting up the filesystem for the non-logged in user
parent
9c79c2fa
Changes
3
Hide whitespace changes
Inline
Side-by-side
apps/files_sharing/lib/sharedmount.php
View file @
7ecd2207
...
...
@@ -22,15 +22,15 @@ class SharedMount extends Mount implements MoveableMount {
public
function
__construct
(
$storage
,
$mountpoint
,
$arguments
=
null
,
$loader
=
null
)
{
// first update the mount point before creating the parent
$newMountPoint
=
self
::
verifyMountPoint
(
$arguments
[
'share'
]);
$absMountPoint
=
'/'
.
\
OCP\User
::
getU
ser
()
.
'/files'
.
$newMountPoint
;
$newMountPoint
=
$this
->
verifyMountPoint
(
$arguments
[
'share'
]
,
$arguments
[
'user'
]
);
$absMountPoint
=
'/'
.
$arguments
[
'u
ser
'
]
.
'/files'
.
$newMountPoint
;
parent
::
__construct
(
$storage
,
$absMountPoint
,
$arguments
,
$loader
);
}
/**
* check if the parent folder exists otherwise move the mount point up
*/
private
static
function
verifyMountPoint
(
&
$share
)
{
private
function
verifyMountPoint
(
&
$share
,
$user
)
{
$mountPoint
=
basename
(
$share
[
'file_target'
]);
$parent
=
dirname
(
$share
[
'file_target'
]);
...
...
@@ -42,7 +42,7 @@ class SharedMount extends Mount implements MoveableMount {
$newMountPoint
=
\
OCA\Files_Sharing\Helper
::
generateUniqueTarget
(
\
OC\Files\Filesystem
::
normalizePath
(
$parent
.
'/'
.
$mountPoint
),
array
(),
new
\
OC\Files\View
(
'/'
.
\
OCP\User
::
getUser
()
.
'/files'
)
new
\
OC\Files\View
(
'/'
.
$user
.
'/files'
)
);
if
(
$newMountPoint
!==
$share
[
'file_target'
])
{
...
...
apps/files_sharing/lib/sharedstorage.php
View file @
7ecd2207
...
...
@@ -397,7 +397,7 @@ class Shared extends \OC\Files\Storage\Common implements ISharedStorage {
}
public
static
function
setup
(
$options
)
{
$shares
=
\
OCP\Share
::
getItemsSharedWith
(
'file'
);
$shares
=
\
OCP\Share
::
getItemsSharedWith
User
(
'file'
,
$options
[
'user'
]
);
$manager
=
Filesystem
::
getMountManager
();
$loader
=
Filesystem
::
getLoader
();
if
(
!
\
OCP\User
::
isLoggedIn
()
||
\
OCP\User
::
getUser
()
!=
$options
[
'user'
]
...
...
@@ -411,7 +411,8 @@ class Shared extends \OC\Files\Storage\Common implements ISharedStorage {
$options
[
'user_dir'
]
.
'/'
.
$share
[
'file_target'
],
array
(
'share'
=>
$share
,
),
'user'
=>
$options
[
'user'
]
),
$loader
);
$manager
->
addMount
(
$mount
);
...
...
apps/files_sharing/tests/sharedstorage.php
View file @
7ecd2207
...
...
@@ -197,4 +197,30 @@ class Test_Files_Sharing_Storage extends OCA\Files_sharing\Tests\TestCase {
$this
->
assertTrue
(
$result
);
}
function
testMountSharesOtherUser
()
{
$folderInfo
=
$this
->
view
->
getFileInfo
(
$this
->
folder
);
$fileInfo
=
$this
->
view
->
getFileInfo
(
$this
->
filename
);
$rootView
=
new
\
OC\Files\View
(
''
);
self
::
loginHelper
(
self
::
TEST_FILES_SHARING_API_USER1
);
// share 2 different files with 2 different users
\
OCP\Share
::
shareItem
(
'folder'
,
$folderInfo
[
'fileid'
],
\
OCP\Share
::
SHARE_TYPE_USER
,
self
::
TEST_FILES_SHARING_API_USER2
,
31
);
\
OCP\Share
::
shareItem
(
'file'
,
$fileInfo
[
'fileid'
],
\
OCP\Share
::
SHARE_TYPE_USER
,
self
::
TEST_FILES_SHARING_API_USER3
,
31
);
self
::
loginHelper
(
self
::
TEST_FILES_SHARING_API_USER2
);
$this
->
assertTrue
(
$rootView
->
file_exists
(
'/'
.
self
::
TEST_FILES_SHARING_API_USER2
.
'/files/'
.
$this
->
folder
));
OC_Hook
::
emit
(
'OC_Filesystem'
,
'setup'
,
array
(
'user'
=>
self
::
TEST_FILES_SHARING_API_USER3
,
'user_dir'
=>
\
OC_User
::
getHome
(
self
::
TEST_FILES_SHARING_API_USER3
)));
$this
->
assertTrue
(
$rootView
->
file_exists
(
'/'
.
self
::
TEST_FILES_SHARING_API_USER3
.
'/files/'
.
$this
->
filename
));
// make sure we didn't double setup shares for user 2 or mounted the shares for user 3 in user's 2 home
$this
->
assertFalse
(
$rootView
->
file_exists
(
'/'
.
self
::
TEST_FILES_SHARING_API_USER2
.
'/files/'
.
$this
->
folder
.
' (2)'
));
$this
->
assertFalse
(
$rootView
->
file_exists
(
'/'
.
self
::
TEST_FILES_SHARING_API_USER2
.
'/files/'
.
$this
->
filename
));
//cleanup
self
::
loginHelper
(
self
::
TEST_FILES_SHARING_API_USER1
);
$this
->
view
->
unlink
(
$this
->
folder
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment