예제 #1
0
void mcc_test()
{
     krb5_ccache id;
     krb5_creds creds;
     krb5_error_code kret;
     krb5_cc_cursor cursor;

     init_test_cred();

     kret = krb5_mcc_resolve(context, &id, "/tmp/tkt_test");
     CHECK(kret, "resolve");
     kret = krb5_mcc_initialize(context, id, test_creds.client);
     CHECK(kret, "initialize");
     kret = krb5_mcc_store(context, id, &test_creds);
     CHECK(kret, "store");

     kret = krb5_mcc_start_seq_get(context, id, &cursor);
     CHECK(kret, "start_seq_get");
     kret = 0;
     while (kret != KRB5_CC_END) {
	  printf("Calling next_cred\n");
	  kret = krb5_mcc_next_cred(context, id, &cursor, &creds);
	  CHECK(kret, "next_cred");
     }
     kret = krb5_mcc_end_seq_get(context, id, &cursor);
     CHECK(kret, "end_seq_get");

     kret = krb5_mcc_destroy(context, id);
     CHECK(kret, "destroy");
     kret = krb5_mcc_close(context, id);
     CHECK(kret, "close");
}
예제 #2
0
파일: cc_memory.c 프로젝트: krb5/krb5
/*
 * Effects:
 * Destroys the contents of id. id is invalid after call.
 */
krb5_error_code KRB5_CALLCONV
krb5_mcc_destroy(krb5_context context, krb5_ccache id)
{
    krb5_mcc_data *d = id->data;
    krb5_boolean removed_from_table = FALSE;

    /* Remove this node from the table if it is still present. */
    k5_cc_mutex_lock(context, &krb5int_mcc_mutex);
    if (k5_hashtab_remove(mcc_hashtab, d->name, strlen(d->name)))
        removed_from_table = TRUE;
    k5_cc_mutex_unlock(context, &krb5int_mcc_mutex);

    /* Empty the cache and remove the reference for the table slot.  There will
     * always be at least one reference left for the handle being destroyed. */
    k5_cc_mutex_lock(context, &d->lock);
    empty_mcc_cache(context, d);
    if (removed_from_table)
        d->refcount--;
    k5_cc_mutex_unlock(context, &d->lock);

    /* Invalidate the handle, possibly removing the last reference to d and
     * freeing it. */
    krb5_mcc_close(context, id);

    krb5_change_cache ();
    return KRB5_OK;
}