/* * Modifies: * id * * Effects: * Creates/refreshes the memory cred cache id. If the cache exists, its * contents are destroyed. * * Errors: * system errors */ krb5_error_code KRB5_CALLCONV krb5_mcc_initialize(krb5_context context, krb5_ccache id, krb5_principal princ) { krb5_os_context os_ctx = &context->os_context; krb5_error_code ret; krb5_mcc_data *d; d = (krb5_mcc_data *)id->data; k5_cc_mutex_lock(context, &d->lock); krb5_mcc_free(context, id); d = (krb5_mcc_data *)id->data; ret = krb5_copy_principal(context, princ, &d->prin); update_mcc_change_time(d); if (os_ctx->os_flags & KRB5_OS_TOFFSET_VALID) { /* Store client time offsets in the cache */ d->time_offset = os_ctx->time_offset; d->usec_offset = os_ctx->usec_offset; } k5_cc_mutex_unlock(context, &d->lock); if (ret == KRB5_OK) krb5_change_cache(); return ret; }
/* * Effects: * Destroys the contents of id. id is invalid after call. * * Errors: * system errors (locks related) */ krb5_error_code KRB5_CALLCONV krb5_mcc_destroy(krb5_context context, krb5_ccache id) { krb5_mcc_list_node **curr, *node; krb5_mcc_data *d; k5_cc_mutex_lock(context, &krb5int_mcc_mutex); d = (krb5_mcc_data *)id->data; for (curr = &mcc_head; *curr; curr = &(*curr)->next) { if ((*curr)->cache == d) { node = *curr; *curr = node->next; free(node); break; } } k5_cc_mutex_unlock(context, &krb5int_mcc_mutex); k5_cc_mutex_lock(context, &d->lock); krb5_mcc_free(context, id); free(d->name); k5_cc_mutex_unlock(context, &d->lock); k5_cc_mutex_destroy(&d->lock); free(d); free(id); krb5_change_cache (); return KRB5_OK; }
/* * Modifies: * id * * Effects: * Creates/refreshes the memory cred cache id. If the cache exists, its * contents are destroyed. * * Errors: * system errors */ krb5_error_code KRB5_CALLCONV krb5_mcc_initialize(krb5_context context, krb5_ccache id, krb5_principal princ) { krb5_error_code ret; krb5_mcc_data *d; d = (krb5_mcc_data *)id->data; ret = k5_cc_mutex_lock(context, &d->lock); if (ret) return ret; krb5_mcc_free(context, id); d = (krb5_mcc_data *)id->data; ret = krb5_copy_principal(context, princ, &d->prin); update_mcc_change_time(d); k5_cc_mutex_unlock(context, &d->lock); if (ret == KRB5_OK) krb5_change_cache(); return ret; }