From 6811175f37ba51691556d64309d59dbff8a1a29c Mon Sep 17 00:00:00 2001 From: Rainer Toebbicke Date: Thu, 9 Aug 2007 15:56:51 +0000 Subject: [PATCH] 64bit-ticket-file-20070809 fix the ticket files we write on 64 bit --- src/auth/ktc.c | 11 +++++++---- src/kauth/krb_tf.c | 6 ++++-- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/auth/ktc.c b/src/auth/ktc.c index b1af7eaea4..805ef25b06 100644 --- a/src/auth/ktc.c +++ b/src/auth/ktc.c @@ -1166,6 +1166,7 @@ afs_tf_get_cred(principal, token) { int k_errno; int kvno, lifetime; + long mit_compat; /* MIT Kerberos 5 with Krb4 uses a "long" for issue_date */ if (fd < 0) { return TKT_FIL_INI; @@ -1202,10 +1203,10 @@ afs_tf_get_cred(principal, token) /* don't try to read a silly amount into ticket->dat */ token->ticketLen > MAXKTCTICKETLEN || tf_read((char *)(token->ticket), token->ticketLen) < 1 - || tf_read((char *)&(token->startTime), - sizeof(token->startTime)) < 1) { + || tf_read((char *)&mit_compat, sizeof(mit_compat)) < 1) { return TKT_FIL_FMT; } + token->startTime = mit_compat; token->endTime = life_to_time(token->startTime, lifetime); token->kvno = kvno; return 0; @@ -1333,6 +1334,7 @@ afs_tf_save_cred(aserver, atoken, aclient) off_t start; int lifetime, kvno; int count; /* count for write */ + long mit_compat; /* MIT Kerberos 5 with Krb4 uses a "long" for issue_date */ if (fd < 0) { /* fd is ticket file as set by afs_tf_init */ return TKT_FIL_INI; @@ -1402,8 +1404,9 @@ afs_tf_save_cred(aserver, atoken, aclient) if (write(fd, atoken->ticket, count) != count) goto bad; /* Issue date */ - if (write(fd, (char *)&atoken->startTime, sizeof(afs_int32)) - != sizeof(afs_int32)) + mit_compat = atoken->startTime; + if (write(fd, (char *)&mit_compat, sizeof(mit_compat)) + != sizeof(mit_compat)) goto bad; /* Actually, we should check each write for success */ diff --git a/src/kauth/krb_tf.c b/src/kauth/krb_tf.c index 5e75d8f02b..f6f4c80790 100644 --- a/src/kauth/krb_tf.c +++ b/src/kauth/krb_tf.c @@ -84,6 +84,7 @@ krb_write_ticket_file(realm) char *tf_name; struct ktc_principal client, server; struct ktc_token token; + long mit_compat; /* MIT Kerberos 5 with Krb4 uses a "long" for issue_date */ if ((strlen(realm) >= sizeof(client.cell))) return KABADNAME; @@ -149,8 +150,9 @@ krb_write_ticket_file(realm) if (write(fd, (char *)(token.ticket), count) != count) goto bad; /* Issue date */ - if (write(fd, (char *)&token.startTime, sizeof(afs_int32)) - != sizeof(afs_int32)) + mit_compat = token.startTime; + if (write(fd, (char *)&mit_compat, sizeof(mit_compat)) + != sizeof(mit_compat)) goto bad; close(fd); return 0;