From 3b7a86024b53fd0ac1a98e92bd93a170a1979aec Mon Sep 17 00:00:00 2001 From: Jakub Hrozek Date: Thu, 4 Nov 2010 19:29:01 +0100 Subject: Use internal implementation of internal Kerberos functions Don't use KRB5_PRIVATE. The patch implements and uses the following krb5 functions that are otherwise private in recent MIT Kerberos releases: * krb5_principal2salt_norealm * krb5_free_ktypes Signed-off-by: Simo Sorce --- util/ipa_krb5.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ util/ipa_krb5.h | 12 ++++++++++++ 2 files changed, 56 insertions(+) create mode 100644 util/ipa_krb5.c create mode 100644 util/ipa_krb5.h (limited to 'util') diff --git a/util/ipa_krb5.c b/util/ipa_krb5.c new file mode 100644 index 00000000..5765087c --- /dev/null +++ b/util/ipa_krb5.c @@ -0,0 +1,44 @@ +#include +#include +#include + +#include "ipa_krb5.h" + +void +ipa_krb5_free_ktypes(krb5_context context, krb5_enctype *val) +{ + free(val); +} + +/* + * Convert a krb5_principal into the default salt for that principal. + */ +krb5_error_code +ipa_krb5_principal2salt_norealm(krb5_context context, krb5_const_principal pr, krb5_data *ret) +{ + unsigned int size = 0, offset=0; + krb5_int32 nelem; + register int i; + + if (pr == NULL) { + ret->length = 0; + ret->data = NULL; + return 0; + } + + nelem = krb5_princ_size(context, pr); + + for (i = 0; i < (int) nelem; i++) + size += krb5_princ_component(context, pr, i)->length; + + ret->length = size; + if (!(ret->data = malloc (size))) + return ENOMEM; + + for (i = 0; i < (int) nelem; i++) { + memcpy(&ret->data[offset], krb5_princ_component(context, pr, i)->data, + krb5_princ_component(context, pr, i)->length); + offset += krb5_princ_component(context, pr, i)->length; + } + return 0; +} diff --git a/util/ipa_krb5.h b/util/ipa_krb5.h new file mode 100644 index 00000000..09f492ea --- /dev/null +++ b/util/ipa_krb5.h @@ -0,0 +1,12 @@ +#ifndef __IPA_KRB5_H_ +#define __IPA_KRB5_H_ + +#include + +void +ipa_krb5_free_ktypes(krb5_context context, krb5_enctype *val); + +krb5_error_code +ipa_krb5_principal2salt_norealm(krb5_context context, krb5_const_principal pr, krb5_data *ret); + +#endif /* __IPA_KRB5_H_ */ -- cgit