rkerberos 0.2.1 → 0.2.3

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7d95bc44b05fe9b2d7d50af063944d2464a39e2387c6af3c9b8dbefd68025e94
4
- data.tar.gz: 8dcdcec07fcdd598065fc7e826dda60b66a683c0cfb500aaa594fdbe5b5c3326
3
+ metadata.gz: 71575b32bb628b8425101d837de9c86ce1dd5e865a5db93462457266c8eb4d2c
4
+ data.tar.gz: 99128f7462ed48175619b224d838f2dd00b7d7f972963530c1276037fe299792
5
5
  SHA512:
6
- metadata.gz: ee3844d89f82e24b9447f67538e40f9af8d4df630c3e3da757e0ce8c3d54b1ba1d3a57d48db0c2ed4001a687dd1ccfbcb2e3c5ef6eb120b5eed5802964a47f74
7
- data.tar.gz: 93003f70201a17ecbc3f158cf4fa997657ee1d25b1c28d3e3019207f3b3664d880db4d3297a8a542d54343ad4fe2f38afa607b028ea161d6bbb50a1a526f4e63
6
+ metadata.gz: d90e4d248f40ae3cd13d02febfe71cd92e0dbc4712f37326444eff8368e5326a55980424263f30d8983a1ddd674b948034cbad0c3ce3e6606649e72feb77ca57
7
+ data.tar.gz: aa5bd082185a5e8b11b4d50d9e58e3fc76f954b9694d5f00aa5c53e4aeca5739c737a4c4477cc028b374391b108b4a4d166c25ce557b4a39eee39f5a1758ad16
data/CHANGES.md CHANGED
@@ -1,4 +1,24 @@
1
- = 0.2.1 - 1-Mar-2026
1
+ # 0.2.3 - 8-Mar-2026
2
+ * All Kadm5 related classes are skipped if not found.
3
+ * Several updates to the spec helper that mainly revolved around supporting
4
+ MS Windows and/or skipping specs when Kadm5 classes aren't found.
5
+ * More potential memory issues addressed, mainly stuff that only happened
6
+ on an error path.
7
+
8
+ # 0.2.2 - 3-Mar-2026
9
+ * Added custom .dup methods for CredentialsCache and Keytab.
10
+ * Added the keytab_name and keytab_type methods to Keytab.
11
+ * Added the cache_name, cache_type and principal methods to CredentialsCache.
12
+ * The Keytab#get_entry method now properly honors the vno and encoding type arguments.
13
+ * Fixed the max_life and max_rlife attributes in Config.
14
+ * Fixed the get_privileges method in Kadm5.
15
+ * Fixed the change_password method in Kadm5 and added specs for it. Previously it would
16
+ generally always return true because it wasn't considering KDC failures, only raw
17
+ function failures.
18
+ * Heaps of memory leak fixes. Get it? Heaps? Right, I'll see myself out.
19
+ * Converted the CHANGES and MANIFEST files to markdown.
20
+
21
+ # 0.2.1 - 1-Mar-2026
2
22
  * Added the verify_init_creds and an authenticate! methods.
3
23
  * The Context constructor now accepts optional :secure and/or :profile arguments
4
24
  for different types of contexts.
@@ -10,37 +30,37 @@
10
30
  * The rake-compiler gem is now a development dependency, not a runtime
11
31
  dependency (thanks Ondřej Gajdušek).
12
32
 
13
- = 0.2.0 - 14-Feb-2026
33
+ # 0.2.0 - 14-Feb-2026
14
34
  * Added Docker and Podman support for running tests in isolated environments with Kerberos and OpenLDAP services.
15
35
  * Updated documentation with modern testing and development workflows, including container-based instructions.
16
36
  * Improved compatibility for Ruby 3.4 and later.
17
37
  * Enhanced build and test automation using docker-compose and podman-compose.
18
38
  * Various bug fixes, code cleanups, and test improvements.
19
39
 
20
- = 0.1.5 - 17-Oct-2016
40
+ # 0.1.5 - 17-Oct-2016
21
41
  * Fix build error on Ruby 2.0.0/2.1 with CFLAGS concatenation
22
42
 
23
- = 0.1.4 - 14-Oct-2016
43
+ # 0.1.4 - 14-Oct-2016
24
44
  * Implement db_args functionality in kadmin (fixes #8)
25
45
  * Fix a double-free error when setting the realm for a principal
26
46
  * Fix an error in policy creation that would sometimes cause a communication failure
27
47
  * Set C99 as the C Standard and fix all compiler warnings at this level
28
48
 
29
- = 0.1.3 - 07-Sep-2013
49
+ # 0.1.3 - 07-Sep-2013
30
50
  * Add optional 'service' argument to get_init_creds_password (fixes #3)
31
51
  * Artistic License 2.0 text now included (fixes #2)
32
52
 
33
- = 0.1.2 - 24-Jun-2013
53
+ # 0.1.2 - 24-Jun-2013
34
54
  * Fix kadm5clnt build issue on EL6
35
55
  * Remove admin_keytab references for krb5 1.11
36
56
  * Add Gemfile
37
57
  * Replace deprecated Config with RbConfig (Ruby 2)
38
58
 
39
- = 0.1.1 - 08-May-2013
59
+ # 0.1.1 - 08-May-2013
40
60
  * Add credential cache argument to get_init_creds_keytab
41
61
  * Fixed invalid VALUE declarations affecting non-gcc compilers
42
62
  * Add OS X install instructions
43
63
 
44
- = 0.1.0 - 28-Apr-2011
64
+ # 0.1.0 - 28-Apr-2011
45
65
  * Initial release. This is effectively a re-release of my own custom branch
46
66
  of the krb5-auth library, with some minor changes.
data/MANIFEST.md CHANGED
@@ -1,16 +1,24 @@
1
- CHANGES.md
2
- rkerberos.gemspec
3
- MANIFEST.md
4
- Rakefile
5
- README
6
- ext/ccache.c
7
- ext/context.c
8
- ext/extconf.rb
9
- ext/kadm5.c
10
- ext/keytab.c
11
- ext/keytab_entry.c
12
- ext/rkerberos.c
13
- ext/rkerberos.h
14
- ext/policy.c
15
- ext/principal.c
16
- test/test_krb5.rb
1
+ * CHANGES.md
2
+ * rkerberos.gemspec
3
+ * MANIFEST.md
4
+ * Rakefile
5
+ * README
6
+ * ext/ccache.c
7
+ * ext/context.c
8
+ * ext/extconf.rb
9
+ * ext/kadm5.c
10
+ * ext/keytab.c
11
+ * ext/keytab_entry.c
12
+ * ext/rkerberos.c
13
+ * ext/rkerberos.h
14
+ * ext/policy.c
15
+ * ext/principal.c
16
+ * spec/config_spec.rb
17
+ * spec/context_spec.rb
18
+ * spec/credentials_spec.rb
19
+ * spec/kadm5_spec.rb
20
+ * spec/keytab_entry_spec.rb
21
+ * spec/krb5_keytab_spec.rb
22
+ * spec/krb5_spec.rb
23
+ * spec/policy_spec.rb
24
+ * spec/principal_spec.rb
data/Rakefile CHANGED
@@ -100,7 +100,10 @@ namespace :spec do
100
100
 
101
101
  FileUtils.rm_rf('Gemfile.lock')
102
102
  begin
103
- sh "#{compose} build --no-cache rkerberos-test" unless fast
103
+ unless fast
104
+ sh "#{compose} build --no-cache kerberos-kdc"
105
+ sh "#{compose} build --no-cache rkerberos-test"
106
+ end
104
107
  sh "#{compose} run --rm rkerberos-test"
105
108
  ensure
106
109
  # redirect stderr so missing-container messages don't appear
@@ -157,6 +157,40 @@ static VALUE rkrb5_ccache_default_name(VALUE self){
157
157
  return rb_str_new2(krb5_cc_default_name(ptr->ctx));
158
158
  }
159
159
 
160
+ // Wrapper for krb5_cc_get_name; returns the actual ccache name.
161
+ static VALUE rkrb5_ccache_get_name(VALUE self){
162
+ RUBY_KRB5_CCACHE* ptr;
163
+ const char *name;
164
+
165
+ TypedData_Get_Struct(self, RUBY_KRB5_CCACHE, &rkrb5_ccache_data_type, ptr);
166
+
167
+ if(!ptr->ctx)
168
+ rb_raise(cKrb5Exception, "no context has been established");
169
+
170
+ name = krb5_cc_get_name(ptr->ctx, ptr->ccache);
171
+ if(!name)
172
+ rb_raise(cKrb5Exception, "krb5_cc_get_name returned NULL");
173
+
174
+ return rb_str_new2(name);
175
+ }
176
+
177
+ // Wrapper for krb5_cc_get_type; returns the cache type string.
178
+ static VALUE rkrb5_ccache_get_type(VALUE self){
179
+ RUBY_KRB5_CCACHE* ptr;
180
+ const char *type;
181
+
182
+ TypedData_Get_Struct(self, RUBY_KRB5_CCACHE, &rkrb5_ccache_data_type, ptr);
183
+
184
+ if(!ptr->ctx)
185
+ rb_raise(cKrb5Exception, "no context has been established");
186
+
187
+ type = krb5_cc_get_type(ptr->ctx, ptr->ccache);
188
+ if(!type)
189
+ rb_raise(cKrb5Exception, "krb5_cc_get_type returned NULL");
190
+
191
+ return rb_str_new2(type);
192
+ }
193
+
160
194
  /*
161
195
  * call-seq:
162
196
  * ccache.primary_principal
@@ -173,6 +207,11 @@ static VALUE rkrb5_ccache_primary_principal(VALUE self){
173
207
  if(!ptr->ctx)
174
208
  rb_raise(cKrb5Exception, "no context has been established");
175
209
 
210
+ if(ptr->principal){
211
+ krb5_free_principal(ptr->ctx, ptr->principal);
212
+ ptr->principal = NULL;
213
+ }
214
+
176
215
  kerror = krb5_cc_get_principal(ptr->ctx, ptr->ccache, &ptr->principal);
177
216
 
178
217
  if(kerror)
@@ -183,7 +222,15 @@ static VALUE rkrb5_ccache_primary_principal(VALUE self){
183
222
  if(kerror)
184
223
  rb_raise(cKrb5Exception, "krb5_unparse_name: %s", error_message(kerror));
185
224
 
186
- return rb_str_new2(name);
225
+ VALUE v_name = rb_str_new2(name);
226
+ krb5_free_unparsed_name(ptr->ctx, name);
227
+
228
+ return v_name;
229
+ }
230
+
231
+ // Simple wrapper around krb5_cc_get_principal returning a principal name string.
232
+ static VALUE rkrb5_ccache_principal(VALUE self){
233
+ return rkrb5_ccache_primary_principal(self);
187
234
  }
188
235
 
189
236
  /*
@@ -220,6 +267,10 @@ static VALUE rkrb5_ccache_destroy(VALUE self){
220
267
  if(ptr->ctx)
221
268
  krb5_free_context(ptr->ctx);
222
269
 
270
+ ptr->ccache = NULL;
271
+ ptr->ctx = NULL;
272
+ ptr->principal = NULL;
273
+
223
274
  rb_raise(cKrb5Exception, "krb5_cc_destroy: %s", error_message(kerror));
224
275
  }
225
276
  }
@@ -237,6 +288,47 @@ static VALUE rkrb5_ccache_destroy(VALUE self){
237
288
  return v_bool;
238
289
  }
239
290
 
291
+ // Duplicate the credentials cache object.
292
+ // call-seq:
293
+ // ccache.dup -> new_ccache
294
+ //
295
+ // Returns a new Kerberos::Krb5::CredentialsCache that references the
296
+ // same underlying cache data. The new object has its own krb5 context so
297
+ // that closing one cache does not affect the other.
298
+ static VALUE rkrb5_ccache_dup(VALUE self){
299
+ RUBY_KRB5_CCACHE *ptr, *newptr;
300
+ krb5_error_code kerror;
301
+ VALUE newobj;
302
+
303
+ TypedData_Get_Struct(self, RUBY_KRB5_CCACHE, &rkrb5_ccache_data_type, ptr);
304
+
305
+ if(!ptr->ctx)
306
+ rb_raise(cKrb5Exception, "no context has been established");
307
+
308
+ // allocate new ruby object and struct
309
+ newobj = rkrb5_ccache_allocate(CLASS_OF(self));
310
+ TypedData_Get_Struct(newobj, RUBY_KRB5_CCACHE, &rkrb5_ccache_data_type, newptr);
311
+
312
+ // initialize a fresh context for the duplicate
313
+ kerror = krb5_init_context(&newptr->ctx);
314
+ if(kerror){
315
+ rb_raise(cKrb5Exception, "krb5_init_context: %s", error_message(kerror));
316
+ }
317
+
318
+ // perform ccache duplication using the new context
319
+ kerror = krb5_cc_dup(newptr->ctx, ptr->ccache, &newptr->ccache);
320
+ if(kerror){
321
+ krb5_free_context(newptr->ctx);
322
+ newptr->ctx = NULL;
323
+ rb_raise(cKrb5Exception, "krb5_cc_dup: %s", error_message(kerror));
324
+ }
325
+
326
+ // principal is not copied; let callers query primary_principal on each
327
+ newptr->principal = NULL;
328
+
329
+ return newobj;
330
+ }
331
+
240
332
  void Init_ccache(void){
241
333
  /* The Kerberos::Krb5::CredentialsCache class encapsulates a Kerberos credentials cache. */
242
334
  cKrb5CCache = rb_define_class_under(cKrb5, "CredentialsCache", rb_cObject);
@@ -250,8 +342,13 @@ void Init_ccache(void){
250
342
  // Instance Methods
251
343
  rb_define_method(cKrb5CCache, "close", rkrb5_ccache_close, 0);
252
344
  rb_define_method(cKrb5CCache, "default_name", rkrb5_ccache_default_name, 0);
345
+ rb_define_method(cKrb5CCache, "cache_name", rkrb5_ccache_get_name, 0);
346
+ rb_define_method(cKrb5CCache, "cache_type", rkrb5_ccache_get_type, 0);
253
347
  rb_define_method(cKrb5CCache, "destroy", rkrb5_ccache_destroy, 0);
254
348
  rb_define_method(cKrb5CCache, "primary_principal", rkrb5_ccache_primary_principal, 0);
349
+ rb_define_method(cKrb5CCache, "principal", rkrb5_ccache_principal, 0);
350
+ rb_define_method(cKrb5CCache, "dup", rkrb5_ccache_dup, 0);
351
+ rb_define_alias(cKrb5CCache, "clone", "dup");
255
352
 
256
353
  // Aliases
257
354
  rb_define_alias(cKrb5CCache, "delete", "destroy");
@@ -1,3 +1,4 @@
1
+ #ifdef HAVE_KADM5_ADMIN_H
1
2
  #include <rkerberos.h>
2
3
 
3
4
  VALUE cKadm5Config;
@@ -8,9 +9,10 @@ VALUE cKeySalt;
8
9
  static void rkadm5_config_typed_free(void *ptr) {
9
10
  if (!ptr) return;
10
11
  RUBY_KADM5_CONFIG *c = (RUBY_KADM5_CONFIG *)ptr;
11
- kadm5_free_config_params(c->ctx, &c->config);
12
- if (c->ctx)
12
+ if (c->ctx) {
13
+ kadm5_free_config_params(c->ctx, &c->config);
13
14
  krb5_free_context(c->ctx);
15
+ }
14
16
  free(c);
15
17
  }
16
18
 
@@ -263,12 +265,12 @@ static VALUE rkadm5_config_inspect(VALUE self){
263
265
  rb_str_buf_append(v_str, rb_inspect(rb_iv_get(self, "@mkey_from_kbd")));
264
266
  rb_str_buf_cat2(v_str, " ");
265
267
 
266
- rb_str_buf_cat2(v_str, "maxlife=");
267
- rb_str_buf_append(v_str, rb_inspect(rb_iv_get(self, "@maxlife")));
268
+ rb_str_buf_cat2(v_str, "max_life=");
269
+ rb_str_buf_append(v_str, rb_inspect(rb_iv_get(self, "@max_life")));
268
270
  rb_str_buf_cat2(v_str, " ");
269
271
 
270
- rb_str_buf_cat2(v_str, "maxrlife=");
271
- rb_str_buf_append(v_str, rb_inspect(rb_iv_get(self, "@maxrlife")));
272
+ rb_str_buf_cat2(v_str, "max_rlife=");
273
+ rb_str_buf_append(v_str, rb_inspect(rb_iv_get(self, "@max_rlife")));
272
274
  rb_str_buf_cat2(v_str, " ");
273
275
 
274
276
  rb_str_buf_cat2(v_str, "num_keysalts=");
@@ -332,4 +334,5 @@ void Init_config(void){
332
334
  cKeySalt = rb_define_class_under(cKadm5, "KeySalt", rb_cObject);
333
335
  rb_define_attr(cKeySalt, "enctype", 1, 0);
334
336
  rb_define_attr(cKeySalt, "salttype", 1, 0);
335
- }
337
+ }
338
+ #endif
@@ -61,6 +61,8 @@ static VALUE rkrb5_context_close(VALUE self){
61
61
  *
62
62
  * :secure => true|false # Use config files only, ignore env variables
63
63
  * :profile => '/path/to/krb5.conf' # Use the specified profile file
64
+ *
65
+ * Note that the profile option may not be supported on your platform.
64
66
  */
65
67
  static VALUE rkrb5_context_initialize(int argc, VALUE *argv, VALUE self){
66
68
  RUBY_KRB5_CONTEXT* ptr;
@@ -92,6 +94,9 @@ static VALUE rkrb5_context_initialize(int argc, VALUE *argv, VALUE self){
92
94
  * is used when the :secure option is truthy.
93
95
  */
94
96
  if (!NIL_P(v_profile)){
97
+ #ifndef HAVE_PROFILE_INIT_PATH
98
+ rb_raise(rb_eArgError, "profile option not supported on this platform");
99
+ #else
95
100
  Check_Type(v_profile, T_STRING);
96
101
 
97
102
  const char *profile_path = StringValueCStr(v_profile);
@@ -110,6 +115,7 @@ static VALUE rkrb5_context_initialize(int argc, VALUE *argv, VALUE self){
110
115
  rb_raise(cKrb5Exception, "krb5_init_context_profile: %s", error_message(kerror));
111
116
 
112
117
  return self;
118
+ #endif
113
119
  }
114
120
 
115
121
  // No profile given, choose secure or normal init.
@@ -14,8 +14,19 @@ else
14
14
  else
15
15
  dir_config('rkerberos', '/usr/local')
16
16
  end
17
+
18
+ if File::ALT_SEPARATOR
19
+ kfw_dir = ENV['KRB5_DIR'] || 'C:/Program Files/MIT/Kerberos'
20
+ kfw_inc = ENV['KRB5_INCLUDE'] || File.join(kfw_dir, 'include')
21
+ kfw_lib = ENV['KRB5_LIB'] || File.join(kfw_dir, 'lib')
22
+ $INCFLAGS << " -I\"#{kfw_inc}\""
23
+ $LDFLAGS << " -L\"#{kfw_lib}\""
24
+ end
25
+
17
26
  have_header('krb5.h')
18
- have_library('krb5')
27
+
28
+ have_library('krb5') || have_library('krb5_64')
29
+ have_library('comerr') || have_library('comerr64')
19
30
  end
20
31
 
21
32
  pkg_config('com_err') || have_library('com_err')
@@ -26,8 +37,10 @@ end
26
37
 
27
38
  if pkg_config('kdb5') || have_library('kdb5')
28
39
  have_header('kdb.h')
29
- else
30
- raise 'kdb5 library not found'
40
+ end
41
+
42
+ if have_header('profile.h')
43
+ have_func('profile_init_path')
31
44
  end
32
45
 
33
46
  create_makefile('rkerberos')