Skip to content

[encryption] don't check if we have a valid user during migration - #13952

Merged
karlitschek merged 1 commit into
masterfrom
fix_migration
Feb 6, 2015
Merged

karlitschek merged 1 commit into
masterfrom
fix_migration

Conversation

@schiessle

Copy link
Copy Markdown
Contributor

This problem happens if a system has local users and ldap users.

The first time the user opens ownCloud on the web interface the upgrade will be triggered. In this case we will only find the local users, not the ldap users, so we will migrate the local users only.
But now for any share from a local user to a ldap user the userExists() check will fail (because the ldap backend isn't loaded) and we will skip the share key.

This PR removes the check, in 99% of all use cases we will have a valid user. This is only problematic in the corner case where we have user names and file names where we are no longer able to detect the user name correctly which should happen really seldom. Even in this case nothing will be lost. The key will be only in the wrong folder and the admin will still have the backup we create before the migration. So he will be able to fix it manually. He will have to do this anyway if this corner-case happens, also with the old code where we skipped the key completely.

issue: #13950

cc @PVince81 @DeepDiver1975

@DeepDiver1975

Copy link
Copy Markdown
Contributor

Please test code before push!!

00:08:31.314 ...........S........................PHP Parse error:  syntax error, unexpected 'private' (T_PRIVATE) in /var/jenkins/workspace/pull-request-analyser-ng-simple@4/label/SLAVE/apps/files_encryption/lib/migration.php on line 270
00:11:00.933 PHP Stack trace:
00:11:00.934 PHP   1. {main}() /usr/local/bin/phpunit:0
00:11:00.934 PHP   2. PHPUnit_TextUI_Command::main() /usr/local/bin/phpunit:605
00:11:00.934 PHP   3. PHPUnit_TextUI_Command->run() phar:///usr/local/bin/phpunit/phpunit/TextUI/Command.php:138
00:11:00.936 PHP   4. PHPUnit_TextUI_TestRunner->doRun() phar:///usr/local/bin/phpunit/phpunit/TextUI/Command.php:186
00:11:00.936 PHP   5. PHPUnit_Framework_TestSuite->run() phar:///usr/local/bin/phpunit/phpunit/TextUI/TestRunner.php:423
00:11:00.936 PHP   6. PHPUnit_Framework_TestSuite->run() phar:///usr/local/bin/phpunit/phpunit/Framework/TestSuite.php:751
00:11:00.936 PHP   7. PHPUnit_Framework_TestCase->run() phar:///usr/local/bin/phpunit/phpunit/Framework/TestSuite.php:751
00:11:00.937 PHP   8. PHPUnit_Framework_TestResult->run() phar:///usr/local/bin/phpunit/phpunit/Framework/TestCase.php:711
00:11:00.937 PHP   9. PHP_Invoker->invoke() phar:///usr/local/bin/phpunit/phpunit/Framework/TestResult.php:641
00:11:00.938 PHP  10. call_user_func_array:{phar:///usr/local/bin/phpunit/php-invoker/Invoker.php:93}() phar:///usr/local/bin/phpunit/php-invoker/Invoker.php:93
00:11:00.938 PHP  11. PHPUnit_Framework_TestCase->runBare() phar:///usr/local/bin/phpunit/php-invoker/Invoker.php:93
00:11:00.938 PHP  12. PHPUnit_Framework_TestCase->runTest() phar:///usr/local/bin/phpunit/phpunit/Framework/TestCase.php:775
00:11:00.938 PHP  13. ReflectionMethod->invokeArgs() phar:///usr/local/bin/phpunit/phpunit/Framework/TestCase.php:905
00:11:00.939 PHP  14. OCA\Files_Encryption\Tests\Migration->testMigrateToNewFolderStructure() phar:///usr/local/bin/phpunit/phpunit/Framework/TestCase.php:905
00:11:00.939 PHP  15. spl_autoload_call() phar:///usr/local/bin/phpunit/phpunit/Framework/TestCase.php:205
00:11:00.939 PHP  16. OC\Autoloader->load() phar:///usr/local/bin/phpunit/phpunit/Framework/TestCase.php:0
00:11:01.513 PHP Warning:  Unknown: Cannot destroy the zip context in Unknown on line 0
00:11:01.513 PHP Stack trace:

@DeepDiver1975

Copy link
Copy Markdown
Contributor

@schiesbn ^

@schiessle

Copy link
Copy Markdown
Contributor Author

Already fixed, saw it directly after push but didn't want to kill Jenkins

@schiessle

Copy link
Copy Markdown
Contributor Author

Tests still run, that's not the final result.

@DeepDiver1975

Copy link
Copy Markdown
Contributor

@owncloud-bot retest this please

@PVince81

PVince81 commented Feb 6, 2015

Copy link
Copy Markdown
Contributor

👍 fixes the issue, code change as discussed

@blizzz

blizzz commented Feb 6, 2015

Copy link
Copy Markdown
Contributor

um, how can you setup the fs for a user if getHome cannot be executed for him?

@PVince81

PVince81 commented Feb 6, 2015

Copy link
Copy Markdown
Contributor

@blizzz good point... that sounds like that other issue where the user manager couldn't find the user and would setup invalid FS entries (see #12801 (comment))

@schiessle

Copy link
Copy Markdown
Contributor Author

@blizzz migration only happens for user we found with getUsers(). Every other user will be skipped and need to be migrated by the occ script until this is merged #13865

@blizzz

blizzz commented Feb 6, 2015

Copy link
Copy Markdown
Contributor

if they are found by getUsers, userExists shouldn't be a problem either?

@PVince81

PVince81 commented Feb 6, 2015

Copy link
Copy Markdown
Contributor

Yes, makes sense. So the local users will be migrated first, but for every file it will migrate ALL share keys (without checking if the key owner exists). The remaining non-local users will get migrated with the ./occ encryption:migrate-keys run.

@PVince81

PVince81 commented Feb 6, 2015

Copy link
Copy Markdown
Contributor

@blizzz no, because for example you're migrating the local user "root" who shared a file with "ldapuser1". Calling getUsers() will only return "root". But for that "root" user, some files have share keys with the name "xxx.ldapuser1.key". If you call userExists('ldapuser1') it will NOT find it, so it will fail to migrate that key. This is why we removed the check.

Does that make sense ?

@scrutinizer-notifier

Copy link
Copy Markdown

The inspection completed: 2 new issues, 4 updated code elements

@ghost

ghost commented Feb 6, 2015

Copy link
Copy Markdown

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

@jnfrmarks

Copy link
Copy Markdown

👍

Validated patch

7.0.4->8.0.0 RC2 server edition
ubuntu 14.04
php 5.5.9
openLDAP

LDAP user shares with LDAP user
LDAP user shares with local user
local user shares with LDAP user
local user shares with local user

Files can be downloaded in all cases above after upgrade

@PVince81

PVince81 commented Feb 6, 2015

Copy link
Copy Markdown
Contributor

@karlitschek @DeepDiver1975 up to you to merge this now (your decision).
Thanks

karlitschek added a commit that referenced this pull request Feb 6, 2015
[encryption] don't check if we have a valid user during migration
@karlitschek
karlitschek merged commit 492fadd into master Feb 6, 2015
@karlitschek
karlitschek deleted the fix_migration branch February 6, 2015 19:04
@lock lock Bot locked as resolved and limited conversation to collaborators Aug 13, 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.

7 participants