diff options
author | Andrew Bartlett <abartlet@samba.org> | 2003-02-17 12:04:09 +0000 |
---|---|---|
committer | Andrew Bartlett <abartlet@samba.org> | 2003-02-17 12:04:09 +0000 |
commit | 55da3690b7cc6e84184b4794bd0fb37e26db20e3 (patch) | |
tree | ce0e447df9ccdc1cbd04c80b9d7463f22b80f616 /source3 | |
parent | f203f1643c520f3887a004d58c6bbe130687b30c (diff) | |
download | samba-55da3690b7cc6e84184b4794bd0fb37e26db20e3.tar.gz samba-55da3690b7cc6e84184b4794bd0fb37e26db20e3.tar.bz2 samba-55da3690b7cc6e84184b4794bd0fb37e26db20e3.zip |
Try to make our getgrouplist replacement better match the 'real' implemenations.
In particular, make sure we include the primary gid in the list.
Andrew Bartlett
(This used to be commit 0cd4b339b7eff55019caaeaa998d5e70b2eed200)
Diffstat (limited to 'source3')
-rw-r--r-- | source3/lib/system_smbd.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/source3/lib/system_smbd.c b/source3/lib/system_smbd.c index 0cd3086945..3ae0a6395e 100644 --- a/source3/lib/system_smbd.c +++ b/source3/lib/system_smbd.c @@ -39,7 +39,7 @@ static int getgrouplist_internals(const char *user, gid_t gid, gid_t *groups, int *grpcnt) { gid_t *gids_saved; - int ret, ngrp_saved; + int ret, ngrp_saved, num_gids; if (non_root_mode()) { *grpcnt = 0; @@ -78,9 +78,16 @@ static int getgrouplist_internals(const char *user, gid_t gid, gid_t *groups, in set_effective_gid(gid); setgid(gid); - ret = getgroups(*grpcnt, groups); - if (ret >= 0) { - *grpcnt = ret; + num_gids = getgroups(0, NULL); + if (num_gids + 1 > *grpcnt) { + *grpcnt = num_gids + 1; + ret = -1; + } else { + ret = getgroups(*grpcnt - 1, &groups[1]); + if (ret >= 0) { + groups[0] = gid; + *grpcnt = ret + 1; + } } restore_re_gid(); |