ruby-ldap 0.9.10 → 0.9.11

Sign up to get free protection for your applications and to get access to all the features.
Files changed (7) hide show
  1. data/ChangeLog +5 -1
  2. data/NOTES +14 -1
  3. data/README +1 -2
  4. data/rbldap.h +2 -2
  5. data/saslconn.c +85 -32
  6. data/test/setup.rb +2 -2
  7. metadata +28 -28
data/ChangeLog CHANGED
@@ -1,9 +1,13 @@
1
+ Mon Mar 15 19:15:49 UTC 2010 Alexey Chebotar <alexey.chebotar@gmail.com>
2
+ * Version 0.9.11
3
+ * Allow passing SASL interaction options.
4
+ Thanks to Anthony M. Martinez.
5
+
1
6
  Fri Jan 29 07:50:30 UTC 2010 Alexey Chebotar <alexey.chebotar@gmail.com>
2
7
  * Version 0.9.10
3
8
  * Added controls and referral extraction to #search_ext and
4
9
  #search_ext2. Thanks to Michael Granger.
5
10
 
6
-
7
11
  Thu Jun 11 06:51:30 UTC 2009 Alexey Chebotar <alexey.chebotar@gmail.com>
8
12
  * Version 0.9.9
9
13
  * Fixed LDAP::VERSION. Thanks to Kouhei Sutou
data/NOTES CHANGED
@@ -1,4 +1,17 @@
1
- $Id: NOTES,v 1.4 2006/08/09 11:22:25 ianmacd Exp $
1
+ 0.9.11
2
+ -----
3
+
4
+ Allow passing SASL interaction options
5
+
6
+ This adds a hash parameter "options" to LDAP::Conn.sasl_bind, which
7
+ can take :authzid, :authcid, and :realm (and corresponding strings),
8
+ for SASL authentication.
9
+
10
+ Also, refactored the rb_scan_args inside rb_ldap_conn_sasl_bind to use
11
+ C's case fallthrough, leading to less code repetition.
12
+
13
+ Tnahks to Anthony M. Martinez.
14
+
2
15
 
3
16
  0.9.10
4
17
  -----
data/README CHANGED
@@ -1,7 +1,5 @@
1
1
  Ruby/LDAP -- A Ruby extension library for LDAP
2
2
 
3
- $Id: README,v 1.19 2009/03/19 15:25:20 alexey.chebotar Exp $
4
-
5
3
  Copyright (C) 2000-2004 Takaaki Tateishi <ttate@users.sourceforge.net>
6
4
  Copyright (C) 2005-2006 Ian Macdonald <ian@caliban.org>
7
5
  Copyright (C) 2009 Alexey Chebotar <alexey.chebotar@gmail.com>
@@ -265,3 +263,4 @@ This list maybe not correct. If you notice mistakes of this list, please point o
265
263
  * S. Potter [mbbx6spp]: Gem Packaging Support
266
264
  * Kouhei Sutou
267
265
  * Michael Granger: Patch.
266
+ * Anthony M. Martinez: Patch.
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 10
31
- #define RB_LDAP_VERSION "0.9.10"
30
+ #define RB_LDAP_PATCH_VERSION 11
31
+ #define RB_LDAP_VERSION "0.9.11"
32
32
 
33
33
  #define LDAP_GET_OPT_MAX_BUFFER_SIZE (1024) /* >= sizeof(LDAPAPIInfo) */
34
34
 
data/saslconn.c CHANGED
@@ -16,17 +16,76 @@ extern VALUE rb_ldap_conn_initialize (int argc, VALUE argv[], VALUE self);
16
16
  extern VALUE rb_ldap_conn_rebind (VALUE self);
17
17
 
18
18
  #if defined(HAVE_LDAP_SASL_BIND_S)
19
+ #include <sasl/sasl.h>
20
+ VALUE
21
+ rb_ldap_indifferent_hash_aref(VALUE hash, const char *key)
22
+ {
23
+ VALUE symval = rb_hash_aref(hash, ID2SYM(rb_intern(key)));
24
+ if (!NIL_P(symval))
25
+ {
26
+ return symval;
27
+ }
28
+ return rb_hash_aref(hash, rb_str_new2(key)); /* this could be Qnil */
29
+ }
30
+
19
31
  int
20
- rb_ldap_sasl_interaction (LDAP * ld, unsigned flags, void *defaults, void *in)
32
+ rb_ldap_sasl_interaction (LDAP * ld, unsigned flags, void *de, void *in)
21
33
  {
22
- /* not implemented */
34
+ sasl_interact_t *interact = in;
35
+ VALUE options = (VALUE)de;
36
+
37
+ VALUE defvalue;
38
+ const char *dflt = NULL;
39
+
40
+ if (ld == NULL)
41
+ {
42
+ return LDAP_PARAM_ERROR;
43
+ }
44
+ if (flags == LDAP_SASL_INTERACTIVE)
45
+ {
46
+ rb_raise (rb_eLDAP_Error, "interactive bind not supported.");
47
+ }
48
+ while (!NIL_P(options) && interact->id != SASL_CB_LIST_END)
49
+ {
50
+ dflt = interact->defresult;
51
+ switch (interact->id)
52
+ {
53
+ case SASL_CB_GETREALM:
54
+ if (!NIL_P(defvalue = rb_ldap_indifferent_hash_aref(options, "realm")))
55
+ {
56
+ dflt = StringValuePtr(defvalue);
57
+ }
58
+ break;
59
+ case SASL_CB_AUTHNAME:
60
+ if (!NIL_P(defvalue = rb_ldap_indifferent_hash_aref(options, "authcid")))
61
+ {
62
+ dflt = StringValuePtr(defvalue);
63
+ }
64
+ break;
65
+ case SASL_CB_USER:
66
+ if (!NIL_P(defvalue = rb_ldap_indifferent_hash_aref(options, "authzid")))
67
+ {
68
+ dflt = StringValuePtr(defvalue);
69
+ }
70
+ break;
71
+ default:
72
+ /* Nothing. */
73
+ break;
74
+ }
75
+ if (dflt != NULL)
76
+ {
77
+ interact->result = dflt;
78
+ interact->len = strlen(dflt);
79
+ }
80
+ interact++;
81
+ }
23
82
  return LDAP_SUCCESS;
24
83
  }
25
84
 
26
85
  /*
27
86
  * call-seq:
28
- * conn.sasl_bind(dn=nil, mech=nil, cred=nil, sctrls=nil, cctrls=nil) => self
29
- * conn.sasl_bind(dn=nil, mech=nil, cred=nil, sctrls=nil, cctrls=nil)
87
+ * conn.sasl_bind(dn=nil, mech=nil, cred=nil, sctrls=nil, cctrls=nil, sasl_options=nil) => self
88
+ * conn.sasl_bind(dn=nil, mech=nil, cred=nil, sctrls=nil, cctrls=nil, sasl_options=nil)
30
89
  * { |conn| } => nil
31
90
  *
32
91
  * Bind an LDAP connection, using the DN, +dn+, the mechanism, +mech+, and the
@@ -35,15 +94,19 @@ rb_ldap_sasl_interaction (LDAP * ld, unsigned flags, void *defaults, void *in)
35
94
  * +sctrls+ is an array of server controls, whilst +cctrls+ is an array of
36
95
  * client controls.
37
96
  *
38
- * and the bind method, +method+. If a block is given, +self+ is yielded to
39
- * the block.
97
+ * sasl_options is a hash which should have the following keys:
98
+ *
99
+ * - +:authcid+ and +:authzid+ for alternate SASL authentication
100
+ * - +realm+ to specify the SASL realm
101
+ *
102
+ * If a block is given, +self+ is yielded to the block.
40
103
  */
41
104
  VALUE
42
105
  rb_ldap_conn_sasl_bind (int argc, VALUE argv[], VALUE self)
43
106
  {
44
107
  RB_LDAP_DATA *ldapdata;
45
108
 
46
- VALUE arg1, arg2, arg3, arg4, arg5;
109
+ VALUE arg1, arg2, arg3, arg4, arg5, sasl_options = Qnil;
47
110
  int version;
48
111
  char *dn = NULL;
49
112
  char *mechanism = NULL;
@@ -81,36 +144,26 @@ rb_ldap_conn_sasl_bind (int argc, VALUE argv[], VALUE self)
81
144
  {
82
145
  rb_raise (rb_eLDAP_Error, "already bound.");
83
146
  };
84
- switch (rb_scan_args (argc, argv, "23", &arg1, &arg2, &arg3, &arg4, &arg5))
147
+
148
+ switch (rb_scan_args (argc, argv, "24", &arg1, &arg2, &arg3, &arg4, &arg5, &sasl_options))
85
149
  {
86
- case 2: /* don't need the cred for GSSAPI */
87
- dn = StringValuePtr (arg1);
88
- mechanism = StringValuePtr (arg2);
89
- serverctrls = NULL;
90
- clientctrls = NULL;
91
- if (rb_iv_get (self, "@sasl_quiet") == Qtrue)
92
- sasl_flags = LDAP_SASL_QUIET;
93
- break;
94
- case 3:
95
- dn = StringValuePtr (arg1);
96
- mechanism = StringValuePtr (arg2);
97
- cred->bv_val = StringValueCStr (arg3);
98
- cred->bv_len = RSTRING_LEN (arg3);
99
- break;
150
+ case 6:
151
+ /* nothing. this requires credentials to be parsed first. we'll get defaults after arg-scanning */
152
+ case 5:
153
+ clientctrls = rb_ldap_get_controls (arg5);
154
+ /* down seems more likely */
100
155
  case 4:
101
- dn = StringValuePtr (arg1);
102
- mechanism = StringValuePtr (arg2);
156
+ serverctrls = rb_ldap_get_controls (arg4);
157
+ /* down seems more likely */
158
+ case 3:
103
159
  cred->bv_val = StringValueCStr (arg3);
104
160
  cred->bv_len = RSTRING_LEN (arg3);
105
- serverctrls = rb_ldap_get_controls (arg4);
106
- break;
107
- case 5:
161
+ /* down seems more likely */
162
+ case 2: /* don't need the cred for GSSAPI */
108
163
  dn = StringValuePtr (arg1);
109
164
  mechanism = StringValuePtr (arg2);
110
- cred->bv_val = StringValueCStr (arg3);
111
- cred->bv_len = RSTRING_LEN (arg3);
112
- serverctrls = rb_ldap_get_controls (arg4);
113
- clientctrls = rb_ldap_get_controls (arg5);
165
+ if (rb_iv_get (self, "@sasl_quiet") == Qtrue)
166
+ sasl_flags = LDAP_SASL_QUIET;
114
167
  break;
115
168
  default:
116
169
  rb_bug ("rb_ldap_conn_bind_s");
@@ -129,7 +182,7 @@ rb_ldap_conn_sasl_bind (int argc, VALUE argv[], VALUE self)
129
182
  ldapdata->err =
130
183
  ldap_sasl_interactive_bind_s (ldapdata->ldap, dn, mechanism,
131
184
  serverctrls, clientctrls, sasl_flags,
132
- rb_ldap_sasl_interaction, NULL);
185
+ rb_ldap_sasl_interaction, (void*)sasl_options);
133
186
 
134
187
  if (ldapdata->err == LDAP_SASL_BIND_IN_PROGRESS)
135
188
  {
data/test/setup.rb CHANGED
@@ -13,7 +13,7 @@ class TC_LDAPTest < Test::Unit::TestCase
13
13
  # Get the LDAP host and base DN from /etc/ldap.conf.
14
14
  def setup
15
15
  unless @@conn && @@conn.bound?
16
- File.open( '/etc/ldap.conf' ) do |f|
16
+ File.open( '/etc/openldap/slapd.conf' ) do |f|
17
17
  while line = f.gets
18
18
  if line =~ /^host\s+(\S+)$/
19
19
  @@host = $1
@@ -33,6 +33,6 @@ class TC_LDAPTest < Test::Unit::TestCase
33
33
  end
34
34
  end
35
35
 
36
- undef_method :default_test
36
+ #undef_method :default_test
37
37
 
38
38
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-ldap
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.10
4
+ version: 0.9.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexey Chebotar
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-02-01 00:00:00 +01:00
12
+ date: 2010-03-15 00:00:00 +01:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -30,44 +30,44 @@ files:
30
30
  - NOTES
31
31
  - README
32
32
  - TODO
33
- - extconf.rb
34
- - test/conf.rb
35
- - test/add3.rb
36
- - test/search2.rb
37
- - test/delete.rb
33
+ - lib/ldap/schema.rb
34
+ - lib/ldap/ldif.rb
35
+ - lib/ldap/control.rb
36
+ - test/add.rb
37
+ - test/misc1.rb
38
+ - test/modrdn.rb
39
+ - test/search3.rb
40
+ - test/add2.rb
38
41
  - test/ts_ldap.rb
39
- - test/setup.rb
42
+ - test/delete.rb
40
43
  - test/bind-ldaps.rb
41
- - test/search3.rb
42
- - test/tc_search.rb
44
+ - test/conf.rb
45
+ - test/tc_conn.rb
46
+ - test/search2.rb
47
+ - test/bind-sasl.rb
43
48
  - test/tc_schema.rb
44
- - test/tc_ldif.rb
45
- - test/compare.rb
46
- - test/search.rb
47
49
  - test/ext.rb
48
- - test/tc_conn.rb
49
- - test/add2.rb
50
+ - test/setup.rb
50
51
  - test/misc2.rb
52
+ - test/bind.rb
51
53
  - test/subschema.rb
54
+ - test/search.rb
55
+ - test/tc_search.rb
56
+ - test/tc_ldif.rb
57
+ - test/compare.rb
58
+ - test/add3.rb
52
59
  - test/bind-ssl.rb
53
- - test/bind.rb
54
- - test/misc1.rb
55
- - test/add.rb
56
- - test/bind-sasl.rb
57
- - test/modrdn.rb
58
- - lib/ldap/control.rb
59
- - lib/ldap/schema.rb
60
- - lib/ldap/ldif.rb
61
- - win/winldap.h
62
- - win/winlber.h
60
+ - extconf.rb
63
61
  - rbldap.h
64
- - misc.c
62
+ - win/winlber.h
63
+ - win/winldap.h
64
+ - sslconn.c
65
65
  - ldap.c
66
- - entry.c
67
66
  - conn.c
67
+ - entry.c
68
68
  - mod.c
69
69
  - saslconn.c
70
- - sslconn.c
70
+ - misc.c
71
71
  has_rdoc: true
72
72
  homepage: http://ruby-ldap.sourceforge.net/
73
73
  licenses: []