rc_file.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* Copyright 2004 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
*
* This file of the Kerberos V5 software is derived from public-domain code
* contributed by Daniel J. Bernstein, <brnstnd@acf10.nyu.edu>.
*
*/
/*
* An implementation for the default replay cache type.
*/
#include "rc_common.h"
#include "rc_file.h"
/*
* Solaris: The NOIOSTUFF macro has been taken out for the Solaris version
* of this module, because this has been split into a separate mem rcache.
*/
/* of course, list is backwards from file */
/* hash could be forwards since we have to search on match, but naaaah */
{
int rephash;
/* Solaris: calling krb_timeofday() here, once for better perf. */
/* Solaris: calling alive() on rep since it doesn't make sense to store an
* expired replay.
*/
return CMP_EXPIRED;
}
{
case CMP_REPLAY: return CMP_REPLAY;
== CMP_EXPIRED)
t->nummisses++;
else
t->numhits++;
break;
default: ; /* wtf? */
}
return CMP_MALLOC;
return CMP_MALLOC;
}
return CMP_MALLOC;
}
return CMP_HOHUM;
}
/*ARGSUSED*/
char * KRB5_CALLCONV
{
}
/*ARGSUSED*/
{
return 0;
}
{
/* default to clockskew from the context */
return retval;
if ((krb5_rc_io_write(context, &t->d,
|| krb5_rc_io_sync(context, &t->d)))
return KRB5_RC_IO;
return 0;
}
{
struct authlist *q;
if (t->h)
free(t->h);
if (t->name)
while ((q = t->a) != NULL)
{
t->a = q->na;
free(q);
}
if (t->d.fd >= 0)
(void) krb5_rc_io_close(context, &t->d);
free(t);
return 0;
}
{
return 0;
}
{
return KRB5_RC_IO;
}
/*ARGSUSED*/
char *name;
{
struct file_data *t = 0;
/* allocate id? no */
return KRB5_RC_MALLOC;
if (name) {
if (!t->name) {
goto cleanup;
}
} else
t->name = 0;
if (!t->h) {
goto cleanup;
}
t->a = (struct authlist *) 0;
t->d.fd = -1;
t->recovering = 0;
return 0;
if (t) {
if (t->name)
krb5_xfree(t->name);
if (t->h)
krb5_xfree(t->h);
krb5_xfree(t);
}
return retval;
}
/*ARGSUSED*/
{
if (rp)
{
}
}
struct file_data *t;
int maxlen;
{
int len;
if (retval)
return retval;
return KRB5_RC_IO_EOF;
return KRB5_RC_MALLOC;
if (retval)
goto errout;
if (retval)
goto errout;
goto errout;
}
goto errout;
}
if (retval)
goto errout;
if (retval)
goto errout;
if (retval)
goto errout;
return 0;
return retval;
}
{
krb5_donot_replay *rep = 0;
long max_size;
int expired_entries = 0;
return retval;
t->recovering = 1;
retval = KRB5_RC_IO;
goto io_fail;
}
goto io_fail;
}
/* now read in each auth_replay and insert into table */
for (;;) {
if (krb5_rc_io_mark(context, &t->d)) {
retval = KRB5_RC_IO;
goto io_fail;
}
if (retval == KRB5_RC_IO_EOF)
break;
else if (retval != 0)
goto io_fail;
/* Solaris: made the change below for better perf. */
case CMP_EXPIRED:
break;
case CMP_MALLOC:
goto io_fail;
break;
}
/*
* free fields allocated by rc_io_fetch
*/
}
retval = 0;
krb5_rc_io_unmark(context, &t->d);
/*
* An automatic expunge here could remove the need for
*/
if (retval)
krb5_rc_io_close(context, &t->d);
else if (expired_entries > EXCESSREPS)
t->recovering = 0;
return retval;
}
static krb5_error_code
struct file_data *t;
{
if (buf == 0)
return KRB5_RC_MALLOC;
return ret;
}
{
case CMP_MALLOC:
return KRB5_RC_MALLOC;
case CMP_REPLAY:
return KRB5KRB_AP_ERR_REPEAT;
case CMP_EXPIRED:
return KRB5KRB_AP_ERR_SKEW;
case CMP_HOHUM: break;
default: /* wtf? */ ;
}
if (ret)
return ret;
/* Shall we automatically expunge? */
{
}
else
{
if (krb5_rc_io_sync(context, &t->d))
return KRB5_RC_IO;
}
return 0;
}
{
struct authlist *q;
char *name;
krb5_error_code retval = 0;
if (! t->recovering) {
t->name = 0; /* Clear name so it isn't freed */
if (retval)
return retval;
if (retval)
return retval;
}
if (!tmp)
return ENOMEM;
goto out;
goto out;
for (q = t->a;q;q = q->na) {
retval = KRB5_RC_IO;
goto out;
}
}
if (krb5_rc_io_sync(context, &t->d)) {
retval = KRB5_RC_IO;
goto out;
}
retval = KRB5_RC_IO;
out:
/*
* krb5_rc_file_close() will free the tmp struct and it's members that the
* previous functions had allocated.
*/
return (retval);
}