00db10
commit 58b930ae216bfa98cd60212b954b07b9963d6d04
00db10
Author: Siddhesh Poyarekar <siddhesh@redhat.com>
00db10
Date:   Wed Sep 10 21:51:50 2014 +0530
00db10
00db10
    Return failure in getnetgrent only when all netgroups have been searched (#17363)
00db10
    
00db10
    The netgroups lookup code fails when one of the groups in the search
00db10
    tree is empty.  In such a case it only returns the leaves of the tree
00db10
    after the blank netgroup.  This is because the line parser returns a
00db10
    NOTFOUND status when the netgroup exists but is empty.  The
00db10
    __getnetgrent_internal implementation needs to be fixed to try
00db10
    remaining groups if the current group is entry.  This patch implements
00db10
    this fix.  Tested on x86_64.
00db10
    
00db10
    	[BZ #17363]
00db10
    	* inet/getnetgrent_r.c (__internal_getnetgrent_r): Try next
00db10
    	group if the current group is empty.
00db10
00db10
diff --git glibc-2.17-c758a686/inet/getnetgrent_r.c glibc-2.17-c758a686/inet/getnetgrent_r.c
00db10
index f6d064d..e101537 100644
00db10
--- glibc-2.17-c758a686/inet/getnetgrent_r.c
00db10
+++ glibc-2.17-c758a686/inet/getnetgrent_r.c
00db10
@@ -297,7 +297,10 @@ __internal_getnetgrent_r (char **hostp, char **userp, char **domainp,
00db10
     {
00db10
       status = DL_CALL_FCT (*fct, (datap, buffer, buflen, &errno));
00db10
 
00db10
-      if (status == NSS_STATUS_RETURN)
00db10
+      if (status == NSS_STATUS_RETURN
00db10
+	  /* The service returned a NOTFOUND, but there are more groups that we
00db10
+	     need to resolve before we give up.  */
00db10
+	  || (status == NSS_STATUS_NOTFOUND && datap->needed_groups != NULL))
00db10
 	{
00db10
 	  /* This was the last one for this group.  Look at next group
00db10
 	     if available.  */