Skip to content

Move in, Move in overwrite and Move out fail using WebDAV with locking #17029

Closed

Description

@nickvergessen

#16963 (comment)

Test Result
test_sharePermissions -t=0 (ALL) ❌ move_in, move_in_overwrite and move_out fail
test_sharePermissions -t=1 (READ) ✅
test_sharePermissions -t=2 (READ + CREATE) ❌ move_in
test_sharePermissions -t=3 (READ + UDPATE) ✅
test_sharePermissions -t=4 (READ + DELETE) ❌ move_out
test_sharePermissions -t=5 (READ + CREATE + UPDATE) ❌ move_in
test_sharePermissions -t=6 (READ + CREATE + DELETE) ❌ move_in, move_in_overwrite and move_out
test_sharePermissions -t=7 (READ + UPDATE + DELETE) ❌ move_out

Note: move_in_overwrite deletes + creates thats why READ+UPDATE is okay.

@icewind1991 @PVince81 @DeepDiver1975

Activity

  1. added this to the milestone on Jun 18, 2015
  2. PVince81 commented on Jun 18, 2015

    @PVince81
    Contributor

    This issue title sounds like a cheat code

  3. nickvergessen commented on Jun 19, 2015

    @nickvergessen
    ContributorAuthor
    {"reqId":"5at1fJdV3+W5ruk+uhYL","remoteAddr":"192.168.178.32","app":"PHP","message":"Call to a member function getPath() on a non-object at \/home\/nickv\/ownCloud\/Smashbox\/master\/lib\/private\/share\/share.php#134","level":3,"time":"2015-06-19T07:02:48+00:00"}
    

    @icewind1991 $meta = $view->getFileInfo($path); in line 133 returns false, so of course the method does not exist then.

  4. icewind1991 commented on Jun 19, 2015

    @icewind1991
    Contributor

    I can't reproduce any of the failures locally...

  5. DeepDiver1975 commented on Jun 19, 2015

    @DeepDiver1975
    Contributor
  6. PVince81 commented on Jun 19, 2015

    @PVince81
    Contributor

    Same for me, running this:

    % bin/smash lib/oc-tests/test_sharePermissions.py
    

    no errors.

    Oh, let me try again with -a to run all test cases...

  7. DeepDiver1975 commented on Jun 19, 2015

    @DeepDiver1975
    Contributor

    Oh, let me try again with -a to run all test cases...

    haha - that bloody switch

  8. PVince81 commented on Jun 19, 2015

    @PVince81
    Contributor

    Tried again twice with the bloody switch, but still no failure

  9. PVince81 commented on Jun 19, 2015

    @PVince81
    Contributor

    @nickvergessen you could also reproduce this locally, consistently ?
    Can you do a "flushall" on redis before you do ?

    Maybe there are stray keys

  10. DeepDiver1975 commented on Jun 19, 2015

    @DeepDiver1975
    Contributor

    Maybe there are stray keys

    even if - on jenkins it's falling apart with http 500

    INFO:requests.packages.urllib3.connectionpool:Starting new HTTPS connection (1): test1.owncloud.com
    2015-06-19 04:56:52,239 - INFO - recipient_worker - Checking that /var/lib/jenkins/build/smashdir/test_sharePermissions/recipient_worker/shared-dir is present in local directory for recipient_worker
    2015-06-19 04:56:52,239 - INFO - recipient_worker - createfile /var/lib/jenkins/build/smashdir/test_sharePermissions/recipient_worker/local_test_file_0.dat character='0' count=1000 bs=1
    2015-06-19 04:56:52,240 - INFO - recipient_worker - Upload file to "shared-dir/test_upload.dat"
    2015-06-19 04:56:55,477 - INFO - recipient_worker - createfile /var/lib/jenkins/build/smashdir/test_sharePermissions/recipient_worker/local_test_file_1.dat character='0' count=1000 bs=1
    2015-06-19 04:56:55,478 - INFO - recipient_worker - Upload file to "shared-dir/overwrite_this.dat"
    2015-06-19 04:56:59,301 - INFO - recipient_worker - Move "shared-dir/rename_this.dat" to "shared-dir/rename_this_renamed.dat"
    2015-06-19 04:57:00,539 - INFO - recipient_worker - createfile /var/lib/jenkins/build/smashdir/test_sharePermissions/recipient_worker/local_test_file_2.dat character='0' count=1000 bs=1
    2015-06-19 04:57:01,734 - INFO - recipient_worker - Move "test_move_in.dat" to "shared-dir/test_move_in.dat"
    2015-06-19 04:57:02,380 - ERROR - recipient_worker - Unexpected response: Status code: 500 - 
    2015-06-19 04:57:02,380 - INFO - recipient_worker - Full Response: 
    2015-06-19 04:57:02,427 - ERROR - recipient_worker - Operation "move_in" must be allowed when share permissions are 31 'Operation "%s" must be %s when share permissions are %i' % (operation, success_message, perms) failed in recipient_worker() ["/var/lib/jenkins/jobs/smashbox/workspace/TEST_NAME/test_sharePermissions/compiler/g++/label/master/mirallBranch/v1.8.1/qt/qt4/serverVersion/owncloud8.1-locking/lib/oc-tests/test_sharePermissions.py" at line 251]
    2015-06-19 04:57:02,427 - INFO - recipient_worker - createfile /var/lib/jenkins/build/smashdir/test_sharePermissions/recipient_worker/local_test_file_3.dat character='0' count=1000 bs=1
    2015-06-19 04:57:04,390 - INFO - recipient_worker - Move "overwrite_this_through_move_in.dat" to "shared-dir/overwrite_this_through_move_in.dat"
    2015-06-19 04:57:13,720 - ERROR - recipient_worker - Unexpected response: Status code: 500 - 
    2015-06-19 04:57:13,721 - INFO - recipient_worker - Full Response: 
    2015-06-19 04:57:13,722 - ERROR - recipient_worker - Operation "move_in_overwrite" must be allowed when share permissions are 31 'Operation "%s" must be %s when share permissions are %i' % (operation, success_message, perms) failed in recipient_worker() ["/var/lib/jenkins/jobs/smashbox/workspace/TEST_NAME/test_sharePermissions/compiler/g++/label/master/mirallBranch/v1.8.1/qt/qt4/serverVersion/owncloud8.1-locking/lib/oc-tests/test_sharePermissions.py" at line 251]
    2015-06-19 04:57:13,722 - INFO - recipient_worker - Move "shared-dir/move_this_to_subdir.dat" to "shared-dir/subdir/moved_this_to_subdir.dat"
    2015-06-19 04:57:16,540 - INFO - recipient_worker - Move "shared-dir/move_this_to_subdir_for_overwrite.dat" to "shared-dir/subdir/overwrite_this.dat"
    2015-06-19 04:57:22,002 - INFO - recipient_worker - Move "shared-dir/move_this_out.dat" to "this_was_moved_out.dat"
    2015-06-19 04:57:22,316 - ERROR - recipient_worker - Unexpected response: Status code: 500 - 
    2015-06-19 04:57:22,317 - INFO - recipient_worker - Full Response: 
    2015-06-19 04:57:22,318 - ERROR - recipient_worker - Operation "move_out" must be allowed when share permissions are 31 'Operation "%s" must be %s when share permissions are %i' % (operation, success_message, perms) failed in recipient_worker() ["/var/lib/jenkins/jobs/smashbox/workspace/TEST_NAME/test_sharePermissions/compiler/g++/label/master/mirallBranch/v1.8.1/qt/qt4/serverVersion/owncloud8.1-locking/lib/oc-tests/test_sharePermissions.py" at line 251]
    2015-06-19 04:57:22,319 - INFO - recipient_worker - Move "shared-dir/subdir/move_this_out.dat" to "shared-dir/this_was_moved_out_of_subdir.dat"
    2015-06-19 04:57:26,627 - INFO - recipient_worker - Delete "shared-dir/delete_this.dat"
    2015-06-19 04:57:31,125 - INFO - recipient_worker - Create folder "shared-dir/test_create_dir"
    2015-06-19 04:57:31,959 - INFO - recipient_worker - Delete "shared-dir/delete_this_dir"
    2015-06-19 04:57:36,373 - INFO - recipient_worker - entering new step 
    
  11. PVince81 commented on Jun 19, 2015

    @PVince81
    Contributor

    Then we might need to setup a VM with the same setup.

    My current setup where tests pass is:

    • openSUSE Factory
    • php5-5.6.9-1.1.x86_64
    • apache2-2.4.12-7.1.x86_64
    • redis-3.0.2-1.1.x86_64
  12. DeepDiver1975 commented on Jun 19, 2015

    @DeepDiver1975
    Contributor

    test1 is using apcu - related?

  13. 19 remaining items

  14. schiessle commented on Jun 24, 2015

    @schiessle
    Contributor

    If I understand the explanation of @nickvergessen correctly we already obtain the lock in the view on file_put_contents. If this is the case I don't see a difference in calling getAccessList() before or after we wrap the stream. The first lock will always be already there.

  15. icewind1991 commented on Jun 25, 2015

    @icewind1991
    Contributor

    imo the way to solve this would to have getAccessList work correctly on files that aren't saved in the cache yet (the file does exist since fopen($path,'w') creates it but the cache is only updated after the write is complete) #17071 was an attempt at that.

  16. nickvergessen commented on Jun 25, 2015

    @nickvergessen
    ContributorAuthor

    From @icewind1991 at #17164 (comment)

    I don't think this is the correct way to solve the problem, having the lock actually lock the file even for the current process prevents getting unexpected results when trying to do fs work in the middle of an existing fs operation, having a storage wrapper call getFileInfo on a file that hasn't been created yet should not return an unspecified maybe-valid-but-relies-completely-on-the-storage-backend result, this should return an error value (or an exception, a man can dream...).

    A write lock is not just to keep other processes from reading the file, it should also prevent the same process from reading the file since we can't guarantee correct behavior when reading a file that's being written to.

    In the past we've had to fix multiple bugs that we're caused by wrappers/hooks/etc interfering with filesystem operations. Locking should make filesystem operations atomic and prevent unexpected behavior, something we cant do if the same process can simply ignore the lock.

  17. nickvergessen commented on Jun 25, 2015

    @nickvergessen
    ContributorAuthor

    Locking should make filesystem operations atomic and prevent unexpected behavior, something we cant do if the same process can simply ignore the lock.

    Well I see the idea behind that, the problem is... they are not. Any hook, storage wrapper, ... that is called in the action, needs to be able to behave like it did in the past. This is exactly why our test is failing atm. Getting the user's an item is shared with is not something randoom (typo intended).
    It is done by encryption (to generate/copy keys), activity (to generate the activities), ...

    The patch you suggest at #17071 falls back to the parent item. However, that information is simply wrong. If a file is shared directly, the directory will not contain those users, which is why the smashbox execution I did fails (it fails differently compared to before the patch):

    OC\Encryption\Exceptions\DecryptionFailedException - Message: Can not decrypt this file, probably this is a shared file. Please ask the file owner to reshare the file with you.

    So the keys of the people sharing the file but not any parent, are not there anymore (assumption, but somehow some keys are missing). We could try and gather all necessary information, before creating the lock. But this means huge overhead (we don't know which methods will be called, so we have to call all of them ....) and then we would still need to tunnel all information to all methods out there, which currently call any filesystem related method directly.

    Feel free to suggest a new way, that is "better" then #17164 while still solving the issues we are seeing. At least #17071 is not the right solution.

  18. PVince81 commented on Jun 25, 2015

    @PVince81
    Contributor

    This issue also seems to break regular file upload, see #17153

  19. PVince81 commented on Jun 25, 2015

    @PVince81
    Contributor

    but smashbox didn't find it because for some mysterious reasons WebDAV upload works and doesn't reach that code path. However web UI upload triggers the issue.

    Will investigate WebDAV separately.

  20. PVince81 commented on Jun 25, 2015

    @PVince81
    Contributor

    Ok got it: when uploading small files with WebDAV (non-chunking), we only set a shared lock on the target file https://github.com/owncloud/core/blob/master/lib/private/connector/sabre/file.php#L117. Then we write into a PART file, so at this point we can still call getFileInfo on the final file path. It's only during the final rename https://github.com/owncloud/core/blob/master/lib/private/connector/sabre/file.php#L205 that the target path gets an exclusive lock.

    So basically if we used PART files for cross-storage moves, we could use the same logic eventually... (#13379)

  21. icewind1991 commented on Jun 25, 2015

    @icewind1991
    Contributor

    Note that is only used to pass by chance, when using a local storage backend the fopen call creates the file, with most external storages the file will only be created after the file handle is closed so it has always been broken on external storages

  22. nickvergessen commented on Jun 26, 2015

    @nickvergessen
    ContributorAuthor

    So @icewind1991 did you have a better idea? I know locking is experimental, but not being able to do webdav move_in, move_in_overwrite and move_out seems like a real draw back, just for the sane of theory-crafting which can not be met at the current time.

    If not then I will fix the unit tests on my PR so they pass and we can go with the non-ideal-world solution rather than a broken one, deal?

    cc @DeepDiver1975

  23. PVince81 commented on Jun 26, 2015

    @PVince81
    Contributor

    This is worse than just move in: web upload is also broken.

  24. icewind1991 commented on Jun 26, 2015

    @icewind1991
    Contributor

    web upload is also broken.

    Ok I was able to reproduce that, will look into it

  25. nickvergessen commented on Jun 29, 2015

    @nickvergessen
    ContributorAuthor

    Seems like #17030 and #17071 had sufficient success. Tests are passing again: closing.

  26. locked as resolved and limited conversation to collaborators on Aug 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions