]> git.pld-linux.org Git - packages/autofs.git/blame - autofs-5.0.4-use-percent-hack-for-master.patch
- updated to 5.0.5, nfy.
[packages/autofs.git] / autofs-5.0.4-use-percent-hack-for-master.patch
CommitLineData
e5fd101c
PS
1autofs-5.0.4 - use percent hack for master map keys
2
3From: Ian Kent <raven@themaw.net>
4
5The percent hack translation has been done for map keys but it
6isn't used for master map keys.
7---
8
9 CHANGELOG | 1 +
10 modules/lookup_ldap.c | 66 +++++++++++++++++++++++++++++++++++++++++++------
11 2 files changed, 59 insertions(+), 8 deletions(-)
12
13
14diff --git a/CHANGELOG b/CHANGELOG
15index 4ed80e0..8258e00 100644
16--- a/CHANGELOG
17+++ b/CHANGELOG
18@@ -40,6 +40,7 @@
19 - fix st_remove_tasks() locking.
20 - reset flex scanner when setting buffer.
21 - zero s_magic is valid.
22+- use percent hack for master map keys.
23
24 4/11/2008 autofs-5.0.4
25 -----------------------
26diff --git a/modules/lookup_ldap.c b/modules/lookup_ldap.c
27index 9b1180c..8c6a8f2 100644
28--- a/modules/lookup_ldap.c
29+++ b/modules/lookup_ldap.c
30@@ -60,6 +60,7 @@ struct ldap_search_params {
31 };
32
33 static LDAP *auth_init(unsigned logopt, const char *, struct lookup_context *);
34+static int decode_percent_hack(const char *, char **);
35
36 #ifndef HAVE_LDAP_CREATE_PAGE_CONTROL
37 int ldap_create_page_control(LDAP *ldap, ber_int_t pagesize,
38@@ -1508,6 +1509,9 @@ int lookup_read_master(struct master *master, time_t age, void *context)
39 debug(logopt, MODPREFIX "examining entries");
40
41 while (e) {
42+ char *key = NULL;
43+ int dec_len, i;
44+
45 keyValue = ldap_get_values(ldap, e, entry);
46
47 if (!keyValue || !*keyValue) {
48@@ -1519,19 +1523,63 @@ int lookup_read_master(struct master *master, time_t age, void *context)
49 * By definition keys must be unique within
50 * each map entry
51 */
52- if (ldap_count_values(keyValue) > 1) {
53- error(logopt,
54- MODPREFIX
55- "key %s has duplicate entries - ignoring",
56- *keyValue);
57- goto next;
58+ count = ldap_count_values(keyValue);
59+ if (strcasecmp(class, "nisObject")) {
60+ if (count > 1) {
61+ error(logopt, MODPREFIX
62+ "key %s has duplicates - ignoring",
63+ *keyValue);
64+ goto next;
65+ }
66+ key = strdup(keyValue[0]);
67+ if (!key) {
68+ error(logopt, MODPREFIX
69+ "failed to dup map key %s - ignoring",
70+ *keyValue);
71+ goto next;
72+ }
73+ } else if (count == 1) {
74+ dec_len = decode_percent_hack(keyValue[0], &key);
75+ if (dec_len < 0) {
76+ error(logopt, MODPREFIX
77+ "invalid map key %s - ignoring",
78+ *keyValue);
79+ goto next;
80+ }
81+ } else {
82+ dec_len = decode_percent_hack(keyValue[0], &key);
83+ if (dec_len < 0) {
84+ error(logopt, MODPREFIX
85+ "invalid map key %s - ignoring",
86+ *keyValue);
87+ goto next;
88+ }
89+
90+ for (i = 1; i < count; i++) {
91+ char *k;
92+ dec_len = decode_percent_hack(keyValue[i], &k);
93+ if (dec_len < 0) {
94+ error(logopt, MODPREFIX
95+ "invalid map key %s - ignoring",
96+ *keyValue);
97+ goto next;
98+ }
99+ if (strcmp(key, k)) {
100+ error(logopt, MODPREFIX
101+ "key entry mismatch %s - ignoring",
102+ *keyValue);
103+ free(k);
104+ goto next;
105+ }
106+ free(k);
107+ }
108 }
109
110 /*
111 * Ignore keys beginning with '+' as plus map
112 * inclusion is only valid in file maps.
113 */
114- if (**keyValue == '+') {
115+ if (*key == '+') {
116 warn(logopt,
117 MODPREFIX
118 "ignoreing '+' map entry - not in file map");
119@@ -1558,7 +1606,7 @@ int lookup_read_master(struct master *master, time_t age, void *context)
120 }
121
122 if (snprintf(parse_buf, sizeof(parse_buf), "%s %s",
123- *keyValue, *values) >= sizeof(parse_buf)) {
124+ key, *values) >= sizeof(parse_buf)) {
125 error(logopt, MODPREFIX "map entry too long");
126 ldap_value_free(values);
127 goto next;
128@@ -1568,6 +1616,8 @@ int lookup_read_master(struct master *master, time_t age, void *context)
129 master_parse_entry(parse_buf, timeout, logging, age);
130 next:
131 ldap_value_free(keyValue);
132+ if (key)
133+ free(key);
134 e = ldap_next_entry(ldap, e);
135 }
136
This page took 0.103809 seconds and 4 git commands to generate.