From: Volker Lendecke Date: Fri, 26 Aug 2022 12:17:26 +0000 (+0200) Subject: libsmb: Allow smb2 neg ctx in cli_full_connection_creds_send() X-Git-Tag: talloc-2.4.0~1223 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=5d95de0637cbf978ba9603e4074ccd3ce37fba9b;p=thirdparty%2Fsamba.git libsmb: Allow smb2 neg ctx in cli_full_connection_creds_send() Will be used to test smb3 posix contexts Signed-off-by: Volker Lendecke Reviewed-by: Ralph Boehme --- diff --git a/source3/libsmb/cliconnect.c b/source3/libsmb/cliconnect.c index 0fb2b6ea45a..edbd2477f60 100644 --- a/source3/libsmb/cliconnect.c +++ b/source3/libsmb/cliconnect.c @@ -2794,7 +2794,8 @@ static struct tevent_req *cli_start_connection_send( TALLOC_CTX *mem_ctx, struct tevent_context *ev, const char *my_name, const char *dest_host, const struct sockaddr_storage *dest_ss, int port, - enum smb_signing_setting signing_state, int flags) + enum smb_signing_setting signing_state, int flags, + struct smb2_negotiate_contexts *negotiate_contexts) { struct tevent_req *req, *subreq; struct cli_start_connection_state *state; @@ -2848,6 +2849,26 @@ static struct tevent_req *cli_start_connection_send( } } + if (negotiate_contexts != NULL) { + uint16_t i; + + for (i=0; inum_contexts; i++) { + struct smb2_negotiate_context *ctx = + &negotiate_contexts->contexts[i]; + NTSTATUS status; + + status = smb2_negotiate_context_add( + state->negotiate_contexts, + state->negotiate_contexts, + ctx->type, + ctx->data.data, + ctx->data.length); + if (tevent_req_nterror(req, status)) { + return tevent_req_post(req, ev); + } + } + } + subreq = cli_connect_nb_send(state, ev, dest_host, dest_ss, port, 0x20, my_name, signing_state, flags); if (tevent_req_nomem(subreq, req)) { @@ -2939,7 +2960,7 @@ NTSTATUS cli_start_connection(struct cli_state **output_cli, goto fail; } req = cli_start_connection_send(ev, ev, my_name, dest_host, dest_ss, - port, signing_state, flags); + port, signing_state, flags, NULL); if (req == NULL) { goto fail; } @@ -3413,7 +3434,8 @@ struct tevent_req *cli_full_connection_creds_send( const struct sockaddr_storage *dest_ss, int port, const char *service, const char *service_type, struct cli_credentials *creds, - int flags) + int flags, + struct smb2_negotiate_contexts *negotiate_contexts) { struct tevent_req *req, *subreq; struct cli_full_connection_creds_state *state; @@ -3452,7 +3474,8 @@ struct tevent_req *cli_full_connection_creds_send( subreq = cli_start_connection_send( state, ev, my_name, dest_host, dest_ss, port, - signing_state, flags); + signing_state, flags, + negotiate_contexts); if (tevent_req_nomem(subreq, req)) { return tevent_req_post(req, ev); } @@ -3783,7 +3806,8 @@ NTSTATUS cli_full_connection_creds(struct cli_state **output_cli, } req = cli_full_connection_creds_send( ev, ev, my_name, dest_host, dest_ss, port, service, - service_type, creds, flags); + service_type, creds, flags, + NULL); if (req == NULL) { goto fail; } diff --git a/source3/libsmb/proto.h b/source3/libsmb/proto.h index ec66582e28a..46db49015fb 100644 --- a/source3/libsmb/proto.h +++ b/source3/libsmb/proto.h @@ -92,13 +92,16 @@ NTSTATUS cli_start_connection(struct cli_state **output_cli, enum smb_signing_setting signing_state, int flags); NTSTATUS cli_smb1_setup_encryption(struct cli_state *cli, struct cli_credentials *creds); + +struct smb2_negotiate_contexts; struct tevent_req *cli_full_connection_creds_send( TALLOC_CTX *mem_ctx, struct tevent_context *ev, const char *my_name, const char *dest_host, const struct sockaddr_storage *dest_ss, int port, const char *service, const char *service_type, struct cli_credentials *creds, - int flags); + int flags, + struct smb2_negotiate_contexts *negotiate_contexts); NTSTATUS cli_full_connection_creds_recv(struct tevent_req *req, struct cli_state **output_cli); NTSTATUS cli_full_connection_creds(struct cli_state **output_cli, diff --git a/source3/libsmb/pylibsmb.c b/source3/libsmb/pylibsmb.c index a3ca41b38d2..bef6b3de9a7 100644 --- a/source3/libsmb/pylibsmb.c +++ b/source3/libsmb/pylibsmb.c @@ -523,7 +523,8 @@ static int py_cli_state_init(struct py_cli_state *self, PyObject *args, req = cli_full_connection_creds_send( NULL, self->ev, "myname", host, NULL, 0, share, "?????", - cli_creds, flags); + cli_creds, flags, + NULL); if (!py_tevent_req_wait_exc(self, req)) { return -1; }