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

Check current node when iterating over path segments #1255

Merged
merged 1 commit into from
Oct 19, 2020
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
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