Skip to content

Commit

Permalink
Merge pull request #2464 from nextcloud/backport/2453/stable25
Browse files Browse the repository at this point in the history
[stable25] preload the acl rules for the root of the groupfolders
  • Loading branch information
icewind1991 authored Jul 12, 2023
2 parents f402422 + 9c7d013 commit 8e65bb0
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/phpunit-mysql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ jobs:
with:
php-version: ${{ matrix.php-versions }}
tools: phpunit
extensions: mbstring, iconv, fileinfo, intl, mysql, pdo_mysql
extensions: mbstring, iconv, fileinfo, intl, mysql, pdo_mysql, gd
coverage: none

- name: Check composer file existence
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/phpunit-oci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ jobs:
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
extensions: mbstring, fileinfo, intl, sqlite, pdo_sqlite, oci8
extensions: mbstring, fileinfo, intl, sqlite, pdo_sqlite, oci8, gd
tools: phpunit
coverage: none

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/phpunit-pgsql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ jobs:
with:
php-version: ${{ matrix.php-versions }}
tools: phpunit
extensions: mbstring, iconv, fileinfo, intl, pgsql, pdo_pgsql
extensions: mbstring, iconv, fileinfo, intl, pgsql, pdo_pgsql, gd
coverage: none

- name: Check composer file existence
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/phpunit-sqlite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ jobs:
with:
php-version: ${{ matrix.php-versions }}
tools: phpunit
extensions: mbstring, iconv, fileinfo, intl, sqlite, pdo_sqlite
extensions: mbstring, iconv, fileinfo, intl, sqlite, pdo_sqlite, gd
coverage: none

- name: Check composer file existence
Expand Down
31 changes: 27 additions & 4 deletions lib/Mount/MountProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

use OC\Files\Storage\Wrapper\Jail;
use OC\Files\Storage\Wrapper\PermissionsMask;
use OCA\GroupFolders\ACL\ACLManager;
use OCA\GroupFolders\ACL\ACLManagerFactory;
use OCA\GroupFolders\ACL\ACLStorageWrapper;
use OCA\GroupFolders\Folder\FolderManager;
Expand Down Expand Up @@ -130,7 +131,16 @@ public function getMountsForUser(IUser $user, IStorageFactory $loader) {
}, $folders);
$conflicts = $this->findConflictsForUser($user, $mountPoints);

return array_values(array_filter(array_map(function ($folder) use ($user, $loader, $conflicts) {
$foldersWithAcl = array_filter($folders, function(array $folder) {
return $folder['acl'];
});
$aclRootPaths = array_map(function(array $folder) {
return $this->getJailPath($folder['folder_id']);
}, $foldersWithAcl);
$aclManager = $this->aclManagerFactory->getACLManager($user, $this->getRootStorageId());
$aclManager->preloadPaths($aclRootPaths);

return array_values(array_filter(array_map(function ($folder) use ($user, $loader, $conflicts, $aclManager) {
// check for existing files in the user home and rename them if needed
$originalFolderName = $folder['mount_point'];
if (in_array($originalFolderName, $conflicts)) {
Expand All @@ -157,7 +167,8 @@ public function getMountsForUser(IUser $user, IStorageFactory $loader) {
$folder['rootCacheEntry'],
$loader,
$folder['acl'],
$user
$user,
$aclManager
);
}, $folders)));
}
Expand All @@ -180,7 +191,20 @@ private function getCurrentUID(): ?string {
return $user ? $user->getUID() : null;
}

public function getMount(int $id, string $mountPoint, int $permissions, int $quota, ?ICacheEntry $cacheEntry = null, IStorageFactory $loader = null, bool $acl = false, IUser $user = null): ?IMountPoint {
public function getMount(
int $id,
string $mountPoint,
int $permissions,
int $quota,
?ICacheEntry $cacheEntry = null,
IStorageFactory $loader = null,
bool $acl = false,
IUser $user = null,
?ACLManager $aclManager = null
): ?IMountPoint {
if (!$aclManager) {
$aclManager = $this->aclManagerFactory->getACLManager($user, $this->getRootStorageId());
}
if (!$cacheEntry) {
// trigger folder creation
$folder = $this->getFolder($id);
Expand All @@ -197,7 +221,6 @@ public function getMount(int $id, string $mountPoint, int $permissions, int $quo
// apply acl before jail
if ($acl && $user) {
$inShare = $this->getCurrentUID() === null || $this->getCurrentUID() !== $user->getUID();
$aclManager = $this->aclManagerFactory->getACLManager($user, $this->getRootStorageId());
$storage = new ACLStorageWrapper([
'storage' => $storage,
'acl_manager' => $aclManager,
Expand Down

0 comments on commit 8e65bb0

Please sign in to comment.