kerberos 0.2 → 0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/README +3 -9
  2. data/ext/ruby_kerberos.c +25 -25
  3. metadata +2 -2
data/README CHANGED
@@ -1,11 +1,5 @@
1
1
 
2
- To install find out where your kerberos libraries and header files are, then do the following:
3
-
4
- ruby extconf.rb --with-kerberos-dir=/kerberos/install/path (/usr/local,/usr,etc..)
5
- make
6
- make install
7
-
8
-
9
- If the compile fails make sure you have the libraries and krb5.h on your system, and that krb5.h is the MIT version, NOT Heimdal.
10
-
2
+ The gem includes krb5.h from the MIT distribution, and admin.h which includes just what is needed from misc other include files
3
+ that will not get installed on your system.
11
4
 
5
+ Documentation is in the c source, so running rdoc on the ext directory will give you the documentation.
@@ -14,7 +14,7 @@ int krb5_error_number = 0;
14
14
  void *kadm5_handle = NULL;
15
15
 
16
16
  static VALUE Kadm5_errstr(VALUE self);
17
- int Kadm55_register_error(int error);
17
+ int Kadm5_register_error(int error);
18
18
  static VALUE Kadm5_init_with_password(VALUE self,VALUE _auser,VALUE _apass);
19
19
  static VALUE Kadm5_create_principal(VALUE self, VALUE _user, VALUE _pass, VALUE options);
20
20
  static VALUE Kadm5_delete_principal(VALUE self, VALUE _auser);
@@ -24,7 +24,6 @@ int Krb5_register_error(int error);
24
24
  static VALUE Krb5_change_password(VALUE self, VALUE _user, VALUE _pass, VALUE _newpass);
25
25
  static VALUE Krb5_get_init_creds_password(VALUE self, VALUE _user, VALUE _pass);
26
26
 
27
-
28
27
  int Krb5_register_error(int error) {
29
28
  krb5_error_number = error;
30
29
  return 0;
@@ -50,7 +49,7 @@ static VALUE Kadm5_errstr(VALUE self) {
50
49
  /* returns the last error message generated or nil */
51
50
  static VALUE Krb5_errstr(VALUE self) {
52
51
  char error[255];
53
- if (kadm5_error_number == 0) {
52
+ if (krb5_error_number == 0) {
54
53
  return Qnil;
55
54
  }
56
55
  strncpy(error,error_message(krb5_error_number), sizeof(error));
@@ -71,11 +70,11 @@ static VALUE Kadm5_init_with_password(VALUE self, VALUE _auser, VALUE _apass) {
71
70
  Check_Type(_apass,T_STRING);
72
71
  char * auser = STR2CSTR(_auser);
73
72
  char * apass = STR2CSTR(_apass);
74
- kadm5_ret_t rc;
73
+ kadm5_ret_t ret;
75
74
 
76
- rc = kadm5_init_with_password(auser, apass, KADM5_ADMIN_SERVICE, NULL, KADM5_STRUCT_VERSION, KADM5_API_VERSION_2, &kadm5_handle);
77
- if (rc) {
78
- Kadm5_register_error(rc);
75
+ ret = kadm5_init_with_password(auser, apass, KADM5_ADMIN_SERVICE, NULL, KADM5_STRUCT_VERSION, KADM5_API_VERSION_2, &kadm5_handle);
76
+ if (ret) {
77
+ Kadm5_register_error(ret);
79
78
  return Qfalse;
80
79
  }
81
80
  return Qtrue;
@@ -241,6 +240,9 @@ static VALUE Krb5_change_password(VALUE self, VALUE _user, VALUE _pass, VALUE _n
241
240
  int pw_result;
242
241
  krb5_data pw_res_string, res_string;
243
242
 
243
+ memset(&princ, 0, sizeof(princ));
244
+ memset(&creds, 0, sizeof(creds));
245
+
244
246
  if ((krbret = krb5_init_context(&ctx))) {
245
247
  Krb5_register_error(krbret);
246
248
  return Qfalse;
@@ -259,17 +261,27 @@ static VALUE Krb5_change_password(VALUE self, VALUE _user, VALUE _pass, VALUE _n
259
261
  return Qfalse;
260
262
  }
261
263
 
262
- krbret = krb5_change_password(ctx, &creds, newpass, &pw_result, &pw_res_string, &res_string );
263
- if (pw_result) {
264
+ /*
265
+ * if ((krbret = krb5_change_password(ctx, &creds, newpass, &pw_result, &pw_res_string, &res_string ))) {
266
+ * krb5_free_cred_contents(ctx, &creds);
267
+ * krb5_free_principal(ctx, princ);
268
+ * krb5_free_context(ctx);
269
+ * Krb5_register_error(krbret);
270
+ * return Qfalse;
271
+ * }
272
+ */
273
+
274
+ if ((krbret = krb5_set_password(ctx, &creds, newpass, NULL, &pw_result, &pw_res_string, &res_string ))) {
264
275
  krb5_free_cred_contents(ctx, &creds);
265
- krb5_free_principal(ctx, princ);
276
+ krb5_free_principal(ctx, princ);
266
277
  krb5_free_context(ctx);
267
- Krb5_register_error(pw_result);
278
+ Krb5_register_error(krbret);
268
279
  return Qfalse;
269
280
  }
270
281
 
282
+
271
283
  krb5_free_cred_contents(ctx, &creds);
272
- krb5_free_principal(ctx, princ);
284
+ krb5_free_principal(ctx, princ);
273
285
  krb5_free_context(ctx);
274
286
  return Qtrue;
275
287
 
@@ -304,8 +316,8 @@ static VALUE Krb5_get_init_creds_password(VALUE self, VALUE _user, VALUE _pass)
304
316
  }
305
317
 
306
318
  if ((krbret = krb5_get_init_creds_password( ctx, &creds, princ, pass, 0, NULL, 0, NULL, NULL))) {
307
- krb5_free_context(ctx);
308
319
  krb5_free_principal(ctx, princ);
320
+ krb5_free_context(ctx);
309
321
  Krb5_register_error(krbret);
310
322
  return Qfalse;
311
323
  }
@@ -317,21 +329,10 @@ static VALUE Krb5_get_init_creds_password(VALUE self, VALUE _user, VALUE _pass)
317
329
  return Qtrue;
318
330
  }
319
331
 
320
- VALUE Krb5_init(VALUE self)
321
- {
322
- return self;
323
- }
324
-
325
- VALUE Kadm5_init(VALUE self)
326
- {
327
- return self;
328
- }
329
-
330
332
  void Init_ruby_kerberos() {
331
333
  mKerberos = rb_define_module("Kerberos");
332
334
 
333
335
  cKadm5 = rb_define_class_under(mKerberos,"Kadm5", rb_cObject);
334
- rb_define_method(cKadm5, "initialize", Kadm5_init,0);
335
336
  rb_define_method(cKadm5, "errstr", Kadm5_errstr,0);
336
337
  rb_define_method(cKadm5, "init_with_password", Kadm5_init_with_password,2);
337
338
  rb_define_method(cKadm5, "create_principal", Kadm5_create_principal,3);
@@ -354,7 +355,6 @@ VALUE Kadm5_init(VALUE self)
354
355
  rb_define_const(cKadm5,"KRB5_KDB_NEW_PRINC",INT2NUM(KRB5_KDB_NEW_PRINC));
355
356
 
356
357
  cKrb5 = rb_define_class_under(mKerberos,"Krb5", rb_cObject);
357
- rb_define_method(cKrb5, "initialize", Krb5_init,0);
358
358
  rb_define_method(cKrb5, "errstr", Krb5_errstr,0);
359
359
  rb_define_method(cKrb5, "get_init_creds_password", Krb5_get_init_creds_password,2);
360
360
  rb_define_method(cKrb5, "change_password", Krb5_change_password,3);
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.8.11
3
3
  specification_version: 1
4
4
  name: kerberos
5
5
  version: !ruby/object:Gem::Version
6
- version: "0.2"
7
- date: 2006-09-22 00:00:00 -07:00
6
+ version: "0.3"
7
+ date: 2006-09-23 00:00:00 -07:00
8
8
  summary: Kerberos binding for ruby
9
9
  require_paths:
10
10
  - lib