mirror of
https://github.com/samba-team/samba.git
synced 2025-01-11 05:18:09 +03:00
r3156: Couple of fixes in the conversion functions between binding structs and
protocol towers
(This used to be commit f41dfc6c5a
)
This commit is contained in:
parent
2641612a49
commit
f1dd80e74e
@ -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;
|
||||
}
|
||||
|
@ -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)
|
||||
|
@ -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 */
|
||||
|
Loading…
Reference in New Issue
Block a user