Annotation of /trunk/gnupg/patches/gnupg-2.1.3-dirmngr-no-ldap.patch
Parent Directory | Revision Log
Revision 2561 -
(hide annotations)
(download)
Sat Apr 18 10:13:17 2015 UTC (9 years, 2 months ago) by niro
File size: 7476 byte(s)
Sat Apr 18 10:13:17 2015 UTC (9 years, 2 months ago) by niro
File size: 7476 byte(s)
-no-ldap patch
1 | niro | 2561 | From 5cde5bf37339cdeb0bd0a33d39477382eafebede Mon Sep 17 00:00:00 2001 |
2 | From: "Neal H. Walfield" <neal@g10code.com> | ||
3 | Date: Mon, 13 Apr 2015 12:02:40 +0200 | ||
4 | Subject: [PATCH 1/1] dirmngr: If LDAP is not enable, don't build the LDAP | ||
5 | bits. | ||
6 | |||
7 | * dirmngr/Makefile.am (dirmngr_SOURCES): Only include | ||
8 | ks-engine-ldap.c, ldap-parse-uri.c and ldap-parse-uri.h if USE_LDAP | ||
9 | is TRUE. | ||
10 | (module_tests): Only add t-ldap-parse-uri if USE_LDAP is TRUE. | ||
11 | * dirmngr/ks-action.c: Only include "ldap-parse-uri.h" if USE_LDAP is | ||
12 | TRUE. | ||
13 | (ks_action_help): Don't invoke LDAP functionality if USE_LDAP is not | ||
14 | TRUE. | ||
15 | (ks_action_search): Likewise. | ||
16 | (ks_action_get): Likewise. | ||
17 | (ks_action_put): Likewise. | ||
18 | * dirmngr/server.c: Only include "ldap-parse-uri.h" if USE_LDAP is | ||
19 | TRUE. | ||
20 | (cmd_keyserver): Don't invoke LDAP functionality if USE_LDAP is not | ||
21 | TRUE. | ||
22 | |||
23 | -- | ||
24 | Signed-off-by: Neal H. Walfield <neal@g10code.com> | ||
25 | GnuPG-bug-id: 1949 | ||
26 | --- | ||
27 | dirmngr/Makefile.am | 14 ++++++---- | ||
28 | dirmngr/ks-action.c | 76 ++++++++++++++++++++++++++++++++++++++--------------- | ||
29 | dirmngr/server.c | 10 +++++-- | ||
30 | 3 files changed, 72 insertions(+), 28 deletions(-) | ||
31 | |||
32 | diff --git a/dirmngr/Makefile.am b/dirmngr/Makefile.am | ||
33 | index a8b1c52..c5713a7 100644 | ||
34 | --- a/dirmngr/Makefile.am | ||
35 | +++ b/dirmngr/Makefile.am | ||
36 | @@ -62,13 +62,12 @@ dirmngr_SOURCES = dirmngr.c dirmngr.h server.c crlcache.c crlfetch.c \ | ||
37 | cdb.h cdblib.c misc.c dirmngr-err.h \ | ||
38 | ocsp.c ocsp.h validate.c validate.h \ | ||
39 | ks-action.c ks-action.h ks-engine.h \ | ||
40 | - ks-engine-hkp.c ks-engine-http.c ks-engine-finger.c ks-engine-kdns.c \ | ||
41 | - ks-engine-ldap.c \ | ||
42 | - ldap-parse-uri.c ldap-parse-uri.h | ||
43 | + ks-engine-hkp.c ks-engine-http.c ks-engine-finger.c ks-engine-kdns.c | ||
44 | |||
45 | if USE_LDAP | ||
46 | dirmngr_SOURCES += ldapserver.h ldapserver.c ldap.c w32-ldap-help.h \ | ||
47 | - ldap-wrapper.h $(ldap_url) $(extraldap_src) | ||
48 | + ldap-wrapper.h ldap-parse-uri.c ldap-parse-uri.h \ | ||
49 | + ks-engine-ldap.c $(ldap_url) $(extraldap_src) | ||
50 | ldaplibs = $(LDAPLIBS) | ||
51 | else | ||
52 | ldaplibs = | ||
53 | @@ -114,7 +113,12 @@ t_common_ldadd = $(libcommontls) $(libcommon) no-libgcrypt.o \ | ||
54 | $(NTBTLS_LIBS) $(LIBGNUTLS_LIBS) \ | ||
55 | $(DNSLIBS) $(LIBINTL) $(LIBICONV) | ||
56 | |||
57 | -module_tests = t-ldap-parse-uri | ||
58 | +module_tests = | ||
59 | + | ||
60 | +if USE_LDAP | ||
61 | +module_tests += t-ldap-parse-uri | ||
62 | +endif | ||
63 | + | ||
64 | t_ldap_parse_uri_SOURCES = \ | ||
65 | t-ldap-parse-uri.c ldap-parse-uri.c ldap-parse-uri.h \ | ||
66 | $(ldap_url) $(t_common_src) | ||
67 | diff --git a/dirmngr/ks-action.c b/dirmngr/ks-action.c | ||
68 | index c76aaaa..dd4516a 100644 | ||
69 | --- a/dirmngr/ks-action.c | ||
70 | +++ b/dirmngr/ks-action.c | ||
71 | @@ -30,7 +30,9 @@ | ||
72 | #include "misc.h" | ||
73 | #include "ks-engine.h" | ||
74 | #include "ks-action.h" | ||
75 | -#include "ldap-parse-uri.h" | ||
76 | +#if USE_LDAP | ||
77 | +# include "ldap-parse-uri.h" | ||
78 | +#endif | ||
79 | |||
80 | /* Called by the engine's help functions to print the actual help. */ | ||
81 | gpg_error_t | ||
82 | @@ -73,10 +75,14 @@ ks_action_help (ctrl_t ctrl, const char *url) | ||
83 | } | ||
84 | else | ||
85 | { | ||
86 | +#if USE_LDAP | ||
87 | if (ldap_uri_p (url)) | ||
88 | err = ldap_parse_uri (&parsed_uri, url); | ||
89 | else | ||
90 | - err = http_parse_uri (&parsed_uri, url, 1); | ||
91 | +#endif | ||
92 | + { | ||
93 | + err = http_parse_uri (&parsed_uri, url, 1); | ||
94 | + } | ||
95 | |||
96 | if (err) | ||
97 | return err; | ||
98 | @@ -90,8 +96,10 @@ ks_action_help (ctrl_t ctrl, const char *url) | ||
99 | err = ks_finger_help (ctrl, parsed_uri); | ||
100 | if (!err) | ||
101 | err = ks_kdns_help (ctrl, parsed_uri); | ||
102 | +#if USE_LDAP | ||
103 | if (!err) | ||
104 | err = ks_ldap_help (ctrl, parsed_uri); | ||
105 | +#endif | ||
106 | |||
107 | if (!parsed_uri) | ||
108 | ks_print_help (ctrl, | ||
109 | @@ -151,16 +159,23 @@ ks_action_search (ctrl_t ctrl, uri_item_t keyservers, | ||
110 | for (uri = keyservers; !err && uri; uri = uri->next) | ||
111 | { | ||
112 | int is_http = uri->parsed_uri->is_http; | ||
113 | - int is_ldap = (strcmp (uri->parsed_uri->scheme, "ldap") == 0 | ||
114 | - || strcmp (uri->parsed_uri->scheme, "ldaps") == 0 | ||
115 | - || strcmp (uri->parsed_uri->scheme, "ldapi") == 0); | ||
116 | + int is_ldap = 0; | ||
117 | +#if USE_LDAP | ||
118 | + is_ldap = (strcmp (uri->parsed_uri->scheme, "ldap") == 0 | ||
119 | + || strcmp (uri->parsed_uri->scheme, "ldaps") == 0 | ||
120 | + || strcmp (uri->parsed_uri->scheme, "ldapi") == 0); | ||
121 | +#endif | ||
122 | if (is_http || is_ldap) | ||
123 | { | ||
124 | any_server = 1; | ||
125 | - if (is_http) | ||
126 | - err = ks_hkp_search (ctrl, uri->parsed_uri, patterns->d, &infp); | ||
127 | - else if (is_ldap) | ||
128 | +#if USE_LDAP | ||
129 | + if (is_ldap) | ||
130 | err = ks_ldap_search (ctrl, uri->parsed_uri, patterns->d, &infp); | ||
131 | + else | ||
132 | +#endif | ||
133 | + { | ||
134 | + err = ks_hkp_search (ctrl, uri->parsed_uri, patterns->d, &infp); | ||
135 | + } | ||
136 | |||
137 | if (!err) | ||
138 | { | ||
139 | @@ -203,18 +218,27 @@ ks_action_get (ctrl_t ctrl, uri_item_t keyservers, | ||
140 | for (uri = keyservers; !err && uri; uri = uri->next) | ||
141 | { | ||
142 | int is_http = uri->parsed_uri->is_http; | ||
143 | - int is_ldap = (strcmp (uri->parsed_uri->scheme, "ldap") == 0 | ||
144 | - || strcmp (uri->parsed_uri->scheme, "ldaps") == 0 | ||
145 | - || strcmp (uri->parsed_uri->scheme, "ldapi") == 0); | ||
146 | + int is_ldap = 0; | ||
147 | + | ||
148 | +#if USE_LDAP | ||
149 | + is_ldap = (strcmp (uri->parsed_uri->scheme, "ldap") == 0 | ||
150 | + || strcmp (uri->parsed_uri->scheme, "ldaps") == 0 | ||
151 | + || strcmp (uri->parsed_uri->scheme, "ldapi") == 0); | ||
152 | +#endif | ||
153 | + | ||
154 | if (is_http || is_ldap) | ||
155 | { | ||
156 | any_server = 1; | ||
157 | for (sl = patterns; !err && sl; sl = sl->next) | ||
158 | { | ||
159 | - if (is_http) | ||
160 | - err = ks_hkp_get (ctrl, uri->parsed_uri, sl->d, &infp); | ||
161 | - else | ||
162 | +#if USE_LDAP | ||
163 | + if (is_ldap) | ||
164 | err = ks_ldap_get (ctrl, uri->parsed_uri, sl->d, &infp); | ||
165 | + else | ||
166 | +#endif | ||
167 | + { | ||
168 | + err = ks_hkp_get (ctrl, uri->parsed_uri, sl->d, &infp); | ||
169 | + } | ||
170 | |||
171 | if (err) | ||
172 | { | ||
173 | @@ -322,22 +346,32 @@ ks_action_put (ctrl_t ctrl, uri_item_t keyservers, | ||
174 | int any_server = 0; | ||
175 | uri_item_t uri; | ||
176 | |||
177 | + (void) info; | ||
178 | + (void) infolen; | ||
179 | + | ||
180 | for (uri = keyservers; !err && uri; uri = uri->next) | ||
181 | { | ||
182 | int is_http = uri->parsed_uri->is_http; | ||
183 | - int is_ldap = (strcmp (uri->parsed_uri->scheme, "ldap") == 0 | ||
184 | - || strcmp (uri->parsed_uri->scheme, "ldaps") == 0 | ||
185 | - || strcmp (uri->parsed_uri->scheme, "ldapi") == 0); | ||
186 | + int is_ldap = 0; | ||
187 | + | ||
188 | +#if USE_LDAP | ||
189 | + is_ldap = (strcmp (uri->parsed_uri->scheme, "ldap") == 0 | ||
190 | + || strcmp (uri->parsed_uri->scheme, "ldaps") == 0 | ||
191 | + || strcmp (uri->parsed_uri->scheme, "ldapi") == 0); | ||
192 | +#endif | ||
193 | |||
194 | if (is_http || is_ldap) | ||
195 | { | ||
196 | any_server = 1; | ||
197 | - if (is_http) | ||
198 | - err = ks_hkp_put (ctrl, uri->parsed_uri, data, datalen); | ||
199 | - else | ||
200 | +#if USE_LDAP | ||
201 | + if (is_ldap) | ||
202 | err = ks_ldap_put (ctrl, uri->parsed_uri, data, datalen, | ||
203 | info, infolen); | ||
204 | - | ||
205 | + else | ||
206 | +#endif | ||
207 | + { | ||
208 | + err = ks_hkp_put (ctrl, uri->parsed_uri, data, datalen); | ||
209 | + } | ||
210 | if (err) | ||
211 | { | ||
212 | first_err = err; | ||
213 | diff --git a/dirmngr/server.c b/dirmngr/server.c | ||
214 | index 506b137..3e6d99d 100644 | ||
215 | --- a/dirmngr/server.c | ||
216 | +++ b/dirmngr/server.c | ||
217 | @@ -48,7 +48,9 @@ | ||
218 | #endif | ||
219 | #include "ks-action.h" | ||
220 | #include "ks-engine.h" /* (ks_hkp_print_hosttable) */ | ||
221 | -#include "ldap-parse-uri.h" | ||
222 | +#if USE_LDAP | ||
223 | +# include "ldap-parse-uri.h" | ||
224 | +#endif | ||
225 | |||
226 | /* To avoid DoS attacks we limit the size of a certificate to | ||
227 | something reasonable. */ | ||
228 | @@ -1530,10 +1532,14 @@ cmd_keyserver (assuan_context_t ctx, char *line) | ||
229 | item->parsed_uri = NULL; | ||
230 | strcpy (item->uri, line); | ||
231 | |||
232 | +#if USE_LDAP | ||
233 | if (ldap_uri_p (item->uri)) | ||
234 | err = ldap_parse_uri (&item->parsed_uri, line); | ||
235 | else | ||
236 | - err = http_parse_uri (&item->parsed_uri, line, 1); | ||
237 | +#endif | ||
238 | + { | ||
239 | + err = http_parse_uri (&item->parsed_uri, line, 1); | ||
240 | + } | ||
241 | if (err) | ||
242 | { | ||
243 | xfree (item); | ||
244 | -- | ||
245 | 2.1.4 | ||
246 |