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

Domain user cannot access files via Web or Client, or WebDAV - Invalid recipient #26683

Closed
turin13 opened this issue Nov 22, 2016 · 35 comments
Closed

Comments

@turin13
Copy link

turin13 commented Nov 22, 2016

Steps to reproduce

  1. Try to login as one of the affected users (currently 5 such users)
  2. Get Internal server error upon successful login with Remote Address (user's IP) and Request ID
  3. Get error in the owncloud.log (see below)

Expected behaviour

Normal login and access to the files

Server configuration

Operating system:

Ubuntu 14.04 x86_64

Web server:

Apache/2.4.7 (Ubuntu)

Database:

MySQL Distrib 5.5.53, for debian-linux-gnu on x86_64

PHP version:

PHP 5.5.9-1ubuntu4.20
Zend Engine v2.5.0

ownCloud version: (see ownCloud admin page)

ownCloud 9.1.2 (stable)

Updated from an older ownCloud or fresh install:

Update from previous major version (done several tymes)

Where did you install ownCloud from:

Ubuntu repository (deb)

Signing status (ownCloud 9.0 and above):

No errors have been found.

List of activated apps:

Enabled:
  - activity: 2.3.2
  - comments: 0.3.0
  - dav: 0.2.7
  - federatedfilesharing: 0.3.0
  - files: 1.5.1
  - files_antivirus: 0.9.0.0
  - files_pdfviewer: 0.8.1
  - files_sharing: 0.10.0
  - files_texteditor: 2.1
  - files_trashbin: 0.9.0
  - files_versions: 1.3.0
  - firstrunwizard: 1.1
  - gallery: 15.0.0
  - notifications: 0.3.0
  - provisioning_api: 0.5.0
  - systemtags: 0.3.0
  - templateeditor: 0.1
  - updatenotification: 0.2.1
  - user_ldap: 0.9.0

The content of config/config.php:

{
    "system": {
        "updatechecker": false,
        "instanceid": "ID",
        "passwordsalt": "***REMOVED SENSITIVE VALUE***",
        "secret": "***REMOVED SENSITIVE VALUE***",
        "trusted_domains": [
			DOMAINS
        ],
        "datadirectory": "\/var\/www\/owncloud\/data",
        "overwrite.cli.url": "http:\/\/URL\/owncloud",
        "dbtype": "mysql",
        "version": "9.1.2.5",
        "dbname": "DB",
        "dbhost": "localhost",
        "dbtableprefix": "PREFIX",
        "dbuser": "***REMOVED SENSITIVE VALUE***",
        "dbpassword": "***REMOVED SENSITIVE VALUE***",
        "logtimezone": "UTC",
        "installed": true,
        "memcache.local": "\\OC\\Memcache\\APC",
        "mail_smtpmode": "smtp",
        "mail_smtphost": "HOST",
        "mail_smtpport": "25",
        "mail_from_address": "EMAIL",
        "mail_domain": "DOMAIN",
        "mail_smtpauthtype": "LOGIN",
        "mail_smtpauth": 1,
        "mail_smtpname": "***REMOVED SENSITIVE VALUE***",
        "mail_smtppassword": "***REMOVED SENSITIVE VALUE***",
        "mail_smtpsecure": "tls",
        "ldapIgnoreNamingRules": false,
        "loglevel": 3,
        "maintenance": false
    }
}

Are you using encryption:

No

Are you using an external user-backend, if yes which one:

ActiveDirectory

Logs

ownCloud log (data/owncloud.log)

Exception: {"Exception":"InvalidArgumentException","Message":"Invalid recipient","Code":0,"Trace":"
#0 /var/www/owncloud/apps/files_sharing/lib/MountProvider.php(171): OC\Share20\Manager->moveShare(Object(OC\Share20\Share), '6C3E62C1-82F4-4...')
#1 /var/www/owncloud/apps/files_sharing/lib/MountProvider.php(76): OCA\Files_Sharing\MountProvider->buildSuperShares(Array, Object(OC\User\User))
#2 /var/www/owncloud/lib/private/Files/Config/MountProviderCollection.php(76): OCA\Files_Sharing\MountProvider->getMountsForUser(Object(OC\User\User), Object(OC\Files\Storage\StorageFactory))
#3 [internal function]: OC\Files\Config\MountProviderCollection->OC\Files\Config\{closure}(Object(OCA\Files_Sharing\MountProvider))
#4 /var/www/owncloud/lib/private/Files/Config/MountProviderCollection.php(77): array_map(Object(Closure), Array)
#5 /var/www/owncloud/lib/private/Files/Filesystem.php(440): OC\Files\Config\MountProviderCollection->getMountsForUser(Object(OC\User\User))
#6 /var/www/owncloud/lib/private/Files/Filesystem.php(370): OC\Files\Filesystem::initMountPoints('6C3E62C1-82F4-4...')
#7 /var/www/owncloud/lib/private/legacy/util.php(226): OC\Files\Filesystem::init('6C3E62C1-82F4-4...', '/6C3E62C1-82F4-...')
#8 /var/www/owncloud/lib/base.php(890): OC_Util::setupFS()
#9 /var/www/owncloud/index.php(54): OC::handleRequest()
#10 {main}","File":"/var/www/owncloud/lib/private/Share20/Manager.php","Line":862}
@PVince81
Copy link
Contributor

moveShare is only called whenever a duplicate share entry was found when the FS is setup.

For example is a user is receiving two shares with the name "test", at the time ownCloud sets up the filesystem it will rename one of the received shares to "test (2)" by calling moveShare.

@turin13 can you provide more information about the sharing scenario for the affected users ?
Maybe one of the sharers or recipients of such folder doesn't exist any more.

@turin13
Copy link
Author

turin13 commented Nov 22, 2016

@PVince81 Thank you for the reply.
How can I check all user's shares if I couldn't login as that user? I hope there's the other way than checking all other users and their shares.

@PVince81
Copy link
Contributor

Check oc_ldap_user_mapping table to find the ownCloud ID (a long hash) of the affected users.

Then do a select * from oc_share where share_with in (...) or uid_owner in (...), replace "..." with a comma separated list of user ids

@turin13
Copy link
Author

turin13 commented Nov 23, 2016

I did the examination as you suggested.
I checked all 5 affected users. 2 of them have nothing shared with them at all and 3 others have different shares and tey looks normal.
But later I check something - one of the affected users have no entry in oc_mounts table. May this be relevant? When I do sudo -u www-data php occ file:scan on the ID of that user I get this:

**Exception while scanning: Invalid recipient**
#0 /var/www/owncloud/apps/files_sharing/lib/MountProvider.php(171): OC\Share20\Manager->moveShare(Object(OC\Share20\Share), '6C3E62C1-82F4-4...')
#1 /var/www/owncloud/apps/files_sharing/lib/MountProvider.php(76): OCA\Files_Sharing\MountProvider->buildSuperShares(Array, Object(OC\User\User))
#2 /var/www/owncloud/lib/private/Files/Config/MountProviderCollection.php(76): OCA\Files_Sharing\MountProvider->getMountsForUser(Object(OC\User\User), Object(OC\Files\Storage\StorageFactory))
#3 [internal function]: OC\Files\Config\MountProviderCollection->OC\Files\Config\{closure}(Object(OCA\Files_Sharing\MountProvider))
#4 /var/www/owncloud/lib/private/Files/Config/MountProviderCollection.php(77): array_map(Object(Closure), Array)
#5 /var/www/owncloud/lib/private/Files/Filesystem.php(440): OC\Files\Config\MountProviderCollection->getMountsForUser(Object(OC\User\User))
#6 /var/www/owncloud/lib/private/Files/Filesystem.php(370): OC\Files\Filesystem::initMountPoints('6C3E62C1-82F4-4...')
#7 /var/www/owncloud/lib/private/legacy/util.php(226): OC\Files\Filesystem::init('6C3E62C1-82F4-4...', '/6C3E62C1-82F4-...')
#8 /var/www/owncloud/lib/private/Files/Utils/Scanner.php(82): OC_Util::setupFS('6C3E62C1-82F4-4...')
#9 /var/www/owncloud/lib/private/Files/Utils/Scanner.php(156): OC\Files\Utils\Scanner->getMounts('/6C3E62C1-82F4-...')
#10 /var/www/owncloud/apps/files/lib/Command/Scan.php(158): OC\Files\Utils\Scanner->scan('/6C3E62C1-82F4-...')
#11 /var/www/owncloud/apps/files/lib/Command/Scan.php(226): OCA\Files\Command\Scan->scanFiles('6C3E62C1-82F4-4...', '/6C3E62C1-82F4-...', false, Object(Symfony\Component\Console\Output\ConsoleOutput), false)
#12 /var/www/owncloud/3rdparty/symfony/console/Command/Command.php(259): OCA\Files\Command\Scan->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#13 /var/www/owncloud/core/Command/Base.php(158): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#14 /var/www/owncloud/3rdparty/symfony/console/Application.php(844): OC\Core\Command\Base->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#15 /var/www/owncloud/3rdparty/symfony/console/Application.php(192): Symfony\Component\Console\Application->doRunCommand(Object(OCA\Files\Command\Scan), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#16 /var/www/owncloud/3rdparty/symfony/console/Application.php(123): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#17 /var/www/owncloud/lib/private/Console/Application.php(146): Symfony\Component\Console\Application->run(NULL, NULL)
#18 /var/www/owncloud/console.php(102): OC\Console\Application->run()
#19 /var/www/owncloud/occ(11): require_once('/var/www/ownclo...')
#20 {main}

@turin13
Copy link
Author

turin13 commented Nov 27, 2016

Any updates, guys? I think I provided the info. If something else is needed just let me know.
Thanks.

@PVince81
Copy link
Contributor

Line 826 is here: https://github.com/owncloud/core/blob/v9.1.2/lib/private/Share20/Manager.php#L862
And the moveShare is called when grouping the shares here: https://github.com/owncloud/core/blob/v9.1.2/apps/files_sharing/lib/MountProvider.php#L171

Some things that we can deduce from this information:

  • the user is receiving the share through a group share
  • the user is likely receiving the share also through either another group share or another direct user share
  • the different shares have different "file_target" entries in the database, which used to be a bug in previous versions that should auto-repair through this very routine in MountProvider
  • the repair that makes "file_target" consistent doesn't seem to work here because moveShare refuses to rename the share target because the user in question is not a member of the group from which the user is receiving the share ?!

So maybe the user received a share directly and also through a group and then later was removed from that group.

@PVince81
Copy link
Contributor

I tried to reproduce a similar situation but couldn't.

This is because for some reason when fetching the user's received shares, my env doesn't return the group shares for groups in which the user does not belong to any more.

Somehow on your env it seems that there is an inconsistency: the API fetches all received shares including some group shares where the user doesn't belong in the group any more. Then when trying to group these shares to display only a single received folder, it tries to normalize the target folder name but fails because a check finds out that the user is not in the group share's group any more.

I'm now thinking of a possible quickfix that prevents fixing file_target for group shares in this specific routine.

@PVince81
Copy link
Contributor

Hmm, I looked a bit in the LDAP code.

What I observed is that:

  1. The user's group membership in the sharing code is retrieved with groupManager->getUserGroups() which itself goes to LDAP's Group_LDAP::getUserGroups()
  2. When verifying if we can rename/move a group share, we check if the user belongs to it using another method groupManager->inGroup() which itself goes to LDAP's Group_LDAP::inGroup().

Now from what I see the LDAP code is slightly different in both methods.
I wonder if it could produce a situation where maybe the cache still says that a user belongs to the group but the other cache/approach says the user is not member any more.

From what I see the cache key is different for both, one starts with "inGroup" the other with "getUserGroups". So there is a slight chance that both caches are telling a different story and causing this weird inconsistency.

@PVince81
Copy link
Contributor

Now here I really wonder why inGroup() isn't simply using getUserGroups(). Maybe some LDAP servers do not support retrieving a user's group memberships and only allow checking inGroup ??

@jvillafanez do you know anything about this ? Is there an easy way to clear the LDAP caches ?

@owncloud/ldap

@PVince81
Copy link
Contributor

Raised owncloud/user_ldap#30 to clarify the general issue for this code inconsistency.

@PVince81
Copy link
Contributor

@turin13 I see you have a memcache set up. Also browsing through the LDAP code shows that the cache it uses is also memcache. So it is likely that there is an inconsistency about group membership in the cache.

Are you able to clear the memcache ? (not sure how, I have no experience with it)

@PVince81
Copy link
Contributor

From what I see here getUserGroups() is called more often than inGroup(). So it is likely that this method has cached some group membership for some time under the key "getUserGroups".
Then at some point an admin removed group membership from LDAP. But "getUserGroups" still contain it.

And then just now as this special code path calls inGroup(), possibly for the first time, asking the LDAP server whether the user belongs to the group which says no, and the result gets cached with the "inGroup" key.

I'm trying to reproduce this locally in some way.

@PVince81
Copy link
Contributor

Note: it is close to impossible to inspect the cache keys without using a debugger and let the method generate the key name for you.

Steps to reproduce:

  1. Setup OC and set "\OC\Memcache\Redis" as memcache.local (or something else, I used redis)
  2. Setup LDAP docker from https://github.com/owncloud/administration/tree/master/ldap-testing with zombies and Box groups.
  3. In LDAP, add "zombie400" into the group "Box10" using the memberUid approach
  4. Setup LS in OC, pick "posixGroup" in the Groups tab and "memberUid" in expert tab
  5. Go to users page and verify that "Box10" contains the user "zombie400"
  6. Clear the cache (flushall with redis-cli)
  7. PROPFIND as zombie400: curl -X PROPFIND -u zombie400:zombie400 -H "Depth: 1" http://localhost/owncloud/remote.php/webdav => this will repopulate the "getUserGroups" keys but not "inGroup*" or "_groupMembers" (observed with a debugger). The key will say that the user belong to "Box10".
  8. Login as "zombie399"
  9. Create a folder "test"
  10. Share "test" with "zombie400" (might need to last name from LDAP)
  11. Share "test" with "Box10" (from which zombie400 is member).
  12. Log out to avoid side effects from pinging
  13. In the database, we'll need to trigger the sharing code from above with some hacking: select * from oc_share where file_target="/test"
  14. Rename the file_target of the user share: update oc_share set file_target='/test2' where file_target='/test' and share_type=0
  15. Now go to the LDAP server and remove "zombie400" from the group "Box10"
  16. PROPFIND as zombie400: curl -X PROPFIND -u zombie400:zombie400 -H "Depth: 1" http://localhost/owncloud/remote.php/webdav

At this point moveShare is called (due to legacy share scenario) which itself calls GroupManager::inGroup. Since the cache key "inGroup*" did not exist, it will fetch the info directly from LDAP, and LDAP says that Box10 does NOT contain the user zombie400.

And then 💥

{"reqId":"IgVpT0VajXxFIU54GFdh","remoteAddr":"127.0.0.1","app":"core","message":"Exception when running cache gc: Invalid recipient","level":2,"time":"2016-11-28T18:04:12+00:00","method":"PROPFIND","url":"\/owncloud\/remote.php\/webdav","user":"0c6f7670-49d7-1036-83dc-bb7d6e5abfd8"}

It is very likely that this discrepancy could happen in other code paths where one uses getUserGroups and another one uses inGroup.

@PVince81
Copy link
Contributor

In this very specific scenario, the PROPFIND still succeeds but zombie400 cannot see the share at all, even though there is a valid user share for that user. This is because the exception is caught and the mount point is discarded.

Quickfix: clear all LDAP-related memcache keys!

@turin13
Copy link
Author

turin13 commented Nov 28, 2016

Good evening PVince81,
Thank you for the great work and the examination.
Regarding to your quickfix proposal - I have an ACPu cache (php5-acpu package). I cleared the cache, but still no change in the affected user behaviour. I tried to reload apache or even to restart the whole server, but still no effect.

@turin13
Copy link
Author

turin13 commented Nov 28, 2016

And also, if it's related to share, why I can't scan user's files? I mean all of them (using php occ files:scan UID).
I tried to move user's directory to let system generate it again, but result was the same.

@PVince81
Copy link
Contributor

"No change" meaning you're still getting the same exception with exact same message ?
Can you post it just to be sure ? Maybe the problem shifted to another code path.

Not sure why you can't scan, what error does the scanner give you for these users ?

@turin13
Copy link
Author

turin13 commented Nov 29, 2016

This is the scanning result:

sudo -u www-data php occ files:scan 6C3E62C1-82F4-482F-9B32-3CD862D6773D
Starting scan for user 1 out of 1 (6C3E62C1-82F4-482F-9B32-3CD862D6773D)
Exception while scanning: Invalid recipient

#0 /var/www/owncloud/apps/files_sharing/lib/MountProvider.php(171): OC\Share20\Manager->moveShare(Object(OC\Share20\Share), '6C3E62C1-82F4-4...')
#1 /var/www/owncloud/apps/files_sharing/lib/MountProvider.php(76): OCA\Files_Sharing\MountProvider->buildSuperShares(Array, Object(OC\User\User))
#2 /var/www/owncloud/lib/private/Files/Config/MountProviderCollection.php(76): OCA\Files_Sharing\MountProvider->getMountsForUser(Object(OC\User\User), Object(OC\Files\Storage\StorageFactory))
#3 [internal function]: OC\Files\Config\MountProviderCollection->OC\Files\Config\{closure}(Object(OCA\Files_Sharing\MountProvider))
#4 /var/www/owncloud/lib/private/Files/Config/MountProviderCollection.php(77): array_map(Object(Closure), Array)
#5 /var/www/owncloud/lib/private/Files/Filesystem.php(440): OC\Files\Config\MountProviderCollection->getMountsForUser(Object(OC\User\User))
#6 /var/www/owncloud/lib/private/Files/Filesystem.php(370): OC\Files\Filesystem::initMountPoints('6C3E62C1-82F4-4...')
#7 /var/www/owncloud/lib/private/legacy/util.php(226): OC\Files\Filesystem::init('6C3E62C1-82F4-4...', '/6C3E62C1-82F4-...')
#8 /var/www/owncloud/lib/private/Files/Utils/Scanner.php(82): OC_Util::setupFS('6C3E62C1-82F4-4...')
#9 /var/www/owncloud/lib/private/Files/Utils/Scanner.php(156): OC\Files\Utils\Scanner->getMounts('/6C3E62C1-82F4-...')
#10 /var/www/owncloud/apps/files/lib/Command/Scan.php(158): OC\Files\Utils\Scanner->scan('/6C3E62C1-82F4-...')
#11 /var/www/owncloud/apps/files/lib/Command/Scan.php(226): OCA\Files\Command\Scan->scanFiles('6C3E62C1-82F4-4...', '/6C3E62C1-82F4-...', false, Object(Symfony\Component\Console\Output\ConsoleOutput), false)
#12 /var/www/owncloud/3rdparty/symfony/console/Command/Command.php(259): OCA\Files\Command\Scan->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#13 /var/www/owncloud/core/Command/Base.php(158): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#14 /var/www/owncloud/3rdparty/symfony/console/Application.php(844): OC\Core\Command\Base->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#15 /var/www/owncloud/3rdparty/symfony/console/Application.php(192): Symfony\Component\Console\Application->doRunCommand(Object(OCA\Files\Command\Scan), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#16 /var/www/owncloud/3rdparty/symfony/console/Application.php(123): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#17 /var/www/owncloud/lib/private/Console/Application.php(146): Symfony\Component\Console\Application->run(NULL, NULL)
#18 /var/www/owncloud/console.php(102): OC\Console\Application->run()
#19 /var/www/owncloud/occ(11): require_once('/var/www/ownclo...')
#20 {main}

+---------+-------+--------------+
| Folders | Files | Elapsed time |
+---------+-------+--------------+
| 0       | 0     | 00:00:00     |
+---------+-------+--------------+`

This is the Login error log:

{"reqId":"13FVEYzuMWNkwFWh03b+","remoteAddr":"IP.AD.DR.ESS","app":"no app in context","message":"Exception: {"Exception":"InvalidArgumentException","Message":"Invalid recipient","Code":0,"Trace":"
#0 /var/www/owncloud/apps/files_sharing/lib/MountProvider.php(171): OC\Share20\Manager->moveShare(Object(OC\Share20\Share), '6C3E62C1-82F4-4...')
#1 /var/www/owncloud/apps/files_sharing/lib/MountProvider.php(76): OCA\Files_Sharing\MountProvider->buildSuperShares(Array, Object(OC\User\User))
#2 /var/www/owncloud/lib/private/Files/Config/MountProviderCollection.php(76): OCA\Files_Sharing\MountProvider->getMountsForUser(Object(OC\User\User), Object(OC\Files\Storage\StorageFactory))
#3 [internal function]: OC\Files\Config\MountProviderCollection->OC\Files\Config\{closure}(Object(OCA\Files_Sharing\MountProvider))
#4 /var/www/owncloud/lib/private/Files/Config/MountProviderCollection.php(77): array_map(Object(Closure), Array)
#5 /var/www/owncloud/lib/private/Files/Filesystem.php(440): OC\Files\Config\MountProviderCollection->getMountsForUser(Object(OC\User\User))
#6 /var/www/owncloud/lib/private/Files/Filesystem.php(370): OC\Files\Filesystem::initMountPoints('6C3E62C1-82F4-4...')
#7 /var/www/owncloud/lib/private/legacy/util.php(226): OC\Files\Filesystem::init('6C3E62C1-82F4-4...', '/6C3E62C1-82F4-...')
#8 /var/www/owncloud/apps/user_ldap/lib/FilesystemHelper.php(44): OC_Util::setupFS('6C3E62C1-82F4-4...')
#9 /var/www/owncloud/apps/user_ldap/lib/User/User.php(519): OCA\User_LDAP\FilesystemHelper->setup('6C3E62C1-82F4-4...')
#10 /var/www/owncloud/apps/user_ldap/lib/User/User.php(499): OCA\User_LDAP\User\User->setOwnCloudAvatar()
#11 /var/www/owncloud/apps/user_ldap/lib/User/User.php(481): OCA\User_LDAP\User\User->updateAvatar()
#12 [internal function]: OCA\User_LDAP\User\User->updateAvatarPostLogin(Array)
#13 /var/www/owncloud/lib/private/legacy/hook.php(105): call_user_func(Array, Array)
#14 /var/www/owncloud/lib/private/Server.php(268): OC_Hook::emit('OC_User', 'post_login', Array)
#15 [internal function]: OC\Server->OC\{closure}(Object(OC\User\User), 'Gali0308!')
#16 /var/www/owncloud/lib/private/Hooks/EmitterTrait.php(98): call_user_func_array(Object(Closure), Array)
#17 /var/www/owncloud/lib/private/Hooks/PublicEmitter.php(32): OC\Hooks\BasicEmitter->emit('\OC\User', 'postLogin', Array)
#18 /var/www/owncloud/lib/private/User/Session.php(439): OC\Hooks\PublicEmitter->emit('\OC\User', 'postLogin', Array)
#19 /var/www/owncloud/lib/private/User/Session.php(287): OC\User\Session->loginWithPassword(*** sensitive parameters replaced ***)
#20 /var/www/owncloud/core/Controller/LoginController.php(196): OC\User\Session->login(*** sensitive parameters replaced ***)
#21 [internal function]: OC\Core\Controller\LoginController->tryLogin(*** sensitive parameters replaced ***)
#22 /var/www/owncloud/lib/private/AppFramework/Http/Dispatcher.php(159): call_user_func_array(Array, Array)
#23 /var/www/owncloud/lib/private/AppFramework/Http/Dispatcher.php(89): OC\AppFramework\Http\Dispatcher->executeController(Object(OC\Core\Controller\LoginController), 'tryLogin')
#24 /var/www/owncloud/lib/private/AppFramework/App.php(99): OC\AppFramework\Http\Dispatcher->dispatch(Object(OC\Core\Controller\LoginController), 'tryLogin')
#25 /var/www/owncloud/lib/private/AppFramework/Routing/RouteActionHandler.php(46): OC\AppFramework\App::main('LoginController', 'tryLogin', Object(OC\AppFramework\DependencyInjection\DIContainer), Array)
#26 [internal function]: OC\AppFramework\Routing\RouteActionHandler->__invoke(Array)
#27 /var/www/owncloud/lib/private/Route/Router.php(280): call_user_func(Object(OC\AppFramework\Routing\RouteActionHandler), Array)
#28 /var/www/owncloud/lib/base.php(891): OC\Route\Router->match('/login')
#29 /var/www/owncloud/index.php(54): OC::handleRequest()
#30 {main}","File":"/var/www/owncloud/lib/private/Share20/Manager.php","Line":862}","level":3,"time":"2016-11-29T08:29:38+00:00","method":"POST","url":"/index.php/login","user":"6C3E62C1-82F4-482F-9B32-3CD862D6773D"}
{"reqId":"eGRBoEQWL1HIFX5soHTG","remoteAddr":"IP.AD.DR.ESS","app":"index","message":"Exception: {"Exception":"InvalidArgumentException","Message":"Invalid recipient","Code":0,"Trace":"
#0 /var/www/owncloud/apps/files_sharing/lib/MountProvider.php(171): OC\Share20\Manager->moveShare(Object(OC\Share20\Share), '6C3E62C1-82F4-4...')
#1 /var/www/owncloud/apps/files_sharing/lib/MountProvider.php(76): OCA\Files_Sharing\MountProvider->buildSuperShares(Array, Object(OC\User\User))
#2 /var/www/owncloud/lib/private/Files/Config/MountProviderCollection.php(76): OCA\Files_Sharing\MountProvider->getMountsForUser(Object(OC\User\User), Object(OC\Files\Storage\StorageFactory))
#3 [internal function]: OC\Files\Config\MountProviderCollection->OC\Files\Config\{closure}(Object(OCA\Files_Sharing\MountProvider))
#4 /var/www/owncloud/lib/private/Files/Config/MountProviderCollection.php(77): array_map(Object(Closure), Array)
#5 /var/www/owncloud/lib/private/Files/Filesystem.php(440): OC\Files\Config\MountProviderCollection->getMountsForUser(Object(OC\User\User))
#6 /var/www/owncloud/lib/private/Files/Filesystem.php(370): OC\Files\Filesystem::initMountPoints('6C3E62C1-82F4-4...')
#7 /var/www/owncloud/lib/private/legacy/util.php(226): OC\Files\Filesystem::init('6C3E62C1-82F4-4...', '/6C3E62C1-82F4-...')
#8 /var/www/owncloud/lib/base.php(890): OC_Util::setupFS()
#9 /var/www/owncloud/index.php(54): OC::handleRequest()
#10 {main}","File":"/var/www/owncloud/lib/private/Share20/Manager.php","Line":862}","level":3,"time":"2016-11-29T08:29:38+00:00","method":"GET","url":"/index.php/apps/files/","user":"6C3E62C1-82F4-482F-9B32-3CD862D6773D"}
{"reqId":"fjWwOM2gEqm/qA5+d8AO","remoteAddr":"IP.AD.DR.ESS","app":"index","message":"Exception: {"Exception":"InvalidArgumentException","Message":"Invalid recipient","Code":0,"Trace":"
#0 /var/www/owncloud/apps/files_sharing/lib/MountProvider.php(171): OC\Share20\Manager->moveShare(Object(OC\Share20\Share), '6C3E62C1-82F4-4...')
#1 /var/www/owncloud/apps/files_sharing/lib/MountProvider.php(76): OCA\Files_Sharing\MountProvider->buildSuperShares(Array, Object(OC\User\User))
#2 /var/www/owncloud/lib/private/Files/Config/MountProviderCollection.php(76): OCA\Files_Sharing\MountProvider->getMountsForUser(Object(OC\User\User), Object(OC\Files\Storage\StorageFactory))
#3 [internal function]: OC\Files\Config\MountProviderCollection->OC\Files\Config\{closure}(Object(OCA\Files_Sharing\MountProvider))
#4 /var/www/owncloud/lib/private/Files/Config/MountProviderCollection.php(77): array_map(Object(Closure), Array)
#5 /var/www/owncloud/lib/private/Files/Filesystem.php(440): OC\Files\Config\MountProviderCollection->getMountsForUser(Object(OC\User\User))
#6 /var/www/owncloud/lib/private/Files/Filesystem.php(370): OC\Files\Filesystem::initMountPoints('6C3E62C1-82F4-4...')
#7 /var/www/owncloud/lib/private/legacy/util.php(226): OC\Files\Filesystem::init('6C3E62C1-82F4-4...', '/6C3E62C1-82F4-...')
#8 /var/www/owncloud/lib/base.php(890): OC_Util::setupFS()
#9 /var/www/owncloud/index.php(54): OC::handleRequest()
#10 {main}","File":"/var/www/owncloud/lib/private/Share20/Manager.php","Line":862}","level":3,"time":"2016-11-29T08:29:39+00:00","method":"GET","url":"/index.php/apps/gallery/config?extramediatypes=1","user":"6C3E62C1-82F4-482F-9B32-3CD862D6773D"}
{"reqId":"+j54qZvTsV/1oNh5QXHx","remoteAddr":"IP.AD.DR.ESS","app":"index","message":"Exception: {"Exception":"InvalidArgumentException","Message":"Invalid recipient","Code":0,"Trace":"
#0 /var/www/owncloud/apps/files_sharing/lib/MountProvider.php(171): OC\Share20\Manager->moveShare(Object(OC\Share20\Share), '6C3E62C1-82F4-4...')
#1 /var/www/owncloud/apps/files_sharing/lib/MountProvider.php(76): OCA\Files_Sharing\MountProvider->buildSuperShares(Array, Object(OC\User\User))
#2 /var/www/owncloud/lib/private/Files/Config/MountProviderCollection.php(76): OCA\Files_Sharing\MountProvider->getMountsForUser(Object(OC\User\User), Object(OC\Files\Storage\StorageFactory))
#3 [internal function]: OC\Files\Config\MountProviderCollection->OC\Files\Config\{closure}(Object(OCA\Files_Sharing\MountProvider))
#4 /var/www/owncloud/lib/private/Files/Config/MountProviderCollection.php(77): array_map(Object(Closure), Array)
#5 /var/www/owncloud/lib/private/Files/Filesystem.php(440): OC\Files\Config\MountProviderCollection->getMountsForUser(Object(OC\User\User))
#6 /var/www/owncloud/lib/private/Files/Filesystem.php(370): OC\Files\Filesystem::initMountPoints('6C3E62C1-82F4-4...')
#7 /var/www/owncloud/lib/private/legacy/util.php(226): OC\Files\Filesystem::init('6C3E62C1-82F4-4...', '/6C3E62C1-82F4-...')
#8 /var/www/owncloud/lib/base.php(890): OC_Util::setupFS()
#9 /var/www/owncloud/index.php(54): OC::handleRequest()
#10 {main}","File":"/var/www/owncloud/lib/private/Share20/Manager.php","Line":862}","level":3,"time":"2016-11-29T08:29:39+00:00","method":"GET","url":"/index.php/apps/files/undefined/img/notifications.svg","user":"6C3E62C1-82F4-482F-9B32-3CD862D6773D"}
{"reqId":"+jJf6w7Zdgx4PfSDd5h6","remoteAddr":"IP.AD.DR.ESS","app":"PHP","message":"InvalidArgumentException: Invalid recipient at /var/www/owncloud/lib/private/Share20/Manager.php#862","level":3,"time":"2016-11-29T08:29:39+00:00","method":"GET","url":"/ocs/v2.php/apps/notifications/api/v1/notifications?format=json","user":"6C3E62C1-82F4-482F-9B32-3CD862D6773D"}`

@PVince81
Copy link
Contributor

Ok thanks. If despite cleaning the memcache the problem still occurs, there is something fishy with the LDAP implementation or with the LDAP queries. I'm not sure if both inGroup() and getUserGroup() are using the same LDAP queries. If they are different then the question is why would LDAP return different results.

@turin13
Copy link
Author

turin13 commented Dec 4, 2016

Hi,
May affected user experience such a behaviour if he has no record in oc_mounts table?

@PVince81
Copy link
Contributor

PVince81 commented Dec 5, 2016

The oc_mounts table isn't authoritative, it's currently just like a cache. If you'd delete entries there they'd appear again the next time the user's FS is setup. In the case of your users experiencing the problem, the code never reaches the part where it actually adds the entries into that table.

It should be possible to provide a quick workaround for these users to be able to bypass that exception. However my worry is that the LDAP API results inconsistency is likely to cause you other kinds of unpredictable trouble in the future. Ideal would be to find out why it happens.

@turin13 what LDAP server are you using ? Can you post your LDAP config dump ? occ ldap:show-config

@jvillafanez

@turin13
Copy link
Author

turin13 commented Dec 5, 2016

@PVince81 we're using Active Directory with all DCs 2012R2 and the same functional level of the domain.

+-------------------------------+------------------------------------------------------------------------------------------------------------------------------+
| Configuration                 |                                                                                                                              |
+-------------------------------+------------------------------------------------------------------------------------------------------------------------------+
| hasMemberOfFilterSupport      | 1                                                                                                                            |
| hasPagedResultSupport         |                                                                                                                              |
| homeFolderNamingRule          |                                                                                                                              |
| lastJpegPhotoLookup           | 0                                                                                                                            |
| ldapAgentName                 | SERVICE-ACCOUNT_DN                                                                                                           |
| ldapAgentPassword             | ***                                                                                                                          |
| ldapAttributesForGroupSearch  |                                                                                                                              |
| ldapAttributesForUserSearch   |                                                                                                                              |
| ldapBackupHost                |                                                                                                                              |
| ldapBackupPort                |                                                                                                                              |
| ldapBase                      | DC=OFFICE,DC=LOCAL                                                                                                           |
| ldapBaseGroups                | DC=OFFICE,DC=LOCAL                                                                                                           |
| ldapBaseUsers                 | DC=OFFICE,DC=LOCAL                                                                                                           |
| ldapCacheTTL                  | 600                                                                                                                          |
| ldapConfigurationActive       | 1                                                                                                                            |
| ldapDynamicGroupMemberURL     |                                                                                                                              |
| ldapEmailAttribute            | mail                                                                                                                         |
| ldapExperiencedAdmin          | 0                                                                                                                            |
| ldapExpertUUIDGroupAttr       |                                                                                                                              |
| ldapExpertUUIDUserAttr        |                                                                                                                              |
| ldapExpertUsernameAttr        |                                                                                                                              |
| ldapGroupDisplayName          | cn                                                                                                                           |
| ldapGroupFilter               | (&(|(objectclass=group)))                                                                                                    |
| ldapGroupFilterGroups         |                                                                                                                              |
| ldapGroupFilterMode           | 0                                                                                                                            |
| ldapGroupFilterObjectclass    | group                                                                                                                        |
| ldapGroupMemberAssocAttr      | uniqueMember                                                                                                                 |
| ldapHost                      | dc01.OFFICE.LOCAL                                                                                                            |
| ldapIgnoreNamingRules         |                                                                                                                              |
| ldapLoginFilter               | (&(&(|(objectclass=organizationalPerson)))(samaccountname=%uid))                                                             |
| ldapLoginFilterAttributes     |                                                                                                                              |
| ldapLoginFilterEmail          | 0                                                                                                                            |
| ldapLoginFilterMode           | 0                                                                                                                            |
| ldapLoginFilterUsername       | 1                                                                                                                            |
| ldapNestedGroups              | 1                                                                                                                            |
| ldapOverrideMainServer        |                                                                                                                              |
| ldapPagingSize                | 1000                                                                                                                         |
| ldapPort                      | 389                                                                                                                          |
| ldapQuotaAttribute            |                                                                                                                              |
| ldapQuotaDefault              |                                                                                                                              |
| ldapTLS                       | 0                                                                                                                            |
| ldapUserDisplayName           | displayName                                                                                                                  |
| ldapUserDisplayName2          |                                                                                                                              |
| ldapUserFilter                | (&(|(objectclass=person)(objectclass=user))(|(|(memberof=CN=Domain Users,CN=Users,DC=OFFICE,DC=LOCAL)(primaryGroupID=513)))) |
| ldapUserFilterGroups          | Domain Users                                                                                                                 |
| ldapUserFilterMode            | 0                                                                                                                            |
| ldapUserFilterObjectclass     | person;user                                                                                                                  |
| ldapUuidGroupAttribute        | auto                                                                                                                         |
| ldapUuidUserAttribute         | auto                                                                                                                         |
| turnOffCertCheck              | 0                                                                                                                            |
| useMemberOfToDetectMembership | 1                                                                                                                            |
+-------------------------------+------------------------------------------------------------------------------------------------------------------------------+

@turin13
Copy link
Author

turin13 commented Dec 10, 2016

Guys, any news? What do you think I can do to workaround this issue? May I somehow reset those users in ownCloud (without deleting them from Active Directory)?

@PVince81
Copy link
Contributor

I'm out of ideas and don't have enough experience with LDAP to be able to debug this further.

Let me provide you with a quick patch to bypass the code in question.

@PVince81
Copy link
Contributor

Comment out this piece:

diff --git a/apps/files_sharing/lib/MountProvider.php b/apps/files_sharing/lib/MountProvider.php
index 54f9fea..92f377e 100644
--- a/apps/files_sharing/lib/MountProvider.php
+++ b/apps/files_sharing/lib/MountProvider.php
@@ -165,11 +165,13 @@ class MountProvider implements IMountProvider {
                        $permissions = 0;
                        foreach ($shares as $share) {
                                $permissions |= $share->getPermissions();
+                               /*
                                if ($share->getTarget() !== $superShare->getTarget()) {
                                        // adjust target, for database consistency
                                        $share->setTarget($superShare->getTarget());
                                        $this->shareManager->moveShare($share, $user->getUID());
                                }
+                                */
                        }
 
                        $superShare->setPermissions($permissions);

This is in the method buildSuperShares() of the class OCA\Files_Sharing\MountProvider.

This will prevent the code to try and fix the share's target. There is a slight chance that the users might see duplicate received shares. But that's better than not being able to login at all.

@turin13
Copy link
Author

turin13 commented Dec 12, 2016

I implemented your patch and upon Apache restart was able to login as affected user. Then I saw some shares with strange behavior - nothing was mentioned on "Shared with me" page.
Then I went to ldap settings, run manual update again (which I did several times during the issue). I also removed affected user from relevant security groups, updated ldap, and placed him back again.
This time it worked - "Shared with me" page filled itself with all the shares.
Then I restored commented out section of the MountProvider.php, restarted Apache and it continued to work fine - affected users were able to log in and occ files:scan passed successfully.
Thank you @PVince81! You really helped me!

@PVince81
Copy link
Contributor

Hmmmm... that behavior is still mysterious. From my understanding removing the patch should bring back the issue. But maybe some other piece of code fixed the files_target when the users were able to login.

@turin13
Copy link
Author

turin13 commented Dec 12, 2016

If I could help you by providing additional info, so that ownCloud will develop protection against such cases, I'll do this gladly.

@PVince81
Copy link
Contributor

I can't think of any info that could help here. From my understanding the issue was caused by the LDAP APIs (or the LDAP server ?) to return inconsistent results when calling the "is user in group" and "get user memberships" functions. But maybe it's something else and what we observed is just a side effect.

@PVince81
Copy link
Contributor

but thanks anyway 😄

@PVince81
Copy link
Contributor

I had another try reproducing this but without luck.

In your specific setup I don't understand how this issue can happen with an already cleared cache.

Anyway, we find other cases where inconsistent cache results could cause null groups to appear here and there, so this PR #26871 will add extra protection against it, including your own specific case.

@turin13
Copy link
Author

turin13 commented Jan 12, 2017

If there's any info I can provide, I'll be happy to do so.
The only thing I believe I can help this project :)

@butonic
Copy link
Member

butonic commented Jan 13, 2017

@turin13 if you coud try #26871 and give feedback there that would also be very valuable :)

@PVince81
Copy link
Contributor

PVince81 commented Apr 6, 2017

please try with #26871

@lock
Copy link

lock bot commented Jul 31, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Jul 31, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants