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

Share: cannot find users when sharing mode is groups only #5016

Closed
nosignleft opened this issue Sep 27, 2013 · 8 comments
Closed

Share: cannot find users when sharing mode is groups only #5016

nosignleft opened this issue Sep 27, 2013 · 8 comments

Comments

@nosignleft
Copy link

Expected behavior

When trying to share a file or folder in "groups_only" mode, we should be able to find users from the user's own groups or its groups themselves.

Actual behavior

Since 5.0.11, it only allow to search groups or users answer on the same search pattern.

It was working in 5.0.10

Steps to reproduce

  1. Select groups_only mode in administration
  2. Create a user "[email protected]" from a group "1234"
  3. Create a user "[email protected]" from a group "1234"
  4. Being [email protected], try to share a file with [email protected] searching for "a"
  5. The user is not found
  6. Searching for "1" will display the user's group

Fix

It seems that the code in core/ajax/share.php try to search for users in the groups... it found after applying the search pattern.

--- a/core/ajax/share.php   2013-09-19 17:05:59.676756537 +0200
+++ b/core/ajax/share.php   2013-09-27 17:36:48.143608015 +0200
@@ -177,6 +177,7 @@
 //                     }
 //                 }
                $groups = OC_Group::getGroups($_GET['search']);
+               $usergroups = array();
                if ($sharePolicy == 'groups_only') {
                    $usergroups = OC_Group::getUserGroups(OC_User::getUser());
                    $groups = array_intersect($groups, $usergroups);
@@ -188,7 +188,7 @@
                while ($count < 15 && count($users) == $limit) {
                    $limit = 15 - $count;
                    if ($sharePolicy == 'groups_only') {
-                       $users = OC_Group::DisplayNamesInGroups($groups, $_GET['search'], $limit, $offset);
+                       $users = OC_Group::displayNamesInGroups($usergroups, $_GET['search'], $limit, $offset);
                    } else {
                        $users = OC_User::getDisplayNames($_GET['search'], $limit, $offset);
                    }

@ghost
Copy link

ghost commented Oct 4, 2013

I can confirm that this bug is still present in 5.0.12 and this solution fixes the problem.

Thank you nosignleft!

@schiessle
Copy link
Contributor

It is already fixed in the stable5 branch and will be released with oc5.0.13. See merged pull request #5211

@mybr4inhurts
Copy link

I have two users that are affected by a bug (?) on a system (oc 7.0.2, nginx, mysql) with about 30 users and three groups. When sharing data or tasks, these two users can't be found by others. Strangely they can see other users of their groups.
Group-only-sharing is enabled, sharing to groups is allowed.
All relevant users are together in a group so they should be seen by other users in these groups (all the other users can be seen).

That's what I tried so far:
I left and rejoined all groups with all depending users (including me) but no change. Then I changed their usernames and passwords and checked their data folders which look good to me. I also deleted and recreated these users from scratch.

any other ideas?

EDIT:
If I disable group-only-sharing I can find the two users.
The strange thing is, they are definitely in my groups - mysql confirmes that if I look into the "group_user" table.

@nosignleft
Copy link
Author

This is probably the same issue I reported. The cause is simple: the searched list is trimmed before doing the research. So you won't be able to anyone outside of this list, even if someone "excluded" is part of your group.

@mybr4inhurts
Copy link

Yup, that explains it. I saw that 15 entry limit in the code but thought of a pagination feature and didn't look closer...
I hope they gonna fix it in the next release.

Do you have a workaround for that issue?

@nosignleft
Copy link
Author

If you don't have thousands of users, you can check my report and temp fix here: #8899

@mybr4inhurts
Copy link

First thing that comes to my mind: Why don't you use Groups.getUsersInGroup($groupId, $limit, $offset)?
That function only searches for users in a particular group.

groups = Group.getUserGroups($uid) 
foreach ($groups as $group){ 
    $users[] = Group.getUsersInGroup($group); 
} 
return $users; 

If you don't have thousands of groups this might work...? I'm neither a php nor owncloud pro...

@nosignleft
Copy link
Author

For this issue or for the #8899 ?

Anyway, don't forget that the code need to be flexible enough to work with or without the group-only-sharing option and with any group/user backends.

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

No branches or pull requests

3 participants