KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL krb5_rc_resolve_full(krb5_context context, krb5_rcache *id, const char *string_name) { krb5_error_code ret; *id = NULL; if(strncmp(string_name, "FILE:", 5)) { krb5_set_error_message(context, KRB5_RC_TYPE_NOTFOUND, N_("replay cache type %s not supported", ""), string_name); return KRB5_RC_TYPE_NOTFOUND; } ret = krb5_rc_resolve_type(context, id, "FILE"); if(ret) return ret; ret = krb5_rc_resolve(context, *id, string_name + 5); if (ret) { krb5_rc_close(context, *id); *id = NULL; } return ret; }
krb5_error_code krb5_rc_default(krb5_context context, krb5_rcache *id) { krb5_error_code retval; if (!(*id = (krb5_rcache )malloc(sizeof(**id)))) return KRB5_RC_MALLOC; retval = krb5_rc_resolve_type(context, id, krb5_rc_default_type(context)); if (retval != 0) { /* * k5_mutex_destroy() is not called here, because the mutex had * not been successfully initialized by krb5_rc_resolve_type(). */ FREE_RC(*id); return (retval); } retval = krb5_rc_resolve(context, *id, krb5_rc_default_name(context)); if (retval) { k5_mutex_destroy(&(*id)->lock); FREE_RC(*id); return retval; } (*id)->magic = KV5M_RCACHE; return retval; }
krb5_error_code krb5_rc_resolve_full(krb5_context context, krb5_rcache *id, char *string_name) { char *type; char *residual; krb5_error_code retval; unsigned int diff; if (!(residual = strchr(string_name,':'))) return KRB5_RC_PARSE; diff = residual - string_name; if (!(type = malloc(diff + 1))) return KRB5_RC_MALLOC; (void) strncpy(type, string_name, diff); type[residual - string_name] = '\0'; if (!(*id = (krb5_rcache) malloc(sizeof(**id)))) { FREE_RC(type); return KRB5_RC_MALLOC; } retval = krb5_rc_resolve_type(context, id, type); if (retval != 0) { /* * k5_mutex_destroy() is not called here, because the mutex had * not been successfully initialized by krb5_rc_resolve_type(). */ FREE_RC(type); FREE_RC(*id); return retval; } FREE_RC(type); retval = krb5_rc_resolve(context, *id, residual + 1); if (retval) { k5_mutex_destroy(&(*id)->lock); FREE_RC(*id); return retval; } (*id)->magic = KV5M_RCACHE; return retval; }
static krb5_error_code krb5_rc_dfl_expunge_locked(krb5_context context, krb5_rcache id) { struct dfl_data *t = (struct dfl_data *)id->data; #ifdef NOIOSTUFF unsigned int i; struct authlist **q; struct authlist **qt; struct authlist *r; struct authlist *rt; krb5_int32 now; if (krb5_timestamp(context, &now)) now = 0; for (q = &t->a; *q; q = qt) { qt = &(*q)->na; if (alive(now, &(*q)->rep, t->lifespan) == CMP_EXPIRED) { free((*q)->rep.client); free((*q)->rep.server); if ((*q)->rep.msghash) free((*q)->rep.msghash); free(*q); *q = *qt; /* why doesn't this feel right? */ } } for (i = 0; i < t->hsize; i++) t->h[i] = (struct authlist *) 0; for (r = t->a; r; r = r->na) { i = hash(&r->rep, t->hsize); rt = t->h[i]; t->h[i] = r; r->nh = rt; } return 0; #else struct authlist *q; char *name; krb5_error_code retval = 0; krb5_rcache tmp; krb5_deltat lifespan = t->lifespan; /* save original lifespan */ if (! t->recovering) { name = t->name; t->name = 0; /* Clear name so it isn't freed */ (void) krb5_rc_dfl_close_no_free(context, id); retval = krb5_rc_dfl_resolve(context, id, name); free(name); if (retval) return retval; retval = krb5_rc_dfl_recover_locked(context, id); if (retval) return retval; t = (struct dfl_data *)id->data; /* point to recovered cache */ } retval = krb5_rc_resolve_type(context, &tmp, "dfl"); if (retval) return retval; retval = krb5_rc_resolve(context, tmp, 0); if (retval) goto cleanup; retval = krb5_rc_initialize(context, tmp, lifespan); if (retval) goto cleanup; for (q = t->a; q; q = q->na) { if (krb5_rc_io_store(context, (struct dfl_data *)tmp->data, &q->rep)) { retval = KRB5_RC_IO; goto cleanup; } } /* NOTE: We set retval in case we have an error */ retval = KRB5_RC_IO; if (krb5_rc_io_sync(context, &((struct dfl_data *)tmp->data)->d)) goto cleanup; if (krb5_rc_io_sync(context, &t->d)) goto cleanup; if (krb5_rc_io_move(context, &t->d, &((struct dfl_data *)tmp->data)->d)) goto cleanup; retval = 0; cleanup: (void) krb5_rc_dfl_close(context, tmp); return retval; #endif }