mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
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 <ssorce@redhat.com>
This commit is contained in:
44
util/ipa_krb5.c
Normal file
44
util/ipa_krb5.c
Normal file
@@ -0,0 +1,44 @@
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
|
||||
#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;
|
||||
}
|
||||
12
util/ipa_krb5.h
Normal file
12
util/ipa_krb5.h
Normal file
@@ -0,0 +1,12 @@
|
||||
#ifndef __IPA_KRB5_H_
|
||||
#define __IPA_KRB5_H_
|
||||
|
||||
#include <krb5.h>
|
||||
|
||||
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_ */
|
||||
Reference in New Issue
Block a user