summaryrefslogtreecommitdiffstats
path: root/source3/lib/system_smbd.c
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2003-02-19 12:31:16 +0000
committerAndrew Bartlett <abartlet@samba.org>2003-02-19 12:31:16 +0000
commit251ea1e6776401005e302addd56a689c01924426 (patch)
treed36c5d4ffc7b2c77264e7f60aa52e8330835e1db /source3/lib/system_smbd.c
parent96cafdd7c735338da0616e0ad638282095f4c4d7 (diff)
downloadsamba-251ea1e6776401005e302addd56a689c01924426.tar.gz
samba-251ea1e6776401005e302addd56a689c01924426.tar.xz
samba-251ea1e6776401005e302addd56a689c01924426.zip
Merge minor library fixes from HEAD to 3.0.
- setenv() replacement - mimir's ASN1/SPNEGO typo fixes - (size_t)-1 fixes for push_* returns - function argument signed/unsigned correction - ASN1 error handling (ensure we don't use initiailsed data) - extra net ads join error checking - allow 'set security discriptor' to fail - escape ldap strings in libads. - getgrouplist() correctness fixes (include primary gid) Andrew Bartlett (This used to be commit e9d6e2ea9a3dc01d3849b925c50702cda6ddf225)
Diffstat (limited to 'source3/lib/system_smbd.c')
-rw-r--r--source3/lib/system_smbd.c15
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();