1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-08 21:18:16 +03:00

libsmb: Pass neg contexts through sync smbXcli_negprot_recv()

Looks much larger than it is, there's a lot of callers too feed NULL to.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>

Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Mon Sep 25 19:59:17 UTC 2023 on atb-devel-224
This commit is contained in:
Volker Lendecke 2023-09-19 11:10:12 -07:00 committed by Jeremy Allison
parent b693b6accc
commit fab08854af
12 changed files with 273 additions and 92 deletions

View File

@ -5595,7 +5595,10 @@ NTSTATUS smbXcli_negprot_recv(
NTSTATUS smbXcli_negprot(struct smbXcli_conn *conn,
uint32_t timeout_msec,
enum protocol_types min_protocol,
enum protocol_types max_protocol)
enum protocol_types max_protocol,
struct smb2_negotiate_contexts *in_ctx,
TALLOC_CTX *mem_ctx,
struct smb2_negotiate_contexts **out_ctx)
{
TALLOC_CTX *frame = talloc_stackframe();
struct tevent_context *ev;
@ -5622,7 +5625,7 @@ NTSTATUS smbXcli_negprot(struct smbXcli_conn *conn,
min_protocol,
max_protocol,
WINDOWS_CLIENT_PURE_SMB2_NEGPROT_INITIAL_CREDIT_ASK,
NULL);
in_ctx);
if (req == NULL) {
goto fail;
}
@ -5630,7 +5633,7 @@ NTSTATUS smbXcli_negprot(struct smbXcli_conn *conn,
if (!ok) {
goto fail;
}
status = smbXcli_negprot_recv(req, NULL, NULL);
status = smbXcli_negprot_recv(req, mem_ctx, out_ctx);
fail:
TALLOC_FREE(frame);
return status;

View File

@ -481,7 +481,10 @@ NTSTATUS smbXcli_negprot_recv(
NTSTATUS smbXcli_negprot(struct smbXcli_conn *conn,
uint32_t timeout_msec,
enum protocol_types min_protocol,
enum protocol_types max_protocol);
enum protocol_types max_protocol,
struct smb2_negotiate_contexts *in_ctx,
TALLOC_CTX *mem_ctx,
struct smb2_negotiate_contexts **out_ctx);
struct tevent_req *smb2cli_validate_negotiate_info_send(TALLOC_CTX *mem_ctx,
struct tevent_context *ev,

View File

@ -193,9 +193,13 @@ static NTSTATUS do_connect(TALLOC_CTX *ctx,
DEBUG(4,(" session request ok\n"));
status = smbXcli_negprot(c->conn, c->timeout,
status = smbXcli_negprot(c->conn,
c->timeout,
lp_client_min_protocol(),
lp_client_max_protocol());
lp_client_max_protocol(),
NULL,
NULL,
NULL);
if (NT_STATUS_EQUAL(status, NT_STATUS_IO_TIMEOUT)) {
d_printf("Protocol negotiation (with timeout %d ms) timed out against server %s\n",

View File

@ -555,9 +555,13 @@ SMBC_server_internal(TALLOC_CTX *ctx,
cli_set_timeout(c, smbc_getTimeout(context));
status = smbXcli_negprot(c->conn, c->timeout,
status = smbXcli_negprot(c->conn,
c->timeout,
lp_client_min_protocol(),
lp_client_max_protocol());
lp_client_max_protocol(),
NULL,
NULL,
NULL);
if (!NT_STATUS_IS_OK(status)) {
cli_shutdown(c);
errno = map_errno_from_nt_status(status);

View File

@ -74,9 +74,13 @@ NTSTATUS remote_password_change(const char *remote_machine,
false); /* password_is_nt_hash */
SMB_ASSERT(creds != NULL);
result = smbXcli_negprot(cli->conn, cli->timeout,
result = smbXcli_negprot(cli->conn,
cli->timeout,
lp_client_ipc_min_protocol(),
lp_client_ipc_max_protocol());
lp_client_ipc_max_protocol(),
NULL,
NULL,
NULL);
if (!NT_STATUS_IS_OK(result)) {
if (asprintf(err_str, "machine %s rejected the negotiate "

View File

@ -90,8 +90,13 @@ static void sync_child(char *name, int nm_type,
return;
}
status = smbXcli_negprot(cli->conn, cli->timeout, PROTOCOL_CORE,
PROTOCOL_NT1);
status = smbXcli_negprot(cli->conn,
cli->timeout,
PROTOCOL_CORE,
PROTOCOL_NT1,
NULL,
NULL,
NULL);
if (!NT_STATUS_IS_OK(status)) {
cli_shutdown(cli);
return;

View File

@ -320,7 +320,10 @@ bool run_posix_ls_single_test(int dummy)
status = smbXcli_negprot(cli_win->conn,
cli_win->timeout,
lp_client_min_protocol(),
lp_client_max_protocol());
lp_client_max_protocol(),
NULL,
NULL,
NULL);
if (!NT_STATUS_IS_OK(status)) {
printf("smbXcli_negprot returned %s\n", nt_errstr(status));
TALLOC_FREE(frame);

View File

@ -55,8 +55,13 @@ bool run_smb2_basic(int dummy)
return false;
}
status = smbXcli_negprot(cli->conn, cli->timeout,
PROTOCOL_SMB2_02, PROTOCOL_SMB2_02);
status = smbXcli_negprot(cli->conn,
cli->timeout,
PROTOCOL_SMB2_02,
PROTOCOL_SMB2_02,
NULL,
NULL,
NULL);
if (!NT_STATUS_IS_OK(status)) {
printf("smbXcli_negprot returned %s\n", nt_errstr(status));
return false;
@ -257,8 +262,13 @@ bool run_smb2_negprot(int dummy)
return false;
}
status = smbXcli_negprot(cli->conn, cli->timeout,
PROTOCOL_CORE, PROTOCOL_LATEST);
status = smbXcli_negprot(cli->conn,
cli->timeout,
PROTOCOL_CORE,
PROTOCOL_LATEST,
NULL,
NULL,
NULL);
if (!NT_STATUS_IS_OK(status)) {
printf("smbXcli_negprot returned %s\n", nt_errstr(status));
return false;
@ -274,8 +284,13 @@ bool run_smb2_negprot(int dummy)
return false;
}
status = smbXcli_negprot(cli->conn, cli->timeout,
protocol, protocol);
status = smbXcli_negprot(cli->conn,
cli->timeout,
protocol,
protocol,
NULL,
NULL,
NULL);
if (!NT_STATUS_EQUAL(status, NT_STATUS_CONNECTION_RESET) &&
!NT_STATUS_EQUAL(status, NT_STATUS_CONNECTION_DISCONNECTED) &&
!NT_STATUS_EQUAL(status, NT_STATUS_CONNECTION_ABORTED)) {
@ -306,8 +321,13 @@ bool run_smb2_anonymous(int dummy)
return false;
}
status = smbXcli_negprot(cli->conn, cli->timeout,
PROTOCOL_SMB2_02, PROTOCOL_LATEST);
status = smbXcli_negprot(cli->conn,
cli->timeout,
PROTOCOL_SMB2_02,
PROTOCOL_LATEST,
NULL,
NULL,
NULL);
if (!NT_STATUS_IS_OK(status)) {
printf("smbXcli_negprot returned %s\n", nt_errstr(status));
return false;
@ -358,8 +378,13 @@ bool run_smb2_session_reconnect(int dummy)
return false;
}
status = smbXcli_negprot(cli1->conn, cli1->timeout,
PROTOCOL_SMB2_02, PROTOCOL_LATEST);
status = smbXcli_negprot(cli1->conn,
cli1->timeout,
PROTOCOL_SMB2_02,
PROTOCOL_LATEST,
NULL,
NULL,
NULL);
if (!NT_STATUS_IS_OK(status)) {
printf("smbXcli_negprot returned %s\n", nt_errstr(status));
return false;
@ -446,8 +471,13 @@ bool run_smb2_session_reconnect(int dummy)
return false;
}
status = smbXcli_negprot(cli2->conn, cli2->timeout,
PROTOCOL_SMB2_02, PROTOCOL_LATEST);
status = smbXcli_negprot(cli2->conn,
cli2->timeout,
PROTOCOL_SMB2_02,
PROTOCOL_LATEST,
NULL,
NULL,
NULL);
if (!NT_STATUS_IS_OK(status)) {
printf("smbXcli_negprot returned %s\n", nt_errstr(status));
return false;
@ -802,8 +832,13 @@ bool run_smb2_tcon_dependence(int dummy)
return false;
}
status = smbXcli_negprot(cli->conn, cli->timeout,
PROTOCOL_SMB2_02, PROTOCOL_LATEST);
status = smbXcli_negprot(cli->conn,
cli->timeout,
PROTOCOL_SMB2_02,
PROTOCOL_LATEST,
NULL,
NULL,
NULL);
if (!NT_STATUS_IS_OK(status)) {
printf("smbXcli_negprot returned %s\n", nt_errstr(status));
return false;
@ -949,22 +984,37 @@ bool run_smb2_multi_channel(int dummy)
cli_state_client_guid = saved_guid;
status = smbXcli_negprot(cli1->conn, cli1->timeout,
PROTOCOL_SMB3_00, PROTOCOL_LATEST);
status = smbXcli_negprot(cli1->conn,
cli1->timeout,
PROTOCOL_SMB3_00,
PROTOCOL_LATEST,
NULL,
NULL,
NULL);
if (!NT_STATUS_IS_OK(status)) {
printf("smbXcli_negprot returned %s\n", nt_errstr(status));
return false;
}
status = smbXcli_negprot(cli2->conn, cli2->timeout,
PROTOCOL_SMB3_00, PROTOCOL_LATEST);
status = smbXcli_negprot(cli2->conn,
cli2->timeout,
PROTOCOL_SMB3_00,
PROTOCOL_LATEST,
NULL,
NULL,
NULL);
if (!NT_STATUS_IS_OK(status)) {
printf("smbXcli_negprot returned %s\n", nt_errstr(status));
return false;
}
status = smbXcli_negprot(cli3->conn, cli3->timeout,
PROTOCOL_SMB3_00, PROTOCOL_LATEST);
status = smbXcli_negprot(cli3->conn,
cli3->timeout,
PROTOCOL_SMB3_00,
PROTOCOL_LATEST,
NULL,
NULL,
NULL);
if (!NT_STATUS_IS_OK(status)) {
printf("smbXcli_negprot returned %s\n", nt_errstr(status));
return false;
@ -1556,8 +1606,13 @@ bool run_smb2_session_reauth(int dummy)
* and returns NT_STATUS_REQUEST_NOT_ACCEPTED,
* while it allows it on PROTOCOL_SMB2_10.
*/
status = smbXcli_negprot(cli->conn, cli->timeout,
PROTOCOL_SMB2_10, PROTOCOL_SMB2_10);
status = smbXcli_negprot(cli->conn,
cli->timeout,
PROTOCOL_SMB2_10,
PROTOCOL_SMB2_10,
NULL,
NULL,
NULL);
if (!NT_STATUS_IS_OK(status)) {
printf("smbXcli_negprot returned %s\n", nt_errstr(status));
return false;
@ -2110,8 +2165,13 @@ bool run_smb2_ftruncate(int dummy)
goto fail;
}
status = smbXcli_negprot(cli->conn, cli->timeout,
PROTOCOL_SMB2_02, PROTOCOL_SMB2_02);
status = smbXcli_negprot(cli->conn,
cli->timeout,
PROTOCOL_SMB2_02,
PROTOCOL_SMB2_02,
NULL,
NULL,
NULL);
if (!NT_STATUS_IS_OK(status)) {
printf("smbXcli_negprot returned %s\n", nt_errstr(status));
goto fail;
@ -2478,8 +2538,13 @@ bool run_smb2_dir_fsync(int dummy)
return false;
}
status = smbXcli_negprot(cli->conn, cli->timeout,
PROTOCOL_SMB2_02, PROTOCOL_SMB2_02);
status = smbXcli_negprot(cli->conn,
cli->timeout,
PROTOCOL_SMB2_02,
PROTOCOL_SMB2_02,
NULL,
NULL,
NULL);
if (!NT_STATUS_IS_OK(status)) {
printf("smbXcli_negprot returned %s\n", nt_errstr(status));
return false;
@ -2541,8 +2606,13 @@ bool run_smb2_path_slash(int dummy)
return false;
}
status = smbXcli_negprot(cli->conn, cli->timeout,
PROTOCOL_SMB2_02, PROTOCOL_SMB2_02);
status = smbXcli_negprot(cli->conn,
cli->timeout,
PROTOCOL_SMB2_02,
PROTOCOL_SMB2_02,
NULL,
NULL,
NULL);
if (!NT_STATUS_IS_OK(status)) {
printf("smbXcli_negprot returned %s\n", nt_errstr(status));
return false;
@ -2786,9 +2856,12 @@ bool run_smb2_sacl(int dummy)
}
status = smbXcli_negprot(cli->conn,
cli->timeout,
PROTOCOL_SMB2_02,
PROTOCOL_SMB3_11);
cli->timeout,
PROTOCOL_SMB2_02,
PROTOCOL_SMB3_11,
NULL,
NULL,
NULL);
if (!NT_STATUS_IS_OK(status)) {
printf("smbXcli_negprot returned %s\n", nt_errstr(status));
return false;
@ -3094,9 +3167,12 @@ bool run_smb2_quota1(int dummy)
}
status = smbXcli_negprot(cli->conn,
cli->timeout,
PROTOCOL_SMB2_02,
PROTOCOL_SMB3_11);
cli->timeout,
PROTOCOL_SMB2_02,
PROTOCOL_SMB3_11,
NULL,
NULL,
NULL);
if (!NT_STATUS_IS_OK(status)) {
printf("smbXcli_negprot returned %s\n", nt_errstr(status));
return false;
@ -3164,9 +3240,12 @@ bool run_smb2_stream_acl(int dummy)
}
status = smbXcli_negprot(cli->conn,
cli->timeout,
PROTOCOL_SMB2_02,
PROTOCOL_SMB3_11);
cli->timeout,
PROTOCOL_SMB2_02,
PROTOCOL_SMB3_11,
NULL,
NULL,
NULL);
if (!NT_STATUS_IS_OK(status)) {
printf("smbXcli_negprot returned %s\n", nt_errstr(status));
return false;
@ -3386,9 +3465,12 @@ bool run_list_dir_async_test(int dummy)
}
status = smbXcli_negprot(cli->conn,
cli->timeout,
PROTOCOL_SMB2_02,
PROTOCOL_SMB3_11);
cli->timeout,
PROTOCOL_SMB2_02,
PROTOCOL_SMB3_11,
NULL,
NULL,
NULL);
if (!NT_STATUS_IS_OK(status)) {
printf("smbXcli_negprot returned %s\n", nt_errstr(status));
return false;
@ -3461,9 +3543,12 @@ bool run_delete_on_close_non_empty(int dummy)
}
status = smbXcli_negprot(cli->conn,
cli->timeout,
PROTOCOL_SMB2_02,
PROTOCOL_SMB3_11);
cli->timeout,
PROTOCOL_SMB2_02,
PROTOCOL_SMB3_11,
NULL,
NULL,
NULL);
if (!NT_STATUS_IS_OK(status)) {
printf("smbXcli_negprot returned %s\n", nt_errstr(status));
return false;
@ -3615,9 +3700,12 @@ bool run_delete_on_close_nonwrite_delete_yes_test(int dummy)
}
status = smbXcli_negprot(cli->conn,
cli->timeout,
PROTOCOL_SMB2_02,
PROTOCOL_SMB3_11);
cli->timeout,
PROTOCOL_SMB2_02,
PROTOCOL_SMB3_11,
NULL,
NULL,
NULL);
if (!NT_STATUS_IS_OK(status)) {
printf("smbXcli_negprot returned %s\n", nt_errstr(status));
return false;
@ -3726,9 +3814,12 @@ bool run_delete_on_close_nonwrite_delete_no_test(int dummy)
}
status = smbXcli_negprot(cli->conn,
cli->timeout,
PROTOCOL_SMB2_02,
PROTOCOL_SMB3_11);
cli->timeout,
PROTOCOL_SMB2_02,
PROTOCOL_SMB3_11,
NULL,
NULL,
NULL);
if (!NT_STATUS_IS_OK(status)) {
printf("smbXcli_negprot returned %s\n", nt_errstr(status));
return false;
@ -4195,9 +4286,12 @@ bool run_smb2_dfs_paths(int dummy)
}
status = smbXcli_negprot(cli->conn,
cli->timeout,
PROTOCOL_SMB2_02,
PROTOCOL_SMB3_11);
cli->timeout,
PROTOCOL_SMB2_02,
PROTOCOL_SMB3_11,
NULL,
NULL,
NULL);
if (!NT_STATUS_IS_OK(status)) {
printf("smbXcli_negprot returned %s\n", nt_errstr(status));
return false;
@ -4599,9 +4693,12 @@ bool run_smb2_non_dfs_share(int dummy)
}
status = smbXcli_negprot(cli->conn,
cli->timeout,
PROTOCOL_SMB2_02,
PROTOCOL_SMB3_11);
cli->timeout,
PROTOCOL_SMB2_02,
PROTOCOL_SMB3_11,
NULL,
NULL,
NULL);
if (!NT_STATUS_IS_OK(status)) {
printf("smbXcli_negprot returned %s\n", nt_errstr(status));
return false;
@ -4764,9 +4861,12 @@ bool run_smb2_dfs_share_non_dfs_path(int dummy)
}
status = smbXcli_negprot(cli->conn,
cli->timeout,
PROTOCOL_SMB2_02,
PROTOCOL_SMB3_11);
cli->timeout,
PROTOCOL_SMB2_02,
PROTOCOL_SMB3_11,
NULL,
NULL,
NULL);
if (!NT_STATUS_IS_OK(status)) {
printf("smbXcli_negprot returned %s\n", nt_errstr(status));
return false;
@ -4979,9 +5079,12 @@ bool run_smb2_dfs_filename_leading_backslash(int dummy)
}
status = smbXcli_negprot(cli->conn,
cli->timeout,
PROTOCOL_SMB2_02,
PROTOCOL_SMB3_11);
cli->timeout,
PROTOCOL_SMB2_02,
PROTOCOL_SMB3_11,
NULL,
NULL,
NULL);
if (!NT_STATUS_IS_OK(status)) {
printf("smbXcli_negprot returned %s\n", nt_errstr(status));
return false;
@ -5162,9 +5265,12 @@ bool run_smb2_pipe_read_async_disconnect(int dummy)
}
status = smbXcli_negprot(cli->conn,
cli->timeout,
PROTOCOL_SMB2_02,
PROTOCOL_SMB3_11);
cli->timeout,
PROTOCOL_SMB2_02,
PROTOCOL_SMB3_11,
NULL,
NULL,
NULL);
if (!NT_STATUS_IS_OK(status)) {
printf("smbXcli_negprot returned %s\n", nt_errstr(status));
return false;

View File

@ -10318,8 +10318,13 @@ static bool run_error_map_extract(int dummy) {
}
disable_spnego = false;
status = smbXcli_negprot(c_nt->conn, c_nt->timeout, PROTOCOL_CORE,
PROTOCOL_NT1);
status = smbXcli_negprot(c_nt->conn,
c_nt->timeout,
PROTOCOL_CORE,
PROTOCOL_NT1,
NULL,
NULL,
NULL);
if (!NT_STATUS_IS_OK(status)) {
printf("%s rejected the NT-error negprot (%s)\n", host,
@ -10346,8 +10351,13 @@ static bool run_error_map_extract(int dummy) {
disable_spnego = false;
force_dos_errors = false;
status = smbXcli_negprot(c_dos->conn, c_dos->timeout, PROTOCOL_CORE,
PROTOCOL_NT1);
status = smbXcli_negprot(c_dos->conn,
c_dos->timeout,
PROTOCOL_CORE,
PROTOCOL_NT1,
NULL,
NULL,
NULL);
if (!NT_STATUS_IS_OK(status)) {
printf("%s rejected the DOS-error negprot (%s)\n", host,
nt_errstr(status));
@ -11525,7 +11535,10 @@ static bool run_large_readx(int dummy)
status = smbXcli_negprot(cli2->conn,
cli2->timeout,
runs[i].protocol,
runs[i].protocol);
runs[i].protocol,
NULL,
NULL,
NULL);
if (!NT_STATUS_IS_OK(status)) {
goto out;
}
@ -14865,7 +14878,13 @@ static bool run_smb1_truncated_sesssetup(int dummy)
return false;
}
status = smbXcli_negprot(conn, 0, PROTOCOL_NT1, PROTOCOL_NT1);
status = smbXcli_negprot(conn,
0,
PROTOCOL_NT1,
PROTOCOL_NT1,
NULL,
NULL,
NULL);
if (!NT_STATUS_IS_OK(status)) {
d_fprintf(stderr, "smbXcli_negprot failed!\n");
return false;
@ -15048,7 +15067,13 @@ static bool run_smb1_negotiate_exit(int dummy)
return false;
}
status = smbXcli_negprot(conn, 0, PROTOCOL_NT1, PROTOCOL_NT1);
status = smbXcli_negprot(conn,
0,
PROTOCOL_NT1,
PROTOCOL_NT1,
NULL,
NULL,
NULL);
if (!NT_STATUS_IS_OK(status)) {
d_fprintf(stderr, "smbXcli_negprot failed!\n");
return false;
@ -15094,7 +15119,13 @@ static bool run_smb1_negotiate_tcon(int dummy)
}
smbXcli_conn_set_sockopt(cli->conn, sockops);
status = smbXcli_negprot(cli->conn, 0, PROTOCOL_NT1, PROTOCOL_NT1);
status = smbXcli_negprot(cli->conn,
0,
PROTOCOL_NT1,
PROTOCOL_NT1,
NULL,
NULL,
NULL);
if (!NT_STATUS_IS_OK(status)) {
d_fprintf(stderr, "smbXcli_negprot failed %s!\n",
nt_errstr(status));
@ -15147,7 +15178,13 @@ static bool run_ign_bad_negprot(int dummy)
return false;
}
status = smbXcli_negprot(conn, 0, PROTOCOL_CORE, PROTOCOL_CORE);
status = smbXcli_negprot(conn,
0,
PROTOCOL_CORE,
PROTOCOL_CORE,
NULL,
NULL,
NULL);
if (NT_STATUS_IS_OK(status)) {
d_fprintf(stderr, "smbXcli_negprot succeeded!\n");
return false;

View File

@ -7463,9 +7463,13 @@ bool net_rpc_check(struct net_context *c, unsigned flags)
}
return false;
}
status = smbXcli_negprot(cli->conn, cli->timeout,
status = smbXcli_negprot(cli->conn,
cli->timeout,
lp_client_min_protocol(),
lp_client_max_protocol());
lp_client_max_protocol(),
NULL,
NULL,
NULL);
if (!NT_STATUS_IS_OK(status))
goto done;
if (smbXcli_conn_protocol(cli->conn) < PROTOCOL_NT1)

View File

@ -47,9 +47,13 @@ static time_t cli_servertime(const char *host,
goto done;
}
status = smbXcli_negprot(cli->conn, cli->timeout,
status = smbXcli_negprot(cli->conn,
cli->timeout,
lp_client_min_protocol(),
lp_client_max_protocol());
lp_client_max_protocol(),
NULL,
NULL,
NULL);
if (!NT_STATUS_IS_OK(status)) {
fprintf(stderr, _("Protocol negotiation failed: %s\n"),
nt_errstr(status));

View File

@ -782,9 +782,13 @@ static NTSTATUS cm_prepare_connection(struct winbindd_domain *domain,
set_socket_options(sockfd, lp_socket_options());
result = smbXcli_negprot((*cli)->conn, (*cli)->timeout,
result = smbXcli_negprot((*cli)->conn,
(*cli)->timeout,
lp_client_ipc_min_protocol(),
lp_client_ipc_max_protocol());
lp_client_ipc_max_protocol(),
NULL,
NULL,
NULL);
if (!NT_STATUS_IS_OK(result)) {
DEBUG(1, ("cli_negprot failed: %s\n", nt_errstr(result)));