From 99448954f4f9504796226bf05e76df22231d51ca Mon Sep 17 00:00:00 2001 From: Russ Allbery Date: Tue, 9 Feb 2010 19:43:27 -0800 Subject: Add additional Kerberos portability needed for the test suite --- portable/krb5-extra.c | 17 +++++++++++++++++ portable/krb5.h | 9 +++++++++ 2 files changed, 26 insertions(+) (limited to 'portable') diff --git a/portable/krb5-extra.c b/portable/krb5-extra.c index 09a717b..afd00e8 100644 --- a/portable/krb5-extra.c +++ b/portable/krb5-extra.c @@ -106,3 +106,20 @@ krb5_get_init_creds_opt_alloc(krb5_context ctx, krb5_get_init_creds_opt **opts) return 0; } #endif /* !HAVE_KRB5_GET_INIT_CREDS_OPT_ALLOC */ + + +#ifndef HAVE_KRB5_PRINCIPAL_GET_REALM +/* + * Return the realm of a principal as a const char *. + */ +const char * +krb5_principal_get_realm(krb5_context ctx UNUSED, krb5_const_principal princ) +{ + const krb5_data *data; + + data = krb5_princ_realm(ctx, princ); + if (data == NULL || data->data == NULL) + return NULL; + return data->data; +} +#endif /* !HAVE_KRB5_PRINCIPAL_GET_REALM */ diff --git a/portable/krb5.h b/portable/krb5.h index 117f5ce..d9ef283 100644 --- a/portable/krb5.h +++ b/portable/krb5.h @@ -68,6 +68,15 @@ krb5_error_code krb5_get_init_creds_opt_alloc(krb5_context, # define krb5_kt_free_entry(c, e) krb5_free_keytab_entry_contents((c), (e)) #endif +/* + * Heimdal provides a nice function that just returns a const char *. On MIT, + * there's an accessor macro that returns the krb5_data pointer, wihch + * requires more work to get at the underlying char *. + */ +#ifndef HAVE_KRB5_PRINCIPAL_GET_REALM +const char *krb5_principal_get_realm(krb5_context, krb5_const_principal); +#endif + /* Undo default visibility change. */ #pragma GCC visibility pop -- cgit v1.2.3