]>
Commit | Line | Data |
---|---|---|
bb330e25 AF |
1 | commit fbd6b5a4052316f7eb03c4617eebfaafc59dcc06 |
2 | Author: Siddhesh Poyarekar <siddhesh@redhat.com> | |
3 | Date: Thu Mar 27 07:15:22 2014 +0530 | |
4 | ||
5 | Fix nscd lookup for innetgr when netgroup has wildcards (BZ #16758) | |
6 | ||
7 | nscd works correctly when the request in innetgr is a wildcard, | |
8 | i.e. when one or more of host, user or domain parameters is NULL. | |
9 | However, it does not work when the the triplet in the netgroup | |
10 | definition has a wildcard. This is easy to reproduce for a triplet | |
11 | defined as follows: | |
12 | ||
13 | foonet (,foo,) | |
14 | ||
15 | Here, an innetgr call that looks like this: | |
16 | ||
17 | innetgr ("foonet", "foohost", "foo", NULL); | |
18 | ||
19 | should succeed and so should: | |
20 | ||
21 | innetgr ("foonet", NULL, "foo", "foodomain"); | |
22 | ||
23 | It does succeed with nscd disabled, but not with nscd enabled. This | |
24 | fix adds this additional check for all three parts of the triplet so | |
25 | that it gives the correct result. | |
26 | ||
27 | [BZ #16758] | |
28 | * nscd/netgroupcache.c (addinnetgrX): Succeed if triplet has | |
29 | blank values. | |
30 | ||
31 | diff --git a/nscd/netgroupcache.c b/nscd/netgroupcache.c | |
32 | index 5ba1e1f..5d15aa4 100644 | |
33 | --- a/nscd/netgroupcache.c | |
34 | +++ b/nscd/netgroupcache.c | |
35 | @@ -560,15 +560,19 @@ addinnetgrX (struct database_dyn *db, int fd, request_header *req, | |
36 | { | |
37 | bool success = true; | |
38 | ||
39 | - if (host != NULL) | |
40 | + /* For the host, user and domain in each triplet, we assume success | |
41 | + if the value is blank because that is how the wildcard entry to | |
42 | + match anything is stored in the netgroup cache. */ | |
43 | + if (host != NULL && *triplets != '\0') | |
44 | success = strcmp (host, triplets) == 0; | |
45 | triplets = (const char *) rawmemchr (triplets, '\0') + 1; | |
46 | ||
47 | - if (success && user != NULL) | |
48 | + if (success && user != NULL && *triplets != '\0') | |
49 | success = strcmp (user, triplets) == 0; | |
50 | triplets = (const char *) rawmemchr (triplets, '\0') + 1; | |
51 | ||
52 | - if (success && (domain == NULL || strcmp (domain, triplets) == 0)) | |
53 | + if (success && (domain == NULL || *triplets == '\0' | |
54 | + || strcmp (domain, triplets) == 0)) | |
55 | { | |
56 | dataset->resp.result = 1; | |
57 | break; |