From: Stefan Metzmacher Date: Fri, 31 Jan 2014 20:10:41 +0000 (+0100) Subject: s3:srv_epmapper: make use of dcerpc_binding_*() functions in build_ep_list() X-Git-Tag: tdb-1.2.13~411 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=516b9d6dead4efcff10ca52aa2efb9d9a248c557;p=thirdparty%2Fsamba.git s3:srv_epmapper: make use of dcerpc_binding_*() functions in build_ep_list() Signed-off-by: Stefan Metzmacher Reviewed-by: Guenther Deschner --- diff --git a/source3/rpc_server/epmapper/srv_epmapper.c b/source3/rpc_server/epmapper/srv_epmapper.c index 871ee2e0243..0e1637887d7 100644 --- a/source3/rpc_server/epmapper/srv_epmapper.c +++ b/source3/rpc_server/epmapper/srv_epmapper.c @@ -214,6 +214,10 @@ static uint32_t build_ep_list(TALLOC_CTX *mem_ctx, struct dcerpc_binding *description; for (iface = d->iface_list; iface != NULL; iface = iface->next) { + enum dcerpc_transport_t transport; + const char *host = NULL; + const char *host_addr = NULL; + if (uuid && !interface_match_by_uuid(iface->iface, uuid)) { continue; } @@ -227,18 +231,42 @@ static uint32_t build_ep_list(TALLOC_CTX *mem_ctx, } eps[total].name = talloc_strdup(eps, iface->iface->name); + if (eps[total].name == NULL) { + return 0; + } eps[total].syntax_id = iface->iface->syntax_id; description = dcerpc_binding_dup(mem_ctx, d->ep_description); if (description == NULL) { return 0; } - description->object = iface->iface->syntax_id; - if (description->transport == NCACN_IP_TCP && - srv_addr != NULL && - (strcmp(description->host, "0.0.0.0") == 0 || - strcmp(description->host, "::") == 0)) { - description->host = srv_addr; + + status = dcerpc_binding_set_abstract_syntax(description, + &iface->iface->syntax_id); + if (!NT_STATUS_IS_OK(status)) { + return 0; + } + + transport = dcerpc_binding_get_transport(description); + host = dcerpc_binding_get_string_option(description, "host"); + + if (transport == NCACN_IP_TCP) { + if (host == NULL) { + host_addr = srv_addr; + } else if (!is_ipaddress_v4(host)) { + host_addr = srv_addr; + } else if (strcmp(host, "0.0.0.0") == 0) { + host_addr = srv_addr; + } + } + + if (host_addr != NULL) { + status = dcerpc_binding_set_string_option(description, + "host", + host_addr); + if (!NT_STATUS_IS_OK(status)) { + return 0; + } } status = dcerpc_binding_build_tower(eps,