diff options
author | assar <assar@FreeBSD.org> | 2001-06-21 02:12:07 +0000 |
---|---|---|
committer | assar <assar@FreeBSD.org> | 2001-06-21 02:12:07 +0000 |
commit | 0c8fa354358381b3f1b92598e7f1b46f8cf744cc (patch) | |
tree | ed28ffb73cc0ae48a9892dab3f10b09bc36436d5 /crypto/heimdal/lib/krb5/fcache.c | |
parent | 06c859ecf534f468a52f24a3eb14409d73a4907c (diff) | |
download | FreeBSD-src-0c8fa354358381b3f1b92598e7f1b46f8cf744cc.zip FreeBSD-src-0c8fa354358381b3f1b92598e7f1b46f8cf744cc.tar.gz |
import of heimdal 0.3f
Diffstat (limited to 'crypto/heimdal/lib/krb5/fcache.c')
-rw-r--r-- | crypto/heimdal/lib/krb5/fcache.c | 52 |
1 files changed, 39 insertions, 13 deletions
diff --git a/crypto/heimdal/lib/krb5/fcache.c b/crypto/heimdal/lib/krb5/fcache.c index fbdb3a1..317f702 100644 --- a/crypto/heimdal/lib/krb5/fcache.c +++ b/crypto/heimdal/lib/krb5/fcache.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997 - 2000 Kungliga Tekniska Högskolan + * Copyright (c) 1997 - 2001 Kungliga Tekniska Högskolan * (Royal Institute of Technology, Stockholm, Sweden). * All rights reserved. * @@ -33,7 +33,7 @@ #include "krb5_locl.h" -RCSID("$Id: fcache.c,v 1.31 2000/12/05 09:15:10 joda Exp $"); +RCSID("$Id: fcache.c,v 1.33 2001/05/14 06:14:46 assar Exp $"); typedef struct krb5_fcache{ char *filename; @@ -70,11 +70,14 @@ fcc_resolve(krb5_context context, krb5_ccache *id, const char *res) { krb5_fcache *f; f = malloc(sizeof(*f)); - if(f == NULL) + if(f == NULL) { + krb5_set_error_string(context, "malloc: out of memory"); return KRB5_CC_NOMEM; + } f->filename = strdup(res); if(f->filename == NULL){ free(f); + krb5_set_error_string(context, "malloc: out of memory"); return KRB5_CC_NOMEM; } f->version = 0; @@ -171,18 +174,23 @@ fcc_gen_new(krb5_context context, krb5_ccache *id) krb5_fcache *f; int fd; char *file; + f = malloc(sizeof(*f)); - if(f == NULL) + if(f == NULL) { + krb5_set_error_string(context, "malloc: out of memory"); return KRB5_CC_NOMEM; + } asprintf (&file, "%sXXXXXX", KRB5_DEFAULT_CCFILE_ROOT); if(file == NULL) { free(f); + krb5_set_error_string(context, "malloc: out of memory"); return KRB5_CC_NOMEM; } fd = mkstemp(file); if(fd < 0) { free(f); free(file); + krb5_set_error_string(context, "mkstemp %s", file); return errno; } close(fd); @@ -231,8 +239,12 @@ fcc_initialize(krb5_context context, unlink (filename); fd = open(filename, O_RDWR | O_CREAT | O_EXCL | O_BINARY, 0600); - if(fd == -1) - return errno; + if(fd == -1) { + ret = errno; + krb5_set_error_string(context, "open(%s): %s", filename, + strerror(ret)); + return ret; + } { krb5_storage *sp; sp = krb5_storage_from_fd(fd); @@ -259,8 +271,11 @@ fcc_initialize(krb5_context context, krb5_storage_free(sp); } if(close(fd) < 0) - if (ret == 0) + if (ret == 0) { ret = errno; + krb5_set_error_string (context, "close %s: %s", filename, + strerror(ret)); + } return ret; } @@ -298,8 +313,11 @@ fcc_store_cred(krb5_context context, f = FILENAME(id); fd = open(f, O_WRONLY | O_APPEND | O_BINARY); - if(fd < 0) - return errno; + if(fd < 0) { + ret = errno; + krb5_set_error_string (context, "open(%s): %s", f, strerror(ret)); + return ret; + } { krb5_storage *sp; sp = krb5_storage_from_fd(fd); @@ -308,8 +326,10 @@ fcc_store_cred(krb5_context context, krb5_storage_free(sp); } if (close(fd) < 0) - if (ret == 0) + if (ret == 0) { ret = errno; + krb5_set_error_string (context, "close %s: %s", f, strerror(ret)); + } return ret; } @@ -339,12 +359,18 @@ init_fcc (krb5_context context, krb5_error_code ret; fd = open(fcache->filename, O_RDONLY | O_BINARY); - if(fd < 0) - return errno; + if(fd < 0) { + ret = errno; + krb5_set_error_string(context, "open(%s): %s", fcache->filename, + strerror(ret)); + return ret; + } sp = krb5_storage_from_fd(fd); ret = krb5_ret_int8(sp, &pvno); - if(ret == KRB5_CC_END) + if(ret == KRB5_CC_END) { + return ENOENT; + } if(ret) return ret; if(pvno != 5) { |