summaryrefslogtreecommitdiff
path: root/portable
diff options
context:
space:
mode:
Diffstat (limited to 'portable')
-rw-r--r--portable/krb5-extra.c17
-rw-r--r--portable/krb5.h9
2 files changed, 26 insertions, 0 deletions
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