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

Don't apply persistent lock on received declined shares #33885

Closed
PVince81 opened this issue Dec 13, 2018 · 10 comments · Fixed by #33888
Closed

Don't apply persistent lock on received declined shares #33885

PVince81 opened this issue Dec 13, 2018 · 10 comments · Fixed by #33888
Assignees
Labels
feature:persistent-locking p2-high Escalation, on top of current planning, release blocker Type:Bug
Milestone

Comments

@PVince81
Copy link
Contributor

From #32250 (comment)

Steps

  1. as user "sharer" create a folder called "parent" and inside that a folder called "subfolder"
  2. from user "sharer" share a folder "parent" with the user "receiver"
  3. as user "sharer" set a lock on the folder "parent"
  4. as user "receiver" decline the share "parent" from the "Shared with you" page
  5. as user "receiver" create a folder called "parent" and inside that a folder called "subfolder"

Expected result

  • the folder "parent/subfolder" of the user "receiver" not locked

Actual result

  • the folder "parent/subfolder" of the user "receiver" will be locked by sharer
  • deleting that lock as "receiver" results in Unlock failed with status: 409
  • deleting/renaming parent/subfolder" as "receiver" is not possible because its locked

Version

discovered on #32250

It is likely that whatever checks for locks is retrieving the full list of share mount points and does not filter it by state. Need to check what APIs are used there as there is already an existing way to only get visible mount points.

@PVince81
Copy link
Contributor Author

PVince81 commented Dec 13, 2018

  • user1 creates "test"
  • user1 shares "test" with user2
  • user2 declines "test"
  • user2 creates "test/x"
  • get lock on "test/x" as user2
SELECT `id`, `owner`, `timeout`, `created_at`, `token`, `token`, `scope`, `depth`, `file_id`, `path`, `owner_account_id`
FROM `oc_persistent_locks` l
INNER JOIN `oc_filecache` f ON l.`file_id` = f.`fileid`
WHERE (
    (`storage` = 4) AND (`created_at` > (1544710587 - `timeout`)) AND (f.`path` = 'files/test/x')
) OR (
    (`depth` <> 0) AND (`path` = 'files')
) OR (
    (`depth` <> 0) AND (`path` = 'files/test')
);

This returns the lock for user1:

+----+-------+---------+------------+--------------------------------------+--------------------------------------+-------+-------+---------+------------+------------------+
| id | owner | timeout | created_at | token                                | token                                | scope | depth | file_id | path       | owner_account_id |
+----+-------+---------+------------+--------------------------------------+--------------------------------------+-------+-------+---------+------------+------------------+
|  1 | user1 |    1800 | 1544709686 | 9cb71e26-3f36-472a-b30f-6bd36cb8b3df | 9cb71e26-3f36-472a-b30f-6bd36cb8b3df |     2 |    -1 |      33 | files/test |                2 |
+----+-------+---------+------------+--------------------------------------+--------------------------------------+-------+-------+---------+------------+------------------+

Looks like the storage limit isn't applied correctly.

@PVince81
Copy link
Contributor Author

looking at the formatted SQL above, it seems we also need to add the storage id in the two other "OR" clauses

@PVince81
Copy link
Contributor Author

  • reenable acceptance test after fixing

@ownclouders
Copy link
Contributor

GitMate.io thinks possibly related issues are #33847 (Persistent lock: cannot unshare from self), #27072 (Cannot move received federated share mount), #17243 (Lock sharing operations when file is locked), #31651 (Adding persistent lock types to ILockingProvider), and #17181 (Properly lock share owner parent folders).

@PVince81
Copy link
Contributor Author

You don't even need to decline the share.
It seems that any user who have the same folder structure will get the lock ⚠️

This is too bad, increasing to p2 as we can't release in this state.

@PVince81 PVince81 added p2-high Escalation, on top of current planning, release blocker and removed p3-medium Normal priority labels Dec 13, 2018
@PVince81
Copy link
Contributor Author

@DeepDiver1975 FYI

@PVince81
Copy link
Contributor Author

We should change the query to:

SELECT `id`, `owner`, `timeout`, `created_at`, `token`, `token`, `scope`, `depth`, `file_id`, `path`, `owner_account_id`
FROM `oc_persistent_locks` l
INNER JOIN `oc_filecache` f ON l.`file_id` = f.`fileid`
WHERE (
    (`storage` = 4)
    AND (`created_at` > (1544710587 - `timeout`))
    AND (
        (f.`path` = 'files/test/x')
        OR ((`depth` <> 0) AND (`path` = 'files'))
        OR ((`depth` <> 0) AND (`path` = 'files/test'))
    )
);

@PVince81
Copy link
Contributor Author

Additional adjustment to have only one depth check:

SELECT `id`, `owner`, `timeout`, `created_at`, `token`, `token`, `scope`, `depth`, `file_id`, `path`, `owner_account_id`
FROM `oc_persistent_locks` l
INNER JOIN `oc_filecache` f ON l.`file_id` = f.`fileid`
WHERE (
    (`storage` = 4)
    AND (`created_at` > (1544710587 - `timeout`))
    AND (
        (f.`path` = 'files/test/x')
        OR ((`depth` <> 0) AND (`path` in ('files', 'files/test')))
    )
);

@PVince81
Copy link
Contributor Author

in the spirit of TDD, here's a PR with a unit test that covers depth 0 and 1 and also an unrelated storage, which proves the issue: #33888

@PVince81
Copy link
Contributor Author

PVince81 commented Dec 14, 2018

let's enforce that so we don't burden ourselves with useless use cases...

@PVince81 PVince81 self-assigned this Dec 18, 2018
@PVince81 PVince81 modified the milestones: backlog, development Dec 18, 2018
@PVince81 PVince81 modified the milestones: development, QA Jan 11, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Jan 11, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature:persistent-locking p2-high Escalation, on top of current planning, release blocker Type:Bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants