From 5d119f3729ec0af6c8b87c6ed46e94fb7a18ff4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Love=20H=C3=B6rnquist=20=C3=85strand?= Date: Mon, 3 Dec 2007 12:46:21 +0000 Subject: [PATCH] (krb5_cc_move): new function. git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@22094 ec53bebd-3082-4978-b11e-865c3cabbd6b --- lib/krb5/cache.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/lib/krb5/cache.c b/lib/krb5/cache.c index b9a89f22b..72ad49721 100644 --- a/lib/krb5/cache.c +++ b/lib/krb5/cache.c @@ -1028,3 +1028,35 @@ krb5_cc_cache_match (krb5_context context, return 0; } +/** + * Move the content from one credential cache to another. The + * operation is an atomic switch. + * + * @param context a Keberos context + * @param from the credential cache to move the content from + * @param to the credential cache to move the content to + + * @return On sucess, from is freed. On failure, error code is + * returned and from and to are both still allocated. + * + * @ingroup krb5_ccache + */ + +krb5_error_code +krb5_cc_move(krb5_context context, krb5_ccache from, krb5_ccache to) +{ + krb5_error_code ret; + + if (strcmp(from->ops->prefix, to->ops->prefix) != 0) { + krb5_set_error_string(context, "Moving credentials between diffrent " + "types not yet supported"); + return KRB5_CC_NOSUPP; + } + + ret = (*to->ops->move)(context, from, to); + if (ret == 0) { + memset(from, 0, sizeof(*from)); + free(from); + } + return ret; +}