Skip to content

Commit

Permalink
fix share jail
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 committed Aug 24, 2023
1 parent 1314c34 commit 157a6dc
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
5 changes: 5 additions & 0 deletions changelog/unreleased/fix-share-jail.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Bugfix: fix share jail

Make matching mountpoints deterministic by comparing whole path segments of mountpoints

https://github.com/cs3org/reva/pull/4134
Original file line number Diff line number Diff line change
Expand Up @@ -1059,7 +1059,7 @@ func (s *service) resolveAcceptedShare(ctx context.Context, ref *provider.Refere
if receivedShare.State != collaboration.ShareState_SHARE_STATE_ACCEPTED {
continue
}
if strings.HasPrefix(strings.TrimPrefix(ref.Path, "./"), receivedShare.MountPoint.Path) {
if isMountPointForPath(receivedShare.MountPoint.Path, ref.Path) {
return receivedShare, lsRes.Status, nil
}
}
Expand All @@ -1069,6 +1069,17 @@ func (s *service) resolveAcceptedShare(ctx context.Context, ref *provider.Refere
return nil, status.NewNotFound(ctx, "sharesstorageprovider: not found "+ref.String()), nil
}

func isMountPointForPath(mountpoint, path string) bool {
requiredSegments := strings.Split(strings.TrimPrefix(mountpoint, "./"), "/")
pathSegments := strings.Split(strings.TrimPrefix(path, "./"), "/")
for i := range requiredSegments {
if pathSegments[i] != requiredSegments[i] {
return false
}
}
return true
}

func (s *service) rejectReceivedShare(ctx context.Context, receivedShare *collaboration.ReceivedShare) error {
receivedShare.State = collaboration.ShareState_SHARE_STATE_REJECTED
receivedShare.MountPoint = nil
Expand Down

0 comments on commit 157a6dc

Please sign in to comment.