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

fix: update re-share if shared-by user has been revoked #43025

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

luka-nextcloud
Copy link
Contributor

@luka-nextcloud luka-nextcloud commented Jan 22, 2024

Summary

Add command occ sharing:fix-broken-shares to fix the shares that were broken on transfer ownership.

Checklist

  • Tests (unit, integration, api and/or acceptance) are included
  • Screenshots before/after for front-end changes
  • Documentation (manuals or wiki) has been updated or is not required
  • Backports requested where applicable (ex: critical bugfixes)

@luka-nextcloud
Copy link
Contributor Author

Another effected case by this issue:

  1. UserA share Folder1 to UserB
  2. UserB share Folder1 to UserC
  3. UserA revoke UserB
  4. UserA try to update sharing permission of UserC
    -> Error: Could not get proper share mount for . Failing since else the next calls are called with null

@luka-nextcloud luka-nextcloud force-pushed the bugfix/error-on-reshare-after-transfer-ownership branch 2 times, most recently from c298bf1 to 0828727 Compare February 5, 2024 18:28
@luka-nextcloud
Copy link
Contributor Author

@artonge I've updated as you requested, please check again.

Copy link
Contributor

@artonge artonge left a comment

Choose a reason for hiding this comment

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

Can you add comments to clarify what each if group does?

I am also wondering if we could find this shares with the following query:

SELECT
	f.fileid,
	f.path,
	f.storage,
	s.id as share_id,
	s.uid_owner as share_owner,
	s.uid_initiator as share_initiator,
	s.share_with as share_recipient
FROM
	oc_filecache f
	JOIN oc_share s ON f.fileid = s.file_source
	AND s.uid_initiator NOT IN (
		SELECT
			user_id
		FROM
			oc_mounts m
		WHERE
			f.storage = m.storage_id
	)

If so, then we could have a background job to remove them every hour or so like https://github.com/nextcloud/server/blob/master/apps/files_sharing/lib/DeleteOrphanedSharesJob.php, which might be easier than the current solution.

lib/private/Share20/Manager.php Outdated Show resolved Hide resolved
lib/private/Share20/Manager.php Outdated Show resolved Hide resolved
lib/private/Share20/Manager.php Outdated Show resolved Hide resolved
@luka-nextcloud
Copy link
Contributor Author

Can you add comments to clarify what each if group does?

I am also wondering if we could find this shares with the following query:

SELECT
	f.fileid,
	f.path,
	f.storage,
	s.id as share_id,
	s.uid_owner as share_owner,
	s.uid_initiator as share_initiator,
	s.share_with as share_recipient
FROM
	oc_filecache f
	JOIN oc_share s ON f.fileid = s.file_source
	AND s.uid_initiator NOT IN (
		SELECT
			user_id
		FROM
			oc_mounts m
		WHERE
			f.storage = m.storage_id
	)

If so, then we could have a background job to remove them every hour or so like https://github.com/nextcloud/server/blob/master/apps/files_sharing/lib/DeleteOrphanedSharesJob.php, which might be easier than the current solution.

@artonge It only works if the shared-by user refreshes his files list after his share has revoked. So, I don't think this query would do the job.

@luka-nextcloud luka-nextcloud force-pushed the bugfix/error-on-reshare-after-transfer-ownership branch 3 times, most recently from 007d650 to df7160f Compare April 1, 2024 08:13
@susnux susnux added this to the Nextcloud 30 milestone Apr 18, 2024
@luka-nextcloud luka-nextcloud force-pushed the bugfix/error-on-reshare-after-transfer-ownership branch from df7160f to 73fb85b Compare May 30, 2024 12:15
apps/files_sharing/lib/Command/FixBrokenShares.php Outdated Show resolved Hide resolved
apps/files_sharing/lib/Command/FixBrokenShares.php Outdated Show resolved Hide resolved
apps/files_sharing/lib/Command/FixBrokenShares.php Outdated Show resolved Hide resolved
apps/files_sharing/lib/Command/FixBrokenShares.php Outdated Show resolved Hide resolved
apps/files_sharing/lib/OrphanHelper.php Outdated Show resolved Hide resolved
@skjnldsv skjnldsv removed their request for review June 3, 2024 08:07
@luka-nextcloud luka-nextcloud force-pushed the bugfix/error-on-reshare-after-transfer-ownership branch from 7e64905 to cf9b02a Compare June 4, 2024 18:39
apps/files_sharing/lib/OrphanHelper.php Outdated Show resolved Hide resolved
apps/files_sharing/lib/Command/FixBrokenShares.php Outdated Show resolved Hide resolved
lib/private/Share20/Manager.php Outdated Show resolved Hide resolved
@luka-nextcloud
Copy link
Contributor Author

@come-nc

  • Reproduce steps:
  1. UserA share Folder1 to UserB
  2. UserB share Folder1 to UserC
  3. UserA deleted sharing to UserB
  4. UserA transfer Folder1 to UserD
    -> UserC lost access to Folder1. When UserC open sharing tab of Folder1, the error message Error: Could not get proper share mount for . Failing since else the next calls are called with null returned.
  • Issue occurred because the sharing of UserB to UserC was not deleted or updated after UserA deleted sharing to UserB. Then, when UserA transfering Folder1 to UserD, that re-share record cannot be transferred because it throws GenericShareException error.

@come-nc
Copy link
Contributor

come-nc commented Jun 27, 2024

@come-nc

  • Reproduce steps:
  1. UserA share Folder1 to UserB
  2. UserB share Folder1 to UserC
  3. UserA deleted sharing to UserB
  4. UserA transfer Folder1 to UserD
    -> UserC lost access to Folder1. When UserC open sharing tab of Folder1, the error message Error: Could not get proper share mount for . Failing since else the next calls are called with null returned.
  • Issue occurred because the sharing of UserB to UserC was not deleted or updated after UserA deleted sharing to UserB. Then, when UserA transfering Folder1 to UserD, that re-share record cannot be transferred because it throws GenericShareException error.

UserC already loses access to Folder1 after step 3, right?
At that point the sharing tab shows no error?

@luka-nextcloud
Copy link
Contributor Author

@come-nc

UserC already loses access to Folder1 after step 3, right?

No, UserC didn't lose access to Folder1 after step3. This is the issue we are trying to fix.

At that point the sharing tab shows no error?

No error.

@luka-nextcloud
Copy link
Contributor Author

@come-nc
Original problem:
Re-share was not deleted when parent share deleted. Then, it caused error while transferring ownership.

Reproduce steps:
Mentioned above.

Solution:
Delete the re-share and its children when parent share is deleted.

This was referenced Jul 30, 2024
@Altahrim Altahrim mentioned this pull request Aug 5, 2024
@luka-nextcloud luka-nextcloud force-pushed the bugfix/error-on-reshare-after-transfer-ownership branch from a03da0a to e1450ee Compare August 7, 2024 09:23
@Altahrim Altahrim mentioned this pull request Aug 7, 2024
@AndyScherzinger AndyScherzinger force-pushed the bugfix/error-on-reshare-after-transfer-ownership branch from e1450ee to 522cf26 Compare August 7, 2024 21:58
@skjnldsv skjnldsv mentioned this pull request Aug 13, 2024
@luka-nextcloud luka-nextcloud force-pushed the bugfix/error-on-reshare-after-transfer-ownership branch from 522cf26 to b23eafb Compare August 13, 2024 19:00
@skjnldsv skjnldsv modified the milestones: Nextcloud 30, Nextcloud 31 Aug 14, 2024
lib/private/Share20/Manager.php Outdated Show resolved Hide resolved
lib/private/Share20/Manager.php Outdated Show resolved Hide resolved
@skjnldsv skjnldsv added 2. developing Work in progress and removed 3. to review Waiting for reviews labels Oct 29, 2024
@luka-nextcloud luka-nextcloud force-pushed the bugfix/error-on-reshare-after-transfer-ownership branch from b23eafb to 5b01338 Compare November 7, 2024 18:44
@luka-nextcloud luka-nextcloud added 3. to review Waiting for reviews and removed 2. developing Work in progress labels Nov 7, 2024
@luka-nextcloud luka-nextcloud force-pushed the bugfix/error-on-reshare-after-transfer-ownership branch from 5b01338 to cc6c3dc Compare November 8, 2024 13:47
@luka-nextcloud luka-nextcloud force-pushed the bugfix/error-on-reshare-after-transfer-ownership branch from cc6c3dc to bff24d1 Compare November 13, 2024 18:59
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 bug
Projects
Status: 👀 In review
Development

Successfully merging this pull request may close these issues.

[Bug]: Sub folder shares were broken on ownership transfer
6 participants