summaryrefslogtreecommitdiff
path: root/source3/nsswitch/winbindd_group.c
diff options
context:
space:
mode:
authorGerald Carter <jerry@samba.org>2002-10-08 18:32:42 +0000
committerGerald Carter <jerry@samba.org>2002-10-08 18:32:42 +0000
commitbfa93735abe52fe07fde1b10ece0c31f5cf73ef8 (patch)
tree8e0c4386faef9eb67bd38cf6230441df134f9088 /source3/nsswitch/winbindd_group.c
parent641dd258adb2a3d265b89b2726d93fac3942e36a (diff)
downloadsamba-bfa93735abe52fe07fde1b10ece0c31f5cf73ef8.tar.gz
samba-bfa93735abe52fe07fde1b10ece0c31f5cf73ef8.tar.bz2
samba-bfa93735abe52fe07fde1b10ece0c31f5cf73ef8.zip
merge from APP_HEAD of winbindd's domain local group fix
(This used to be commit 09c6f6329d6ae9327b7ef06de0ea78d24d805456)
Diffstat (limited to 'source3/nsswitch/winbindd_group.c')
-rw-r--r--source3/nsswitch/winbindd_group.c57
1 files changed, 49 insertions, 8 deletions
diff --git a/source3/nsswitch/winbindd_group.c b/source3/nsswitch/winbindd_group.c
index abb6b9da75..dc22be1754 100644
--- a/source3/nsswitch/winbindd_group.c
+++ b/source3/nsswitch/winbindd_group.c
@@ -406,7 +406,7 @@ static BOOL get_sam_group_entries(struct getent_state *ent)
{
NTSTATUS status;
uint32 num_entries;
- struct acct_info *name_list = NULL;
+ struct acct_info *name_list = NULL, *tmp_name_list = NULL;
TALLOC_CTX *mem_ctx;
BOOL result = False;
struct acct_info *sam_grp_entries = NULL;
@@ -436,10 +436,9 @@ static BOOL get_sam_group_entries(struct getent_state *ent)
goto done;
}
- status = domain->methods->enum_dom_groups(domain,
- mem_ctx,
- &num_entries,
- &sam_grp_entries);
+ /* always get the domain global groups */
+
+ status = domain->methods->enum_dom_groups(domain, mem_ctx, &num_entries, &sam_grp_entries);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(3, ("get_sam_group_entries: could not enumerate domain groups! Error: %s", nt_errstr(status)));
@@ -450,12 +449,54 @@ static BOOL get_sam_group_entries(struct getent_state *ent)
/* Copy entries into return buffer */
if (num_entries) {
- name_list = malloc(sizeof(struct acct_info) * num_entries);
- memcpy(name_list, sam_grp_entries,
- num_entries * sizeof(struct acct_info));
+ if ( !(name_list = malloc(sizeof(struct acct_info) * num_entries)) ) {
+ DEBUG(0,("get_sam_group_entries: Failed to malloc memory for %d domain groups!\n",
+ num_entries));
+ result = False;
+ goto done;
+ }
+ memcpy( name_list, sam_grp_entries, num_entries * sizeof(struct acct_info) );
}
ent->num_sam_entries = num_entries;
+
+ /* get the domain local groups if we are a member of
+ a native win2k domain */
+
+ if ( domain->native_mode )
+ {
+ DEBUG(4,("get_sam_group_entries: Native Mode 2k domain; enumerating local groups as well\n"));
+
+ status = domain->methods->enum_local_groups(domain, mem_ctx, &num_entries, &sam_grp_entries);
+
+ if ( !NT_STATUS_IS_OK(status) ) {
+ DEBUG(3,("get_sam_group_entries: Failed to enumerate domain local groups!\n"));
+ num_entries = 0;
+ }
+ else
+ DEBUG(4,("get_sam_group_entries: Returned %d local groups\n", num_entries));
+
+ /* Copy entries into return buffer */
+
+ if ( num_entries ) {
+ if ( !(tmp_name_list = Realloc( name_list, sizeof(struct acct_info) * (ent->num_sam_entries+num_entries))) )
+ {
+ DEBUG(0,("get_sam_group_entries: Failed to realloc more memory for %d local groups!\n",
+ num_entries));
+ result = False;
+ SAFE_FREE( name_list );
+ goto done;
+ }
+
+ name_list = tmp_name_list;
+
+ memcpy( &name_list[ent->num_sam_entries], sam_grp_entries,
+ num_entries * sizeof(struct acct_info) );
+ }
+
+ ent->num_sam_entries += num_entries;
+ }
+
/* Fill in remaining fields */