aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Yu <tlyu@mit.edu>2006-11-18 01:53:27 +0000
committerTom Yu <tlyu@mit.edu>2006-11-18 01:53:27 +0000
commitea34547e917e0b72b41c453ec60e9784fdff079c (patch)
tree107e7435e5f508a2ac3c19aac14376e56bfab3a1
parent6c3f85e40270175d3f178d013a65cce358646fcb (diff)
downloadkrb5-ea34547e917e0b72b41c453ec60e9784fdff079c.zip
krb5-ea34547e917e0b72b41c453ec60e9784fdff079c.tar.gz
krb5-ea34547e917e0b72b41c453ec60e9784fdff079c.tar.bz2
* src/lib/krb5/ccache/ccbase.c (krb5int_cc_getops): Internal
function to fetch ops vector given ccache prefix string. (krb5_cc_new_unique): New function to generate a new unique ccache of a given type. * src/include/krb5/krb5.hin: Prototype for krb5_cc_new_unique(). * src/lib/krb5/libkrb5.exports: * src/lib/krb5_32.def: Add krb5_cc_new_unique(). ticket: 3091 tags: pullup git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@18857 dc483132-0cff-0310-8789-dd5450dbe970
-rw-r--r--src/include/krb5/krb5.hin6
-rw-r--r--src/lib/krb5/ccache/ccbase.c72
-rw-r--r--src/lib/krb5/libkrb5.exports1
-rw-r--r--src/lib/krb5_32.def1
4 files changed, 69 insertions, 11 deletions
diff --git a/src/include/krb5/krb5.hin b/src/include/krb5/krb5.hin
index 7dacc57..9d9920e 100644
--- a/src/include/krb5/krb5.hin
+++ b/src/include/krb5/krb5.hin
@@ -1310,6 +1310,12 @@ krb5_cccol_cursor_next(
krb5_error_code KRB5_CALLCONV
krb5_cccol_cursor_free(krb5_context context, krb5_cccol_cursor *cursor);
+krb5_error_code KRB5_CALLCONV
+krb5_cc_new_unique(
+ krb5_context context,
+ const char *type,
+ const char *hint,
+ krb5_ccache *id);
/*
* end "ccache.h"
diff --git a/src/lib/krb5/ccache/ccbase.c b/src/lib/krb5/ccache/ccbase.c
index 044f48e..76360bd 100644
--- a/src/lib/krb5/ccache/ccbase.c
+++ b/src/lib/krb5/ccache/ccbase.c
@@ -72,6 +72,9 @@ static struct krb5_cc_typelist cc_fcc_entry = { &krb5_cc_file_ops,
static struct krb5_cc_typelist *cc_typehead = INITIAL_TYPEHEAD;
static k5_mutex_t cc_typelist_lock = K5_MUTEX_PARTIAL_INITIALIZER;
+static krb5_error_code
+krb5int_cc_getops(krb5_context, const char *, const krb5_cc_ops **);
+
int
krb5int_cc_initialize(void)
{
@@ -162,12 +165,13 @@ krb5_cc_register(krb5_context context, krb5_cc_ops *ops, krb5_boolean override)
krb5_error_code KRB5_CALLCONV
krb5_cc_resolve (krb5_context context, const char *name, krb5_ccache *cache)
{
- struct krb5_cc_typelist *tlist;
char *pfx, *cp;
const char *resid;
unsigned int pfxlen;
krb5_error_code err;
-
+ const krb5_cc_ops *ops;
+
+ pfx = NULL;
cp = strchr (name, ':');
if (!cp) {
if (krb5_cc_dfl_ops)
@@ -198,29 +202,75 @@ krb5_cc_resolve (krb5_context context, const char *name, krb5_ccache *cache)
*cache = (krb5_ccache) 0;
- err = k5_mutex_lock(&cc_typelist_lock);
- if (err) {
+ err = krb5int_cc_getops(context, pfx, &ops);
+ if (pfx != NULL)
free(pfx);
+ if (err)
return err;
- }
+
+ return ops->resolve(context, cache, resid);
+}
+
+/*
+ * cc_getops
+ *
+ * Internal function to return the ops vector for a given ccache
+ * prefix string.
+ */
+static krb5_error_code
+krb5int_cc_getops(
+ krb5_context context,
+ const char *pfx,
+ const krb5_cc_ops **ops)
+{
+ krb5_error_code err;
+ struct krb5_cc_typelist *tlist;
+
+ err = k5_mutex_lock(&cc_typelist_lock);
+ if (err)
+ return err;
+
for (tlist = cc_typehead; tlist; tlist = tlist->next) {
if (strcmp (tlist->ops->prefix, pfx) == 0) {
- krb5_error_code (KRB5_CALLCONV *ccresolver)() = tlist->ops->resolve;
+ *ops = tlist->ops;
k5_mutex_unlock(&cc_typelist_lock);
- free(pfx);
- return (*ccresolver)(context, cache, resid);
+ return 0;
}
}
k5_mutex_unlock(&cc_typelist_lock);
if (krb5_cc_dfl_ops && !strcmp (pfx, krb5_cc_dfl_ops->prefix)) {
- free (pfx);
- return (*krb5_cc_dfl_ops->resolve)(context, cache, resid);
+ *ops = krb5_cc_dfl_ops;
+ return 0;
}
- free(pfx);
return KRB5_CC_UNKNOWN_TYPE;
}
/*
+ * cc_new_unique
+ *
+ * Generate a new unique ccache, given a ccache type and a hint
+ * string. Ignores the hint string for now.
+ */
+krb5_error_code KRB5_CALLCONV
+krb5_cc_new_unique(
+ krb5_context context,
+ const char *type,
+ const char *hint,
+ krb5_ccache *id)
+{
+ const krb5_cc_ops *ops;
+ krb5_error_code err;
+
+ *id = NULL;
+
+ err = krb5int_cc_getops(context, type, &ops);
+ if (err)
+ return err;
+
+ return ops->gen_new(context, id);
+}
+
+/*
* cc_typecursor
*
* Note: to avoid copying the typelist at cursor creation time, among
diff --git a/src/lib/krb5/libkrb5.exports b/src/lib/krb5/libkrb5.exports
index add0402..d7998f9 100644
--- a/src/lib/krb5/libkrb5.exports
+++ b/src/lib/krb5/libkrb5.exports
@@ -306,6 +306,7 @@ krb5_cc_get_name
krb5_cc_get_principal
krb5_cc_get_type
krb5_cc_initialize
+krb5_cc_new_unique
krb5_cc_next_cred
krb5_cc_register
krb5_cc_remove_cred
diff --git a/src/lib/krb5_32.def b/src/lib/krb5_32.def
index 07527c9..6a9060b 100644
--- a/src/lib/krb5_32.def
+++ b/src/lib/krb5_32.def
@@ -88,6 +88,7 @@ krb5_c_string_to_key_with_params
krb5_cc_get_principal
krb5_cc_get_type
krb5_cc_initialize
+ krb5_cc_new_unique
krb5_cc_next_cred
krb5_cc_remove_cred
krb5_cc_resolve