~ubuntu-branches/ubuntu/wily/spl-linux/wily

« back to all changes in this revision

Viewing changes to module/spl/spl-cred.c

  • Committer: Package Import Robot
  • Author(s): Liang Guo
  • Date: 2014-07-31 15:16:53 UTC
  • Revision ID: package-import@ubuntu.com-20140731151653-tgao12alohj26jcs
Tags: upstream-0.6.3+git20140731
ImportĀ upstreamĀ versionĀ 0.6.3+git20140731

Show diffs side-by-side

added added

removed removed

Lines of Context:
44
44
cr_groups_search(const struct group_info *group_info, gid_t grp)
45
45
#endif
46
46
{
47
 
        unsigned int left, right;
 
47
        unsigned int left, right, mid;
 
48
        int cmp;
48
49
 
49
50
        if (!group_info)
50
51
                return 0;
52
53
        left = 0;
53
54
        right = group_info->ngroups;
54
55
        while (left < right) {
55
 
                unsigned int mid = (left+right)/2;
56
 
                int cmp = KGID_TO_SGID(grp) - KGID_TO_SGID(GROUP_AT(group_info, mid));
 
56
                mid = (left + right) / 2;
 
57
                cmp = KGID_TO_SGID(grp) -
 
58
                    KGID_TO_SGID(GROUP_AT(group_info, mid));
 
59
 
57
60
                if (cmp > 0)
58
61
                        left = mid + 1;
59
62
                else if (cmp < 0)
120
123
        return gids;
121
124
}
122
125
 
123
 
/* Check if the passed gid is available is in supplied credential. */
 
126
/* Check if the passed gid is available in supplied credential. */
124
127
int
125
128
groupmember(gid_t gid, const cred_t *cr)
126
129
{
128
131
        int rc;
129
132
 
130
133
        gi = get_group_info(cr->group_info);
131
 
        rc = cr_groups_search(cr->group_info, SGID_TO_KGID(gid));
 
134
        rc = cr_groups_search(gi, SGID_TO_KGID(gid));
132
135
        put_group_info(gi);
133
136
 
134
137
        return rc;