diff options
Diffstat (limited to 'crypto/heimdal/lib/krb5/cache.c')
-rw-r--r-- | crypto/heimdal/lib/krb5/cache.c | 69 |
1 files changed, 52 insertions, 17 deletions
diff --git a/crypto/heimdal/lib/krb5/cache.c b/crypto/heimdal/lib/krb5/cache.c index d25a5159a7dcb..26cda9a626041 100644 --- a/crypto/heimdal/lib/krb5/cache.c +++ b/crypto/heimdal/lib/krb5/cache.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997-2002 Kungliga Tekniska Högskolan + * Copyright (c) 1997-2003 Kungliga Tekniska Högskolan * (Royal Institute of Technology, Stockholm, Sweden). * All rights reserved. * @@ -33,7 +33,7 @@ #include "krb5_locl.h" -RCSID("$Id: cache.c,v 1.49 2002/05/29 16:08:23 joda Exp $"); +RCSID("$Id: cache.c,v 1.52 2003/03/16 18:23:59 lha Exp $"); /* * Add a new ccache type with operations `ops', overwriting any @@ -180,24 +180,57 @@ krb5_cc_get_type(krb5_context context, } /* - * Return a pointer to a static string containing the default ccache name. + * Return krb5_cc_ops of a the ccache `id'. + */ + +const krb5_cc_ops * +krb5_cc_get_ops(krb5_context context, krb5_ccache id) +{ + return id->ops; +} + +/* + * Set the default cc name for `context' to `name'. + */ + +krb5_error_code +krb5_cc_set_default_name(krb5_context context, const char *name) +{ + krb5_error_code ret = 0; + char *p; + + if (name == NULL) { + char *e; + e = getenv("KRB5CCNAME"); + if (e) + p = strdup(e); + else + asprintf(&p,"FILE:/tmp/krb5cc_%u", (unsigned)getuid()); + } else + p = strdup(name); + + if (p == NULL) + return ENOMEM; + + if (context->default_cc_name) + free(context->default_cc_name); + + context->default_cc_name = p; + + return ret; +} + +/* + * Return a pointer to a context static string containing the default ccache name. */ const char* krb5_cc_default_name(krb5_context context) { - static char name[1024]; - char *p; + if (context->default_cc_name == NULL) + krb5_cc_set_default_name(context, NULL); - p = getenv("KRB5CCNAME"); - if(p) - strlcpy (name, p, sizeof(name)); - else - snprintf(name, - sizeof(name), - "FILE:/tmp/krb5cc_%u", - (unsigned)getuid()); - return name; + return context->default_cc_name; } /* @@ -209,9 +242,11 @@ krb5_error_code krb5_cc_default(krb5_context context, krb5_ccache *id) { - return krb5_cc_resolve(context, - krb5_cc_default_name(context), - id); + const char *p = krb5_cc_default_name(context); + + if (p == NULL) + return ENOMEM; + return krb5_cc_resolve(context, p, id); } /* |