diff options
author | Vincent Petry <pvince81@owncloud.com> | 2016-11-15 11:04:03 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-11-15 11:04:03 +0300 |
commit | b9edfca4d82d4c374c3620bcceed43c0de56ebd5 (patch) | |
tree | d7069323740797bfa514561276cbc42eccfc5c97 /lib | |
parent | 78eacaa4a2abb81211aba31b8cab4b2d6b146afa (diff) | |
parent | 8eb08028420d3d8f2e6c6f1bd30ba79683f80636 (diff) |
Merge pull request #26618 from owncloud/stable9-fix-invalid-share-perms
[stable9] Add repair step to fix file share permissions
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/repair.php | 1 | ||||
-rw-r--r-- | lib/private/repair/repairinvalidshares.php | 33 |
2 files changed, 34 insertions, 0 deletions
diff --git a/lib/private/repair.php b/lib/private/repair.php index 3fe03dafcc1..50af3681ba7 100644 --- a/lib/private/repair.php +++ b/lib/private/repair.php @@ -119,6 +119,7 @@ class Repair extends BasicEmitter { new DropOldJobs(\OC::$server->getJobList()), new RemoveGetETagEntries(\OC::$server->getDatabaseConnection()), new UpdateOutdatedOcsIds(\OC::$server->getConfig()), + new RepairInvalidShares(\OC::$server->getConfig(), \OC::$server->getDatabaseConnection()), new RepairUnmergedShares( \OC::$server->getConfig(), \OC::$server->getDatabaseConnection(), diff --git a/lib/private/repair/repairinvalidshares.php b/lib/private/repair/repairinvalidshares.php index beef5e37798..4c5ad1f09db 100644 --- a/lib/private/repair/repairinvalidshares.php +++ b/lib/private/repair/repairinvalidshares.php @@ -24,6 +24,7 @@ namespace OC\Repair; use OC\Hooks\BasicEmitter; +use Doctrine\DBAL\Platforms\OraclePlatform; /** * Repairs shares with invalid data @@ -74,6 +75,35 @@ class RepairInvalidShares extends BasicEmitter implements \OC\RepairStep { } /** + * Adjust file share permissions + */ + private function adjustFileSharePermissions() { + $mask = \OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_UPDATE | \OCP\Constants::PERMISSION_SHARE; + $builder = $this->connection->getQueryBuilder(); + + + if ($this->connection->getDatabasePlatform() instanceof OraclePlatform) { + $permsFunc = $builder->createFunction( + 'bitand(' . $builder->getColumnName('permissions') . ', ' . $mask . ')' + ); + } else { + $permsFunc = $builder->createFunction( + '(' . $builder->getColumnName('permissions') . ' & ' . $mask . ')' + ); + } + $builder + ->update('share') + ->set('permissions', $permsFunc) + ->where($builder->expr()->eq('item_type', $builder->expr()->literal('file'))) + ->andWhere($builder->expr()->neq('permissions', $permsFunc)); + + $updatedEntries = $builder->execute(); + if ($updatedEntries > 0) { + $this->emit('\OC\Repair', 'info', ['Fixed file share permissions for ' . $updatedEntries . ' shares']); + } + } + + /** * Remove shares where the parent share does not exist anymore */ private function removeSharesNonExistingParent() { @@ -115,6 +145,9 @@ class RepairInvalidShares extends BasicEmitter implements \OC\RepairStep { // this situation was only possible before 8.2 $this->removeExpirationDateFromNonLinkShares(); } + if (version_compare($ocVersionFromBeforeUpdate, '9.0.6.6', '<')) { + $this->adjustFileSharePermissions(); + } $this->removeSharesNonExistingParent(); } |