mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 02:30:34 +02:00 
			
		
		
		
	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>
This commit is contained in:
		
							parent
							
								
									92361636e0
								
							
						
					
					
						commit
						72cda3d1ef
					
				
					 2 changed files with 8 additions and 10 deletions
				
			
		| 
						 | 
					@ -73,8 +73,8 @@ extern int groups_search(const struct group_info *, kgid_t);
 | 
				
			||||||
#define GROUP_AT(gi, i) \
 | 
					#define GROUP_AT(gi, i) \
 | 
				
			||||||
	((gi)->blocks[(i) / NGROUPS_PER_BLOCK][(i) % NGROUPS_PER_BLOCK])
 | 
						((gi)->blocks[(i) / NGROUPS_PER_BLOCK][(i) % NGROUPS_PER_BLOCK])
 | 
				
			||||||
 | 
					
 | 
				
			||||||
extern int in_group_p(gid_t);
 | 
					extern int in_group_p(kgid_t);
 | 
				
			||||||
extern int in_egroup_p(gid_t);
 | 
					extern int in_egroup_p(kgid_t);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/*
 | 
					/*
 | 
				
			||||||
 * The common credentials for a thread group
 | 
					 * The common credentials for a thread group
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -256,27 +256,25 @@ SYSCALL_DEFINE2(setgroups, int, gidsetsize, gid_t __user *, grouplist)
 | 
				
			||||||
/*
 | 
					/*
 | 
				
			||||||
 * Check whether we're fsgid/egid or in the supplemental group..
 | 
					 * Check whether we're fsgid/egid or in the supplemental group..
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
int in_group_p(gid_t grp)
 | 
					int in_group_p(kgid_t grp)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	const struct cred *cred = current_cred();
 | 
						const struct cred *cred = current_cred();
 | 
				
			||||||
	int retval = 1;
 | 
						int retval = 1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (grp != cred->fsgid)
 | 
						if (!gid_eq(grp, cred->fsgid))
 | 
				
			||||||
		retval = groups_search(cred->group_info,
 | 
							retval = groups_search(cred->group_info, grp);
 | 
				
			||||||
				       make_kgid(cred->user_ns, grp));
 | 
					 | 
				
			||||||
	return retval;
 | 
						return retval;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
EXPORT_SYMBOL(in_group_p);
 | 
					EXPORT_SYMBOL(in_group_p);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int in_egroup_p(gid_t grp)
 | 
					int in_egroup_p(kgid_t grp)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	const struct cred *cred = current_cred();
 | 
						const struct cred *cred = current_cred();
 | 
				
			||||||
	int retval = 1;
 | 
						int retval = 1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (grp != cred->egid)
 | 
						if (!gid_eq(grp, cred->egid))
 | 
				
			||||||
		retval = groups_search(cred->group_info,
 | 
							retval = groups_search(cred->group_info, grp);
 | 
				
			||||||
				       make_kgid(cred->user_ns, grp));
 | 
					 | 
				
			||||||
	return retval;
 | 
						return retval;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue