#define KRB5_FCC_MAXLEN 100
-#define KRB5_FCC_FVNO 0x0501 /* krb v5, fcc v1 */
+/*
+ * FCC version 2 contains type information for principals. FCC
+ * version 1 does not. The code will accept either, and depending on
+ * what KRB5_FCC_DEFAULT_FVNO is set to, it will create version 1 or
+ * version 2 FCC caches.
+ *
+ * KRB5_FCC_DEFAULT_FVNO should be set to version 2, unless there is
+ * some overriding compatibility reasons not to do so.
+ */
+
+#define KRB5_FCC_FVNO_1 0x0501 /* krb v5, fcc v1 */
+#define KRB5_FCC_FVNO 0x0502 /* krb5 v5, fcc v2 */
+
+#define KRB5_FCC_DEFAULT_FVNO KRB5_FCC_FVNO
+
#define FCC_OPEN_AND_ERASE 1
#define FCC_OPEN_RDWR 2
#define FCC_OPEN_RDONLY 3
int fd;
krb5_flags flags;
int mode; /* needed for locking code */
+ int version; /* version number of the file */
} krb5_fcc_data;
/* An off_t can be arbitrarily complex */
#include "fcc.h"
#include <krb5/osconf.h>
+int krb5_fcc_default_format = KRB5_FCC_DEFAULT_FVNO;
+
#ifdef KRB5_USE_INET
#include <netinet/in.h>
#else
int mode;
{
krb5_fcc_data *data = (krb5_fcc_data *)id->data;
- krb5_int16 fcc_fvno = htons(KRB5_FCC_FVNO);
+ krb5_int16 fcc_fvno;
int fd;
int open_flag;
krb5_error_code retval;
/* write the version number */
int errsave, cnt;
+ fcc_fvno = htons(krb5_fcc_default_format);
+ data->version = krb5_fcc_default_format;
if ((cnt = write(fd, (char *)&fcc_fvno, sizeof(fcc_fvno))) !=
sizeof(fcc_fvno)) {
errsave = errno;
(void) close(fd);
return KRB5_CCACHE_BADVNO;
}
- if (fcc_fvno != htons(KRB5_FCC_FVNO)) {
+ if ((fcc_fvno != htons(KRB5_FCC_FVNO)) &&
+ (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;
krb5_ccache id;
krb5_principal *princ;
{
+ krb5_fcc_data *data = (krb5_fcc_data *)id->data;
krb5_error_code kret;
register krb5_principal tmpprinc;
- krb5_int32 length;
+ krb5_int32 length, type;
int i;
+ if (data->version == KRB5_FCC_FVNO_1) {
+ type = KRB5_NT_UNKNOWN;
+ } else {
+ /* Read principal type */
+ kret = krb5_fcc_read_int32(id, &type);
+ if (kret != KRB5_OK)
+ return kret;
+ }
+
/* Read the number of components */
kret = krb5_fcc_read_int32(id, &length);
if (kret != KRB5_OK)
return KRB5_CC_NOMEM;
}
tmpprinc->length = length;
+ tmpprinc->type = type;
kret = krb5_fcc_read_data(id, krb5_princ_realm(tmpprinc));
* $Source$
* $Author$
*
- * Copyright 1990,1991 by the Massachusetts Institute of Technology.
+ * Copyright 1990,1991,1992 by the Massachusetts Institute of Technology.
* All Rights Reserved.
*
* Export of this software from the United States of America is assumed
* system errors
*/
-/* XXX TODO: write principal type to file XXX */
-
krb5_error_code
krb5_fcc_store_principal(id, princ)
krb5_ccache id;
krb5_principal princ;
{
+ krb5_fcc_data *data = (krb5_fcc_data *)id->data;
krb5_error_code ret;
- krb5_int32 i, length;
+ krb5_int32 i, length, type;
+ type = krb5_princ_type(princ);
length = krb5_princ_size(princ);
+ if (data->version != KRB5_FCC_FVNO_1) {
+ ret = krb5_fcc_store_int32(id, &type);
+ CHECK(ret);
+ }
+
ret = krb5_fcc_store_int32(id, &length);
CHECK(ret);
#define KRB5_SCC_MAXLEN 100
-#define KRB5_SCC_FVNO 0x0501 /* krb v5, scc v1 */
+/*
+ * SCC version 2 contains type information for principals. SCC
+ * version 1 does not. The code will accept either, and depending on
+ * what KRB5_SCC_DEFAULT_FVNO is set to, it will create version 1 or
+ * version 2 SCC caches.
+ *
+ * KRB5_SCC_DEFAULT_FVNO should be set to version 2, unless there is
+ * some overriding compatibility reasons not to do so.
+ */
+
+#define KRB5_SCC_FVNO_1 0x0501 /* krb v5, scc v1 */
+#define KRB5_SCC_FVNO 0x0502 /* krb5 v5, scc v2 */
+
+#define KRB5_SCC_DEFAULT_FVNO KRB5_SCC_FVNO
#define SCC_OPEN_AND_ERASE 1
#define SCC_OPEN_RDWR 2
FILE *file;
krb5_flags flags;
char stdio_buffer[BUFSIZ];
+ int version;
} krb5_scc_data;
/* An off_t can be arbitrarily complex */
#include <krb5/libos.h>
#include <krb5/los-proto.h>
+int krb5_scc_default_format = KRB5_SCC_DEFAULT_FVNO;
+
krb5_error_code
krb5_scc_close_file (id)
krb5_ccache id;
krb5_ccache id;
int mode;
{
- krb5_int16 scc_fvno = htons(KRB5_SCC_FVNO);
+ krb5_int16 scc_fvno;
krb5_scc_data *data;
FILE *f;
char *open_flag;
/* write the version number */
int errsave;
+ scc_fvno = htons(krb5_scc_default_format);
+ data->version = krb5_scc_default_format;
if (!fwrite((char *)&scc_fvno, sizeof(scc_fvno), 1, f)) {
errsave = errno;
(void) krb5_unlock_file(f, data->filename);
(void) fclose(f);
return KRB5_CCACHE_BADVNO;
}
- if (scc_fvno != (krb5_int16)htons(KRB5_SCC_FVNO)) {
+ if ((scc_fvno != htons(KRB5_SCC_FVNO)) &&
+ (scc_fvno != htons(KRB5_SCC_FVNO_1))) {
(void) krb5_unlock_file(f, data->filename);
(void) fclose(f);
return KRB5_CCACHE_BADVNO;
}
+ data->version = ntohs(scc_fvno);
}
data->file = f;
return 0;
krb5_ccache id;
krb5_principal *princ;
{
+ krb5_scc_data *data = (krb5_scc_data *)id->data;
krb5_error_code kret;
register krb5_principal tmpprinc;
- krb5_int32 length;
+ krb5_int32 length, type;
int i;
+ if (data->version == KRB5_SCC_FVNO_1) {
+ type = KRB5_NT_UNKNOWN;
+ } else {
+ /* Read the principal type */
+ kret = krb5_scc_read_int32(id, &type);
+ if (kret != KRB5_OK)
+ return kret;
+ }
+
/* Read the number of components */
kret = krb5_scc_read_int32(id, &length);
if (kret != KRB5_OK)
return KRB5_CC_NOMEM;
}
tmpprinc->length = length;
+ tmpprinc->type = type;
kret = krb5_scc_read_data(id, krb5_princ_realm(tmpprinc));
i = 0;
krb5_ccache id;
krb5_principal princ;
{
+ krb5_scc_data *data = (krb5_scc_data *)id->data;
krb5_error_code ret;
- krb5_int32 i, length;
+ krb5_int32 i, length, type;
+ type = krb5_princ_type(princ);
length = krb5_princ_size(princ);
+ if (data->version != KRB5_SCC_FVNO_1) {
+ ret = krb5_scc_store_int32(id, &type);
+ CHECK(ret);
+ }
+
ret = krb5_scc_store_int32(id, &length);
CHECK(ret);