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