From 09e04bcdf2a6da81f6a7edad8d105ed81205b151 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Sun, 5 Feb 2012 19:05:01 -0500 Subject: Fix accept_sec_context to properly return src_name --- proxy/src/gp_conv.c | 47 +++++++++++++++++++++++++++++ proxy/src/gp_conv.h | 2 ++ proxy/src/mechglue/gpm_accept_sec_context.c | 8 +++++ 3 files changed, 57 insertions(+) diff --git a/proxy/src/gp_conv.c b/proxy/src/gp_conv.c index 4f06987..f93f48e 100644 --- a/proxy/src/gp_conv.c +++ b/proxy/src/gp_conv.c @@ -631,3 +631,50 @@ int gp_conv_oid_set_to_gssx(gss_OID_set in, gssx_OID_set *out) return 0; } + +int gp_copy_gssx_name_alloc(gssx_name *in, gssx_name **out) +{ + gssx_name *o; + int ret; + + o = calloc(1, sizeof(gssx_name)); + if (!o) { + return ENOMEM; + } + + if (in->display_name) { + ret = gp_conv_octet_string_alloc(in->display_name->octet_string_len, + in->display_name->octet_string_val, + &o->display_name); + if (ret) { + goto done; + } + } + ret = gp_conv_octet_string(in->name_type.octet_string_len, + in->name_type.octet_string_val, + &o->name_type); + if (ret) { + goto done; + } + ret = gp_conv_octet_string(in->exported_name.octet_string_len, + in->exported_name.octet_string_val, + &o->exported_name); + if (ret) { + goto done; + } + ret = gp_conv_octet_string(in->exported_composite_name.octet_string_len, + in->exported_composite_name.octet_string_val, + &o->exported_composite_name); + if (ret) { + goto done; + } + + *out = o; + +done: + if (ret) { + xdr_free((xdrproc_t)xdr_gssx_name, (char *)o); + free(o); + } + return ret; +} diff --git a/proxy/src/gp_conv.h b/proxy/src/gp_conv.h index 110970a..02c8c52 100644 --- a/proxy/src/gp_conv.h +++ b/proxy/src/gp_conv.h @@ -68,4 +68,6 @@ int gp_copy_gssx_status_alloc(gssx_status *in, gssx_status **out); int gp_conv_gssx_to_oid_set(gssx_OID_set *in, gss_OID_set *out); int gp_conv_oid_set_to_gssx(gss_OID_set in, gssx_OID_set *out); +int gp_copy_gssx_name_alloc(gssx_name *in, gssx_name **out); + #endif /* _GSS_CONV_H_ */ diff --git a/proxy/src/mechglue/gpm_accept_sec_context.c b/proxy/src/mechglue/gpm_accept_sec_context.c index 3075938..11637c9 100644 --- a/proxy/src/mechglue/gpm_accept_sec_context.c +++ b/proxy/src/mechglue/gpm_accept_sec_context.c @@ -24,6 +24,7 @@ */ #include "gssapi_gpm.h" +#include "src/gp_conv.h" OM_uint32 gpm_accept_sec_context(OM_uint32 *minor_status, gss_ctx_id_t *context_handle, @@ -104,6 +105,13 @@ OM_uint32 gpm_accept_sec_context(OM_uint32 *minor_status, res->context_handle = NULL; } + if (src_name) { + ret = gp_copy_gssx_name_alloc(&ctx->src_name, &name); + if (ret) { + goto done; + } + } + ret = gp_conv_gssx_to_buffer_alloc(res->output_token, &outbuf); if (ret) { goto done; -- cgit