1 diff --git a/CHANGELOG b/CHANGELOG
2 index da8c599..c6ab15f 100644
6 - mark map instances stale so they aren't "cleaned" during updates.
7 - fix large file compile time option.
8 - don't fail on empty master map.
9 +- add support for the "%" hack for case insensitive attribute schemas.
11 18/06/2007 autofs-5.0.2
12 -----------------------
13 diff --git a/modules/lookup_ldap.c b/modules/lookup_ldap.c
14 index de8d515..a412797 100644
15 --- a/modules/lookup_ldap.c
16 +++ b/modules/lookup_ldap.c
17 @@ -1210,50 +1210,68 @@ static int read_one_map(struct autofs_point *ap,
21 - * By definition keys must be unique within
23 + * By definition keys should be unique within each map entry,
24 + * but as always there are exceptions.
30 - * Keys must be unique so, in general, there shouldn't be
31 + * Keys should be unique so, in general, there shouldn't be
32 * more than one attribute value. We make an exception for
33 * wildcard entries as people may have values for '*' or
34 * '/' for compaibility reasons. We use the '/' as the
35 * wildcard in LDAP but allow '*' as well to allow for
36 * people using older schemas that allow '*' as a key
38 + * value. Another case where there can be multiple key
39 + * values is when people have used the "%" hack to specify
40 + * case matching ctriteria in a caase insensitive attribute.
42 count = ldap_count_values_len(bvKey);
46 - "key %.*s has duplicate entries - ignoring",
47 - bvKey[0]->bv_len, bvKey[0]->bv_val);
49 - } else if (count == 2) {
53 /* Check for the "/" and "*" and use as "/" if found */
54 for (i = 0; i < count; i++) {
55 - /* check for wildcard */
56 - if (bvKey[i]->bv_len != 1)
57 + bvKey[i]->bv_val[bvKey[i]->bv_len] = '\0';
60 + * If multiple entries are present they could
61 + * be the result of people using the "%" hack so
64 + if (strchr(bvKey[i]->bv_val, '%'))
66 - if (*bvKey[i]->bv_val != '/' &&
67 - *bvKey[i]->bv_val != '*')
69 - /* always use '/' internally */
70 - *bvKey[i]->bv_val = '/';
72 + /* check for wildcard */
73 + if (bvKey[i]->bv_len == 1 &&
74 + (*bvKey[i]->bv_val == '/' ||
75 + *bvKey[i]->bv_val == '*')) {
76 + /* always use '/' internally */
77 + *bvKey[i]->bv_val = '/';
78 + k_val = bvKey[i]->bv_val;
84 + * We have a result from LDAP so this is a
85 + * valid entry. Set the result to the LDAP
86 + * key that isn't a wildcard and doesn't have
87 + * any "%" hack values present. This should be
88 + * the case insensitive match string for the
89 + * nis schema, the default value.
91 k_val = bvKey[i]->bv_val;
93 + k_len = bvKey[i]->bv_len;
101 - "key %.*s has duplicate entries - ignoring",
102 + "invalid entry %.*s - ignoring",
103 bvKey[0]->bv_len, bvKey[0]->bv_val);
106 @@ -1495,7 +1513,10 @@ static int lookup_one(struct autofs_point *ap,
110 - /* By definition keys must be unique within each map entry */
112 + * By definition keys should be unique within each map entry,
113 + * but as always there are exceptions.
118 @@ -1506,37 +1527,53 @@ static int lookup_one(struct autofs_point *ap,
119 * '/' for compaibility reasons. We use the '/' as the
120 * wildcard in LDAP but allow '*' as well to allow for
121 * people using older schemas that allow '*' as a key
123 + * value. Another case where there can be multiple key
124 + * values is when people have used the "%" hack to specify
125 + * case matching ctriteria in a caase insensitive attribute.
127 count = ldap_count_values_len(bvKey);
131 - "key %.*s has duplicate entries - ignoring",
132 - bvKey[0]->bv_len, bvKey[0]->bv_val);
134 - } else if (count == 2) {
138 /* Check for the "/" and "*" and use as "/" if found */
139 for (i = 0; i < count; i++) {
140 - /* check for wildcard */
141 - if (bvKey[i]->bv_len != 1)
143 - if (*bvKey[i]->bv_val != '/' &&
144 - *bvKey[i]->bv_val != '*')
145 + bvKey[i]->bv_val[bvKey[i]->bv_len] = '\0';
148 + * If multiple entries are present they could
149 + * be the result of people using the "%" hack so
152 + if (strchr(bvKey[i]->bv_val, '%'))
154 - /* always use '/' internally */
155 - *bvKey[i]->bv_val = '/';
156 - k_val = bvKey[i]->bv_val;
159 + /* check for wildcard */
160 + if (bvKey[i]->bv_len == 1 &&
161 + (*bvKey[i]->bv_val == '/' ||
162 + *bvKey[i]->bv_val == '*')) {
163 + /* always use '/' internally */
164 + *bvKey[i]->bv_val = '/';
165 + k_val = bvKey[i]->bv_val;
171 + * The key was matched by LDAP so this is a
172 + * valid entry. Set the result key to the
173 + * lookup key to provide the mixed case
174 + * matching provided by the "%" hack.
177 + k_len = strlen(qKey);
184 - MODPREFIX "key %.*s has duplicate entries",
185 - bvKey[0]->bv_len, bvKey[0]->bv_val);
186 + MODPREFIX "no valid key found for %.*s",