mirror of
https://github.com/samba-team/samba.git
synced 2025-01-27 14:04:05 +03:00
s4:torture: use a connected CLDAP socket.
This is needed because we don't (want) to specify an explicit local address. And the socket family (ipv4 vs. ipv6) needs to be autodetected based on the remote address before the socket() syscall. Otherwise we would try to connect to a ipv4 address through an ipv6only socket. metze
This commit is contained in:
parent
b6737c1a7c
commit
3751485c84
@ -280,16 +280,24 @@ static bool test_cldap_netlogon_flags(struct torture_context *tctx,
|
||||
struct netlogon_samlogon_response n1;
|
||||
uint32_t server_type;
|
||||
struct smb_iconv_convenience *iconv_convenience = lp_iconv_convenience(tctx->lp_ctx);
|
||||
struct tsocket_address *dest_addr;
|
||||
int ret;
|
||||
|
||||
ret = tsocket_address_inet_from_strings(tctx, "ip",
|
||||
dest,
|
||||
lp_cldap_port(tctx->lp_ctx),
|
||||
&dest_addr);
|
||||
CHECK_VAL(ret, 0);
|
||||
|
||||
/* cldap_socket_init should now know about the dest. address */
|
||||
status = cldap_socket_init(tctx, NULL, NULL, NULL, &cldap);
|
||||
status = cldap_socket_init(tctx, NULL, NULL, dest_addr, &cldap);
|
||||
CHECK_STATUS(status, NT_STATUS_OK);
|
||||
|
||||
printf("Printing out netlogon server type flags: %s\n", dest);
|
||||
|
||||
ZERO_STRUCT(search);
|
||||
search.in.dest_address = dest;
|
||||
search.in.dest_port = lp_cldap_port(tctx->lp_ctx);
|
||||
search.in.dest_address = NULL;
|
||||
search.in.dest_port = 0;
|
||||
search.in.acct_control = -1;
|
||||
search.in.version = NETLOGON_NT_VERSION_5 | NETLOGON_NT_VERSION_5EX;
|
||||
search.in.map_response = true;
|
||||
@ -393,16 +401,24 @@ static bool test_cldap_netlogon_flag_ds_dns_forest(struct torture_context *tctx,
|
||||
struct netlogon_samlogon_response n1;
|
||||
struct smb_iconv_convenience *iconv_convenience = lp_iconv_convenience(tctx->lp_ctx);
|
||||
bool result = true;
|
||||
struct tsocket_address *dest_addr;
|
||||
int ret;
|
||||
|
||||
ret = tsocket_address_inet_from_strings(tctx, "ip",
|
||||
dest,
|
||||
lp_cldap_port(tctx->lp_ctx),
|
||||
&dest_addr);
|
||||
CHECK_VAL(ret, 0);
|
||||
|
||||
/* cldap_socket_init should now know about the dest. address */
|
||||
status = cldap_socket_init(tctx, NULL, NULL, NULL, &cldap);
|
||||
status = cldap_socket_init(tctx, NULL, NULL, dest_addr, &cldap);
|
||||
CHECK_STATUS(status, NT_STATUS_OK);
|
||||
|
||||
printf("Testing netlogon server type flag NBT_SERVER_FOREST_ROOT: ");
|
||||
|
||||
ZERO_STRUCT(search);
|
||||
search.in.dest_address = dest;
|
||||
search.in.dest_port = lp_cldap_port(tctx->lp_ctx);
|
||||
search.in.dest_address = NULL;
|
||||
search.in.dest_port = 0;
|
||||
search.in.acct_control = -1;
|
||||
search.in.version = NETLOGON_NT_VERSION_5 | NETLOGON_NT_VERSION_5EX;
|
||||
search.in.map_response = true;
|
||||
@ -467,14 +483,22 @@ static bool test_cldap_generic(struct torture_context *tctx, const char *dest)
|
||||
const char *attrs1[] = { "currentTime", "highestCommittedUSN", NULL };
|
||||
const char *attrs2[] = { "currentTime", "highestCommittedUSN", "netlogon", NULL };
|
||||
const char *attrs3[] = { "netlogon", NULL };
|
||||
struct tsocket_address *dest_addr;
|
||||
int ret;
|
||||
|
||||
ret = tsocket_address_inet_from_strings(tctx, "ip",
|
||||
dest,
|
||||
lp_cldap_port(tctx->lp_ctx),
|
||||
&dest_addr);
|
||||
CHECK_VAL(ret, 0);
|
||||
|
||||
/* cldap_socket_init should now know about the dest. address */
|
||||
status = cldap_socket_init(tctx, NULL, NULL, NULL, &cldap);
|
||||
status = cldap_socket_init(tctx, NULL, NULL, dest_addr, &cldap);
|
||||
CHECK_STATUS(status, NT_STATUS_OK);
|
||||
|
||||
ZERO_STRUCT(search);
|
||||
search.in.dest_address = dest;
|
||||
search.in.dest_port = lp_cldap_port(tctx->lp_ctx);
|
||||
search.in.dest_address = NULL;
|
||||
search.in.dest_port = 0;
|
||||
search.in.timeout = 10;
|
||||
search.in.retries = 3;
|
||||
|
||||
|
@ -80,8 +80,8 @@ static bool bench_cldap_netlogon(struct torture_context *tctx, const char *addre
|
||||
state->tctx = tctx;
|
||||
|
||||
ZERO_STRUCT(search);
|
||||
search.in.dest_address = address;
|
||||
search.in.dest_port = lp_cldap_port(tctx->lp_ctx);
|
||||
search.in.dest_address = NULL;
|
||||
search.in.dest_port = 0;
|
||||
search.in.acct_control = -1;
|
||||
search.in.version = 6;
|
||||
|
||||
@ -147,16 +147,24 @@ static bool bench_cldap_rootdse(struct torture_context *tctx, const char *addres
|
||||
struct cldap_search search;
|
||||
struct bench_state *state;
|
||||
NTSTATUS status;
|
||||
struct tsocket_address *dest_addr;
|
||||
int ret;
|
||||
|
||||
ret = tsocket_address_inet_from_strings(tctx, "ip",
|
||||
address,
|
||||
lp_cldap_port(tctx->lp_ctx),
|
||||
&dest_addr);
|
||||
CHECK_VAL(ret, 0);
|
||||
|
||||
/* cldap_socket_init should now know about the dest. address */
|
||||
status = cldap_socket_init(tctx, tctx->ev, NULL, NULL, &cldap);
|
||||
status = cldap_socket_init(tctx, tctx->ev, NULL, dest_addr, &cldap);
|
||||
torture_assert_ntstatus_ok(tctx, status, "cldap_socket_init");
|
||||
|
||||
state = talloc_zero(tctx, struct bench_state);
|
||||
|
||||
ZERO_STRUCT(search);
|
||||
search.in.dest_address = address;
|
||||
search.in.dest_port = lp_cldap_port(tctx->lp_ctx);
|
||||
search.in.dest_address = NULL;
|
||||
search.in.dest_port = 0;
|
||||
search.in.filter = "(objectClass=*)";
|
||||
search.in.timeout = 2;
|
||||
search.in.retries = 1;
|
||||
|
@ -33,7 +33,7 @@
|
||||
#include "lib/ldb_wrap.h"
|
||||
#include "torture/rpc/rpc.h"
|
||||
#include "torture/drs/proto.h"
|
||||
|
||||
#include "lib/tsocket/tsocket.h"
|
||||
|
||||
struct DsSyncBindInfo {
|
||||
struct dcerpc_pipe *drs_pipe;
|
||||
@ -294,8 +294,21 @@ static bool test_GetInfo(struct torture_context *tctx, struct DsSyncTest *ctx)
|
||||
bool ret = true;
|
||||
struct cldap_socket *cldap;
|
||||
struct cldap_netlogon search;
|
||||
struct tsocket_address *dest_addr;
|
||||
int ret2;
|
||||
|
||||
status = cldap_socket_init(ctx, NULL, NULL, NULL, &cldap);
|
||||
ret2 = tsocket_address_inet_from_strings(tctx, "ip",
|
||||
ctx->drsuapi_binding->host,
|
||||
lp_cldap_port(tctx->lp_ctx),
|
||||
&dest_addr);
|
||||
if (ret2 != 0) {
|
||||
printf("failed to create tsocket_address for '%s' port %u - %s\n",
|
||||
ctx->drsuapi_binding->host, lp_cldap_port(tctx->lp_ctx),
|
||||
strerror(errno));
|
||||
return false;
|
||||
}
|
||||
|
||||
status = cldap_socket_init(ctx, NULL, NULL, dest_addr, &cldap);
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
printf("failed to setup cldap socket - %s\n",
|
||||
nt_errstr(status));
|
||||
@ -333,8 +346,8 @@ static bool test_GetInfo(struct torture_context *tctx, struct DsSyncTest *ctx)
|
||||
ctx->domain_dn = r.out.ctr->ctr1->array[0].result_name;
|
||||
|
||||
ZERO_STRUCT(search);
|
||||
search.in.dest_address = ctx->drsuapi_binding->host;
|
||||
search.in.dest_port = lp_cldap_port(tctx->lp_ctx);
|
||||
search.in.dest_address = NULL;
|
||||
search.in.dest_port = 0;
|
||||
search.in.acct_control = -1;
|
||||
search.in.version = NETLOGON_NT_VERSION_5 | NETLOGON_NT_VERSION_5EX;
|
||||
search.in.map_response = true;
|
||||
|
Loading…
x
Reference in New Issue
Block a user