OM_uint32 ntlm_gss_export_name_composite(OM_uint32 *minor_status, gss_name_t name, gss_buffer_t exp_composite_name) { OM_uint32 ret; ret = gss_export_name_composite(minor_status, name, exp_composite_name); return (ret); }
uint32_t gp_conv_name_to_gssx(uint32_t *min, gss_name_t in, gssx_name *_out) { uint32_t ret_maj; uint32_t ret_min; gss_buffer_desc name_buffer = GSS_C_EMPTY_BUFFER; gss_OID name_type; gss_buffer_desc exported_name = GSS_C_EMPTY_BUFFER; gss_buffer_desc exported_composite_name = GSS_C_EMPTY_BUFFER; gssx_name out = { .display_name.octet_string_len = 0 }; int ret; ret_maj = gss_display_name(&ret_min, in, &name_buffer, &name_type); if (ret_maj) { goto done; } ret = gp_conv_buffer_to_gssx(&name_buffer, &out.display_name); if (ret) { ret_maj = GSS_S_FAILURE; ret_min = ret; goto done; } ret = gp_conv_oid_to_gssx(name_type, &out.name_type); if (ret) { ret_maj = GSS_S_FAILURE; ret_min = ret; goto done; } ret_maj = gss_export_name(&ret_min, in, &exported_name); if (ret_maj == 0) { ret = gp_conv_buffer_to_gssx(&exported_name, &out.exported_name); if (ret) { ret_maj = GSS_S_FAILURE; ret_min = ret; goto done; } } else { /* In case the error is GSS_S_NAME_NOT_MN the name was not * canonicalized but that is ok we simply do not export the name * in this case */ if (ret_maj != GSS_S_NAME_NOT_MN) { goto done; } } ret_maj = gss_export_name_composite(&ret_min, in, &exported_composite_name); if (ret_maj == 0) { ret = gp_conv_buffer_to_gssx(&exported_composite_name, &out.exported_composite_name); if (ret) { ret_maj = GSS_S_FAILURE; ret_min = ret; goto done; } } else { /* In case the error is GSS_S_NAME_NOT_MN the name was not * canonicalized but that is ok we simply do not export the name * in this case */ if (ret_maj != GSS_S_NAME_NOT_MN && ret_maj != GSS_S_UNAVAILABLE) { goto done; } } ret_maj = GSS_S_COMPLETE; /* out->name_attributes */ done: *min = ret_min; gss_release_buffer(&ret_min, &name_buffer); gss_release_buffer(&ret_min, &exported_name); gss_release_buffer(&ret_min, &exported_composite_name); if (ret_maj) { xdr_free((xdrproc_t)xdr_gssx_buffer, (char *)&out.display_name); xdr_free((xdrproc_t)xdr_gssx_OID, (char *)&out.name_type); xdr_free((xdrproc_t)xdr_gssx_buffer, (char *)&out.exported_name); xdr_free((xdrproc_t)xdr_gssx_buffer, (char *)&out.exported_composite_name); } else { *_out = out; } return ret_maj; } uint32_t gp_conv_name_to_gssx_alloc(uint32_t *min, gss_name_t in, gssx_name **out) { gssx_name *o; uint32_t ret_maj; o = calloc(1, sizeof(gssx_name)); if (!o) { return ENOMEM; } ret_maj = gp_conv_name_to_gssx(min, in, o); if (ret_maj) { free(o); } else { *out = o; } return ret_maj; }