Skip to content

Conversation

@artonge
Copy link
Contributor

@artonge artonge commented Jan 30, 2026

Previously, this was preventing users without a specific USERGROUP entry to see GROUP shares.

The path filtering is now done at resolution time. This is less efficient, but keeps the old behavior. (crossed out from Salvatore)

I think we should probably update the other share providers to follow the same logic.

@artonge artonge requested a review from a team as a code owner January 30, 2026 19:54
@artonge artonge requested review from ArtificialOwl, CarlSchwan, come-nc and icewind1991 and removed request for a team January 30, 2026 19:54
@artonge artonge self-assigned this Jan 30, 2026
@artonge artonge added bug 3. to review Waiting for reviews feature: sharing php Pull requests that update Php code labels Jan 30, 2026
@artonge artonge added this to the Nextcloud 33 milestone Jan 30, 2026
@salmart-dev salmart-dev self-assigned this Feb 2, 2026
Copy link
Contributor

@come-nc come-nc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Won’t that cause an issue with non-accepted group shares?
Or if the user left the share?

salmart-dev

This comment was marked as outdated.

@salmart-dev

This comment was marked as outdated.

@salmart-dev

This comment was marked as outdated.

@salmart-dev salmart-dev dismissed their stale review February 2, 2026 13:52

Moving the path filtering to the resolve step would remove the filtering on the "parent" share, having the result of returning all shares received by a user where the only resolved ones are the ones where the path condition matches. This is not what we want.

Previously, this was preventing users without a specific USERGROUP entry to see GROUP shares.

Signed-off-by: Louis Chmn <[email protected]>
Signed-off-by: Salvatore Martire <[email protected]>
@salmart-dev salmart-dev force-pushed the artonge/fix/share_resolution branch from f4a8d15 to 073d980 Compare February 2, 2026 14:24
@salmart-dev
Copy link
Contributor

Edited the PR to avoid filtering by path only during the resolution step, as that would cause only the shares with a specific path to be resolved + would return shares unrelated to the path, since the first step would not filter by path any longer.

The new changes:

  • keep the join query as a way to filter by path (customised paths are only present in the usegroup row, while the unchanged path can be present both in the usergroup or in the group rows, also the usergroup row could be missing but we still want the share)
  • moved where clauses that belong to the to the join into the join condition instead of where
  • changed the path query to target either file_target in s or in sc

This fixes the case where a share's permission get reduced because some usergroup rows may be missing for a specific share/user and others may be present resulting in incorrect permissions.

@salmart-dev salmart-dev requested a review from come-nc February 2, 2026 14:31
@provokateurin
Copy link
Member

In all cases on master I am able to share and access the share and its contents

Try the same on stable33, there seem to be some things working on master that aren't working on stable33 for some reason.

@salmart-dev salmart-dev changed the title fix(files_sharing): Move path filtering to group share resolution fix(files_sharing): stop ignoring shares without a usergroup entry when filtering by path Feb 2, 2026
@salmart-dev
Copy link
Contributor

In all cases on master I am able to share and access the share and its contents

Try the same on stable33, there seem to be some things working on master that aren't working on stable33 for some reason.

Do you have more context? I can reproduce this issue also on stable33

Comment on lines 964 to 972
$qb->expr()->like('s.file_target', $qb->createNamedParameter($this->dbConn->escapeLikeParameter($path) . '_%')),
$qb->expr()->like('sc.file_target', $qb->createNamedParameter($this->dbConn->escapeLikeParameter($path) . '_%')),
)
);
} else {
$qb->andWhere($qb->expr()->eq('sc.file_target', $qb->createNamedParameter($path)));
$qb->andWhere(
$qb->expr()->orX(
$qb->expr()->eq('s.file_target', $qb->createNamedParameter($path)),
$qb->expr()->eq('sc.file_target', $qb->createNamedParameter($path)),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't these only match on sc.file_target? The file_target of the share parent is irrelevant, because only the usergroup share will dictate where the mount will actually be. The current filter could return some false-positives where the group share matches, while the usergroup share doesn't.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I agree, see #51602 , the target of the USERGROUP share is the one holding the actual path to the share.
But then that breaks again when the USERGROUP share is missing 🫨

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But then that breaks again when the USERGROUP share is missing

But by matching against the group share it's also broken.

So do we need to sync all missing usergroup shares?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, GitHub keeps not refreshing fast enough (not sure if it's Firefox or just GH) so I am seeing this only now.

Shouldn't these only match on sc.file_target? The file_target of the share parent is irrelevant, because only the usergroup share will dictate where the mount will actually be. The current filter could return some false-positives where the group share matches, while the usergroup share doesn't.

Yes, the problem would happen in the resolution step though, as if the share was renamed and for any reason the previous target is used, the code here would return the GROUP row, but then the resolution step would not return the USERGROUP row and we'd fail to patch the share object.

I will change the query again, Louis had a good suggestion for it: WHERE ... (sc.file_target = ... OR (sc.file_target IS NULL AND s.file_target = ...)), this should fix the problem, as we will only use s.file_target if the user actually doesn't have a USERGROUP row.

@salmart-dev
Copy link
Contributor

/backport to stable33

Copy link
Contributor

@come-nc come-nc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I cannot see any problem anymore, does not mean there are none 🙈

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

Labels

3. to review Waiting for reviews backport-request bug feature: sharing php Pull requests that update Php code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants