From c3194788166a8c4ccb92938cff2590c4c2c2b7b5 Mon Sep 17 00:00:00 2001 From: nathangray Date: Tue, 16 Feb 2021 16:14:32 -0700 Subject: [PATCH] Fix readonly shares were mounted as writable when shared to another user --- api/src/Vfs/Base.php | 2 +- api/tests/Vfs/Filesystem/StreamWrapperTest.php | 10 ++++++++++ api/tests/Vfs/StreamWrapperBase.php | 5 +++-- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/api/src/Vfs/Base.php b/api/src/Vfs/Base.php index b88171bf86..e12be94077 100644 --- a/api/src/Vfs/Base.php +++ b/api/src/Vfs/Base.php @@ -259,7 +259,7 @@ class Base 'host' => $GLOBALS['egw_info']['user']['domain'], 'home' => str_replace(array('\\\\','\\'),array('','/'),$GLOBALS['egw_info']['user']['homedirectory']), ); - $parts = array_merge(Vfs::parse_url($path),$defaults); + $parts = array_merge(Vfs::parse_url($_path),Vfs::parse_url($path),$defaults); if (!$parts['host']) $parts['host'] = 'default'; // otherwise we get an invalid url (scheme:///path/to/something)! if (!empty($parts['scheme']) && $parts['scheme'] != self::SCHEME) diff --git a/api/tests/Vfs/Filesystem/StreamWrapperTest.php b/api/tests/Vfs/Filesystem/StreamWrapperTest.php index b35dcb11be..093e3036b2 100644 --- a/api/tests/Vfs/Filesystem/StreamWrapperTest.php +++ b/api/tests/Vfs/Filesystem/StreamWrapperTest.php @@ -32,6 +32,16 @@ class StreamWrapperTest extends Vfs\StreamWrapperBase { parent::tearDown(); } + /** + * Check that a user with permission to a file can access the file + * + * @depends testSimpleReadWrite + * @throws Api\Exception\AssertionFailed + */ + public function testWithAccess() : void + { + $this->markTestSkipped("Filesystem StreamWrapper does not support giving access to a file by changing group permissions"); + } protected function mount(): void { diff --git a/api/tests/Vfs/StreamWrapperBase.php b/api/tests/Vfs/StreamWrapperBase.php index 24f4f661e7..b3f482cd22 100644 --- a/api/tests/Vfs/StreamWrapperBase.php +++ b/api/tests/Vfs/StreamWrapperBase.php @@ -287,7 +287,8 @@ abstract class StreamWrapperBase extends LoggedInTest "Could not write file $file" ); $pre = Vfs::stat($this->test_file); - + // Check that it's actually there + $this->assertEquals($contents,file_get_contents(Vfs::PREFIX . $file), "Did not write test file"); // Create another user who has no access to our file $user_b = $this->makeUser(); @@ -307,7 +308,7 @@ abstract class StreamWrapperBase extends LoggedInTest // Check the file $post = Vfs::stat($file); - $this->assertNotNull($post, + $this->assertIsArray($post, "File '$file' was not accessible by another user who had permission" ); $this->assertEquals(