summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source4/librpc/rpc/dcerpc_util.c53
-rw-r--r--source4/torture/local/binding_string.c5
-rw-r--r--source4/torture/torture.c2
3 files changed, 34 insertions, 26 deletions
diff --git a/source4/librpc/rpc/dcerpc_util.c b/source4/librpc/rpc/dcerpc_util.c
index 1adcac8eab..9125f9e017 100644
--- a/source4/librpc/rpc/dcerpc_util.c
+++ b/source4/librpc/rpc/dcerpc_util.c
@@ -242,11 +242,11 @@ static const struct {
enum epm_protocols protseq[MAX_PROTSEQ];
} transports[] = {
{ "ncacn_np", NCACN_NP, 3,
- { EPM_PROTOCOL_NCACN, EPM_PROTOCOL_SMB, EPM_PROTOCOL_PIPE }},
+ { EPM_PROTOCOL_NCACN, EPM_PROTOCOL_SMB, EPM_PROTOCOL_NETBIOS }},
{ "ncacn_ip_tcp", NCACN_IP_TCP, 3,
- { EPM_PROTOCOL_NCACN, EPM_PROTOCOL_IP, EPM_PROTOCOL_TCP } },
+ { EPM_PROTOCOL_NCACN, EPM_PROTOCOL_TCP, EPM_PROTOCOL_IP } },
{ "ncadg_ip_udp", NCACN_IP_UDP, 3,
- { EPM_PROTOCOL_NCACN, EPM_PROTOCOL_IP, EPM_PROTOCOL_UDP } },
+ { EPM_PROTOCOL_NCADG, EPM_PROTOCOL_UDP, EPM_PROTOCOL_IP } },
{ "ncalrpc", NCALRPC, 2,
{ EPM_PROTOCOL_NCALRPC, EPM_PROTOCOL_PIPE } },
{ "ncacn_unix_stream", NCACN_UNIX_STREAM, 2,
@@ -604,23 +604,17 @@ static NTSTATUS floor_set_rhs_data(TALLOC_CTX *mem_ctx, struct epm_floor *floor,
return NT_STATUS_NOT_SUPPORTED;
}
-NTSTATUS dcerpc_binding_from_tower(TALLOC_CTX *mem_ctx, struct epm_tower *tower, struct dcerpc_binding *binding)
+enum dcerpc_transport_t dcerpc_transport_by_tower(struct epm_tower *tower)
{
int i;
- binding->transport = -1;
- ZERO_STRUCT(binding->object);
- binding->options = NULL;
- binding->host = NULL;
- binding->flags = 0;
-
/* Find a transport that matches this tower */
for (i=0;i<ARRAY_SIZE(transports);i++) {
int j;
if (transports[i].num_protocols != tower->num_floors - 2) {
continue;
}
-
+
for (j = 0; j < transports[i].num_protocols; j++) {
if (transports[i].protseq[j] != tower->floors[j+2].lhs.protocol) {
break;
@@ -628,10 +622,22 @@ NTSTATUS dcerpc_binding_from_tower(TALLOC_CTX *mem_ctx, struct epm_tower *tower,
}
if (j == transports[i].num_protocols) {
- binding->transport = transports[i].transport;
- break;
+ return transports[i].transport;
}
}
+
+ /* Unknown transport */
+ return -1;
+}
+
+NTSTATUS dcerpc_binding_from_tower(TALLOC_CTX *mem_ctx, struct epm_tower *tower, struct dcerpc_binding *binding)
+{
+ ZERO_STRUCT(binding->object);
+ binding->options = NULL;
+ binding->host = NULL;
+ binding->flags = 0;
+
+ binding->transport = dcerpc_transport_by_tower(tower);
if (binding->transport == -1) {
return NT_STATUS_NOT_SUPPORTED;
@@ -650,16 +656,16 @@ NTSTATUS dcerpc_binding_from_tower(TALLOC_CTX *mem_ctx, struct epm_tower *tower,
binding->options = talloc_array_p(mem_ctx, const char *, 2);
/* Set endpoint */
- if (tower->num_floors >= 3) {
- binding->options[0] = floor_get_rhs_data(mem_ctx, &tower->floors[tower->num_floors-1]);
+ if (tower->num_floors >= 4) {
+ binding->options[0] = floor_get_rhs_data(mem_ctx, &tower->floors[3]);
} else {
binding->options[0] = NULL;
}
binding->options[1] = NULL;
/* Set network address */
- if (tower->num_floors >= 4) {
- binding->host = floor_get_rhs_data(mem_ctx, &tower->floors[tower->num_floors-2]);
+ if (tower->num_floors >= 5) {
+ binding->host = floor_get_rhs_data(mem_ctx, &tower->floors[4]);
}
return NT_STATUS_OK;
}
@@ -709,17 +715,16 @@ NTSTATUS dcerpc_binding_build_tower(TALLOC_CTX *mem_ctx, struct dcerpc_binding *
ZERO_STRUCT(tower->floors[2 + i].rhs);
}
- /* The top floor contains the endpoint */
- if (num_protocols >= 1 && binding->options && binding->options[0]) {
- status = floor_set_rhs_data(mem_ctx, &tower->floors[2 + num_protocols - 1], binding->options[0]);
+ /* The 4th floor contains the endpoint */
+ if (num_protocols >= 2 && binding->options && binding->options[0]) {
+ status = floor_set_rhs_data(mem_ctx, &tower->floors[3], binding->options[0]);
if (NT_STATUS_IS_ERR(status)) {
return status;
}
}
-
- /* The second-to-top floor contains the network address */
- if (num_protocols >= 2 && binding->host) {
- status = floor_set_rhs_data(mem_ctx, &tower->floors[2 + num_protocols - 2], binding->host);
+ /* The 5th contains the network address */
+ if (num_protocols >= 3 && binding->host) {
+ status = floor_set_rhs_data(mem_ctx, &tower->floors[4], binding->host);
if (NT_STATUS_IS_ERR(status)) {
return status;
}
diff --git a/source4/torture/local/binding_string.c b/source4/torture/local/binding_string.c
index 6522449e64..5e346b4831 100644
--- a/source4/torture/local/binding_string.c
+++ b/source4/torture/local/binding_string.c
@@ -94,7 +94,7 @@ static BOOL test_BindingString(TALLOC_CTX *mem_ctx, const char *binding)
static const char *test_strings[] = {
"ncacn_np:",
"ncalrpc:",
- "ncalrpc:[Security=Sane]",
+ "ncalrpc:[,Security=Sane]",
"ncacn_np:[rpcecho]",
"ncacn_np:127.0.0.1[rpcecho]",
"ncacn_ip_tcp:127.0.0.1",
@@ -105,6 +105,9 @@ static const char *test_strings[] = {
"ncadg_ip_udp:",
"308FB580-1EB2-11CA-923B-08002B1075A7@ncacn_np:localhost",
"308FB580-1EB2-11CA-923B-08002B1075A7@ncacn_ip_tcp:127.0.0.1",
+ "ncacn_unix_stream:[/tmp/epmapper]",
+ "ncalrpc:[IDENTIFIER]",
+ "ncacn_unix_stream:[/tmp/epmapper,sign]",
};
BOOL torture_local_binding_string(int dummy)
diff --git a/source4/torture/torture.c b/source4/torture/torture.c
index 19e8bf266e..e05dba7ee7 100644
--- a/source4/torture/torture.c
+++ b/source4/torture/torture.c
@@ -2972,7 +2972,7 @@ static struct {
{"LOCAL-ICONV", torture_local_iconv, 0},
{"LOCAL-TALLOC", torture_local_talloc, 0},
{"LOCAL-MESSAGING", torture_local_messaging, 0},
- {"LOCAL-BINDINGSTRING", torture_local_binding_string, 0},
+ {"LOCAL-BINDING", torture_local_binding_string, 0},
{"LOCAL-IDTREE", torture_local_idtree, 0},
/* ldap testers */