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