This (hopefully) fixes a bug reported by Kai Krueger <kai@kruegernetz.de>
authorAndrew Bartlett <abartlet@samba.org>
Sun, 9 Jun 2002 08:45:35 +0000 (08:45 +0000)
committerAndrew Bartlett <abartlet@samba.org>
Sun, 9 Jun 2002 08:45:35 +0000 (08:45 +0000)
involving the use of lp_winbind_gid() without checking if they have been
set.

Also revert the 'clashing user' check back to a Get_Pwnam() - I probably should
never have changed it.

Andrew Bartlett
(This used to be commit 1d6ba405589cee4e1582bc91cf659b89564899d4)

source3/rpc_server/srv_samr_nt.c
source3/rpc_server/srv_util.c

index 0b4fa1cf2d96afda892a13a5b1bd39aed8348dbd..daa39b215fead53e43bcbc660c651c880ab6d733 100644 (file)
@@ -226,7 +226,9 @@ static NTSTATUS load_group_domain_entries(struct samr_info *info, DOM_SID *sid)
                return NT_STATUS_OK;
        }
 
-       enum_group_mapping(SID_NAME_DOM_GRP, &map, (int *)&group_entries, ENUM_ONLY_MAPPED, MAPPING_WITHOUT_PRIV);
+       if (!enum_group_mapping(SID_NAME_DOM_GRP, &map, (int *)&group_entries, ENUM_ONLY_MAPPED, MAPPING_WITHOUT_PRIV)) {
+               return NT_STATUS_NO_MEMORY;
+       }
 
        info->disp_info.num_group_account=group_entries;
 
@@ -688,8 +690,7 @@ static NTSTATUS get_group_alias_entries(TALLOC_CTX *ctx, DOMAIN_GRP **d_grp, DOM
                struct sys_grent *grp;
                struct passwd *pw;
                gid_t winbind_gid_low, winbind_gid_high;
-       
-               lp_winbind_gid(&winbind_gid_low, &winbind_gid_high);
+               BOOL winbind_groups_exist = lp_winbind_gid(&winbind_gid_low, &winbind_gid_high);
 
                /* local aliases */
                /* we return the UNIX groups here.  This seems to be the right */
@@ -719,24 +720,15 @@ static NTSTATUS get_group_alias_entries(TALLOC_CTX *ctx, DOMAIN_GRP **d_grp, DOM
                                continue;
 
                        /* Don't return winbind groups as they are not local! */
-                       if ((grp->gr_gid >= winbind_gid_low)&&(grp->gr_gid <= winbind_gid_high)) {
+                       if (winbind_groups_exist && (grp->gr_gid >= winbind_gid_low)&&(grp->gr_gid <= winbind_gid_high)) {
                                DEBUG(10,("get_group_alias_entries: not returing %s, not local.\n", smap.nt_name ));
                                continue;
                        }
 
                        /* Don't return user private groups... */
-                       
-                       /* 
-                        *  We used to do a Get_Pwnam() here, but this has been
-                        * trimmed back to the common case for private groups
-                        * to save lookups and to use the _alloc interface.
-                        *
-                        * This also matches the group mapping code
-                        */
 
-                       if ((pw = getpwnam_alloc(smap.nt_name)) != 0) {
+                       if ((pw = Get_Pwnam(smap.nt_name)) != 0) {
                                DEBUG(10,("get_group_alias_entries: not returing %s, clashes with user.\n", smap.nt_name ));
-                               passwd_free(&pw);
                                continue;                       
                        }
 
index af653ba0e8e2b500ee3dd6ae4b9f6632138a77f0..7500ec361fb7dcdb031481a14b532dcf6697af15 100644 (file)
@@ -93,6 +93,7 @@ NTSTATUS get_alias_user_groups(TALLOC_CTX *ctx, DOM_SID *sid, int *numgroups, ui
        uint32 *rids=NULL, *new_rids=NULL;
        gid_t winbind_gid_low, winbind_gid_high;
        BOOL ret;
+       BOOL winbind_groups_exist;
 
        /*
         * this code is far from perfect.
@@ -108,7 +109,7 @@ NTSTATUS get_alias_user_groups(TALLOC_CTX *ctx, DOM_SID *sid, int *numgroups, ui
        *prids=NULL;
        *numgroups=0;
 
-       lp_winbind_gid(&winbind_gid_low, &winbind_gid_high);
+       winbind_groups_exist = lp_winbind_gid(&winbind_gid_low, &winbind_gid_high);
 
 
        DEBUG(10,("get_alias_user_groups: looking if SID %s is a member of groups in the SID domain %s\n", 
@@ -155,7 +156,7 @@ NTSTATUS get_alias_user_groups(TALLOC_CTX *ctx, DOM_SID *sid, int *numgroups, ui
                }
 
                /* Don't return winbind groups as they are not local! */
-               if ((grp->gr_gid >= winbind_gid_low) && (grp->gr_gid <= winbind_gid_high)) {
+               if (winbind_groups_exist && (grp->gr_gid >= winbind_gid_low) && (grp->gr_gid <= winbind_gid_high)) {
                        DEBUG(10,("get_alias_user_groups: not returing %s, not local.\n", map.nt_name));
                        continue;
                }
@@ -224,7 +225,7 @@ NTSTATUS get_alias_user_groups(TALLOC_CTX *ctx, DOM_SID *sid, int *numgroups, ui
        }
 
        /* Don't return winbind groups as they are not local! */
-       if ((gid >= winbind_gid_low) && (gid <= winbind_gid_high)) {
+       if (winbind_groups_exist && (gid >= winbind_gid_low) && (gid <= winbind_gid_high)) {
                DEBUG(10,("get_alias_user_groups: not returing %s, not local.\n", map.nt_name ));
                goto done;
        }