From 8aeabdadf71d015084caf36580a8e2f75d2ce773 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Love=20H=C3=B6rnquist=20=C3=85strand?= Date: Sat, 26 Jul 2008 18:36:33 +0000 Subject: [PATCH] Add principal to storing config data. git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@23417 ec53bebd-3082-4978-b11e-865c3cabbd6b --- lib/krb5/cache.c | 43 ++++++++++++++++++++++++++++--------------- 1 file changed, 28 insertions(+), 15 deletions(-) diff --git a/lib/krb5/cache.c b/lib/krb5/cache.c index fc20d901e..02db405f7 100644 --- a/lib/krb5/cache.c +++ b/lib/krb5/cache.c @@ -1118,24 +1118,16 @@ krb5_cc_move(krb5_context context, krb5_ccache from, krb5_ccache to) return ret; } -/** - * Store some configuration for the credential cache in the cache. - * Existing configuration under the same name is over-written. - * - * @param context a Keberos context - * @param id the credential cache to store the data for - * @param name name under which the configuraion is stored. - * @param data data to store - */ - #define KRB5_CONF_NAME "@krb5_ccache_conf_data" static krb5_error_code build_conf_principals(krb5_context context, krb5_ccache id, + krb5_const_principal principal, const char *name, krb5_creds *cred) { krb5_principal client; krb5_error_code ret; + char *pname = NULL; memset(cred, 0, sizeof(*cred)); @@ -1143,9 +1135,16 @@ build_conf_principals(krb5_context context, krb5_ccache id, if (ret) return ret; + if (principal) { + ret = krb5_unparse_name(context, principal, &pname); + if (ret) + return ret; + } + ret = krb5_make_principal(context, &cred->server, krb5_principal_get_realm(context, client), - KRB5_CONF_NAME, name, NULL); + KRB5_CONF_NAME, name, pname, NULL); + free(pname); if (ret) { krb5_free_principal(context, client); return ret; @@ -1155,16 +1154,27 @@ build_conf_principals(krb5_context context, krb5_ccache id, return ret; } - +/** + * Store some configuration for the credential cache in the cache. + * Existing configuration under the same name is over-written. + * + * @param context a Keberos context + * @param id the credential cache to store the data for + * @param principal configuration for a specific principal, if + * NULL, global for the whole cache. + * @param name name under which the configuraion is stored. + * @param data data to store + */ krb5_error_code KRB5_LIB_FUNCTION krb5_cc_set_config(krb5_context context, krb5_ccache id, + krb5_const_principal principal, const char *name, krb5_data *data) { krb5_error_code ret; krb5_creds cred; - ret = build_conf_principals(context, id, name, &cred); + ret = build_conf_principals(context, id, principal, name, &cred); if (ret) goto out; @@ -1193,13 +1203,16 @@ out: * * @param context a Keberos context * @param id the credential cache to store the data for + * @param principal configuration for a specific principal, if + * NULL, global for the whole cache. * @param name name under which the configuraion is stored. * @param data data to fetched, free with krb5_data_free() */ krb5_error_code KRB5_LIB_FUNCTION -krb5_cc_get_config(krb5_context context, krb5_ccache id, +krb5_cc_get_config(krb5_context context, krb5_ccache id, + krb5_const_principal principal, const char *name, krb5_data *data) { krb5_creds mcred, cred; @@ -1208,7 +1221,7 @@ krb5_cc_get_config(krb5_context context, krb5_ccache id, memset(&cred, 0, sizeof(cred)); krb5_data_zero(data); - ret = build_conf_principals(context, id, name, &mcred); + ret = build_conf_principals(context, id, principal, name, &mcred); if (ret) goto out;