From 6ba25276589cda3bd8b37ac489833c701dad8569 Mon Sep 17 00:00:00 2001 From: Chris Provenzano Date: Wed, 6 Sep 1995 03:33:29 +0000 Subject: [PATCH] * fcc.h : Add another KRB5_FCC_FVNO but don't up the default. * fcc_gennew.c, fcc_maybe.c : New version saves a length after version for whatever we want to put into the ccache before the first credential (like a time skew) * fcc_read.c, fcc_write.c : Remove krb5_enctype references, and replace with krb5_keytype where appropriate git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@6683 dc483132-0cff-0310-8789-dd5450dbe970 --- src/lib/krb5/ccache/file/ChangeLog | 9 ++++++++ src/lib/krb5/ccache/file/fcc.h | 1 + src/lib/krb5/ccache/file/fcc_gennew.c | 12 +++++++++++ src/lib/krb5/ccache/file/fcc_maybe.c | 30 ++++++++++++++++++++++----- src/lib/krb5/ccache/file/fcc_read.c | 7 ++----- src/lib/krb5/ccache/file/fcc_write.c | 5 ++--- 6 files changed, 51 insertions(+), 13 deletions(-) diff --git a/src/lib/krb5/ccache/file/ChangeLog b/src/lib/krb5/ccache/file/ChangeLog index 4ec1d6eab..ae7a1221f 100644 --- a/src/lib/krb5/ccache/file/ChangeLog +++ b/src/lib/krb5/ccache/file/ChangeLog @@ -1,4 +1,13 @@ +Tue Sep 05 22:58:52 1995 + + * fcc.h : Add another KRB5_FCC_FVNO but don't up the default. + * fcc_gennew.c, fcc_maybe.c : New version saves a length after + version for whatever we want to put into the ccache before + the first credential (like a time skew) + * fcc_read.c, fcc_write.c : Remove krb5_enctype references, and + replace with krb5_keytype where appropriate + Tue Aug 29 13:36:00 EDT 1995 Paul Park (pjpark@mit.edu) * fcc_reslv.c - Set magic number in successfully resolved ccache. diff --git a/src/lib/krb5/ccache/file/fcc.h b/src/lib/krb5/ccache/file/fcc.h index 980a9c17e..0e26fa7f6 100644 --- a/src/lib/krb5/ccache/file/fcc.h +++ b/src/lib/krb5/ccache/file/fcc.h @@ -55,6 +55,7 @@ #define KRB5_FCC_FVNO_1 0x0501 /* krb5 v5, fcc v1 */ #define KRB5_FCC_FVNO_2 0x0502 /* krb5 v5, fcc v2 */ #define KRB5_FCC_FVNO_3 0x0503 /* krb5 v5, fcc v3 */ +#define KRB5_FCC_FVNO_4 0x0504 /* krb5 v5, fcc v4 */ #define KRB5_FCC_DEFAULT_FVNO KRB5_FCC_FVNO_3 diff --git a/src/lib/krb5/ccache/file/fcc_gennew.c b/src/lib/krb5/ccache/file/fcc_gennew.c index 13757e9d5..93d963b15 100644 --- a/src/lib/krb5/ccache/file/fcc_gennew.c +++ b/src/lib/krb5/ccache/file/fcc_gennew.c @@ -107,6 +107,7 @@ krb5_fcc_generate_new (context, id) goto err_out; } else { krb5_int16 fcc_fvno = htons(KRB5_FCC_DEFAULT_FVNO); + krb5_int16 fcc_flen = 0; int errsave, cnt; /* Ignore user's umask, set mode = 0600 */ @@ -125,6 +126,17 @@ krb5_fcc_generate_new (context, id) retcode = (cnt == -1) ? krb5_fcc_interpret(context, errsave) : KRB5_CC_IO; goto err_out; } + /* For version 4 we save a length for the rest of the header */ + if (KRB5_FCC_DEFAULT_FVNO == KRB5_FCC_FVNO_4) { + if ((cnt = write(ret, (char *)&fcc_flen, sizeof(fcc_flen))) + != sizeof(fcc_flen)) { + errsave = errno; + (void) close(ret); + (void) unlink(((krb5_fcc_data *) lid->data)->filename); + retcode = (cnt == -1) ? krb5_fcc_interpret(context, errsave) : KRB5_CC_IO; + goto err_out; + } + } if (close(ret) == -1) { errsave = errno; (void) unlink(((krb5_fcc_data *) lid->data)->filename); diff --git a/src/lib/krb5/ccache/file/fcc_maybe.c b/src/lib/krb5/ccache/file/fcc_maybe.c index 232bb2275..9aaba98fb 100644 --- a/src/lib/krb5/ccache/file/fcc_maybe.c +++ b/src/lib/krb5/ccache/file/fcc_maybe.c @@ -267,15 +267,35 @@ krb5_fcc_open_file (context, id, mode) (void) close(fd); return KRB5_CCACHE_BADVNO; } - if ((fcc_fvno != htons(KRB5_FCC_FVNO_3)) && + if ((fcc_fvno != htons(KRB5_FCC_FVNO_4)) && + (fcc_fvno != htons(KRB5_FCC_FVNO_3)) && (fcc_fvno != htons(KRB5_FCC_FVNO_2)) && (fcc_fvno != htons(KRB5_FCC_FVNO_1))) { (void) fcc_lock_file(data, fd, UNLOCK_IT); (void) close(fd); return KRB5_CCACHE_BADVNO; } - data->version = ntohs(fcc_fvno); - } - data->fd = fd; - return 0; + if (fcc_fvno == htons(KRB5_FCC_FVNO_4)) { + krb5_ui_2 fcc_flen; + char buf[1024]; + + if (read(fd, (char *)&fcc_flen, sizeof(fcc_flen)) + != sizeof(fcc_flen)) { + (void) fcc_lock_file(data, fd, UNLOCK_IT); + (void) close(fd); + return KRB5_CCACHE_BADVNO; + } + /* Skip past the header info for now */ + if (fcc_flen = htons(fcc_flen)) { + if (read(fd, buf, fcc_flen) != fcc_flen) { + (void) fcc_lock_file(data, fd, UNLOCK_IT); + (void) close(fd); + return KRB5_CCACHE_BADVNO; + } + } + } + data->version = ntohs(fcc_fvno); + } + data->fd = fd; + return 0; } diff --git a/src/lib/krb5/ccache/file/fcc_read.c b/src/lib/krb5/ccache/file/fcc_read.c index e963d9eb7..fddff7aef 100644 --- a/src/lib/krb5/ccache/file/fcc_read.c +++ b/src/lib/krb5/ccache/file/fcc_read.c @@ -206,12 +206,9 @@ krb5_fcc_read_keyblock(context, id, keyblock) kret = krb5_fcc_read_ui_2(context, id, &ui2); keyblock->keytype = ui2; CHECK(kret); - if ((data->version == KRB5_FCC_FVNO_1) || - (data->version == KRB5_FCC_FVNO_2)) - keyblock->etype = ETYPE_UNKNOWN; - else { + if (data->version == KRB5_FCC_FVNO_3) { kret = krb5_fcc_read_ui_2(context, id, &ui2); - keyblock->etype = ui2; + keyblock->keytype = ui2; CHECK(kret); } diff --git a/src/lib/krb5/ccache/file/fcc_write.c b/src/lib/krb5/ccache/file/fcc_write.c index 38067b5f5..2c52aaf6c 100644 --- a/src/lib/krb5/ccache/file/fcc_write.c +++ b/src/lib/krb5/ccache/file/fcc_write.c @@ -149,9 +149,8 @@ krb5_fcc_store_keyblock(context, id, keyblock) ret = krb5_fcc_store_ui_2(context, id, keyblock->keytype); CHECK(ret); - if ((data->version != KRB5_FCC_FVNO_1) && - (data->version != KRB5_FCC_FVNO_2)) { - ret = krb5_fcc_store_ui_2(context, id, keyblock->etype); + if (data->version == KRB5_FCC_FVNO_3) { + ret = krb5_fcc_store_ui_2(context, id, keyblock->keytype); CHECK(ret); } ret = krb5_fcc_store_int32(context, id, keyblock->length); -- 2.26.2