diff options
author | Volker Lendecke <vlendec@samba.org> | 2004-03-01 13:02:06 +0000 |
---|---|---|
committer | Volker Lendecke <vlendec@samba.org> | 2004-03-01 13:02:06 +0000 |
commit | 480fd4f9b558b668c77af2825963e5f9c616c165 (patch) | |
tree | 916389534ec453490c3956a733a7ffd42d261092 /source3/passdb | |
parent | 0af6ee14c1ab480e5a3d2e82f803253581a2896f (diff) | |
download | samba-480fd4f9b558b668c77af2825963e5f9c616c165.tar.gz samba-480fd4f9b558b668c77af2825963e5f9c616c165.tar.bz2 samba-480fd4f9b558b668c77af2825963e5f9c616c165.zip |
Add aliases to winbindd_getgroups().
su - WINDOWS\\vl
now includes the locally defined aliases I'm member of.
Next will be getent group.
Volker
(This used to be commit 52dae45684317ac8ac529017607bb5787dda7c50)
Diffstat (limited to 'source3/passdb')
-rw-r--r-- | source3/passdb/util_sam_sid.c | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/source3/passdb/util_sam_sid.c b/source3/passdb/util_sam_sid.c index f6cc2491a8..db88ea7aea 100644 --- a/source3/passdb/util_sam_sid.c +++ b/source3/passdb/util_sam_sid.c @@ -305,3 +305,60 @@ BOOL map_name_to_wellknown_sid(DOM_SID *sid, enum SID_NAME_USE *use, const char return False; } + +void add_sid_to_array(DOM_SID sid, DOM_SID **sids, int *num) +{ + *sids = Realloc(*sids, ((*num)+1) * sizeof(DOM_SID)); + + if (*sids == NULL) + return; + + sid_copy(&((*sids)[*num]), &sid); + *num += 1; + + return; +} + +void add_gid_to_array_unique(gid_t gid, gid_t **gids, int *num) +{ + int i; + + if ((*num) >= groups_max()) + return; + + 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; +} + +/************************************************************************** + Augment a gid list with gids from alias memberships +***************************************************************************/ + +void add_foreign_gids_from_sid(const DOM_SID *sid, gid_t **gids, int *num) +{ + DOM_SID *aliases; + int j, num_aliases; + + if (!pdb_enum_alias_memberships(sid, &aliases, &num_aliases)) + return; + + for (j=0; j<num_aliases; j++) { + gid_t gid; + + if (!NT_STATUS_IS_OK(sid_to_gid(&aliases[j], &gid))) + continue; + + add_gid_to_array_unique(gid, gids, num); + } + SAFE_FREE(aliases); +} |