mirror of
https://github.com/samba-team/samba.git
synced 2025-07-29 15:42:04 +03:00
r2868: Well, I'm not quite sure what I'm doing back in Samba 3.0, but anyway...
I've been grumbling about under-efficient calls in SAMR, and finally got around to fixing some of them. We now call sys_getgroups() (which in turn calls initgroups(), until glibc 3.4 is released) to figure out a user's group membership. This is far, far more efficient than scanning all the groups looking for a match, and is still the 'posix way', just using an effiecient call. The seperate issue of 'who is in this group' remains, but this one has been biting some people. I need to talk to VL about how best to exersise nasty corner cases, but my initial tests hold strong. (The code is also much simpiler than before, which has to count for something :-) Andrew Bartlett
This commit is contained in:
committed by
Gerald (Jerry) Carter
parent
f16ed2616a
commit
dc19f16169
@ -288,6 +288,28 @@ BOOL in_group(gid_t group, gid_t current_gid, int ngroups, const gid_t *groups)
|
||||
return(False);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
Add a gid to an array of gids if it's not already there.
|
||||
****************************************************************************/
|
||||
|
||||
void add_gid_to_array_unique(gid_t gid, gid_t **gids, int *num)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i=0; i<*num; i++) {
|
||||
if ((*gids)[i] == gid)
|
||||
return;
|
||||
}
|
||||
|
||||
*gids = Realloc(*gids, (*num+1) * sizeof(gid_t));
|
||||
|
||||
if (*gids == NULL)
|
||||
return;
|
||||
|
||||
(*gids)[*num] = gid;
|
||||
*num += 1;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
Like atoi but gets the value up to the separator character.
|
||||
****************************************************************************/
|
||||
|
Reference in New Issue
Block a user