Blame SOURCES/glibc-rh1080766.patch

147e83
commit fbd6b5a4052316f7eb03c4617eebfaafc59dcc06
147e83
Author: Siddhesh Poyarekar <siddhesh@redhat.com>
147e83
Date:   Thu Mar 27 07:15:22 2014 +0530
147e83
147e83
    Fix nscd lookup for innetgr when netgroup has wildcards (BZ #16758)
147e83
    
147e83
    nscd works correctly when the request in innetgr is a wildcard,
147e83
    i.e. when one or more of host, user or domain parameters is NULL.
147e83
    However, it does not work when the the triplet in the netgroup
147e83
    definition has a wildcard.  This is easy to reproduce for a triplet
147e83
    defined as follows:
147e83
    
147e83
        foonet (,foo,)
147e83
    
147e83
    Here, an innetgr call that looks like this:
147e83
    
147e83
        innetgr ("foonet", "foohost", "foo", NULL);
147e83
    
147e83
    should succeed and so should:
147e83
    
147e83
        innetgr ("foonet", NULL, "foo", "foodomain");
147e83
    
147e83
    It does succeed with nscd disabled, but not with nscd enabled.  This
147e83
    fix adds this additional check for all three parts of the triplet so
147e83
    that it gives the correct result.
147e83
    
147e83
    	[BZ #16758]
147e83
    	* nscd/netgroupcache.c (addinnetgrX): Succeed if triplet has
147e83
    	blank values.
147e83
147e83
diff --git glibc-2.17-c758a686/nscd/netgroupcache.c glibc-2.17-c758a686/nscd/netgroupcache.c
147e83
index 5ba1e1f..5d15aa4 100644
147e83
--- glibc-2.17-c758a686/nscd/netgroupcache.c
147e83
+++ glibc-2.17-c758a686/nscd/netgroupcache.c
147e83
@@ -560,15 +560,19 @@ addinnetgrX (struct database_dyn *db, int fd, request_header *req,
147e83
 	{
147e83
 	  bool success = true;
147e83
 
147e83
-	  if (host != NULL)
147e83
+	  /* For the host, user and domain in each triplet, we assume success
147e83
+	     if the value is blank because that is how the wildcard entry to
147e83
+	     match anything is stored in the netgroup cache.  */
147e83
+	  if (host != NULL && *triplets != '\0')
147e83
 	    success = strcmp (host, triplets) == 0;
147e83
 	  triplets = (const char *) rawmemchr (triplets, '\0') + 1;
147e83
 
147e83
-	  if (success && user != NULL)
147e83
+	  if (success && user != NULL && *triplets != '\0')
147e83
 	    success = strcmp (user, triplets) == 0;
147e83
 	  triplets = (const char *) rawmemchr (triplets, '\0') + 1;
147e83
 
147e83
-	  if (success && (domain == NULL || strcmp (domain, triplets) == 0))
147e83
+	  if (success && (domain == NULL || *triplets == '\0'
147e83
+			  || strcmp (domain, triplets) == 0))
147e83
 	    {
147e83
 	      dataset->resp.result = 1;
147e83
 	      break;