/*
* 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)
{
VALUE cache_val;
struct ruby_krb5 *kerb;
krb5_error_code krbret;
char *cache_name;
krb5_ccache cc;
rb_scan_args(argc, argv, "01", &cache_val);
cache_name = get_string_or_nil(cache_val);
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;
}