Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable25] preload the acl rules for the root of the groupfolders #2464

Merged
merged 2 commits into from
Jul 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading