getgroups() gives wrong result with nss_winbind

Andreas andreas at conectiva.com.br
Fri Sep 17 14:43:06 GMT 2004


On Fri, Sep 17, 2004 at 11:07:41AM -0300, Andreas wrote:
> As I recall, NSS functions return an NSS_TRY_AGAIN in the case of, for
> example, not enough memory allocated for the task. Browsing glibc code, I
> see that it calls initgroups_dyn with a size of 64 (I'm about to confirm
> that with those printf's):

After some debugging, this seems to be the case. I added the following code
to winbind_nss_linux.c and all started working:

--- winbind_nss_linux.c.orig    2004-09-17 11:40:18.717985984 -0300
+++ winbind_nss_linux.c 2004-09-17 11:41:15.191400720 -0300
@@ -825,6 +825,11 @@

        if (ret == NSS_STATUS_SUCCESS) {
                int num_gids = response.data.num_entries;
+               if (num_gids >= (int)(*size)) {
+                       ret = NSS_STATUS_TRYAGAIN;
+                       *start = (long int) (num_gids);
+                       goto done;
+               }
                gid_t *gid_list = (gid_t *)response.extra_data;

                /* Copy group list to client */

I'm not proposing this patch, it's just to show what I think the problem is :)



More information about the samba-technical mailing list