#include "k5-int.h"
#include "auth_con.h"
#ifndef LEAN_CLIENT
krb5_error_code KRB5_CALLCONV
krb5_copy_authenticator(krb5_context context, const krb5_authenticator *authfrom,
krb5_authenticator **authto)
{
krb5_error_code retval;
krb5_authenticator *tempto;
if (!(tempto = (krb5_authenticator *)malloc(sizeof(*tempto))))
return ENOMEM;
*tempto = *authfrom;
retval = krb5_copy_principal(context, authfrom->client, &tempto->client);
if (retval) {
free(tempto);
return retval;
}
if (authfrom->checksum &&
(retval = krb5_copy_checksum(context, authfrom->checksum, &tempto->checksum))) {
krb5_free_principal(context, tempto->client);
free(tempto);
return retval;
}
if (authfrom->subkey) {
retval = krb5_copy_keyblock(context, authfrom->subkey, &tempto->subkey);
if (retval) {
krb5_free_checksum(context, tempto->checksum);
krb5_free_principal(context, tempto->client);
free(tempto);
return retval;
}
}
if (authfrom->authorization_data) {
retval = krb5_copy_authdata(context, authfrom->authorization_data,
&tempto->authorization_data);
if (retval) {
krb5_free_keyblock(context, tempto->subkey);
krb5_free_checksum(context, tempto->checksum);
krb5_free_principal(context, tempto->client);
free(tempto);
return retval;
}
}
*authto = tempto;
return 0;
}
krb5_error_code KRB5_CALLCONV
krb5_auth_con_getauthenticator(krb5_context context, krb5_auth_context auth_context,
krb5_authenticator **authenticator)
{
return (krb5_copy_authenticator(context, auth_context->authentp,
authenticator));
}
#endif