Skip to content

Share jail should not expose the same resource under several paths #4055

Open

Description

@butonic

Describe the bug

The share jail can expose the same resource under several paths. The desktop client syncs the share jail via the Windows Cloud Files API (cfapi), which needs a 1:1 mapping between file id and path: every placeholder lives in exactly one place on disk. When the same file id shows up under two paths in the jail, the client has to fake unique ids (e.g. share id + resource id) and download the file twice.

There are two ways to end up with duplicates:

  1. nested shares: Alice shares /foo with a group Brian is a member of (Viewer) and /foo/bar with Brian directly (Editor). Brian's share jail lists two mountpoints, foo and bar, so baz.txt is reachable as foo/bar/baz.txt and bar/baz.txt with the same oc:fileid. The jail root only dedupes shares of the same resource id, see ListContainer in the sharesstorageprovider.
  2. shares from a space the user is a member of: if Alice shares a folder in a project space with Brian, and Brian is also a member of that space, the folder shows up in the space and in the share jail.

IMO the share jail should only expose subtrees the user cannot reach any other way:

  • a share contained in another received share is merged into the outermost mountpoint
  • shares from spaces the user is a member of are not listed in the jail

The graph sharedWithMe list is a different thing. Web uses it to show incoming shares and should keep listing every share.

There is a second problem when merging: the sharesstorageprovider checks permissions against the single share the path resolved to, e.g. in InitiateFileUpload:

if !receivedShare.GetShare().GetPermissions().GetPermissions().GetInitiateFileUpload() {
	return &provider.InitiateFileUploadResponse{
		Status: status.NewPermissionDenied(ctx, nil, "share does not grant InitiateFileDownload permission"),
	}, nil
}

So an upload to foo/bar/baz.txt is checked against the Viewer share on foo and denied, although Brian has Editor on bar. We should forward to the real storage provider and let it evaluate the effective grants on the node. The desktop client already picks up the per-resource permissions via oc:permissions.

Steps to reproduce

  1. Alice creates /foo/bar/baz.txt
  2. Alice shares /foo with a group containing Brian, role Viewer
  3. Alice shares /foo/bar with Brian, role Editor
  4. Brian sends a PROPFIND with Depth: 1 to the share jail root /dav/spaces/a0ca6a90-a365-4782-871e-d44447bbc668$a0ca6a90-a365-4782-871e-d44447bbc668

Expected behavior

  • Brian's share jail only contains foo
  • Brian can write foo/bar/baz.txt
  • a share from a project space Brian is a member of does not show up in the share jail
  • GET /graph/v1beta1/me/drive/sharedWithMe still lists both shares

Actual behavior

  • the share jail contains foo and bar, and baz.txt has the same file id under both paths
  • uploading to foo/bar/baz.txt is denied
  • the project space share shows up in the share jail

Additional context

related: opencloud-eu/reva#1031 ... share roots in the jail should report the rename permission, because renaming a mountpoint is always allowed. When we merge bar into foo, bar is no longer a share root, so renaming it becomes a regular move inside foo and is governed by the permissions there.

related upstream: owncloud/ocis#8464 (lost permission with multiple shares on the same resource), owncloud/ocis#8232, owncloud/ocis#9933

AI assistance: Claude Code (claude-opus-5-5) helped trace the code and draft this issue.

Activity

  1. butonic commented on Nov 18, 2026

    @butonic
    MemberAuthor

    cc @TheOneRing @micbar @dragotin @tbsbdr Opinions?

    An acceptance test that documents the desired behavior is in #4056

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions