From aac08b6b4666f06c625d49252c4cad776c52731e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Love=20H=C3=B6rnquist=20=C3=85strand?= Date: Mon, 7 Apr 2008 11:46:42 +0000 Subject: [PATCH] Implement destroy. git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@22816 ec53bebd-3082-4978-b11e-865c3cabbd6b --- lib/krb5/scache.c | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/lib/krb5/scache.c b/lib/krb5/scache.c index 1a017f190..25358442e 100644 --- a/lib/krb5/scache.c +++ b/lib/krb5/scache.c @@ -60,7 +60,7 @@ typedef struct krb5_scache { #define SCACHE(X) ((krb5_scache *)(X)->data.data) -#define DEFAULT_SCACHE "/tmp/scache-foo" /* XXX */ +#define DEFAULT_SCACHE "/tmp/scache-bar" /* XXX */ #define SCACHE_STRING(x) #x #define SCACHE_XSTRING(x) SCACHE_STRING(x) @@ -263,7 +263,7 @@ create_cache(krb5_context context, krb5_scache *s) return 0; } -#if 0 +#ifdef TRACEME static void trace(void* ptr, const char * str) { @@ -283,8 +283,7 @@ make_database(krb5_context context, krb5_scache *s) ret = open_database(context, s, 0); if (ret) { ret = open_database(context, s, SQLITE_OPEN_CREATE); - if (ret) - return ret; + if (ret) goto out; created_file = 1; @@ -305,7 +304,7 @@ make_database(krb5_context context, krb5_scache *s) if (ret) goto out; } -#if 0 +#ifdef TRACEME sqlite3_trace(s->db, trace, NULL); #endif @@ -500,7 +499,7 @@ static krb5_error_code scc_close(krb5_context context, krb5_ccache id) { - krb5_data_free(&id->data); + scc_free(SCACHE(id)); return 0; } @@ -508,7 +507,19 @@ static krb5_error_code scc_destroy(krb5_context context, krb5_ccache id) { - scc_close(context, id); + krb5_scache *s = SCACHE(id); + int ret; + + sqlite3_bind_int(s->dcache, 1, s->cid); + do { + ret = sqlite3_step(s->dcache); + } while (ret == SQLITE_ROW); + sqlite3_reset(s->dcache); + if (ret != SQLITE_DONE) { + krb5_set_error_string(context, "Failed to destroy cache %s: %s", + s->name, sqlite3_errmsg(s->db)); + return KRB5_CC_IO; + } return 0; }