ruby-ldap 0.9.13 → 0.9.14

Sign up to get free protection for your applications and to get access to all the features.
Files changed (10) hide show
  1. data/ChangeLog +13 -0
  2. data/NOTES +15 -0
  3. data/conn.c +66 -1
  4. data/extconf.rb +1 -0
  5. data/ldap.c +3 -0
  6. data/rbldap.h +5 -4
  7. data/saslconn.c +19 -6
  8. data/test/moz_cert.rb +0 -1
  9. metadata +38 -33
  10. checksums.yaml +0 -7
data/ChangeLog CHANGED
@@ -1,3 +1,16 @@
1
+ Wed Aug 28 13:21:53 UTC 2013 Alexey Chebotar <alexey.chebotar@gmail.com>
2
+ * Version 0.9.14
3
+ * Fixed option parsing bug for LDAP::Conn.sasl_bind. Thanks to Brian Leake.
4
+ * Added possibility to use :nocanon option in rb_ldap_conn_sasl_bind.
5
+ See ldap_set_option(3) for more information. Thanks to Brian Leake.
6
+ * Added function conn.rename(dn, new_rdn, new_parent_dn, delete_old_rdn, sctrls, cctrls) => self
7
+ Modify the RDN of the entry with DN, dn, giving it the new RDN in parent new_parent_dn,
8
+ new_rdn. If delete_old_rdn is true, the old RDN value will be deleted from the entry.
9
+ Thanks to Marek Veber.
10
+ * Added option LDAP_OPT_NETWORK_TIMEOUT for openLDAP. Thanks to David Campbell.
11
+ * Fixed build error with GCC 4.8.1. Thanks to Kouhei Sutou.
12
+ * Add missing ldap_raname_s() function availability check. Thanks to Kouhei Sutou.
13
+
1
14
  Wed Jun 5 17:44:47 UTC 2013 Alexey Chebotar <alexey.chebotar@gmail.com>
2
15
  * Version 0.9.13
3
16
  * Prevent SyntaxError raised under Ruby 2.0.0 by line 107 regex
data/NOTES CHANGED
@@ -1,3 +1,18 @@
1
+ 0.9.14
2
+ -----
3
+
4
+ * Fixed option parsing bug for LDAP::Conn.sasl_bind. Thanks to Brian Leake.
5
+ * Added possibility to use :nocanon option in rb_ldap_conn_sasl_bind.
6
+ See ldap_set_option(3) for more information. Thanks to Brian Leake.
7
+ * Added function conn.rename(dn, new_rdn, new_parent_dn, delete_old_rdn, sctrls, cctrls) => self
8
+ Modify the RDN of the entry with DN, dn, giving it the new RDN in parent new_parent_dn,
9
+ new_rdn. If delete_old_rdn is true, the old RDN value will be deleted from the entry.
10
+ Thanks to Marek Veber.
11
+ * Added option LDAP_OPT_NETWORK_TIMEOUT for openLDAP. Thanks to David Campbell.
12
+ * Fixed build error with GCC 4.8.1. Thanks to Kouhei Sutou.
13
+ * Add missing ldap_raname_s() function availability check. Thanks to Kouhei Sutou.
14
+
15
+
1
16
  0.9.13
2
17
  -----
3
18
 
data/conn.c CHANGED
@@ -471,6 +471,15 @@ rb_ldap_conn_set_option (VALUE self, VALUE opt, VALUE data)
471
471
 
472
472
  switch (copt)
473
473
  {
474
+ #if defined(USE_OPENLDAP1) || defined(USE_OPENLDAP2)
475
+ case LDAP_OPT_NETWORK_TIMEOUT:
476
+ {
477
+ struct timeval tv;
478
+ tv = rb_time_interval(data);
479
+ optdata = &tv;
480
+ }
481
+ break;
482
+ #endif
474
483
  case LDAP_OPT_REFERRALS:
475
484
  optdata = (void *) NUM2INT (data);
476
485
  break;
@@ -595,6 +604,20 @@ rb_ldap_conn_get_option (VALUE self, VALUE opt)
595
604
  ldapdata->err = ldap_get_option (NULL, copt, (void *) info);
596
605
  data = (long *) info;
597
606
  }
607
+ #if defined(USE_OPENLDAP1) || defined(USE_OPENLDAP2)
608
+ else if (copt == LDAP_OPT_NETWORK_TIMEOUT)
609
+ {
610
+ struct timeval tv;
611
+ ldapdata->err = ldap_get_option (ldapdata->ldap, copt, &tv);
612
+ if (!tv.tv_sec)
613
+ {
614
+ long x = -1;
615
+ data = &x;
616
+ }
617
+ else
618
+ data = (void *) tv.tv_sec;
619
+ }
620
+ #endif
598
621
  else
599
622
  {
600
623
  data = (void *) ALLOCA_N (char, LDAP_GET_OPT_MAX_BUFFER_SIZE);
@@ -616,6 +639,9 @@ rb_ldap_conn_get_option (VALUE self, VALUE opt)
616
639
  case LDAP_OPT_RESTART:
617
640
  case LDAP_OPT_PROTOCOL_VERSION:
618
641
  case LDAP_OPT_ERROR_NUMBER:
642
+ #if defined(USE_OPENLDAP1) || defined(USE_OPENLDAP2)
643
+ case LDAP_OPT_NETWORK_TIMEOUT:
644
+ #endif
619
645
  #ifdef USE_OPENLDAP2
620
646
  #ifdef LDAP_OPT_X_TLS
621
647
  case LDAP_OPT_X_TLS:
@@ -674,7 +700,7 @@ rb_ldap_conn_get_option (VALUE self, VALUE opt)
674
700
  }
675
701
  else
676
702
  {
677
- rb_raise (rb_eLDAP_Error, ldap_err2string (ldapdata->err));
703
+ rb_raise (rb_eLDAP_Error, "%s", ldap_err2string (ldapdata->err));
678
704
  };
679
705
  #else
680
706
  rb_notimplement ();
@@ -1626,6 +1652,42 @@ rb_ldap_conn_modrdn_s (VALUE self, VALUE dn, VALUE newrdn, VALUE delete_p)
1626
1652
  return self;
1627
1653
  };
1628
1654
 
1655
+ #if defined(HAVE_LDAPCONTROL) && defined(HAVE_LDAP_RENAME_S)
1656
+ /*
1657
+ * call-seq:
1658
+ * conn.rename(dn, new_rdn, new_parent_dn, delete_old_rdn, sctrls, cctrls) => self
1659
+ *
1660
+ * Modify the RDN of the entry with DN, +dn+, giving it the new RDN in parent +new_parent_dn+,
1661
+ * +new_rdn+. If +delete_old_rdn+ is *true*, the old RDN value will be deleted
1662
+ * from the entry.
1663
+ */
1664
+ VALUE
1665
+ rb_ldap_conn_rename_s (VALUE self, VALUE dn, VALUE newrdn, VALUE newparentdn, VALUE delete_p,
1666
+ VALUE serverctrls, VALUE clientctrls)
1667
+ {
1668
+ RB_LDAP_DATA *ldapdata;
1669
+ char *c_dn;
1670
+ char *c_newrdn;
1671
+ char *c_newparentdn;
1672
+ int c_delete_p;
1673
+ LDAPControl **sctrls, **cctrls;
1674
+
1675
+ GET_LDAP_DATA (self, ldapdata);
1676
+ c_dn = StringValueCStr (dn);
1677
+ c_newrdn = StringValueCStr (newrdn);
1678
+ c_newparentdn = StringValueCStr (newparentdn);
1679
+ c_delete_p = (delete_p == Qtrue) ? 1 : 0;
1680
+ sctrls = rb_ldap_get_controls (serverctrls);
1681
+ cctrls = rb_ldap_get_controls (clientctrls);
1682
+
1683
+ ldapdata->err =
1684
+ ldap_rename_s (ldapdata->ldap, c_dn, c_newrdn, c_newparentdn, c_delete_p, sctrls, cctrls);
1685
+ Check_LDAP_Result (ldapdata->err);
1686
+
1687
+ return self;
1688
+ }
1689
+ #endif
1690
+
1629
1691
  /*
1630
1692
  * call-seq:
1631
1693
  * conn.delete(dn) => self
@@ -1817,6 +1879,9 @@ Init_ldap_conn ()
1817
1879
  rb_ldap_conn_define_method ("add", rb_ldap_conn_add_s, 2);
1818
1880
  rb_ldap_conn_define_method ("modify", rb_ldap_conn_modify_s, 2);
1819
1881
  rb_ldap_conn_define_method ("modrdn", rb_ldap_conn_modrdn_s, 3);
1882
+ #if defined(HAVE_LDAPCONTROL) && defined(HAVE_LDAP_RENAME_S)
1883
+ rb_ldap_conn_define_method ("rename", rb_ldap_conn_rename_s, 6);
1884
+ #endif
1820
1885
  rb_ldap_conn_define_method ("delete", rb_ldap_conn_delete_s, 1);
1821
1886
  #if defined(HAVE_LDAP_COMPARE_S)
1822
1887
  rb_ldap_conn_define_method ("compare", rb_ldap_conn_compare_s, 3);
data/extconf.rb CHANGED
@@ -245,6 +245,7 @@ have_func("ldap_sort_entries")
245
245
  have_func("ldapssl_init") # NS SDK
246
246
  have_func("ldap_sslinit") # WLDAP32
247
247
  have_func("ldap_sasl_bind_s")
248
+ have_func("ldap_rename_s")
248
249
  have_func("ldap_compare_s")
249
250
  have_func("ldap_add_ext_s")
250
251
  have_func("ldap_compare_ext_s")
data/ldap.c CHANGED
@@ -407,6 +407,9 @@ Init_ldap ()
407
407
  #ifdef LDAP_OPT_TIMELIMIT
408
408
  rb_ldap_define_opt (LDAP_OPT_TIMELIMIT);
409
409
  #endif
410
+ #ifdef LDAP_OPT_NETWORK_TIMEOUT
411
+ rb_ldap_define_opt (LDAP_OPT_NETWORK_TIMEOUT);
412
+ #endif
410
413
  #ifdef LDAP_OPT_THREAD_FN_PTRS
411
414
  rb_ldap_define_opt (LDAP_OPT_THREAD_FN_PTRS);
412
415
  #endif
data/rbldap.h CHANGED
@@ -27,8 +27,8 @@
27
27
 
28
28
  #define RB_LDAP_MAJOR_VERSION 0
29
29
  #define RB_LDAP_MINOR_VERSION 9
30
- #define RB_LDAP_PATCH_VERSION 12
31
- #define RB_LDAP_VERSION "0.9.13"
30
+ #define RB_LDAP_PATCH_VERSION 14
31
+ #define RB_LDAP_VERSION "0.9.14"
32
32
 
33
33
  #define LDAP_GET_OPT_MAX_BUFFER_SIZE (1024) /* >= sizeof(LDAPAPIInfo) */
34
34
 
@@ -62,6 +62,7 @@ typedef struct rb_ldapmod_data
62
62
  LDAPMod *mod;
63
63
  } RB_LDAPMOD_DATA;
64
64
 
65
+ struct timeval rb_time_interval(VALUE num);
65
66
 
66
67
  #ifndef HAVE_LDAP_MEMFREE
67
68
  # define ldap_memfree(ptr) free(ptr)
@@ -141,13 +142,13 @@ VALUE rb_ldap_mod_vals (VALUE);
141
142
 
142
143
  #define Check_LDAP_Result(err) { \
143
144
  if( (err) != LDAP_SUCCESS && (err) != LDAP_SIZELIMIT_EXCEEDED ){ \
144
- rb_raise(rb_eLDAP_ResultError, ldap_err2string(err)); \
145
+ rb_raise(rb_eLDAP_ResultError, "%s", ldap_err2string(err)); \
145
146
  } \
146
147
  }
147
148
 
148
149
  #define Check_LDAP_OPT_Result(err) { \
149
150
  if( (err) != LDAP_OPT_SUCCESS ){ \
150
- rb_raise(rb_eLDAP_ResultError, ldap_err2string(err)); \
151
+ rb_raise(rb_eLDAP_ResultError, "%s", ldap_err2string(err)); \
151
152
  } \
152
153
  }
153
154
 
data/saslconn.c CHANGED
@@ -106,7 +106,7 @@ rb_ldap_conn_sasl_bind (int argc, VALUE argv[], VALUE self)
106
106
  {
107
107
  RB_LDAP_DATA *ldapdata;
108
108
 
109
- VALUE arg1, arg2, arg3, arg4, arg5, sasl_options = Qnil;
109
+ VALUE arg1, arg2, arg3, arg4, arg5, sasl_options, other_options = Qnil;
110
110
  int version;
111
111
  char *dn = NULL;
112
112
  char *mechanism = NULL;
@@ -145,19 +145,32 @@ rb_ldap_conn_sasl_bind (int argc, VALUE argv[], VALUE self)
145
145
  rb_raise (rb_eLDAP_Error, "already bound.");
146
146
  };
147
147
 
148
- switch (rb_scan_args (argc, argv, "24", &arg1, &arg2, &arg3, &arg4, &arg5, &sasl_options))
148
+ switch (rb_scan_args (argc, argv, "25", &arg1, &arg2, &arg3, &arg4, &arg5, &sasl_options, &other_options))
149
149
  {
150
+ case 7:
151
+ /* Parse through the hash. Currently there's only one option, nothing fancy needed. */
152
+ if (!NIL_P(rb_ldap_indifferent_hash_aref(other_options, "nocanon")))
153
+ {
154
+ /* Inspired by the ldapsearch -N option, inspired by the code in OpenLDAP (BSD style license) in clients/tools/common.c */
155
+ ldapdata->err = ldap_set_option( ldapdata->ldap, LDAP_OPT_X_SASL_NOCANON, LDAP_OPT_ON);
156
+ Check_LDAP_Result(ldapdata->err);
157
+ }
150
158
  case 6:
151
159
  /* nothing. this requires credentials to be parsed first. we'll get defaults after arg-scanning */
152
160
  case 5:
153
- clientctrls = rb_ldap_get_controls (arg5);
161
+ if(!NIL_P(arg5))
162
+ clientctrls = rb_ldap_get_controls (arg5);
154
163
  /* down seems more likely */
155
164
  case 4:
156
- serverctrls = rb_ldap_get_controls (arg4);
165
+ if(!NIL_P(arg4))
166
+ serverctrls = rb_ldap_get_controls (arg4);
157
167
  /* down seems more likely */
158
168
  case 3:
159
- cred->bv_val = StringValueCStr (arg3);
160
- cred->bv_len = RSTRING_LEN (arg3);
169
+ if(!NIL_P(arg3))
170
+ {
171
+ cred->bv_val = StringValueCStr (arg3);
172
+ cred->bv_len = RSTRING_LEN (arg3);
173
+ }
161
174
  /* down seems more likely */
162
175
  case 2: /* don't need the cred for GSSAPI */
163
176
  dn = StringValuePtr (arg1);
data/test/moz_cert.rb CHANGED
@@ -1,7 +1,6 @@
1
1
  #!/usr/bin/ruby
2
2
 
3
3
  require 'rubygems'
4
- # gem 'ruby-ldap', '~> 0.9.12'
5
4
  require 'ldap'
6
5
  require 'optparse'
7
6
  require 'pp'
metadata CHANGED
@@ -1,17 +1,21 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-ldap
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.13
4
+ version: 0.9.14
5
+ prerelease:
5
6
  platform: ruby
6
7
  authors:
7
8
  - Alexey Chebotar
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2013-06-05 00:00:00.000000000 Z
12
+ date: 2013-08-28 00:00:00.000000000 Z
12
13
  dependencies: []
13
- description: |
14
- It provides the interface to some LDAP libraries (e.g. OpenLDAP, Netscape SDK and Active Directory). The common API for application development is described in RFC1823 and is supported by Ruby/LDAP.
14
+ description: ! 'It provides the interface to some LDAP libraries (e.g. OpenLDAP, Netscape
15
+ SDK and Active Directory). The common API for application development is described
16
+ in RFC1823 and is supported by Ruby/LDAP.
17
+
18
+ '
15
19
  email: alexey.chebotar@gmail.com
16
20
  executables: []
17
21
  extensions:
@@ -24,68 +28,69 @@ files:
24
28
  - NOTES
25
29
  - README
26
30
  - TODO
27
- - extconf.rb
28
- - lib/ldap/control.rb
29
- - lib/ldap/ldif.rb
30
- - lib/ldap/schema.rb
31
+ - test/ext.rb
32
+ - test/compare.rb
33
+ - test/bind-sasl.rb
34
+ - test/misc1.rb
31
35
  - test/add.rb
36
+ - test/tc_schema.rb
32
37
  - test/add2.rb
38
+ - test/search.rb
33
39
  - test/add3.rb
34
- - test/bind-ldaps.rb
35
- - test/bind-sasl.rb
40
+ - test/modrdn.rb
36
41
  - test/bind-ssl.rb
37
- - test/bind.rb
38
- - test/compare.rb
39
- - test/conf.rb
42
+ - test/setup.rb
43
+ - test/search3.rb
40
44
  - test/delete.rb
41
- - test/ext.rb
42
- - test/misc1.rb
43
- - test/misc2.rb
44
- - test/modrdn.rb
45
- - test/moz_cert.rb
46
- - test/search.rb
47
45
  - test/search2.rb
48
- - test/search3.rb
49
- - test/setup.rb
50
- - test/subschema.rb
51
46
  - test/tc_conn.rb
52
- - test/tc_ldif.rb
53
- - test/tc_schema.rb
54
- - test/tc_search.rb
55
47
  - test/ts_ldap.rb
48
+ - test/conf.rb
49
+ - test/misc2.rb
50
+ - test/bind-ldaps.rb
51
+ - test/tc_search.rb
52
+ - test/bind.rb
53
+ - test/tc_ldif.rb
54
+ - test/subschema.rb
55
+ - test/moz_cert.rb
56
+ - lib/ldap/schema.rb
57
+ - lib/ldap/control.rb
58
+ - lib/ldap/ldif.rb
59
+ - extconf.rb
56
60
  - rbldap.h
57
61
  - win/winlber.h
58
62
  - win/winldap.h
59
- - clientauth.c
60
63
  - conn.c
64
+ - sslconn.c
61
65
  - entry.c
66
+ - clientauth.c
62
67
  - ldap.c
63
- - misc.c
64
68
  - mod.c
65
69
  - saslconn.c
66
- - sslconn.c
70
+ - misc.c
67
71
  - win/wldap32.def
68
72
  homepage: http://ruby-ldap.sourceforge.net/
69
73
  licenses: []
70
- metadata: {}
71
74
  post_install_message:
72
75
  rdoc_options: []
73
76
  require_paths:
74
77
  - lib
75
78
  required_ruby_version: !ruby/object:Gem::Requirement
79
+ none: false
76
80
  requirements:
77
- - - '>='
81
+ - - ! '>='
78
82
  - !ruby/object:Gem::Version
79
83
  version: '0'
80
84
  required_rubygems_version: !ruby/object:Gem::Requirement
85
+ none: false
81
86
  requirements:
82
- - - '>='
87
+ - - ! '>='
83
88
  - !ruby/object:Gem::Version
84
89
  version: '0'
85
90
  requirements: []
86
91
  rubyforge_project: ruby-ldap
87
- rubygems_version: 2.0.2
92
+ rubygems_version: 1.8.25
88
93
  signing_key:
89
- specification_version: 4
94
+ specification_version: 3
90
95
  summary: Ruby/LDAP is an extension module for Ruby
91
96
  test_files: []
checksums.yaml DELETED
@@ -1,7 +0,0 @@
1
- ---
2
- SHA1:
3
- metadata.gz: df51bf1583a52ae481a36a094cc0b13485cb4427
4
- data.tar.gz: c68dcb046b37bf72da38bb609a4b20a041bae0ad
5
- SHA512:
6
- metadata.gz: 61ca227999a49618d0a87076578c7a2699f0d0fd39fab8ebfa95f011178bfeff8b120f88dc63137cec493f8d168a9a32a8462c56e1020b9b115a41e27dc9ce4f
7
- data.tar.gz: 91b6abc130135548351a4a6450eeab35add793246d118db165d91c0fefd5c79cde9047b89401219e3a7a77527e0578cb93b19e0ecddda5c45e8d0bc10d657095