diff options
author | Eric W. Biederman <ebiederm@xmission.com> | 2012-02-09 12:09:39 -0500 |
---|---|---|
committer | Eric W. Biederman <ebiederm@xmission.com> | 2012-05-03 06:29:33 -0400 |
commit | 72cda3d1ef24ab0a9a89c15e9776ca737b75f45a (patch) | |
tree | 91f91efb04ff8afd01f840666cc0cdc61d9c1b17 | |
parent | 92361636e0153bd0cb22e7dfe3fc6287f6537c66 (diff) |
userns: Convert in_group_p and in_egroup_p to use kgid_t
Acked-by: Serge Hallyn <serge.hallyn@canonical.com>
Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
-rw-r--r-- | include/linux/cred.h | 4 | ||||
-rw-r--r-- | kernel/groups.c | 14 |
2 files changed, 8 insertions, 10 deletions
diff --git a/include/linux/cred.h b/include/linux/cred.h index fac0579258fc..917dc5aeb1d4 100644 --- a/include/linux/cred.h +++ b/include/linux/cred.h | |||
@@ -73,8 +73,8 @@ extern int groups_search(const struct group_info *, kgid_t); | |||
73 | #define GROUP_AT(gi, i) \ | 73 | #define GROUP_AT(gi, i) \ |
74 | ((gi)->blocks[(i) / NGROUPS_PER_BLOCK][(i) % NGROUPS_PER_BLOCK]) | 74 | ((gi)->blocks[(i) / NGROUPS_PER_BLOCK][(i) % NGROUPS_PER_BLOCK]) |
75 | 75 | ||
76 | extern int in_group_p(gid_t); | 76 | extern int in_group_p(kgid_t); |
77 | extern int in_egroup_p(gid_t); | 77 | extern int in_egroup_p(kgid_t); |
78 | 78 | ||
79 | /* | 79 | /* |
80 | * The common credentials for a thread group | 80 | * The common credentials for a thread group |
diff --git a/kernel/groups.c b/kernel/groups.c index 84156f2d4c8c..6b2588dd04ff 100644 --- a/kernel/groups.c +++ b/kernel/groups.c | |||
@@ -256,27 +256,25 @@ SYSCALL_DEFINE2(setgroups, int, gidsetsize, gid_t __user *, grouplist) | |||
256 | /* | 256 | /* |
257 | * Check whether we're fsgid/egid or in the supplemental group.. | 257 | * Check whether we're fsgid/egid or in the supplemental group.. |
258 | */ | 258 | */ |
259 | int in_group_p(gid_t grp) | 259 | int in_group_p(kgid_t grp) |
260 | { | 260 | { |
261 | const struct cred *cred = current_cred(); | 261 | const struct cred *cred = current_cred(); |
262 | int retval = 1; | 262 | int retval = 1; |
263 | 263 | ||
264 | if (grp != cred->fsgid) | 264 | if (!gid_eq(grp, cred->fsgid)) |
265 | retval = groups_search(cred->group_info, | 265 | retval = groups_search(cred->group_info, grp); |
266 | make_kgid(cred->user_ns, grp)); | ||
267 | return retval; | 266 | return retval; |
268 | } | 267 | } |
269 | 268 | ||
270 | EXPORT_SYMBOL(in_group_p); | 269 | EXPORT_SYMBOL(in_group_p); |
271 | 270 | ||
272 | int in_egroup_p(gid_t grp) | 271 | int in_egroup_p(kgid_t grp) |
273 | { | 272 | { |
274 | const struct cred *cred = current_cred(); | 273 | const struct cred *cred = current_cred(); |
275 | int retval = 1; | 274 | int retval = 1; |
276 | 275 | ||
277 | if (grp != cred->egid) | 276 | if (!gid_eq(grp, cred->egid)) |
278 | retval = groups_search(cred->group_info, | 277 | retval = groups_search(cred->group_info, grp); |
279 | make_kgid(cred->user_ns, grp)); | ||
280 | return retval; | 278 | return retval; |
281 | } | 279 | } |
282 | 280 | ||