diff options
| author | Alexandra Ellwood <lxs@mit.edu> | 2000-04-13 22:05:46 +0000 |
|---|---|---|
| committer | Alexandra Ellwood <lxs@mit.edu> | 2000-04-13 22:05:46 +0000 |
| commit | ffb5a241062c119f7542fb1e3a7adc73585df440 (patch) | |
| tree | 08fdbe6687050c768cfa85a7c082df0daade4c95 /src/lib | |
| parent | 53589d32bd0d5ffbbfc9b491a74a08e75b354d2b (diff) | |
2000-4-13 Alexandra Ellwood <lxs@mit.edu>
* ccdefault.c: Added Kerberos Login library support (with ifdefs to control
whether or not it is on. Also added support to store a krb5_principal in the
os_context along with the default ccache name (if known, this principal is
the same as the last time we looked at the ccache.
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@12166 dc483132-0cff-0310-8789-dd5450dbe970
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/krb5/ccache/ccdefault.c | 63 |
1 files changed, 62 insertions, 1 deletions
diff --git a/src/lib/krb5/ccache/ccdefault.c b/src/lib/krb5/ccache/ccdefault.c index 3e2699c56..1393f270f 100644 --- a/src/lib/krb5/ccache/ccdefault.c +++ b/src/lib/krb5/ccache/ccdefault.c @@ -29,10 +29,71 @@ #include "k5-int.h" +#ifdef USE_LOGIN_LIBRARY +#include <KerberosLoginInternal.h> +#endif + KRB5_DLLIMP krb5_error_code KRB5_CALLCONV krb5_cc_default(context, ccache) krb5_context context; krb5_ccache FAR *ccache; { - return krb5_cc_resolve(context, krb5_cc_default_name(context), ccache); + krb5_error_code retval, err; + krb5_os_context os_ctx; + + if (!context || context->magic != KV5M_CONTEXT) + return KV5M_CONTEXT; + + os_ctx = context->os_context; + +#ifdef USE_LOGIN_LIBRARY + { + /* this is the best place to do this: + * make sure the default cache has tix before you open it */ + char *outCacheName; + KLPrincipal desiredPrincipal = nil; + krb5_principal desiredKrb5Principal; + + desiredKrb5Principal = os_ctx->default_ccprincipal; + + /* do we want a specific client principal? */ + if (desiredKrb5Principal != NULL) { + char *desiredName; + + err = krb5_unparse_name (context, desiredKrb5Principal, &desiredName); + if (!err) { + err = KLCreatePrincipalFromString (desiredName, + kerberosPrincipal_V5, &desiredPrincipal); + krb5_free_unparsed_name (context, desiredName); + if (err != klNoErr) + desiredPrincipal = nil; + } + } + + /* Try to make sure a krb5 tgt is in the cache */ + err = __KLInternalAcquireTicketsForCache (desiredPrincipal, + krb5_cc_default_name(context), nil, &outCacheName); + if (err == klNoErr) { + /* This function tries to get tickets and put them in the specified + cache, however, if the cache does not exist, it may choose to put + them elsewhere (ie: the system default) so we set that here */ + if (strcmp (krb5_cc_default_name (context), outCacheName) != 0) { + krb5_cc_set_default_name (context, outCacheName); + } + KLDisposeString (outCacheName); + } + + if (desiredPrincipal != nil) + KLDisposePrincipal (desiredPrincipal); + } +#endif + + retval = krb5_cc_resolve(context, krb5_cc_default_name(context), ccache); + if (!retval && ccache && !os_ctx->default_ccprincipal) { + /* We got a ccache... remember what principal is associated with it */ + err = krb5_cc_get_principal (context, *ccache, &os_ctx->default_ccprincipal); + if (err) + os_ctx->default_ccprincipal == 0; + } + return retval; } |
