Add principal to storing config data.

git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@23417 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
Love Hörnquist Åstrand
2008-07-26 18:36:33 +00:00
parent 0b7c16c7c4
commit 8aeabdadf7

View File

@@ -1118,24 +1118,16 @@ krb5_cc_move(krb5_context context, krb5_ccache from, krb5_ccache to)
return ret; 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" #define KRB5_CONF_NAME "@krb5_ccache_conf_data"
static krb5_error_code static krb5_error_code
build_conf_principals(krb5_context context, krb5_ccache id, build_conf_principals(krb5_context context, krb5_ccache id,
krb5_const_principal principal,
const char *name, krb5_creds *cred) const char *name, krb5_creds *cred)
{ {
krb5_principal client; krb5_principal client;
krb5_error_code ret; krb5_error_code ret;
char *pname = NULL;
memset(cred, 0, sizeof(*cred)); memset(cred, 0, sizeof(*cred));
@@ -1143,9 +1135,16 @@ build_conf_principals(krb5_context context, krb5_ccache id,
if (ret) if (ret)
return ret; return ret;
if (principal) {
ret = krb5_unparse_name(context, principal, &pname);
if (ret)
return ret;
}
ret = krb5_make_principal(context, &cred->server, ret = krb5_make_principal(context, &cred->server,
krb5_principal_get_realm(context, client), krb5_principal_get_realm(context, client),
KRB5_CONF_NAME, name, NULL); KRB5_CONF_NAME, name, pname, NULL);
free(pname);
if (ret) { if (ret) {
krb5_free_principal(context, client); krb5_free_principal(context, client);
return ret; return ret;
@@ -1155,16 +1154,27 @@ build_conf_principals(krb5_context context, krb5_ccache id,
return ret; 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_error_code KRB5_LIB_FUNCTION
krb5_cc_set_config(krb5_context context, krb5_ccache id, krb5_cc_set_config(krb5_context context, krb5_ccache id,
krb5_const_principal principal,
const char *name, krb5_data *data) const char *name, krb5_data *data)
{ {
krb5_error_code ret; krb5_error_code ret;
krb5_creds cred; krb5_creds cred;
ret = build_conf_principals(context, id, name, &cred); ret = build_conf_principals(context, id, principal, name, &cred);
if (ret) if (ret)
goto out; goto out;
@@ -1193,6 +1203,8 @@ out:
* *
* @param context a Keberos context * @param context a Keberos context
* @param id the credential cache to store the data for * @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 name name under which the configuraion is stored.
* @param data data to fetched, free with krb5_data_free() * @param data data to fetched, free with krb5_data_free()
*/ */
@@ -1200,6 +1212,7 @@ out:
krb5_error_code KRB5_LIB_FUNCTION 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) const char *name, krb5_data *data)
{ {
krb5_creds mcred, cred; krb5_creds mcred, cred;
@@ -1208,7 +1221,7 @@ krb5_cc_get_config(krb5_context context, krb5_ccache id,
memset(&cred, 0, sizeof(cred)); memset(&cred, 0, sizeof(cred));
krb5_data_zero(data); krb5_data_zero(data);
ret = build_conf_principals(context, id, name, &mcred); ret = build_conf_principals(context, id, principal, name, &mcred);
if (ret) if (ret)
goto out; goto out;