/* * call-seq: * destroy([cache_name]) * * Call krb5_cc_destroy to destroy all credentials in a cachefile. With no parameters, it destroys the credentials in the default cachefile. With one parameter, it destroys the credentials in the named cachefile. Returns true on success, raises Krb5Auth::Krb5::Exception on failure. */ static VALUE Krb5_destroy_creds(int argc, VALUE *argv, VALUE self) { struct ruby_krb5 *kerb; krb5_error_code krbret; char *cache_name; krb5_ccache cc; if (argc == 0) { cache_name = NULL; } else if (argc == 1) { Check_Type(argv[0], T_STRING); cache_name = STR2CSTR(argv[0]); } else { rb_raise(rb_eRuntimeError, "Invalid arguments"); } Data_Get_Struct(self, struct ruby_krb5, kerb); if (!kerb) { NOSTRUCT_EXCEPT(); return Qfalse; } if (cache_name == NULL) { krbret = krb5_cc_default(kerb->ctx, &cc); } else { krbret = krb5_cc_resolve(kerb->ctx, cache_name, &cc); } if (krbret) { Krb5_register_error(krbret); return Qfalse; } krbret = krb5_cc_destroy(kerb->ctx, cc); if (krbret) { Krb5_register_error(krbret); return Qfalse; } // NOTE: we don't need to call krb5_cc_close here since it is freed // automatically by krb5_cc_destroy() return Qtrue; }