Skip to content

[stable6] backport share key pattern matching fix - #11560

Merged
LukasReschke merged 4 commits into
stable6from
stable6-encsharekeymatchingdirectbackport
Oct 17, 2014
Merged

LukasReschke merged 4 commits into
stable6from
stable6-encsharekeymatchingdirectbackport

Conversation

@PVince81

Copy link
Copy Markdown
Contributor

Backport of

Fixes #11252

@schiesbn the backport of #11137 applies with no major conflicts thanks to the backport of #9897.

  • Needs extensive testing
  • Double check that there are no remaining bogus preg_match or glob calls

@PVince81

Copy link
Copy Markdown
Contributor Author

I've split the backports to avoid confusion: #11560 will have to be tested and merged first.

@PVince81

Copy link
Copy Markdown
Contributor Author

I checked the code and there is no suspicious use of glob() or preg_match. The code matches what was put on stable7 in the original fix.

Next up: testing

@PVince81

Copy link
Copy Markdown
Contributor Author

As owner

  • two files: "test.txt" and "test_review.txt", move into shared folders: still readable for all users
  • two files: "test.txt" and "test_review.txt" in shared folder, move into subfolder: still readable for all users

As recipient

  • two files: "test.txt" and "test_review.txt", move into shared folders: still readable for all users
  • two files: "test.txt" and "test_review.txt" in shared folder, move into subfolder: still readable for all users

The failing steps are as follows, with cadaver:

  1. "user1" shared folder "pics" with "user2"
  2. With cadaver, login as "user2"
  3. Upload test.txt and test_review.txt (two files with different contents)
  4. mv test_review.txt test.txt Shared/pics
  5. cd Shared/pics
  6. mkdir sub
  7. mv test_review.txt test.txt sub
  8. Login as "user1" in the web UI and see that both files are broken in sub (missing share key)

I tried this on stable7 and it did NOT happen, so it's specific to this backport.
Needs some debugging.

@PVince81
PVince81 force-pushed the stable6-encsharekeymatchingdirectbackport branch from 36654fa to d671e04 Compare October 14, 2014 11:06
@PVince81

Copy link
Copy Markdown
Contributor Author

Fixed the problem with moving files with d671e04

@PVince81

Copy link
Copy Markdown
Contributor Author

Please do not relaunch Jenkins here to save resources.
#11561 needs to pass first and be merged first.

@PVince81

Copy link
Copy Markdown
Contributor Author

I went through many of the cases from #11137 and they all seem to work well here.

Vincent Petry added 2 commits October 15, 2014 12:34
Instead of inaccurate pattern matching, use the list of users who we
know have access to the file to build the list of share keys.

This covers the following cases:

- Move/copy files into a subfolder within a share
- Unsharing from a user
- Deleting files directlry / moving share keys to trashbin

Conflicts:
	apps/files_encryption/lib/keymanager.php
	apps/files_encryption/tests/hooks.php
	apps/files_encryption/tests/keymanager.php
	apps/files_encryption/tests/trashbin.php
fixFileSize is not needed as the target file will already have the
correct unencrypted size after renaming
@PVince81
PVince81 force-pushed the stable6-encsharekeymatchingdirectbackport branch from d671e04 to 9878f00 Compare October 15, 2014 10:34
@PVince81

Copy link
Copy Markdown
Contributor Author

Rebased onto stable6 with the webdav copy patch in.

This PR now only contains the "share key pattern matching" fix.

Please review @schiesbn

@PVince81 PVince81 changed the title [stable6] backport webdav copy fix + share key pattern matching fix [stable6] backport share key pattern matching fix Oct 15, 2014
@ghost

ghost commented Oct 15, 2014

Copy link
Copy Markdown

💣 Test FAILed. 💣
Refer to this link for build results (access rights to CI server needed):
https://ci.owncloud.org//job/pull-request-analyser-ng-simple/203/

Build result: FAILURE


💣 Test FAILed. 💣

@PVince81

Copy link
Copy Markdown
Contributor Author

Ah! Test results! Encryption tests fail.
I'll try and run them locally.

@PVince81

Copy link
Copy Markdown
Contributor Author

Unit tests fail locally:

1) Test_Encryption_Share::testMoveFileToFolder
Failed asserting that false is true.

/var/www/owncloud/apps/files_encryption/tests/share.php:1102

2) Test_Encryption_Hooks::testDeleteHooksForSharedFiles
Failed asserting that true is false.

/var/www/owncloud/apps/files_encryption/tests/hooks.php:260

I'll have a look.

@PVince81

Copy link
Copy Markdown
Contributor Author

Race condition / side effect... when running only the encryption unit tests it works, but running all the tests make it fail. It sounds familiar.

@PVince81

Copy link
Copy Markdown
Contributor Author

Some share keys aren't properly cleant up.
On stable7 deleting a file will go through removeMount -> unshareFromSelf and cleanup the keys.
But on stable6 it goes through the unlink operation which seem to miss a few users.

@schiesbn this is similar to what I observed yestered: getSharingUsersArray() will only return a single user instead of two (it doesn't include the owner).

Will continue investigating.

@PVince81

Copy link
Copy Markdown
Contributor Author

@schiesbn this is very strange: the "unlink" operation on a shared file will not only delete the file itself, but also the file cache entry. And only after that comes the postDelete() hook where a call to getUsersSharingFile() is made on the file's path.
Trouble is, at that moment it tries to get the file entry from the cache, but it's already deleted.
So it carries on with the parent folder and checks who has access there, which is only the owner.
This is why only one user is returned.

I wonder whether this is an already existing bug that has just now been discovered through these new unit tests or whether the backport itself is bringing new bugs... That bug in itself isn't that bad as it would leave stray share keys but no data loss, but still now breaks the unit test.

@PVince81

Copy link
Copy Markdown
Contributor Author

To debug this, put a breakpoint in "apps/files_encryption/tests/hooks.php" line 252:

    $result = $this->user2View->unlink($this->filename);

As soon as it stops, put another breakpoint here: "apps/files_encryption/lib/keymanager.php" line 444.
Then carry on debugging, make sure to step into getSharingUsersArray() and getUsersSharingItem().

I'll see whether the bug already exists on stable6.

Then we either need to find a stable6 specific fix or adjust the unit tests...

FileInfo class doesn't exist in stable6
@PVince81

Copy link
Copy Markdown
Contributor Author

The issue indeed exists on stable6 and was just highlighted by the backported unit test...
I've raised the blocking issue as #11598

@PVince81 PVince81 added this to the 2014-sprint-06-current milestone Oct 15, 2014
@PVince81

Copy link
Copy Markdown
Contributor Author

@karlitschek don't release 6.0.6 without this backport.

@craigpg we don't have a tag for that ? I'd have set the milestone to OC 6.0.6.

@karlitschek

Copy link
Copy Markdown
Contributor

@PVince81 Sure. Do you have an ETA?

@PVince81

Copy link
Copy Markdown
Contributor Author

If this is urgent I can hijack the unit tests so that we at least get the important regex part in.
Then the blocking ticket can be solved afterwards, and add back the unit test.

How about that ?

@PVince81 PVince81 self-assigned this Oct 15, 2014
@ghost

ghost commented Oct 15, 2014

Copy link
Copy Markdown

💣 Test FAILed. 💣
Refer to this link for build results (access rights to CI server needed):
https://ci.owncloud.org//job/pull-request-analyser-ng-simple/280/

Build result: FAILURE

GitHub pull request #11560 of commit 962b410 automatically merged.Building remotely on vm-slave-02 (SLAVE) in workspace /var/jenkins/workspace/pull-request-analyser-ng-simple@13 > git rev-parse --is-inside-work-tree # timeout=10Fetching changes from the remote Git repository > git config remote.origin.url https://github.com/owncloud/core.git # timeout=10Fetching upstream changes from https://github.com/owncloud/core.git > git --version # timeout=10 > git fetch --tags --progress https://github.com/owncloud/core.git +refs/pull/:refs/remotes/origin/pr/ > git rev-parse origin/pr/11560/merge^{commit} # timeout=10Checking out Revision 69a86386f815ee023a0dfa7b2ba4a6afd40494a2 (detached) > git config core.sparsecheckout # timeout=10 > git checkout -f 69a86386f815ee023a0dfa7b2ba4a6afd40494a2 > git rev-list 6f02a7b1b1a59a42361641fb1326096c647cda42 # timeout=10 > git remote # timeout=10 > git submodule init # timeout=10 > git submodule sync # timeout=10 > git config --get remote.origin.url # timeout=10 > git submodule update --init --recursiveTriggering pull-request-analyser-ng-simple » vm-slave-02Configuration pull-request-analyser-ng-simple » vm-slave-02 is still in the queue: Waiting for next available executor on vm-slave-02pull-request-analyser-ng-simple » vm-slave-02 completed with result FAILUREStarted calculate disk usage of buildFinished Calculation of disk usage of build in 0 secondsStarted calculate disk usage of workspaceFinished Calculation of disk usage of workspace in 27 second
💣 Test FAILed. 💣

@craigpg craigpg modified the milestones: ownCloud 6.0.6, 2014-sprint-06-current Oct 15, 2014
stable6 has a bug where the share keys are not properly deleted when
deleting a shared file as non-owner.

To make sure the more important fix from the backport of
1e63175 can be applied, the
corresponding assert introduced by the backport is disabled.
@scrutinizer-notifier

Copy link
Copy Markdown

A new inspection was created.

@PVince81

Copy link
Copy Markdown
Contributor Author

Since #11598 is not an easy fix and we don't want to break the RC for a minor issue, I decided to comment out the failing assert so we can move forward with this important backport.

@schiesbn can you review the code ?

@scrutinizer-notifier

Copy link
Copy Markdown

The inspection completed: 20 new issues, 13 updated code elements

@ghost

ghost commented Oct 16, 2014

Copy link
Copy Markdown

💣 Test FAILed. 💣
Refer to this link for build results (access rights to CI server needed):
https://ci.owncloud.org//job/pull-request-analyser-ng-simple/351/

Build result: FAILURE

GitHub pull request #11560 of commit d63bba3 automatically merged.Building remotely on vm-slave-02 (SLAVE) in workspace /var/jenkins/workspace/pull-request-analyser-ng-simple@4 > git rev-parse --is-inside-work-tree # timeout=10Fetching changes from the remote Git repository > git config remote.origin.url https://github.com/owncloud/core.git # timeout=10Fetching upstream changes from https://github.com/owncloud/core.git > git --version # timeout=10 > git fetch --tags --progress https://github.com/owncloud/core.git +refs/pull/:refs/remotes/origin/pr/ > git rev-parse origin/pr/11560/merge^{commit} # timeout=10Checking out Revision c37ebe42efe2574fa2b829aff57528d9e5412a8a (detached) > git config core.sparsecheckout # timeout=10 > git checkout -f c37ebe42efe2574fa2b829aff57528d9e5412a8a > git rev-list db53d25bae4c88051f06d234b47f99bf70aca3cc # timeout=10First time build. Skipping changelog. > git remote # timeout=10 > git submodule init # timeout=10 > git submodule sync # timeout=10 > git config --get remote.origin.url # timeout=10 > git submodule update --init --recursiveTriggering pull-request-analyser-ng-simple » vm-slave-02pull-request-analyser-ng-simple » vm-slave-02 completed with result FAILUREStarted calculate disk usage of buildFinished Calculation of disk usage of build in 0 secondsStarted calculate disk usage of workspaceFinished Calculation of disk usage of workspace in 2 second
💣 Test FAILed. 💣

@schiessle

Copy link
Copy Markdown
Contributor

@owncloud-bot retest this please

@ghost

ghost commented Oct 16, 2014

Copy link
Copy Markdown

💣 Test FAILed. 💣
Refer to this link for build results (access rights to CI server needed):
https://ci.owncloud.org//job/pull-request-analyser-ng-simple/354/

Build result: FAILURE

GitHub pull request #11560 of commit d63bba3 automatically merged.Building remotely on vm-slave-02 (SLAVE) in workspace /var/jenkins/workspace/pull-request-analyser-ng-simple > git rev-parse --is-inside-work-tree # timeout=10Fetching changes from the remote Git repository > git config remote.origin.url https://github.com/owncloud/core.git # timeout=10Fetching upstream changes from https://github.com/owncloud/core.git > git --version # timeout=10 > git fetch --tags --progress https://github.com/owncloud/core.git +refs/pull/:refs/remotes/origin/pr/ > git rev-parse origin/pr/11560/merge^{commit} # timeout=10Checking out Revision c37ebe42efe2574fa2b829aff57528d9e5412a8a (detached) > git config core.sparsecheckout # timeout=10 > git checkout -f c37ebe42efe2574fa2b829aff57528d9e5412a8a > git rev-list f595c3a82746ab6ed4aadbe1725fef6be9f27d25 # timeout=10 > git remote # timeout=10 > git submodule init # timeout=10 > git submodule sync # timeout=10 > git config --get remote.origin.url # timeout=10 > git submodule update --init --recursiveTriggering pull-request-analyser-ng-simple » vm-slave-02pull-request-analyser-ng-simple » vm-slave-02 completed with result FAILUREStarted calculate disk usage of buildFinished Calculation of disk usage of build in 0 secondsStarted calculate disk usage of workspaceFinished Calculation of disk usage of workspace in 1 second
💣 Test FAILed. 💣

@PVince81

Copy link
Copy Markdown
Contributor Author

Maybe we need a bot to restart the bot when it fails ?

@PVince81

Copy link
Copy Markdown
Contributor Author

@owncloud-bot retest this please

@ghost

ghost commented Oct 16, 2014

Copy link
Copy Markdown

💣 Test FAILed. 💣
Refer to this link for build results (access rights to CI server needed):
https://ci.owncloud.org//job/pull-request-analyser-ng-simple/408/

Build result: FAILURE

GitHub pull request #11560 of commit d63bba3 automatically merged.Building remotely on vm-slave-02 (SLAVE) in workspace /var/jenkins/workspace/pull-request-analyser-ng-simple@8 > git rev-parse --is-inside-work-tree # timeout=10Fetching changes from the remote Git repository > git config remote.origin.url https://github.com/owncloud/core.git # timeout=10Fetching upstream changes from https://github.com/owncloud/core.git > git --version # timeout=10 > git fetch --tags --progress https://github.com/owncloud/core.git +refs/pull/:refs/remotes/origin/pr/ > git rev-parse origin/pr/11560/merge^{commit} # timeout=10Checking out Revision 751dc23e130a21a36f0f51b92d10c02f3037ee18 (detached) > git config core.sparsecheckout # timeout=10 > git checkout -f 751dc23e130a21a36f0f51b92d10c02f3037ee18 > git rev-list 79d4c2efe369d10b6a12a7dd227377f73213e585 # timeout=10 > git remote # timeout=10 > git submodule init # timeout=10 > git submodule sync # timeout=10 > git config --get remote.origin.url # timeout=10 > git submodule update --init --recursiveTriggering pull-request-analyser-ng-simple » vm-slave-02Configuration pull-request-analyser-ng-simple » vm-slave-02 is still in the queue: Waiting for next available executor on vm-slave-02pull-request-analyser-ng-simple » vm-slave-02 completed with result FAILUREStarted calculate disk usage of buildFinished Calculation of disk usage of build in 0 secondsDisk usage plugin fails during calculation disk usage of this build.
💣 Test FAILed. 💣

@PVince81

Copy link
Copy Markdown
Contributor Author

@schiesbn forget Jenkins... the tests should run locally.
Does the code look ok ?

@schiessle

Copy link
Copy Markdown
Contributor

code looks good
did also some short manual testing and run the tests locally on postgresql, all fine... 👍

@PVince81

Copy link
Copy Markdown
Contributor Author

Thanks. Needs a second reviewer @LukasReschke @icewind1991

@LukasReschke

Copy link
Copy Markdown
Contributor

👍

LukasReschke added a commit that referenced this pull request Oct 17, 2014
…rectbackport

[stable6] backport share key pattern matching fix
@LukasReschke
LukasReschke merged commit 65b439d into stable6 Oct 17, 2014
@LukasReschke
LukasReschke deleted the stable6-encsharekeymatchingdirectbackport branch October 17, 2014 09:36
@lock lock Bot locked as resolved and limited conversation to collaborators Aug 15, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants