aboutsummaryrefslogtreecommitdiff
path: root/src/lib/krb5/ccache/file/fcc_store.c
diff options
context:
space:
mode:
authorBarry Jaspan <bjaspan@mit.edu>1990-01-21 16:50:43 +0000
committerBarry Jaspan <bjaspan@mit.edu>1990-01-21 16:50:43 +0000
commit587f799ffea0b9e35c2633be0ebbc263c03c1083 (patch)
tree4f0511380e8e808117a996e0d6ab4424b5c922da /src/lib/krb5/ccache/file/fcc_store.c
parenta8624b5e1f0978913ffa32fce2fbcd3a2e6edec8 (diff)
downloadkrb5-587f799ffea0b9e35c2633be0ebbc263c03c1083.zip
krb5-587f799ffea0b9e35c2633be0ebbc263c03c1083.tar.gz
krb5-587f799ffea0b9e35c2633be0ebbc263c03c1083.tar.bz2
a slightly debugged version (not really), leaving for usenix now
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@161 dc483132-0cff-0310-8789-dd5450dbe970
Diffstat (limited to 'src/lib/krb5/ccache/file/fcc_store.c')
-rw-r--r--src/lib/krb5/ccache/file/fcc_store.c98
1 files changed, 7 insertions, 91 deletions
diff --git a/src/lib/krb5/ccache/file/fcc_store.c b/src/lib/krb5/ccache/file/fcc_store.c
index e0240fc..3f20b32 100644
--- a/src/lib/krb5/ccache/file/fcc_store.c
+++ b/src/lib/krb5/ccache/file/fcc_store.c
@@ -10,24 +10,14 @@
* This file contains the source code for krb5_fcc_store.
*/
-#ifndef lint
+#if !defined(lint) && !defined(SABER)
static char fcc_store_c[] = "$Id$";
-#endif /* lint */
+#endif /* !lint && !SABER */
#include <krb5/copyright.h>
#include "fcc.h"
-/* XXX Doesn't deal if < sizeof(o) bytes are written XXX */
-#define krb5_fcc_write(i,b,l) (write(((krb5_fcc_data *)i->data)->fd,b,l) == -1\
- ? errno : KRB5_OK)
-
-#define krb5_fcc_store_int32(id,i) krb5_fcc_write(id, i, sizeof(krb5_int32))
-#define krb5_fcc_store_keytype(id,k) krb5_fcc_write(id,k,sizeof(krb5_keytype))
-#define krb5_fcc_store_int(id,i) krb5_fcc_write(id,i,sizeof(int))
-#define krb5_fcc_store_bool(id,b) krb5_fcc_write(id,b,sizeof(krb5_boolean))
-#define krb5_fcc_store_times(id,t) krb5_fcc_write(id,t,sizeof(krb5_ticket_times))
-
#define CHECK(ret) if (ret != KRB5_OK) return ret;
/*
@@ -51,14 +41,15 @@ krb5_fcc_store(id, creds)
/* Make sure we are writing to the end of the file */
#ifdef OPENCLOSE
- ((krb5_fcc_data *) id->data)->fd = open(((krb5_fcc_data *) id->data)->filename, O_APPEND, 0);
+ ((krb5_fcc_data *) id->data)->fd = open(((krb5_fcc_data *) id->data)->
+ filename, O_RDWR|O_APPEND, 0);
if (((krb5_fcc_data *) id->data)->fd < 0)
return errno;
-#else
- ret = lseek(((krb5_fcc_data *) id->data)->fd, L_XTND, 0);
+#endif
+
+ ret = lseek(((krb5_fcc_data *) id->data)->fd, 0, L_XTND);
if (ret < 0)
return errno;
-#endif
ret = krb5_fcc_store_principal(id, creds->client);
TCHECK(ret);
@@ -84,78 +75,3 @@ lose:
return ret;
#undef TCHECK
}
-
-/*
- * 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
- */
-
-static 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_store_data(id, princ[i]);
- CHECK(ret);
- }
-
- return KRB5_OK;
-}
-
-static krb5_error_code
-krb5_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));
- CHECK(ret);
-
- return KRB5_OK;
-}
-
-
-static 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;
-}
-
-