ruby-ldap3 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/entry.c ADDED
@@ -0,0 +1,342 @@
1
+ /*
2
+ * entry.c
3
+ * $Id: entry.c,v 1.13 2005/03/15 10:15:32 ianmacd Exp $
4
+ */
5
+
6
+ #include "ruby.h"
7
+ #include "rbldap.h"
8
+
9
+ VALUE rb_cLDAP_Entry;
10
+
11
+ #if RUBY_VERSION_CODE >= 190
12
+ static void
13
+ rb_ldap_entry_mark(RB_LDAPENTRY_DATA *edata)
14
+ {
15
+ rb_gc_mark(edata->dn);
16
+ rb_gc_mark(edata->attr);
17
+ /*
18
+ * edata->ldap and edata->msg are managed in a block given by each search
19
+ * operation. ldap_msgfree should be called after ldap_search.
20
+ * they are just for C language interfaces, don't touch these members
21
+ * in ruby method implementation.
22
+ */
23
+ }
24
+
25
+ /*
26
+ * load libldap's value data structure into ruby array of string
27
+ */
28
+ static VALUE
29
+ rb_ldap_entry_load_val(LDAP *ldap, LDAPMessage *msg, char *c_attr)
30
+ {
31
+ struct berval **bv;
32
+ VALUE vals;
33
+ int nvals;
34
+ int i;
35
+
36
+ bv = ldap_get_values_len(ldap, msg, c_attr);
37
+ if (bv == NULL)
38
+ return Qnil;
39
+
40
+ nvals = ldap_count_values_len(bv);
41
+ vals = rb_ary_new2(nvals);
42
+ for (i = 0; i < nvals; i++) {
43
+ rb_ary_push(vals, rb_tainted_str_new(bv[i]->bv_val, bv[i]->bv_len));
44
+ }
45
+ ldap_value_free_len(bv);
46
+
47
+ return vals;
48
+ }
49
+
50
+ /*
51
+ * load libldap's attributes data structure into ruby hash
52
+ */
53
+ static VALUE
54
+ rb_ldap_entry_load_attr(LDAP *ldap, LDAPMessage *msg)
55
+ {
56
+ VALUE hash = rb_hash_new();
57
+ BerElement *ber = NULL;
58
+ char *c_attr;
59
+
60
+ for (c_attr = ldap_first_attribute(ldap, msg, &ber);
61
+ c_attr != NULL;
62
+ c_attr = ldap_next_attribute(ldap, msg, ber)) {
63
+ VALUE attr = rb_tainted_str_new2(c_attr);
64
+ VALUE vals = rb_ldap_entry_load_val(ldap, msg, c_attr);
65
+
66
+ rb_hash_aset(hash, attr, vals);
67
+ ldap_memfree(c_attr);
68
+ }
69
+
70
+ #if !defined(USE_OPENLDAP1)
71
+ ber_free(ber, 0);
72
+ #endif
73
+
74
+ return hash;
75
+ }
76
+ #endif
77
+
78
+ void
79
+ rb_ldap_entry_free (RB_LDAPENTRY_DATA * edata)
80
+ {
81
+ xfree(edata);
82
+ /* edata->msg is valid in a block given by each search operation */
83
+ /* ldap_msgfree should be called after ldap_search */
84
+ }
85
+
86
+ VALUE
87
+ rb_ldap_entry_new (LDAP * ldap, LDAPMessage * msg)
88
+ {
89
+ VALUE val;
90
+ RB_LDAPENTRY_DATA *edata;
91
+ #if RUBY_VERSION_CODE >= 190
92
+ char *c_dn;
93
+ #endif
94
+
95
+ #if RUBY_VERSION_CODE >= 190
96
+ val = Data_Make_Struct (rb_cLDAP_Entry, RB_LDAPENTRY_DATA,
97
+ rb_ldap_entry_mark, rb_ldap_entry_free, edata);
98
+ #else
99
+ val = Data_Make_Struct (rb_cLDAP_Entry, RB_LDAPENTRY_DATA,
100
+ 0, rb_ldap_entry_free, edata);
101
+ #endif
102
+ edata->ldap = ldap;
103
+ edata->msg = msg;
104
+
105
+ #if RUBY_VERSION_CODE >= 190
106
+ /* get dn */
107
+ c_dn = ldap_get_dn(ldap, msg);
108
+ if (c_dn) {
109
+ edata->dn = rb_tainted_str_new2(c_dn);
110
+ ldap_memfree(c_dn);
111
+ }
112
+ else {
113
+ edata->dn = Qnil;
114
+ }
115
+
116
+ /* get attributes */
117
+ edata->attr = rb_ldap_entry_load_attr(ldap, msg);
118
+ #endif
119
+ return val;
120
+ }
121
+
122
+ /*
123
+ * call-seq:
124
+ * entry.get_dn => String
125
+ * entry.dn => String
126
+ */
127
+ VALUE
128
+ rb_ldap_entry_get_dn (VALUE self)
129
+ {
130
+ RB_LDAPENTRY_DATA *edata;
131
+ #if RUBY_VERSION_CODE < 190
132
+ char *cdn;
133
+ VALUE dn;
134
+ #endif
135
+
136
+ GET_LDAPENTRY_DATA (self, edata);
137
+
138
+ #if RUBY_VERSION_CODE < 190
139
+ cdn = ldap_get_dn (edata->ldap, edata->msg);
140
+ if (cdn)
141
+ {
142
+ dn = rb_tainted_str_new2 (cdn);
143
+ ldap_memfree (cdn);
144
+ }
145
+ else
146
+ {
147
+ dn = Qnil;
148
+ }
149
+
150
+ return dn;
151
+ #else
152
+ return edata->dn;
153
+ #endif
154
+ }
155
+
156
+ /*
157
+ * call-seq:
158
+ * entry.get_values(attr) => Array of String
159
+ * entry.vals(attr) => Array of String
160
+ * entry[attr] => Array of String
161
+ *
162
+ * Return an array of all the values belonging to the attribute, +attr+, of
163
+ * the entry.
164
+ */
165
+ VALUE
166
+ rb_ldap_entry_get_values (VALUE self, VALUE attr)
167
+ {
168
+ RB_LDAPENTRY_DATA *edata;
169
+ #if RUBY_VERSION_CODE < 190
170
+ char *c_attr;
171
+ struct berval **c_vals;
172
+ int i;
173
+ int count;
174
+ VALUE vals;
175
+ #endif
176
+
177
+ GET_LDAPENTRY_DATA (self, edata);
178
+ #if RUBY_VERSION_CODE < 190
179
+ c_attr = StringValueCStr (attr);
180
+
181
+ c_vals = ldap_get_values_len (edata->ldap, edata->msg, c_attr);
182
+ if (c_vals)
183
+ {
184
+ vals = rb_ary_new ();
185
+ count = ldap_count_values_len (c_vals);
186
+ for (i = 0; i < count; i++)
187
+ {
188
+ VALUE str;
189
+ str = rb_tainted_str_new (c_vals[i]->bv_val, c_vals[i]->bv_len);
190
+ rb_ary_push (vals, str);
191
+ }
192
+ ldap_value_free_len (c_vals);
193
+ }
194
+ else
195
+ {
196
+ vals = Qnil;
197
+ }
198
+
199
+ return vals;
200
+ #else
201
+ return rb_hash_aref(edata->attr, attr);
202
+ #endif
203
+ }
204
+
205
+ /*
206
+ * call-seq:
207
+ * entry.get_attributes => Array of String
208
+ * entry.attrs => Array of String
209
+ *
210
+ * Return an array of all the attributes belonging to the entry.
211
+ */
212
+ VALUE
213
+ rb_ldap_entry_get_attributes (VALUE self)
214
+ {
215
+ RB_LDAPENTRY_DATA *edata;
216
+ #if RUBY_VERSION_CODE < 190
217
+ VALUE vals;
218
+ char *attr;
219
+ BerElement *ber = NULL;
220
+ #else
221
+ VALUE attrs;
222
+ #endif
223
+
224
+ GET_LDAPENTRY_DATA (self, edata);
225
+
226
+ #if RUBY_VERSION_CODE < 190
227
+ vals = rb_ary_new ();
228
+ for (attr = ldap_first_attribute (edata->ldap, edata->msg, &ber);
229
+ attr != NULL;
230
+ attr = ldap_next_attribute (edata->ldap, edata->msg, ber))
231
+ {
232
+ rb_ary_push (vals, rb_tainted_str_new2 (attr));
233
+ ldap_memfree(attr);
234
+ }
235
+
236
+ #if !defined(USE_OPENLDAP1)
237
+ if( ber != NULL ){
238
+ ber_free(ber, 0);
239
+ }
240
+ #endif
241
+
242
+ return vals;
243
+ #else
244
+ attrs = rb_funcall(edata->attr, rb_intern("keys"), 0);
245
+ if (TYPE(attrs) != T_ARRAY) {
246
+ return Qnil;
247
+ }
248
+
249
+ return attrs;
250
+ #endif
251
+ }
252
+
253
+ /*
254
+ * call-seq:
255
+ * entry.to_hash => Hash
256
+ *
257
+ * Convert the entry to a hash.
258
+ */
259
+ VALUE
260
+ rb_ldap_entry_to_hash (VALUE self)
261
+ {
262
+ #if RUBY_VERSION_CODE < 190
263
+ VALUE attrs = rb_ldap_entry_get_attributes (self);
264
+ VALUE hash = rb_hash_new ();
265
+ VALUE attr, vals;
266
+ int i;
267
+ #else
268
+ RB_LDAPENTRY_DATA *edata;
269
+ VALUE hash, dn_ary;
270
+ #endif
271
+
272
+ #if RUBY_VERSION_CODE < 190
273
+ Check_Type (attrs, T_ARRAY);
274
+ rb_hash_aset (hash, rb_tainted_str_new2 ("dn"),
275
+ rb_ary_new3 (1, rb_ldap_entry_get_dn (self)));
276
+ for (i = 0; i < RARRAY_LEN (attrs); i++)
277
+ {
278
+ attr = rb_ary_entry (attrs, i);
279
+ vals = rb_ldap_entry_get_values (self, attr);
280
+ rb_hash_aset (hash, attr, vals);
281
+ }
282
+ #else
283
+ GET_LDAPENTRY_DATA (self, edata);
284
+ hash = rb_hash_dup(edata->attr);
285
+ dn_ary = rb_ary_new3(1, edata->dn);
286
+ rb_hash_aset(hash, rb_tainted_str_new2("dn"), dn_ary);
287
+ #endif
288
+
289
+ return hash;
290
+ }
291
+
292
+ /*
293
+ * call-seq:
294
+ * entry.inspect => String
295
+ *
296
+ * Produce a concise representation of the entry.
297
+ */
298
+ VALUE
299
+ rb_ldap_entry_inspect (VALUE self)
300
+ {
301
+ VALUE str;
302
+ const char *c;
303
+
304
+ c = rb_obj_classname (self);
305
+ str = rb_str_new (0, strlen (c) + 10 + 16 + 1); /* 10:tags 16:addr 1:nul */
306
+ sprintf (RSTRING_PTR (str), "#<%s:0x%lx\n", c, self);
307
+
308
+ #if RUBY_VERSION_CODE < 190
309
+ RSTRING(str)->len = strlen (RSTRING_PTR (str));
310
+ #else
311
+ rb_str_set_len(str, strlen (RSTRING_PTR (str)));
312
+ #endif
313
+
314
+ rb_str_concat (str, rb_inspect (rb_ldap_entry_to_hash (self)));
315
+ rb_str_cat2 (str, ">");
316
+
317
+ return str;
318
+ }
319
+
320
+ /* Document-class: LDAP::Entry
321
+ *
322
+ * These methods can be used to probe the entries returned by LDAP searches.
323
+ */
324
+ void
325
+ Init_ldap_entry ()
326
+ {
327
+ rb_cLDAP_Entry = rb_define_class_under (rb_mLDAP, "Entry", rb_cObject);
328
+ rb_define_const (rb_mLDAP, "Message", rb_cLDAP_Entry); /* for compatibility */
329
+ rb_undef_method (CLASS_OF (rb_cLDAP_Entry), "new");
330
+ rb_undef_alloc_func (rb_cLDAP_Entry);
331
+ rb_ldap_entry_define_method ("get_dn", rb_ldap_entry_get_dn, 0);
332
+ rb_ldap_entry_define_method ("get_values", rb_ldap_entry_get_values, 1);
333
+ rb_ldap_entry_define_method ("get_attributes",
334
+ rb_ldap_entry_get_attributes, 0);
335
+ rb_alias (rb_cLDAP_Entry, rb_intern ("dn"), rb_intern ("get_dn"));
336
+ rb_alias (rb_cLDAP_Entry, rb_intern ("vals"), rb_intern ("get_values"));
337
+ rb_alias (rb_cLDAP_Entry, rb_intern ("[]"), rb_intern ("get_values"));
338
+ rb_alias (rb_cLDAP_Entry, rb_intern ("attrs"),
339
+ rb_intern ("get_attributes"));
340
+ rb_ldap_entry_define_method ("to_hash", rb_ldap_entry_to_hash, 0);
341
+ rb_ldap_entry_define_method ("inspect", rb_ldap_entry_inspect, 0);
342
+ }
data/extconf.rb ADDED
@@ -0,0 +1,310 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # extconf.rb for ldap extension
4
+ # $Id: extconf.rb,v 1.7 2006/04/18 23:49:56 ianmacd Exp $
5
+ #
6
+
7
+ require 'mkmf'
8
+
9
+ $INTERACTIVE = false
10
+
11
+ if( ARGV.include?("--help") )
12
+ print <<EOF
13
+ --with-ldap-dir specify the LDAP directory.
14
+ --with-ldap-include specify the directory containing ldap.h and lber.h.
15
+ --with-ldap-lib specify the directory containing the LDAP libraries.
16
+ --with-netscape build with Netscape SDK.
17
+ --with-mozilla build with Mozilla SDK (Enables certificate authentication).
18
+ --with-openldap1 build with OpenLDAP 1.x.
19
+ --with-openldap2 build with OpenLDAP 2.x.
20
+ --with-wldap32 Active Directory Client API.
21
+
22
+ The following are library configuration options:
23
+ --with-libcrypto=crypto, --without-libcrypto
24
+ --with-libssl=ssl, --without-libssl
25
+ --with-libnsl=nsl, --without-libnsl
26
+ --with-libldap=ldap, --without-libldap
27
+ --with-liblber=lber, --without-liblber
28
+ --with-libldap_r=ldap_r, --without-libldap_r
29
+ --with-libpthread=pthread, --without-libpthread
30
+ --with-libresolv=resolv, --without-libresolv
31
+
32
+ --help show this help.
33
+ EOF
34
+ exit(0)
35
+ end
36
+
37
+ def find_files(dir = nil)
38
+ if( dir )
39
+ search_dirs = [dir]
40
+ else
41
+ search_dirs =
42
+ ["/usr/local", "/usr", "/opt"] +
43
+ Dir.glob("/usr/local/./*ldap*").collect{|d| d.gsub(/\/\.\//, "/")} +
44
+ Dir.glob("/usr/./*ldap*").collect{|d| d.gsub(/\/\.\//, "/") +
45
+ Dir.glob("/usr/lib{64,}/mozldap/*ldap*") + ["/usr/include/mozldap"]
46
+ }
47
+ end
48
+ for d in search_dirs
49
+ h = File.join(d,"include","ldap.h")
50
+ l = File.join(d,"lib","libldap*")
51
+ if( File.exist?(h) )
52
+ l = Dir.glob(l)[0]
53
+ if( l )
54
+ if( $INTERACTIVE )
55
+ print("--with-ldap-dir=#{d} [y/n]")
56
+ ans = $stdin.gets
57
+ ans.chop!
58
+ if( ans == "y" )
59
+ result = [d, File.basename(l).split(".")[0][3..-1], File.basename(h)]
60
+ return result
61
+ break
62
+ end
63
+ else
64
+ print("--with-ldap-dir=#{d}\n")
65
+ result = [d, File.basename(l).split(".")[0][3..-1], File.basename(h)]
66
+ return result
67
+ break
68
+ end
69
+ end
70
+ end
71
+ end
72
+ end
73
+
74
+ def ldap_with_config(arg, default = nil)
75
+ cfg1 = with_config(arg, nil)
76
+ cfg2 = arg_config("--without-" + arg, nil)
77
+ if( cfg1 )
78
+ return cfg1
79
+ else
80
+ if( cfg2 )
81
+ return nil
82
+ else
83
+ return default
84
+ end
85
+ end
86
+ end
87
+
88
+ $use_netscape = ldap_with_config("netscape")
89
+ if ldap_with_config("mozilla")
90
+ $use_netscape = '6'
91
+ end
92
+ $use_openldap1 = ldap_with_config("openldap1")
93
+ $use_openldap2 = ldap_with_config("openldap2")
94
+ $use_wldap32 = ldap_with_config("wldap32")
95
+
96
+ dir_config('ldap')
97
+ $ldap_dir = ldap_with_config("ldap-dir") || ldap_with_config("ldap")
98
+
99
+ $ldap_dir, $libldap, $ldap_h = find_files($ldap_dir)
100
+
101
+ if( !($use_netscape || $use_openldap1 || $use_openldap2 || $use_wldap32) )
102
+ case $libldap
103
+ when /^ldapssl[0-9]+$/
104
+ print("--with-netscape\n")
105
+ $use_netscape = "4"
106
+ when /^ssldap50+$/, /^ldap50+$/
107
+ print("--with-netscape=5")
108
+ $use_netscape = "5"
109
+ when /^ssldap60+$/, /^ldap60+$/
110
+ print("--with-netscape=6")
111
+ $use_netscape = "6"
112
+ else
113
+ if RUBY_PLATFORM =~ /-(:?mingw32|mswin32)/
114
+ print("--with-wldap32\n")
115
+ $use_wldap32 = true
116
+ else
117
+ print("--with-openldap2\n")
118
+ $use_openldap2 = true
119
+ end
120
+ end
121
+ end
122
+ if( $use_netscape == true )
123
+ $use_netscape = "5"
124
+ end
125
+
126
+ if( $use_netscape )
127
+ case $use_netscape
128
+ when /^4/
129
+ $defs << "-DUSE_NETSCAPE_SDK"
130
+ #$libnsl = ldap_with_config("libnsl", "nsl")
131
+ #$libpthread = ldap_with_config("libpthread", "pthread")
132
+ $libresolv = ldap_with_config("libresolv", "resolv")
133
+ $libldap = ldap_with_config("libldap", $libldap)
134
+ $libns = ldap_with_config("libns", "nspr3,plc3,plds3").split(",")
135
+ when /^5/
136
+ $defs << "-DUSE_NETSCAPE_SDK"
137
+ #$libnsl = ldap_with_config("libnsl", "nsl")
138
+ #$libpthread = ldap_with_config("libpthread", "pthread")
139
+ $libresolv = ldap_with_config("libresolv", "resolv")
140
+ $libldap = ldap_with_config("libldap", $libldap)
141
+ $libns = ldap_with_config("libns", "nspr4,plc4,plds4").split(",")
142
+ $liblber = ldap_with_config("liblber", "lber50")
143
+ $libssl = ldap_with_config("libssl", "ssl3")
144
+ when /^6/
145
+ %x{pkg-config --exists 'mozldap >= 6.0 nspr >= 4.0'}
146
+
147
+ if $? == 0
148
+ puts 'Mozzilla LDAP libs will be used.'
149
+ $mozlibs = %x{pkg-config mozldap nspr --libs}.chomp
150
+ $mozincs = %x{pkg-config mozldap nspr --cflags}.chomp
151
+ else
152
+ puts 'pkg-config reported that no right mozilla LDAP libs were found'
153
+ puts 'we need mozldap >= 6.0 and nspr >= 4.0'
154
+ exit 1
155
+ end
156
+
157
+ $defs << "-DUSE_NETSCAPE_SDK -DUSE_SSL_CLIENTAUTH"
158
+ #$libnsl = ldap_with_config("libnsl", "nsl")
159
+ #$libpthread = ldap_with_config("libpthread", "pthread")
160
+ $libresolv = ldap_with_config("libresolv", "resolv")
161
+ $libldap = ldap_with_config("libldap", "ldap60")
162
+ $libns = ldap_with_config("libns", "nspr4,plc4,plds4").split(",")
163
+ $liblber = ldap_with_config("liblber", "lber60")
164
+ $libssl = ldap_with_config("libssl", "ssl3")
165
+ end
166
+ end
167
+
168
+ if( $use_openldap1 )
169
+ $defs << "-DUSE_OPENLDAP1"
170
+ $defs << "-DUSE_OPENLDAP"
171
+ $libresolv = ldap_with_config("libresolv", "resolv")
172
+ $libldap = ldap_with_config("libldap", "ldap")
173
+ $liblber = ldap_with_config("liblber", "lber")
174
+ end
175
+
176
+ if( $use_openldap2 )
177
+ $defs << "-DUSE_OPENLDAP2"
178
+ $defs << "-DUSE_OPENLDAP"
179
+ # OpenLDAP 2.3 finally deprecates a bunch of non-_ext functions. We need
180
+ # this to enable them.
181
+ $defs << "-DLDAP_DEPRECATED"
182
+ $libresolv = ldap_with_config("libresolv", "resolv")
183
+ $libcrypto = ldap_with_config("libcrypto", "crypto")
184
+ $libssl = ldap_with_config("libssl", "ssl")
185
+ $libpthread = ldap_with_config("libpthread", "pthread")
186
+ $libnsl = ldap_with_config("libnsl", "nsl")
187
+ $liblber = ldap_with_config("liblber", "lber")
188
+ $libldap_r = ldap_with_config("libldap_r", "ldap_r")
189
+ $libldap = ldap_with_config("libldap", "ldap")
190
+ end
191
+
192
+ if( $use_wldap32 )
193
+ srcdir = File.dirname($0)
194
+ if( !File.exist?("win") )
195
+ Dir.mkdir("win")
196
+ end
197
+ `lib /def:#{srcdir}/win/wldap32.def /out:#{srcdir}/win/wldap32.lib`
198
+ $defs << "-DUSE_WLDAP32"
199
+ dir_config("wldap32", "#{srcdir}/win", "./win")
200
+ $libldap = ldap_with_config("libldap", "wldap32")
201
+ end
202
+
203
+ if( $libpthread )
204
+ $defs << "-D_REENTRANT"
205
+ end
206
+
207
+ if( $use_wldap32 )
208
+ have_header("winldap.h")
209
+ have_header("winlber.h")
210
+ have_header("sys/time.h")
211
+ elsif $use_netscape =~ /^6/
212
+ # mozilla
213
+ pkg_config('mozldap')
214
+ pkg_config('nspr')
215
+ else
216
+ ldap_h = have_header("ldap.h")
217
+ lber_h = have_header("lber.h")
218
+ ldap_ssl_h = have_header("ldap_ssl.h")
219
+ if( !(ldap_h && lber_h) )
220
+ print("can't find ldap.h and lber.h\n")
221
+ print("use the option '--with-ldap-dir'!\n")
222
+ exit(0)
223
+ end
224
+
225
+ have_header("openssl/ssl.h") || have_header("ssl.h")
226
+ have_header("openssl/crypto.h") || have_header("crypto.h")
227
+ end
228
+
229
+ $LIBS << ' -pthread'
230
+ for l in [$libcrypto, $libssl, $libnsl, $libpthread, $libresolv,
231
+ $libns, $liblber, $libldap_r, $libldap].flatten
232
+ if( l )
233
+ have_library(l)
234
+ end
235
+ end
236
+
237
+ have_func("ldap_init", 'ldap.h')
238
+ have_func("ldap_set_option")
239
+ have_func("ldap_get_option")
240
+ have_func("ldap_start_tls_s") if $use_openldap2
241
+ have_func("ldap_memfree")
242
+ have_func("ldap_perror") if !arg_config("--disable-ldap-perror")
243
+ have_func("ldap_sort_entries")
244
+ #have_func("ldap_sort_values")
245
+ have_func("ldapssl_init") # NS SDK
246
+ have_func("ldap_sslinit") # WLDAP32
247
+ have_func("ldap_sasl_bind_s")
248
+ have_func("ldap_rename_s")
249
+ have_func("ldap_compare_s")
250
+ have_func("ldap_add_ext_s")
251
+ have_func("ldap_compare_ext_s")
252
+ have_func("ldap_delete_ext_s")
253
+ have_func("ldap_modify_ext_s")
254
+ have_func("ldap_search_ext_s")
255
+ have_func("ldap_unbind_ext_s")
256
+ have_func("ldap_sasl_interactive_bind_s")
257
+
258
+ $defs << "-DRUBY_VERSION_CODE=#{RUBY_VERSION.gsub(/\D/, '')}"
259
+
260
+ create_makefile("ldap")
261
+
262
+
263
+ $slapd = ldap_with_config("slapd") || File.join($ldap_dir,"libexec","slapd")
264
+ $schema_dir = ldap_with_config("schema-dir")
265
+ if( !$schema_dir )
266
+ $schema_dir = File.join($ldap_dir,"etc","openldap","schema")
267
+ if( !File.exist?($schema_dir) )
268
+ $schema_dir = File.join($ldap_dir,"etc","openldap")
269
+ end
270
+ end
271
+
272
+ $run_test = "/bin/sh $(srcdir)/test/test.sh #{CONFIG['RUBY_INSTALL_NAME']}"
273
+ if( $use_openldap1 )
274
+ $run_test += " openldap1"
275
+ else( $use_openldap2 )
276
+ if( $libssl && $libcrypto )
277
+ $run_test = "/bin/sh $(srcdir)/test/test.sh #{CONFIG['RUBY_INSTALL_NAME']} newcert; " + $run_test
278
+ $run_test += " openldap2-ssl"
279
+ else
280
+ $run_test += " openldap2"
281
+ end
282
+ end
283
+ $run_test += " #{$slapd} #{$schema_dir}"
284
+
285
+
286
+ File.open("Makefile","a") do |f|
287
+ f.print <<EOF
288
+
289
+ test::
290
+ \t#{$run_test}
291
+
292
+ testclean: test-clean
293
+
294
+ test-clean::
295
+ \t(cd $(srcdir); /bin/sh test/test.sh clean)
296
+
297
+ reconfig::
298
+ \t$(RUBY_INSTALL_NAME) $(srcdir)/extconf.rb #{ARGV.join(" ")}
299
+
300
+ doc:
301
+ #\t$(RUBY_INSTALL_NAME) -rrdoc/ri/ri_paths -e 'puts RI::Paths::PATH[0]'
302
+ \trdoc --ri-site *.c lib/ldap
303
+
304
+ unit:
305
+ \t(cd test; $(RUBY_INSTALL_NAME) tc_ldif.rb)
306
+
307
+ .PHONY: doc
308
+ EOF
309
+
310
+ end