]> git.ipfire.org Git - people/ms/ipfire-3.x.git/blob - nss_ldap/patches/nss_ldap-257-mozldap.patch
Move all packages to root.
[people/ms/ipfire-3.x.git] / nss_ldap / patches / nss_ldap-257-mozldap.patch
1 Go back to using AC_TRY_COMPILE to detect <ldap_ssl.h>, which requires
2 that <ldap.h> be included before it.
3
4 Use the draft-specified value "0" instead of a preprocessor define which
5 mozldap doesn't provide (LDAP_OPT_SUCCESS).
6
7 Don't fail to compile if libldap doesn't provide ldap_create_control(),
8 just fail at run-time if we try to use it.
9
10 Only try to set non-portable options that the libldap which is being used
11 supports.
12
13 Don't depend on ldap_alloc_ber_with_options() being there; fall back to
14 either ber_alloc_t() or the deprecated der_alloc().
15
16 Learn about Mozilla LDAP 6.
17
18 Prefer </usr/include/nss.h> to <nss.h>, because <nss.h> can also be the
19 security toolkit used by Mozilla's LDAP SDK rather than libc's nsswitch
20 header, and if we've set the include path, we could be screwed.
21
22 Strip off any '/' which appears in our hostname before passing it to
23 ldap_init().
24
25 diff -up nss_ldap/configure.in nss_ldap/configure.in
26 --- nss_ldap/configure.in 2007-11-14 14:21:54.000000000 -0500
27 +++ nss_ldap/configure.in 2007-11-14 15:01:32.000000000 -0500
28 @@ -41,7 +41,7 @@ dnl
29 AC_ARG_ENABLE(configurable-krb5-ccname-env, [ --enable-configurable-krb5-ccname-env enable configurable Kerberos V credentials cache name (putenv method)], [AC_DEFINE(CONFIGURE_KRB5_CCNAME) AC_DEFINE(CONFIGURE_KRB5_CCNAME_ENV)])
30 AC_ARG_ENABLE(configurable-krb5-ccname-gssapi, [ --enable-configurable-krb5-ccname-gssapi enable configurable Kerberos V credentials cache name (gssapi method)], [AC_DEFINE(CONFIGURE_KRB5_CCNAME) AC_DEFINE(CONFIGURE_KRB5_CCNAME_GSSAPI)])
31
32 -AC_ARG_WITH(ldap-lib, [ --with-ldap-lib=type select ldap library [auto|netscape5|netscape4|netscape3|umich|openldap]])
33 +AC_ARG_WITH(ldap-lib, [ --with-ldap-lib=type select ldap library [auto|mozilla|netscape5|netscape4|netscape3|umich|openldap]])
34 AC_ARG_WITH(ldap-dir, [ --with-ldap-dir=DIR base directory of LDAP SDK])
35 AC_ARG_WITH(ldap-conf-file, [ --with-ldap-conf-file path to LDAP configuration file],
36 [ NSS_LDAP_PATH_CONF="$with_ldap_conf_file" ],
37 @@ -132,17 +132,18 @@ AC_SUBST(NSS_LDAP_LDFLAGS)
38
39 AC_CHECK_HEADERS(lber.h)
40 AC_CHECK_HEADERS(ldap.h, , AC_MSG_ERROR(could not locate <ldap.h>))
41 -AC_CHECK_HEADERS(ldap_ssl.h)
42 +dnl AC_CHECK_HEADERS(ldap_ssl.h)
43
44 -dnl AC_MSG_CHECKING(for ldap_ssl.h)
45 -dnl AC_TRY_COMPILE([#include <sys/types.h>
46 -dnl #include <ldap.h>
47 -dnl #include <ldap_ssl.h>], ,
48 -dnl [
49 -dnl AC_MSG_RESULT(yes),
50 -dnl AC_DEFINE(HAVE_LDAP_SSL_H, 1)
51 -dnl ],
52 -dnl AC_MSG_RESULT(no))
53 +AC_MSG_CHECKING(for ldap_ssl.h)
54 +AC_TRY_COMPILE([
55 + #include <sys/types.h>
56 + #include <ldap.h>
57 + #include <ldap_ssl.h>],[],
58 + [
59 + AC_MSG_RESULT(yes)
60 + AC_DEFINE(HAVE_LDAP_SSL_H,1,[Define if you have <ldap_ssl.h>.])
61 + ],
62 + AC_MSG_RESULT(no))
63
64 # For HP-UX and AIX we use private API, the headers for which
65 # are included locally. We need to do something to stop both
66 @@ -150,7 +151,8 @@ dnl AC_MSG_RESULT(no))
67 case "$target_os" in
68 aix*) AC_CHECK_HEADERS(irs.h usersec.h) ;;
69 hpux*) AC_CHECK_HEADERS(nsswitch.h) ;;
70 - *) AC_CHECK_HEADERS(nss.h)
71 + *) AC_CHECK_HEADERS(/usr/include/nss.h)
72 + AC_CHECK_HEADERS(nss.h)
73 AC_CHECK_HEADERS(nsswitch.h)
74 AC_CHECK_HEADERS(irs.h) ;;
75 esac
76 @@ -297,6 +299,9 @@ if test -z "$found_ldap_lib" -a \( $with
77 AC_CHECK_LIB(lber, main)
78 AC_CHECK_LIB(ldap, main, [LIBS="-lldap $LIBS" found_ldap_lib=yes],,$LIBS)
79 fi
80 +if test -z "$found_ldap_lib" -a \( $with_ldap_lib = auto -o $with_ldap_lib = mozilla \); then
81 +AC_CHECK_LIB(ldap60, main, LIBS="-lssldap60 -lprldap60 -lldap60 -lssl3 -lsmime3 -lnss3 -lplds4 -lplc4 -lnspr4 $LIBS" found_ldap_lib=yes need_pthread=yes,, -lpthread)
82 +fi
83 if test -z "$found_ldap_lib" -a \( $with_ldap_lib = auto -o $with_ldap_lib = netscape5 \); then
84 AC_CHECK_LIB(ldap50, main, LIBS="-lldap50 -lssldap50 -lssl3 -lnss3 -lnspr4 -lprldap50 -lplc4 -lplds4 $LIBS" found_ldap_lib=yes need_pthread=yes,, -lpthread)
85 fi
86 @@ -331,6 +336,7 @@ AC_CHECK_FUNCS(ldap_init ldap_get_lderrn
87 AC_CHECK_FUNCS(ldap_ld_free ldap_explode_rdn ldap_set_option ldap_get_option)
88 AC_CHECK_FUNCS(ldap_sasl_interactive_bind_s ldap_initialize ldap_search_ext)
89 AC_CHECK_FUNCS(ldap_create_control ldap_create_page_control ldap_parse_page_control)
90 +AC_CHECK_FUNCS(ldap_alloc_ber_with_options ber_alloc_t der_alloc)
91 if test "$enable_ssl" \!= "no"; then
92 AC_CHECK_FUNCS(ldapssl_client_init ldap_start_tls_s ldap_pvt_tls_set_option ldap_start_tls)
93 fi
94 diff -up nss_ldap/ldap-nss.h nss_ldap/ldap-nss.h
95 --- nss_ldap/ldap-nss.h 2007-11-14 14:21:54.000000000 -0500
96 +++ nss_ldap/ldap-nss.h 2007-11-14 15:05:57.000000000 -0500
97 @@ -58,6 +58,8 @@
98 #include <nss_common.h>
99 #include <nss_dbdefs.h>
100 #include <nsswitch.h>
101 +#elif defined(HAVE__USR_INCLUDE_NSS_H)
102 +#include </usr/include/nss.h>
103 #elif defined(HAVE_NSS_H)
104 #include <nss.h>
105 #elif defined(HAVE_IRS_H)
106 diff -up nss_ldap/ldap-nss.c nss_ldap/ldap-nss.c
107 --- nss_ldap/ldap-nss.c 2007-11-14 14:21:54.000000000 -0500
108 +++ nss_ldap/ldap-nss.c 2007-11-14 14:21:54.000000000 -0500
109 @@ -1069,6 +1069,23 @@ do_init_session (LDAP ** ld, const char
110 defport = atoi (p + 1);
111 uri = uribuf;
112 }
113 + else
114 + {
115 + size_t urilen = strlen(uri);
116 +
117 + if (urilen >= sizeof (uribuf))
118 + {
119 + return NSS_UNAVAIL;
120 + }
121 +
122 + memcpy (uribuf, uri, urilen);
123 + uribuf[urilen] = '\0';
124 +
125 + if ((urilen > 0) && (uribuf[urilen - 1] == '/'))
126 + uribuf[urilen - 1] = '\0';
127 +
128 + uri = uribuf;
129 + }
130
131 # ifdef HAVE_LDAP_INIT
132 *ld = ldap_init (uri, defport);
133 @@ -1537,7 +1554,7 @@ do_open (void)
134
135 if (ldap_get_option
136 (__session.ls_conn, LDAP_OPT_PROTOCOL_VERSION,
137 - &version) == LDAP_OPT_SUCCESS)
138 + &version) == 0)
139 {
140 if (version < LDAP_VERSION3)
141 {
142 @@ -1697,6 +1714,7 @@ do_ssl_options (ldap_config_t * cfg)
143 }
144 #endif /* LDAP_OPT_X_TLS_RANDOM_FILE */
145
146 +#ifdef LDAP_OPT_X_TLS_CACERTFILE
147 if (cfg->ldc_tls_cacertfile != NULL)
148 {
149 /* ca cert file */
150 @@ -1709,7 +1727,9 @@ do_ssl_options (ldap_config_t * cfg)
151 return LDAP_OPERATIONS_ERROR;
152 }
153 }
154 +#endif
155
156 +#ifdef LDAP_OPT_X_TLS_CACERTDIR
157 if (cfg->ldc_tls_cacertdir != NULL)
158 {
159 /* ca cert directory */
160 @@ -1722,7 +1742,9 @@ do_ssl_options (ldap_config_t * cfg)
161 return LDAP_OPERATIONS_ERROR;
162 }
163 }
164 +#endif
165
166 +#ifdef LDAP_OPT_X_TLS_REQUIRE_CERT
167 /* require cert? */
168 if (cfg->ldc_tls_checkpeer > -1)
169 {
170 @@ -1735,7 +1757,9 @@ do_ssl_options (ldap_config_t * cfg)
171 return LDAP_OPERATIONS_ERROR;
172 }
173 }
174 +#endif
175
176 +#ifdef LDAP_OPT_X_TLS_CIPHER_SUITE
177 if (cfg->ldc_tls_ciphers != NULL)
178 {
179 /* set cipher suite, certificate and private key: */
180 @@ -1748,7 +1772,9 @@ do_ssl_options (ldap_config_t * cfg)
181 return LDAP_OPERATIONS_ERROR;
182 }
183 }
184 +#endif
185
186 +#ifdef LDAP_OPT_X_TLS_CERTFILE
187 if (cfg->ldc_tls_cert != NULL)
188 {
189 rc = ldap_set_option (NULL, LDAP_OPT_X_TLS_CERTFILE, cfg->ldc_tls_cert);
190 @@ -1759,7 +1785,9 @@ do_ssl_options (ldap_config_t * cfg)
191 return LDAP_OPERATIONS_ERROR;
192 }
193 }
194 +#endif
195
196 +#ifdef LDAP_OPT_X_TLS_CERTFILE
197 if (cfg->ldc_tls_key != NULL)
198 {
199 rc = ldap_set_option (NULL, LDAP_OPT_X_TLS_KEYFILE, cfg->ldc_tls_key);
200 @@ -1770,6 +1798,7 @@ do_ssl_options (ldap_config_t * cfg)
201 return LDAP_OPERATIONS_ERROR;
202 }
203 }
204 +#endif
205
206 debug ("<== do_ssl_options");
207
208 diff -up nss_ldap/pagectrl.c nss_ldap/pagectrl.c
209 --- nss_ldap/pagectrl.c 2007-08-03 00:51:09.000000000 -0400
210 +++ nss_ldap/pagectrl.c 2007-11-14 14:21:54.000000000 -0500
211 @@ -38,6 +38,17 @@ static char rcsId[] = "$Id: pagectrl.c,v
212 #define LDAP_CONTROL_PAGE_OID "1.2.840.113556.1.4.319"
213 #endif
214
215 +#ifndef HAVE_LDAP_CREATE_CONTROL
216 +#define ldap_create_control _nss_ldap_fail_to_create_control
217 +static int
218 +ldap_create_control(const char *oid, BerElement *value,
219 + int iscritical, LDAPControl ** ctrlp)
220 +{
221 + *ctrlp = NULL;
222 + return LDAP_ENCODING_ERROR;
223 +}
224 +#endif
225 +
226 #ifndef HAVE_LDAP_CREATE_PAGE_CONTROL
227 /*---
228 ldap_create_page_control
229 @@ -78,9 +89,6 @@ static char rcsId[] = "$Id: pagectrl.c,v
230
231 ---*/
232
233 -#ifndef HAVE_LDAP_CREATE_CONTROL
234 -#error LDAP client library does not support ldap_create_control()
235 -#else
236 int
237 ldap_create_page_control (LDAP * ld,
238 unsigned long pagesize,
239 @@ -97,10 +105,24 @@ ldap_create_page_control (LDAP * ld,
240 return (LDAP_PARAM_ERROR);
241 }
242
243 +#ifdef HAVE_LDAP_ALLOC_BER_WITH_OPTIONS
244 if ((ber = ldap_alloc_ber_with_options (ld)) == NULL)
245 {
246 return (LDAP_NO_MEMORY);
247 }
248 +#elif defined(HAVE_BER_ALLOC_T) && defined(LBER_USE_DER)
249 + if ((ber = ber_alloc_t(LBER_USE_DER)) == NULL)
250 + {
251 + return (LDAP_NO_MEMORY);
252 + }
253 +#elif defined(HAVE_DER_ALLOC)
254 + if ((ber = der_alloc()) == NULL)
255 + {
256 + return (LDAP_NO_MEMORY);
257 + }
258 +#else
259 + return (LDAP_NO_MEMORY);
260 +#endif
261
262 tag = ber_printf (ber, "{i", pagesize);
263 if (tag == LBER_ERROR)
264 @@ -126,7 +148,6 @@ exit:
265 ber_free (ber, 1);
266 return (LDAP_ENCODING_ERROR);
267 }
268 -#endif /* HAVE_LDAP_CREATE_CONTROL */
269 #endif /* HAVE_LDAP_CREATE_PAGE_CONTROL */
270
271 #ifndef HAVE_LDAP_PARSE_PAGE_CONTROL
272 @@ -154,9 +175,6 @@ exit:
273
274 ---*/
275
276 -#ifndef HAVE_LDAP_CREATE_CONTROL
277 -#error LDAP client library does not support ldap_create_control()
278 -#else
279 int
280 ldap_parse_page_control (LDAP * ld,
281 LDAPControl ** ctrls,
282 @@ -222,5 +240,4 @@ foundPageControl:
283
284 return (LDAP_SUCCESS);
285 }
286 -#endif /* HAVE_LDAP_CREATE_CONTROL */
287 #endif /* HAVE_LDAP_PARSE_PAGE_CONTROL */