diff options
author | Andrew Bartlett <abartlet@samba.org> | 2002-08-26 00:43:06 +0000 |
---|---|---|
committer | Andrew Bartlett <abartlet@samba.org> | 2002-08-26 00:43:06 +0000 |
commit | 9c7742727a03daa486d77a4ae5f7c4314ced6ad4 (patch) | |
tree | b1d301b2b4fa2a8e15aac97592199950627a8a8d /source3/auth/auth_util.c | |
parent | 014792fc03c9d4030794e4e06fb137cd2ce32b17 (diff) | |
download | samba-9c7742727a03daa486d77a4ae5f7c4314ced6ad4.tar.gz samba-9c7742727a03daa486d77a4ae5f7c4314ced6ad4.tar.bz2 samba-9c7742727a03daa486d77a4ae5f7c4314ced6ad4.zip |
Try to support non-root-mode systems without getgrouplist().
Andrew Bartlett
(This used to be commit 17096315a0f30f946ddecb79708604a111c37011)
Diffstat (limited to 'source3/auth/auth_util.c')
-rw-r--r-- | source3/auth/auth_util.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/source3/auth/auth_util.c b/source3/auth/auth_util.c index 210c4d09f9..118126a275 100644 --- a/source3/auth/auth_util.c +++ b/source3/auth/auth_util.c @@ -643,7 +643,7 @@ static NTSTATUS get_user_groups_from_local_sam(const DOM_SID *user_sid, } if (sys_getgrouplist(usr->pw_name, usr->pw_gid, *unix_groups, &n_unix_groups) == -1) { - *unix_groups = realloc(unix_groups, sizeof(gid_t) * n_unix_groups); + *unix_groups = Realloc(unix_groups, sizeof(gid_t) * n_unix_groups); if (sys_getgrouplist(usr->pw_name, usr->pw_gid, *unix_groups, &n_unix_groups) == -1) { DEBUG(0, ("get_user_groups_from_local_sam: failed to get the unix group list\n")); SAFE_FREE(unix_groups); @@ -657,12 +657,14 @@ static NTSTATUS get_user_groups_from_local_sam(const DOM_SID *user_sid, DEBUG(5,("get_user_groups_from_local_sam: user is in the unix following groups\n")); for (i = 0; i < n_unix_groups; i++) DEBUGADD(5,("supplementary group gid:%ld\n",(long int)(*unix_groups)[i])); - - *groups = malloc(sizeof(DOM_SID) * n_unix_groups); - if (!*groups) { - DEBUG(0, ("get_user_group_from_local_sam: malloc() failed for DOM_SID list!\n")); - SAFE_FREE(unix_groups); - return NT_STATUS_NO_MEMORY; + + if (n_unix_groups > 0) { + *groups = malloc(sizeof(DOM_SID) * n_unix_groups); + if (!*groups) { + DEBUG(0, ("get_user_group_from_local_sam: malloc() failed for DOM_SID list!\n")); + SAFE_FREE(unix_groups); + return NT_STATUS_NO_MEMORY; + } } *n_groups = n_unix_groups; |