/* * destroy * * - free our storage and the cache */ krb5_error_code KRB5_CALLCONV krb5_stdccv3_destroy (krb5_context context, krb5_ccache id) { krb5_error_code err = 0; stdccCacheDataPtr ccapi_data = id->data; if (!err) { err = stdccv3_setup(context, ccapi_data); } if (!err) { if (ccapi_data) { if (ccapi_data->cache_name) { free(ccapi_data->cache_name); } if (ccapi_data->NamedCache) { /* destroy the named cache */ err = cc_ccache_destroy(ccapi_data->NamedCache); if (err == ccErrCCacheNotFound) { err = 0; /* ccache maybe already destroyed */ } cache_changed(); } free(ccapi_data); id->data = NULL; } free(id); } return cc_err_xlate(err); }
/* * Destroy credentials file * * Implementation in dest_tkt.c */ int KRB5_CALLCONV dest_tkt (void) { cc_int32 cc_err = ccNoError; cc_context_t cc_context = NULL; cc_int32 cc_version; cc_ccache_t ccache = NULL; cc_err = cc_initialize (&cc_context, ccapi_version_3, &cc_version, NULL); if (cc_err == ccNoError) { cc_err = cc_context_open_ccache (cc_context, TKT_FILE, &ccache); } if (cc_err == ccNoError) { cc_ccache_destroy (ccache); } if (ccache != NULL) cc_ccache_release (ccache); if (cc_context != NULL) cc_context_release (cc_context); if (cc_err != ccNoError) return RET_TKFIL; else return KSUCCESS; }
/* * Destroy all credential caches * * Implementation in memcache.c */ int KRB5_CALLCONV dest_all_tkts (void) { int count = 0; cc_ccache_iterator_t iterator = NULL; cc_int32 cc_err = ccNoError; cc_context_t cc_context = NULL; cc_int32 cc_version; cc_ccache_t ccache = NULL; cc_err = cc_initialize (&cc_context, ccapi_version_3, &cc_version, NULL); if (cc_err == ccNoError) { cc_err = cc_context_new_ccache_iterator (cc_context, &iterator); } if (cc_err == ccNoError) { for (;;) { /* get next ccache */ cc_err = cc_ccache_iterator_next (iterator, &ccache); if (cc_err != ccNoError) break; cc_ccache_destroy (ccache); count++; } } if (iterator != NULL) cc_credentials_iterator_release (iterator); if (cc_context != NULL) cc_context_release (cc_context); if ((cc_err == ccIteratorEnd) && (count == 0)) { /* first time, nothing to destroy */ return KFAILURE; } else { if (cc_err == ccIteratorEnd) { /* done */ return KSUCCESS; } else { /* error */ return KFAILURE; } } }