|
Packit |
fd8b60 |
/*
|
|
Packit |
fd8b60 |
* Copyright 2004 Sun Microsystems, Inc. All rights reserved.
|
|
Packit |
fd8b60 |
* Use is subject to license terms.
|
|
Packit |
fd8b60 |
*/
|
|
Packit |
fd8b60 |
|
|
Packit |
fd8b60 |
/* #pragma ident "@(#)g_dup_name.c 1.14 04/02/23 SMI" */
|
|
Packit |
fd8b60 |
|
|
Packit |
fd8b60 |
/*
|
|
Packit |
fd8b60 |
* routine gss_duplicate_name
|
|
Packit |
fd8b60 |
*
|
|
Packit |
fd8b60 |
* This routine does not rely on mechanism implementation of this
|
|
Packit |
fd8b60 |
* name, but instead uses mechanism specific gss_import_name routine.
|
|
Packit |
fd8b60 |
*/
|
|
Packit |
fd8b60 |
|
|
Packit |
fd8b60 |
#include <mglueP.h>
|
|
Packit |
fd8b60 |
#ifdef HAVE_STDLIB_H
|
|
Packit |
fd8b60 |
#include <stdlib.h>
|
|
Packit |
fd8b60 |
#endif
|
|
Packit |
fd8b60 |
#include <string.h>
|
|
Packit |
fd8b60 |
#include <errno.h>
|
|
Packit |
fd8b60 |
|
|
Packit |
fd8b60 |
static OM_uint32
|
|
Packit |
fd8b60 |
val_dup_name_args(
|
|
Packit |
fd8b60 |
OM_uint32 *minor_status,
|
|
Packit |
fd8b60 |
const gss_name_t src_name,
|
|
Packit |
fd8b60 |
gss_name_t *dest_name)
|
|
Packit |
fd8b60 |
{
|
|
Packit |
fd8b60 |
|
|
Packit |
fd8b60 |
/* Initialize outputs. */
|
|
Packit |
fd8b60 |
|
|
Packit |
fd8b60 |
if (minor_status != NULL)
|
|
Packit |
fd8b60 |
*minor_status = 0;
|
|
Packit |
fd8b60 |
|
|
Packit |
fd8b60 |
if (dest_name != NULL)
|
|
Packit |
fd8b60 |
*dest_name = GSS_C_NO_NAME;
|
|
Packit |
fd8b60 |
|
|
Packit |
fd8b60 |
/* Validate arguments. */
|
|
Packit |
fd8b60 |
|
|
Packit |
fd8b60 |
if (minor_status == NULL)
|
|
Packit |
fd8b60 |
return (GSS_S_CALL_INACCESSIBLE_WRITE);
|
|
Packit |
fd8b60 |
|
|
Packit |
fd8b60 |
/* if output_name is NULL, simply return */
|
|
Packit |
fd8b60 |
if (dest_name == NULL)
|
|
Packit |
fd8b60 |
return (GSS_S_CALL_INACCESSIBLE_WRITE);
|
|
Packit |
fd8b60 |
|
|
Packit |
fd8b60 |
if (src_name == GSS_C_NO_NAME)
|
|
Packit |
fd8b60 |
return (GSS_S_CALL_INACCESSIBLE_READ | GSS_S_BAD_NAME);
|
|
Packit |
fd8b60 |
|
|
Packit |
fd8b60 |
return (GSS_S_COMPLETE);
|
|
Packit |
fd8b60 |
}
|
|
Packit |
fd8b60 |
|
|
Packit |
fd8b60 |
|
|
Packit |
fd8b60 |
OM_uint32 KRB5_CALLCONV
|
|
Packit |
fd8b60 |
gss_duplicate_name(minor_status,
|
|
Packit |
fd8b60 |
src_name,
|
|
Packit |
fd8b60 |
dest_name)
|
|
Packit |
fd8b60 |
OM_uint32 *minor_status;
|
|
Packit |
fd8b60 |
const gss_name_t src_name;
|
|
Packit |
fd8b60 |
gss_name_t *dest_name;
|
|
Packit |
fd8b60 |
{
|
|
Packit |
fd8b60 |
gss_union_name_t src_union, dest_union;
|
|
Packit |
fd8b60 |
OM_uint32 major_status = GSS_S_FAILURE;
|
|
Packit |
fd8b60 |
|
|
Packit |
fd8b60 |
major_status = val_dup_name_args(minor_status, src_name, dest_name);
|
|
Packit |
fd8b60 |
if (major_status != GSS_S_COMPLETE)
|
|
Packit |
fd8b60 |
return (major_status);
|
|
Packit |
fd8b60 |
|
|
Packit |
fd8b60 |
src_union = (gss_union_name_t)src_name;
|
|
Packit |
fd8b60 |
|
|
Packit |
fd8b60 |
/*
|
|
Packit |
fd8b60 |
* First create the union name struct that will hold the external
|
|
Packit |
fd8b60 |
* name and the name type.
|
|
Packit |
fd8b60 |
*/
|
|
Packit |
fd8b60 |
dest_union = (gss_union_name_t)malloc(sizeof (gss_union_name_desc));
|
|
Packit |
fd8b60 |
if (!dest_union)
|
|
Packit |
fd8b60 |
goto allocation_failure;
|
|
Packit |
fd8b60 |
|
|
Packit |
fd8b60 |
dest_union->loopback = 0;
|
|
Packit |
fd8b60 |
dest_union->mech_type = 0;
|
|
Packit |
fd8b60 |
dest_union->mech_name = 0;
|
|
Packit |
fd8b60 |
dest_union->name_type = 0;
|
|
Packit |
fd8b60 |
dest_union->external_name = 0;
|
|
Packit |
fd8b60 |
|
|
Packit |
fd8b60 |
/* Now copy the external representaion */
|
|
Packit |
fd8b60 |
if (gssint_create_copy_buffer(src_union->external_name,
|
|
Packit |
fd8b60 |
&dest_union->external_name, 0))
|
|
Packit |
fd8b60 |
goto allocation_failure;
|
|
Packit |
fd8b60 |
|
|
Packit |
fd8b60 |
if (src_union->name_type != GSS_C_NULL_OID) {
|
|
Packit |
fd8b60 |
major_status = generic_gss_copy_oid(minor_status,
|
|
Packit |
fd8b60 |
src_union->name_type,
|
|
Packit |
fd8b60 |
&dest_union->name_type);
|
|
Packit |
fd8b60 |
if (major_status != GSS_S_COMPLETE) {
|
|
Packit |
fd8b60 |
map_errcode(minor_status);
|
|
Packit |
fd8b60 |
goto allocation_failure;
|
|
Packit |
fd8b60 |
}
|
|
Packit |
fd8b60 |
}
|
|
Packit |
fd8b60 |
|
|
Packit |
fd8b60 |
/*
|
|
Packit |
fd8b60 |
* See if source name is mechanim specific, if so then need to import it
|
|
Packit |
fd8b60 |
*/
|
|
Packit |
fd8b60 |
if (src_union->mech_type) {
|
|
Packit |
fd8b60 |
major_status = generic_gss_copy_oid(minor_status,
|
|
Packit |
fd8b60 |
src_union->mech_type,
|
|
Packit |
fd8b60 |
&dest_union->mech_type);
|
|
Packit |
fd8b60 |
if (major_status != GSS_S_COMPLETE) {
|
|
Packit |
fd8b60 |
map_errcode(minor_status);
|
|
Packit |
fd8b60 |
goto allocation_failure;
|
|
Packit |
fd8b60 |
}
|
|
Packit |
fd8b60 |
|
|
Packit |
fd8b60 |
major_status = gssint_import_internal_name(minor_status,
|
|
Packit |
fd8b60 |
src_union->mech_type,
|
|
Packit |
fd8b60 |
src_union,
|
|
Packit |
fd8b60 |
&dest_union->mech_name);
|
|
Packit |
fd8b60 |
if (major_status != GSS_S_COMPLETE)
|
|
Packit |
fd8b60 |
goto allocation_failure;
|
|
Packit |
fd8b60 |
}
|
|
Packit |
fd8b60 |
|
|
Packit |
fd8b60 |
|
|
Packit |
fd8b60 |
dest_union->loopback = dest_union;
|
|
Packit |
fd8b60 |
*dest_name = (gss_name_t)dest_union;
|
|
Packit |
fd8b60 |
return (GSS_S_COMPLETE);
|
|
Packit |
fd8b60 |
|
|
Packit |
fd8b60 |
allocation_failure:
|
|
Packit |
fd8b60 |
if (dest_union) {
|
|
Packit |
fd8b60 |
if (dest_union->external_name) {
|
|
Packit |
fd8b60 |
if (dest_union->external_name->value)
|
|
Packit |
fd8b60 |
free(dest_union->external_name->value);
|
|
Packit |
fd8b60 |
free(dest_union->external_name);
|
|
Packit |
fd8b60 |
}
|
|
Packit |
fd8b60 |
if (dest_union->name_type)
|
|
Packit |
fd8b60 |
(void) generic_gss_release_oid(minor_status,
|
|
Packit |
fd8b60 |
&dest_union->name_type);
|
|
Packit |
fd8b60 |
if (dest_union->mech_name)
|
|
Packit |
fd8b60 |
(void) gssint_release_internal_name(minor_status,
|
|
Packit |
fd8b60 |
dest_union->mech_type,
|
|
Packit |
fd8b60 |
&dest_union->mech_name);
|
|
Packit |
fd8b60 |
if (dest_union->mech_type)
|
|
Packit |
fd8b60 |
(void) generic_gss_release_oid(minor_status,
|
|
Packit |
fd8b60 |
&dest_union->mech_type);
|
|
Packit |
fd8b60 |
free(dest_union);
|
|
Packit |
fd8b60 |
}
|
|
Packit |
fd8b60 |
return (major_status);
|
|
Packit |
fd8b60 |
} /* gss_duplicate_name */
|