From b2c518db9a5c508d84f1293e106df71ab3dab5eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Love=20H=C3=B6rnquist=20=C3=85strand?= Date: Sun, 28 Sep 2008 05:14:51 +0000 Subject: [PATCH] add krb5_is_config_principal() git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@23869 ec53bebd-3082-4978-b11e-865c3cabbd6b --- lib/krb5/cache.c | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/lib/krb5/cache.c b/lib/krb5/cache.c index 1eca0d9a5..f8eb5a737 100644 --- a/lib/krb5/cache.c +++ b/lib/krb5/cache.c @@ -1121,7 +1121,8 @@ krb5_cc_move(krb5_context context, krb5_ccache from, krb5_ccache to) return ret; } -#define KRB5_CONF_NAME "@krb5_ccache_conf_data" +#define KRB5_CONF_NAME "krb5_ccache_conf_data" +#define KRB5_REALM_NAME "X-CACHECONF:" static krb5_error_code build_conf_principals(krb5_context context, krb5_ccache id, @@ -1157,6 +1158,31 @@ build_conf_principals(krb5_context context, krb5_ccache id, return ret; } +/** + * Return TRUE (non zero) if the principal is a configuration + * principal (generated part of krb5_cc_set_config()). Returns FALSE + * (zero) if not a configuration principal. + * + * @param context a Keberos context + * @param principal principal to check if it a configuration principal + * + * @ingroup krb5_ccache + */ + +krb5_boolean KRB5_LIB_FUNCTION +krb5_is_config_principal(krb5_context context, + krb5_const_principal principal) +{ + if (strcmp(principal->realm, KRB5_REALM_NAME) != 0) + return FALSE; + + if (principal->name.name_string.len == 0 || + strcmp(principal->name.name_string.val[0], KRB5_CONF_NAME) != 0) + return FALSE; + + return TRUE; +} + /** * Store some configuration for the credential cache in the cache. * Existing configuration under the same name is over-written.