add some support for reading and writing old cache formats;

(fcc_store_cred): use krb5_store_creds; (fcc_read_cred): use
krb5_ret_creds


git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@5963 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
Johan Danielsson
1999-04-15 15:47:05 +00:00
parent 2f3f002dcf
commit 48650b3b4a

View File

@@ -49,9 +49,13 @@ typedef struct krb5_fcache{
int version;
}krb5_fcache;
#define KRB5_FCC_FVNO_1 0x501
#define KRB5_FCC_FVNO_2 0x502
#define KRB5_FCC_FVNO_3 0x503
#define KRB5_FCC_FVNO_4 0x504
#define BYTESWAP(F) ((F)->version == KRB5_FCC_FVNO_1 || (F)->version == KRB5_FCC_FVNO_2)
#define FCC_TAG_DELTATIME 1
#define FILENAME(X) (((krb5_fcache*)(X)->data.data)->filename)
@@ -157,6 +161,8 @@ fcc_initialize(krb5_context context,
sp = krb5_storage_from_fd(fd);
f->version = KRB5_FCC_FVNO_4;
krb5_store_int16(sp, f->version);
krb5_storage_set_host_byteorder(sp, BYTESWAP(f));
if(f->version == KRB5_FCC_FVNO_4) {
/* V4 stuff */
if (context->kdc_sec_offset) {
krb5_store_int16 (sp, 12); /* length */
@@ -167,6 +173,7 @@ fcc_initialize(krb5_context context,
} else {
krb5_store_int16 (sp, 0);
}
}
krb5_store_principal(sp, primary_principal);
krb5_storage_free(sp);
}
@@ -212,17 +219,8 @@ fcc_store_cred(krb5_context context,
{
krb5_storage *sp;
sp = krb5_storage_from_fd(fd);
krb5_store_principal(sp, creds->client);
krb5_store_principal(sp, creds->server);
krb5_store_keyblock(sp, creds->session);
krb5_store_times(sp, creds->times);
krb5_store_int8(sp, 0); /* this is probably the
enc-tkt-in-skey bit from KDCOptions */
krb5_store_int32(sp, creds->flags.i);
krb5_store_addrs(sp, creds->addresses);
krb5_store_authdata(sp, creds->authdata);
krb5_store_data(sp, creds->ticket);
krb5_store_data(sp, creds->second_ticket);
krb5_storage_set_host_byteorder(sp, BYTESWAP(FCACHE(id)));
krb5_store_creds(sp, creds);
krb5_storage_free(sp);
}
close(fd);
@@ -230,38 +228,20 @@ fcc_store_cred(krb5_context context,
}
static krb5_error_code
fcc_read_cred (int fd,
fcc_read_cred (krb5_fcache *fc,
int fd,
krb5_creds *creds)
{
int ret = 0;
int8_t dummy8;
int32_t dummy32;
krb5_error_code ret;
krb5_storage *sp;
sp = krb5_storage_from_fd(fd);
if(sp == NULL)
return ENOMEM;
ret = krb5_ret_principal (sp, &creds->client);
if(ret) goto cleanup;
ret = krb5_ret_principal (sp, &creds->server);
if(ret) goto cleanup;
ret = krb5_ret_keyblock (sp, &creds->session);
if(ret) goto cleanup;
ret = krb5_ret_times (sp, &creds->times);
if(ret) goto cleanup;
ret = krb5_ret_int8 (sp, &dummy8);
if(ret) goto cleanup;
ret = krb5_ret_int32 (sp, &dummy32);
if(ret) goto cleanup;
creds->flags.i = dummy32;
ret = krb5_ret_addrs (sp, &creds->addresses);
if(ret) goto cleanup;
ret = krb5_ret_authdata (sp, &creds->authdata);
if(ret) goto cleanup;
ret = krb5_ret_data (sp, &creds->ticket);
if(ret) goto cleanup;
ret = krb5_ret_data (sp, &creds->second_ticket);
krb5_storage_set_host_byteorder(sp, BYTESWAP(fc));
cleanup:
ret = krb5_ret_creds(sp, creds);
krb5_storage_free(sp);
return ret;
}
@@ -280,10 +260,11 @@ init_fcc (krb5_context context,
if(fd < 0)
return errno;
sp = krb5_storage_from_fd(fd);
krb5_ret_int16(sp, &tag);
krb5_ret_int16(sp, &tag); /* should not be host byte order */
fcache->version = tag;
krb5_storage_set_host_byteorder(sp, BYTESWAP(fcache));
switch (tag) {
case KRB5_FCC_FVNO_4 : {
case KRB5_FCC_FVNO_4: {
int16_t length;
krb5_ret_int16 (sp, &length);
@@ -308,7 +289,9 @@ init_fcc (krb5_context context,
}
break;
}
case KRB5_FCC_FVNO_3 :
case KRB5_FCC_FVNO_3:
case KRB5_FCC_FVNO_2:
case KRB5_FCC_FVNO_1:
break;
default :
krb5_storage_free (sp);
@@ -364,7 +347,7 @@ fcc_get_next (krb5_context context,
krb5_cc_cursor *cursor,
krb5_creds *creds)
{
return fcc_read_cred (cursor->u.fd, creds);
return fcc_read_cred (FCACHE(id), cursor->u.fd, creds);
}
static krb5_error_code