olga / rpms / glibc

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