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:
@@ -49,9 +49,13 @@ typedef struct krb5_fcache{
|
|||||||
int version;
|
int version;
|
||||||
}krb5_fcache;
|
}krb5_fcache;
|
||||||
|
|
||||||
|
#define KRB5_FCC_FVNO_1 0x501
|
||||||
|
#define KRB5_FCC_FVNO_2 0x502
|
||||||
#define KRB5_FCC_FVNO_3 0x503
|
#define KRB5_FCC_FVNO_3 0x503
|
||||||
#define KRB5_FCC_FVNO_4 0x504
|
#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 FCC_TAG_DELTATIME 1
|
||||||
|
|
||||||
#define FILENAME(X) (((krb5_fcache*)(X)->data.data)->filename)
|
#define FILENAME(X) (((krb5_fcache*)(X)->data.data)->filename)
|
||||||
@@ -157,15 +161,18 @@ fcc_initialize(krb5_context context,
|
|||||||
sp = krb5_storage_from_fd(fd);
|
sp = krb5_storage_from_fd(fd);
|
||||||
f->version = KRB5_FCC_FVNO_4;
|
f->version = KRB5_FCC_FVNO_4;
|
||||||
krb5_store_int16(sp, f->version);
|
krb5_store_int16(sp, f->version);
|
||||||
/* V4 stuff */
|
krb5_storage_set_host_byteorder(sp, BYTESWAP(f));
|
||||||
if (context->kdc_sec_offset) {
|
if(f->version == KRB5_FCC_FVNO_4) {
|
||||||
krb5_store_int16 (sp, 12); /* length */
|
/* V4 stuff */
|
||||||
krb5_store_int16 (sp, FCC_TAG_DELTATIME); /* Tag */
|
if (context->kdc_sec_offset) {
|
||||||
krb5_store_int16 (sp, 8); /* length of data */
|
krb5_store_int16 (sp, 12); /* length */
|
||||||
krb5_store_int32 (sp, context->kdc_sec_offset);
|
krb5_store_int16 (sp, FCC_TAG_DELTATIME); /* Tag */
|
||||||
krb5_store_int32 (sp, context->kdc_usec_offset);
|
krb5_store_int16 (sp, 8); /* length of data */
|
||||||
} else {
|
krb5_store_int32 (sp, context->kdc_sec_offset);
|
||||||
krb5_store_int16 (sp, 0);
|
krb5_store_int32 (sp, context->kdc_usec_offset);
|
||||||
|
} else {
|
||||||
|
krb5_store_int16 (sp, 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
krb5_store_principal(sp, primary_principal);
|
krb5_store_principal(sp, primary_principal);
|
||||||
krb5_storage_free(sp);
|
krb5_storage_free(sp);
|
||||||
@@ -212,17 +219,8 @@ fcc_store_cred(krb5_context context,
|
|||||||
{
|
{
|
||||||
krb5_storage *sp;
|
krb5_storage *sp;
|
||||||
sp = krb5_storage_from_fd(fd);
|
sp = krb5_storage_from_fd(fd);
|
||||||
krb5_store_principal(sp, creds->client);
|
krb5_storage_set_host_byteorder(sp, BYTESWAP(FCACHE(id)));
|
||||||
krb5_store_principal(sp, creds->server);
|
krb5_store_creds(sp, creds);
|
||||||
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_free(sp);
|
krb5_storage_free(sp);
|
||||||
}
|
}
|
||||||
close(fd);
|
close(fd);
|
||||||
@@ -230,38 +228,20 @@ fcc_store_cred(krb5_context context,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static krb5_error_code
|
static krb5_error_code
|
||||||
fcc_read_cred (int fd,
|
fcc_read_cred (krb5_fcache *fc,
|
||||||
|
int fd,
|
||||||
krb5_creds *creds)
|
krb5_creds *creds)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
krb5_error_code ret;
|
||||||
int8_t dummy8;
|
|
||||||
int32_t dummy32;
|
|
||||||
krb5_storage *sp;
|
krb5_storage *sp;
|
||||||
|
|
||||||
sp = krb5_storage_from_fd(fd);
|
sp = krb5_storage_from_fd(fd);
|
||||||
|
if(sp == NULL)
|
||||||
|
return ENOMEM;
|
||||||
|
|
||||||
|
krb5_storage_set_host_byteorder(sp, BYTESWAP(fc));
|
||||||
|
|
||||||
ret = krb5_ret_principal (sp, &creds->client);
|
ret = krb5_ret_creds(sp, creds);
|
||||||
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);
|
|
||||||
|
|
||||||
cleanup:
|
|
||||||
krb5_storage_free(sp);
|
krb5_storage_free(sp);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@@ -280,10 +260,11 @@ init_fcc (krb5_context context,
|
|||||||
if(fd < 0)
|
if(fd < 0)
|
||||||
return errno;
|
return errno;
|
||||||
sp = krb5_storage_from_fd(fd);
|
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;
|
fcache->version = tag;
|
||||||
|
krb5_storage_set_host_byteorder(sp, BYTESWAP(fcache));
|
||||||
switch (tag) {
|
switch (tag) {
|
||||||
case KRB5_FCC_FVNO_4 : {
|
case KRB5_FCC_FVNO_4: {
|
||||||
int16_t length;
|
int16_t length;
|
||||||
|
|
||||||
krb5_ret_int16 (sp, &length);
|
krb5_ret_int16 (sp, &length);
|
||||||
@@ -308,7 +289,9 @@ init_fcc (krb5_context context,
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case KRB5_FCC_FVNO_3 :
|
case KRB5_FCC_FVNO_3:
|
||||||
|
case KRB5_FCC_FVNO_2:
|
||||||
|
case KRB5_FCC_FVNO_1:
|
||||||
break;
|
break;
|
||||||
default :
|
default :
|
||||||
krb5_storage_free (sp);
|
krb5_storage_free (sp);
|
||||||
@@ -364,7 +347,7 @@ fcc_get_next (krb5_context context,
|
|||||||
krb5_cc_cursor *cursor,
|
krb5_cc_cursor *cursor,
|
||||||
krb5_creds *creds)
|
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
|
static krb5_error_code
|
||||||
|
Reference in New Issue
Block a user