diff options
Diffstat (limited to 'src/lib/krb5/os/ccdefname.c')
-rw-r--r-- | src/lib/krb5/os/ccdefname.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/lib/krb5/os/ccdefname.c b/src/lib/krb5/os/ccdefname.c index 53e7888..76c7528 100644 --- a/src/lib/krb5/os/ccdefname.c +++ b/src/lib/krb5/os/ccdefname.c @@ -31,8 +31,8 @@ #include "k5-int.h" #include <stdio.h> -#ifdef macintosh -#include "CCache.h" +#if TARGET_OS_MAC +#include <Kerberos/CredentialsCache.h> #endif #if defined(_WIN32) @@ -160,7 +160,7 @@ static krb5_error_code get_from_os(char *name_buf, int name_size) if (get_from_registry_indirect(name_buf, name_size) != 0) return 0; - strncpy(name_buf, prefix, name_size); + strncpy(name_buf, prefix, name_size - 1); name_buf[name_size - 1] = 0; size = name_size - strlen(prefix); if (size > 0) @@ -186,7 +186,7 @@ static krb5_error_code get_from_os(char *name_buf, int name_size) } #endif -#if defined (macintosh) +#if TARGET_OS_MAC static krb5_error_code get_from_os(char *name_buf, int name_size) { @@ -261,6 +261,13 @@ krb5_cc_set_default_name(context, name) return ENOMEM; strcpy(new_name, name_buf); + if (!os_ctx->default_ccname || (strcmp(os_ctx->default_ccname, new_name) != 0)) { + /* the ccache changed... forget the old principal */ + if (os_ctx->default_ccprincipal) + krb5_free_principal (context, os_ctx->default_ccprincipal); + os_ctx->default_ccprincipal = 0; /* we don't care until we use it */ + } + if (os_ctx->default_ccname) free(os_ctx->default_ccname); |