Skip to content

Commit

Permalink
Merge pull request #73 from cernbox/cernbox-prod-8.2.2-fix-eos-perm-m…
Browse files Browse the repository at this point in the history
…apping-for-files

Fixing the eos to oc permission mapping for files and system folders
  • Loading branch information
NadirRoGue authored Sep 2, 2016
2 parents 3a56450 + 36906cd commit 7a72615
Showing 1 changed file with 41 additions and 24 deletions.
65 changes: 41 additions & 24 deletions lib/private/files/objectstore/eosparser.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,41 +96,58 @@ public static function parseFileInfoMonitorMode($line_to_parse) {
$data['permissions'] = 31;
}

$groups = \OC\LDAPCache\LDAPCacheManager::getUserEGroups($currentUser);
$ocPerm = EosUtil::toOcAcl($data['sys.acl']);

if(!$linkShare)
{
$isInACL = false;
$aclMember = '';
if(isset($ocPerm[$currentUser]))
$isOwner = EosUtil::getOwner($data['eospath']) === $currentUser;
if($data['eostype'] === 'file' || strpos($data['eospath'], '.sys.v#') !== FALSE) //Files and sys folder
{
$isInACL = true;
$aclMember = $currentUser;
if($isOwner)
{
$data['permissions'] = 31; // Read + write + share
}
else
{
$data['permissions'] = 15; // Read + write
}
}
else
else // Folders
{
$highestOcPerm = 0;
foreach($groups as $group)
$groups = \OC\LDAPCache\LDAPCacheManager::getUserEGroups($currentUser);
$ocPerm = EosUtil::toOcAcl($data['sys.acl']);

$isInACL = false;
$aclMember = '';
if(isset($ocPerm[$currentUser]))
{
$isInACL = true;
$aclMember = $currentUser;
}
else
{
if(isset($ocPerm[$group]) && $ocPerm[$group]['ocperm'] > $highestOcPerm)
$highestOcPerm = 0;
foreach($groups as $group)
{
$isInACL = true;
$aclMember = $group;
$highestOcPerm = $ocPerm[$group]['ocperm'];
if(isset($ocPerm[$group]) && $ocPerm[$group]['ocperm'] > $highestOcPerm)
{
$isInACL = true;
$aclMember = $group;
$highestOcPerm = $ocPerm[$group]['ocperm'];
}
}
}
}

if($isInACL)
{
$permissions = $ocPerm[$aclMember]['ocperm'];
if(EosUtil::getOwner($data['eospath']) === $aclMember) //is the owner, so give share permissions

if($isInACL)
{
$permissions = 31;
if($isOwner) //is the owner, so give share permissions
{
$permissions = 31;
}
else
{
$permissions = $ocPerm[$aclMember]['ocperm'];
}
$data['permissions'] = $permissions;
}

$data['permissions'] = $permissions;
}
}

Expand Down

0 comments on commit 7a72615

Please sign in to comment.