From a8624b5e1f0978913ffa32fce2fbcd3a2e6edec8 Mon Sep 17 00:00:00 2001 From: Barry Jaspan Date: Sun, 21 Jan 1990 16:50:42 +0000 Subject: [PATCH] Initial revision git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@160 dc483132-0cff-0310-8789-dd5450dbe970 --- src/lib/krb5/ccache/file/fcc-proto.h | 70 ++++++++++++ src/lib/krb5/ccache/file/fcc_ops.c | 45 ++++++++ src/lib/krb5/ccache/file/fcc_skip.c | 39 +++++++ src/lib/krb5/ccache/file/fcc_write.c | 162 +++++++++++++++++++++++++++ 4 files changed, 316 insertions(+) create mode 100644 src/lib/krb5/ccache/file/fcc-proto.h create mode 100644 src/lib/krb5/ccache/file/fcc_ops.c create mode 100644 src/lib/krb5/ccache/file/fcc_skip.c create mode 100644 src/lib/krb5/ccache/file/fcc_write.c diff --git a/src/lib/krb5/ccache/file/fcc-proto.h b/src/lib/krb5/ccache/file/fcc-proto.h new file mode 100644 index 000000000..9036000c5 --- /dev/null +++ b/src/lib/krb5/ccache/file/fcc-proto.h @@ -0,0 +1,70 @@ +/* fcc_close.c */ +krb5_error_code krb5_fcc_close PROTOTYPE((krb5_ccache id )); + +/* fcc_defnam.c */ +char *krb5_fcc_default_name PROTOTYPE((void )); + +/* fcc_destry.c */ +krb5_error_code krb5_fcc_destroy PROTOTYPE((krb5_ccache id )); + +/* fcc_eseq.c */ +krb5_error_code krb5_fcc_end_seq_get PROTOTYPE((krb5_ccache id , krb5_cc_cursor *cursor )); + +/* fcc_gennew.c */ +krb5_error_code krb5_fcc_generate_new PROTOTYPE((krb5_ccache id )); + +/* fcc_getnam.c */ +char *krb5_fcc_get_name PROTOTYPE((krb5_ccache id )); + +/* fcc_gprin.c */ +krb5_error_code krb5_fcc_get_principal PROTOTYPE((krb5_ccache id , krb5_principal *princ )); + +/* fcc_init.c */ +krb5_error_code krb5_fcc_initialize PROTOTYPE((krb5_ccache id , krb5_principal princ )); + +/* fcc_nseq.c */ +krb5_error_code krb5_fcc_next_cred PROTOTYPE((krb5_ccache id , krb5_cc_cursor *cursor , krb5_creds *creds )); + +/* fcc_read.c */ +krb5_error_code krb5_fcc_read_principal PROTOTYPE((krb5_ccache id , krb5_principal *princ )); +krb5_error_code krb5_fcc_read_keyblock PROTOTYPE((krb5_ccache id , krb5_keyblock *keyblock )); +krb5_error_code krb5_fcc_read_data PROTOTYPE((krb5_ccache id , krb5_data *data )); +krb5_error_code krb5_fcc_read_int32 PROTOTYPE((krb5_ccache id , krb5_int32 *i )); +krb5_error_code krb5_fcc_read_keytype PROTOTYPE((krb5_ccache id , krb5_keytype *k )); +krb5_error_code krb5_fcc_read_int PROTOTYPE((krb5_ccache id , int *i )); +krb5_error_code krb5_fcc_read_bool PROTOTYPE((krb5_ccache id , krb5_boolean *b )); +krb5_error_code krb5_fcc_read_times PROTOTYPE((krb5_ccache id , krb5_ticket_times *t )); +krb5_error_code krb5_fcc_read_flags PROTOTYPE((krb5_ccache id , krb5_flags *f )); + +/* fcc_reslv.c */ +krb5_error_code krb5_fcc_resolve PROTOTYPE((krb5_ccache *id , char *residual )); + +/* fcc_retrv.c */ +krb5_error_code krb5_fcc_retrieve PROTOTYPE((krb5_ccache id , krb5_flags whichfields , krb5_creds *mcreds , krb5_creds *creds )); + +/* fcc_sseq.c */ +krb5_error_code krb5_fcc_start_seq_get PROTOTYPE((krb5_ccache id , krb5_cc_cursor *cursor )); + +/* fcc_store.c */ +krb5_error_code krb5_fcc_store PROTOTYPE((krb5_ccache id , krb5_creds *creds )); + +/* fcc_skip.c */ +krb5_error_code krb5_fcc_skip_principal PROTOTYPE((krb5_ccache id )); + +/* fcc_ops.c */ + +/* fcc_write.c */ +krb5_error_code krb5_fcc_write PROTOTYPE((krb5_ccache id , krb5_pointer buf , int len )); +krb5_error_code krb5_fcc_store_principal PROTOTYPE((krb5_ccache id , krb5_principal princ )); +krb5_error_code krb5_fcc_store_keyblock PROTOTYPE((krb5_ccache id , krb5_keyblock *keyblock )); +krb5_error_code krb5_fcc_store_data PROTOTYPE((krb5_ccache id , krb5_data *data )); +krb5_error_code krb5_fcc_store_int32 PROTOTYPE((krb5_ccache id , krb5_int32 *i )); +krb5_error_code krb5_fcc_store_keytype PROTOTYPE((krb5_ccache id , krb5_keytype *k )); +krb5_error_code krb5_fcc_store_int PROTOTYPE((krb5_ccache id , int *i )); +krb5_error_code krb5_fcc_store_bool PROTOTYPE((krb5_ccache id , krb5_boolean *b )); +krb5_error_code krb5_fcc_store_times PROTOTYPE((krb5_ccache id , krb5_ticket_times *t )); + +/* fcc_test.c */ +void init_test_cred PROTOTYPE((void )); + + diff --git a/src/lib/krb5/ccache/file/fcc_ops.c b/src/lib/krb5/ccache/file/fcc_ops.c new file mode 100644 index 000000000..d26d2408c --- /dev/null +++ b/src/lib/krb5/ccache/file/fcc_ops.c @@ -0,0 +1,45 @@ +/* + * $Source$ + * $Author$ + * + * Copyright 1990 by the Massachusetts Institute of Technology. + * + * For copying and distribution information, please see the file + * . + * + * This file contains the structure krb5_fcc_ops. + */ + +#if !defined(lint) && !defined(SABER) +static char fcc_ops_c[] = "$Id$ +#endif /* !lint && !SABER */ + +#include + +#include "fcc.h" + +krb5_cc_ops krb5_fcc_ops = { + "file", + krb5_fcc_get_name, + krb5_fcc_resolve, + krb5_fcc_generate_new, + krb5_fcc_initialize, + krb5_fcc_destroy, + krb5_fcc_close, + krb5_fcc_store, + krb5_fcc_retrieve, + krb5_fcc_get_principal, + krb5_fcc_start_seq_get, + krb5_fcc_next_cred, + krb5_fcc_end_seq_get, + NULL, /* XXX krb5_fcc_remove, */ + NULL, /* XXX What is the set_flags field? */ +}; + + + + + + + + diff --git a/src/lib/krb5/ccache/file/fcc_skip.c b/src/lib/krb5/ccache/file/fcc_skip.c new file mode 100644 index 000000000..d557f863c --- /dev/null +++ b/src/lib/krb5/ccache/file/fcc_skip.c @@ -0,0 +1,39 @@ +/* + * $Source$ + * $Author$ + * + * Copyright 1990 by the Massachusetts Institute of Technology. + * + * For copying and distribution information, please see the file + * . + * + * This file contains the source code for reading variables from a + * credentials cache. These are not library-exported functions. + */ + +#if !defined(lint) && !defined(SABER) +static char fcc_read_c[] = "$Id$"; +#endif /* !lint && !SABER */ + +#include +#include "fcc.h" + +#define krb5_fcc_skip(i,l) (lseek(((krb5_fcc_data *)i->data)->fd, l, L_INCR)\ + == -1 ? errno : KRB5_OK) + +krb5_error_code +krb5_fcc_skip_principal(id) + krb5_ccache id; +{ + krb5_error_code kret; + krb5_principal princ; + + kret = krb5_fcc_read_principal(id, &princ); + if (kret != KRB5_OK) + return kret; + + /* XXX krb5_destroy_principal(&princ); */ + return KRB5_OK; +} + + diff --git a/src/lib/krb5/ccache/file/fcc_write.c b/src/lib/krb5/ccache/file/fcc_write.c new file mode 100644 index 000000000..741eb2275 --- /dev/null +++ b/src/lib/krb5/ccache/file/fcc_write.c @@ -0,0 +1,162 @@ +/* + * $Source$ + * $Author$ + * + * Copyright 1990 by the Massachusetts Institute of Technology. + * + * For copying and distribution information, please see the file + * . + * + * This file contains the source code for krb5_fcc_write_. + */ + +#if !defined(lint) && !defined(SABER) +static char fcc_write_c[] = "$Id$"; +#endif /* !lint && !SABER */ + +#include + +#include "fcc.h" + +#define CHECK(ret) if (ret != KRB5_OK) return ret; + +/* + * Requires: + * id is open + * + * Effects: + * Writes len bytes from buf into the file cred cache id. + * + * Errors: + * system errors + */ +krb5_error_code +krb5_fcc_write(id, buf, len) + krb5_ccache id; + krb5_pointer buf; + int len; +{ + int ret; + + ret = write(((krb5_fcc_data *)id->data)->fd, (char *) buf, len); + if (ret < 0) + return errno; + return KRB5_OK; +} + +/* + * FOR ALL OF THE FOLLOWING FUNCTIONS: + * + * Requires: + * ((krb5_fcc_data *) id->data)->fd is open and at the right position. + * + * Effects: + * Stores an encoded version of the second argument in the + * cache file. + * + * Errors: + * system errors + */ + +krb5_error_code +krb5_fcc_store_principal(id, princ) + krb5_ccache id; + krb5_principal princ; +{ + krb5_error_code ret; + krb5_principal temp; + krb5_int32 i, length = 0; + + /* Count the number of components */ + temp = princ; + while (*temp++) + length += 1; + + ret = krb5_fcc_store_int32(id, &length); + CHECK(ret); + for (i=0; i < length; i++) { + ret = krb5_fcc_store_data(id, princ[i]); + CHECK(ret); + } + + return KRB5_OK; +} + +krb5_error_code +krb5_fcc_store_keyblock(id, keyblock) + krb5_ccache id; + krb5_keyblock *keyblock; +{ + krb5_error_code ret; + + ret = krb5_fcc_store_keytype(id, &keyblock->keytype); + CHECK(ret); + ret = krb5_fcc_store_int(id, &keyblock->length); + CHECK(ret); + ret = write(((krb5_fcc_data *) id->data)->fd, keyblock->contents, + (keyblock->length)*sizeof(krb5_octet)); + if (ret < 0) + return errno; + + return KRB5_OK; +} + + +krb5_error_code +krb5_fcc_store_data(id, data) + krb5_ccache id; + krb5_data *data; +{ + krb5_error_code ret; + + ret = krb5_fcc_store_int32(id, &data->length); + CHECK(ret); + ret = write(((krb5_fcc_data *) id->data)->fd, data->data, data->length); + if (ret == -1) + return errno; + + return KRB5_OK; +} + +krb5_error_code +krb5_fcc_store_int32(id, i) + krb5_ccache id; + krb5_int32 *i; +{ + return krb5_fcc_write(id, i, sizeof(krb5_int32)); +} + +krb5_error_code +krb5_fcc_store_keytype(id, k) + krb5_ccache id; + krb5_keytype *k; +{ + return krb5_fcc_write(id, k, sizeof(krb5_keytype)); +} + +krb5_error_code +krb5_fcc_store_int(id, i) + krb5_ccache id; + int *i; +{ + return krb5_fcc_write(id, i, sizeof(int)); +} + +krb5_error_code +krb5_fcc_store_bool(id, b) + krb5_ccache id; + krb5_boolean *b; +{ + return krb5_fcc_write(id, b, sizeof(krb5_boolean)); +} + +krb5_error_code +krb5_fcc_store_times(id, t) + krb5_ccache id; + krb5_ticket_times *t; +{ + return krb5_fcc_write(id, t, sizeof(krb5_ticket_times)); +} + + + -- 2.26.2