diff options
author | Vincent Petry <pvince81@owncloud.com> | 2016-11-07 14:25:05 +0300 |
---|---|---|
committer | Vincent Petry <pvince81@owncloud.com> | 2016-11-14 11:17:23 +0300 |
commit | a3dec9572673291243a198f747b84e6b2c0258b7 (patch) | |
tree | b5fe4ca9acef6abd7045c90e4a74985990a47ee4 /lib | |
parent | 553740c0454271cdf03e8f2c30ce25cdca6bf407 (diff) |
Add repair step to fix file share permissions
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/repair/repairinvalidshares.php | 33 |
1 files changed, 33 insertions, 0 deletions
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(); } |