Skip to content

Commit

Permalink
Check current node when iterating over path segments (#1255)
Browse files Browse the repository at this point in the history
Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>
  • Loading branch information
butonic authored Oct 19, 2020
1 parent a3c7b87 commit e221f0b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
5 changes: 5 additions & 0 deletions changelog/unreleased/ocis-fix-permission-checks.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Bugfix: Check current node when iterating over path segments

When checking permissions we were always checking the leaf instead of using the current node while iterating over path segments.

https://github.com/cs3org/reva/pull/1255
6 changes: 3 additions & 3 deletions pkg/storage/fs/ocis/permissions.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func (p *Permissions) HasPermission(ctx context.Context, n *Node, check func(*pr
for cn.ID != rn.ID {

var grantees []string
if grantees, err = n.ListGrantees(ctx); err != nil {
if grantees, err = cn.ListGrantees(ctx); err != nil {
appctx.GetLogger(ctx).Error().Err(err).Interface("node", cn).Msg("error listing grantees")
return false, err
}
Expand All @@ -106,11 +106,11 @@ func (p *Permissions) HasPermission(ctx context.Context, n *Node, check func(*pr
// we only need the find the user once per node
switch {
case !userFound && grantees[i] == userace:
g, err = n.ReadGrant(ctx, grantees[i])
g, err = cn.ReadGrant(ctx, grantees[i])
case strings.HasPrefix(grantees[i], grantPrefix+"g:"):
gr := strings.TrimPrefix(grantees[i], grantPrefix+"g:")
if groupsMap[gr] {
g, err = n.ReadGrant(ctx, grantees[i])
g, err = cn.ReadGrant(ctx, grantees[i])
} else {
// no need to check attribute
continue
Expand Down

0 comments on commit e221f0b

Please sign in to comment.