From 2711521b5f60e1899f60443f0b97fef5398726c5 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Thu, 25 Aug 2022 12:20:26 +0200 Subject: [PATCH] libsmb: Allow to request SMB311 posix in source3/libsmb Signed-off-by: Volker Lendecke Reviewed-by: Ralph Boehme --- source3/include/client.h | 1 + source3/libsmb/cliconnect.c | 23 ++++++++++++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/source3/include/client.h b/source3/include/client.h index 14be20ef1e0..4939e1879cf 100644 --- a/source3/include/client.h +++ b/source3/include/client.h @@ -119,5 +119,6 @@ struct file_info { #define CLI_FULL_CONNECTION_FORCE_SMB1 0x0400 #define CLI_FULL_CONNECTION_DISABLE_SMB1 0x0800 #define CLI_FULL_CONNECTION_IPC 0x1000 +#define CLI_FULL_CONNECTION_REQUEST_POSIX 0x2000 #endif /* _CLIENT_H */ diff --git a/source3/libsmb/cliconnect.c b/source3/libsmb/cliconnect.c index 34cbbd723a8..0fb2b6ea45a 100644 --- a/source3/libsmb/cliconnect.c +++ b/source3/libsmb/cliconnect.c @@ -2776,6 +2776,7 @@ struct cli_start_connection_state { struct cli_state *cli; int min_protocol; int max_protocol; + struct smb2_negotiate_contexts *negotiate_contexts; }; static void cli_start_connection_connected(struct tevent_req *subreq); @@ -2827,6 +2828,26 @@ static struct tevent_req *cli_start_connection_send( state->min_protocol); } + state->negotiate_contexts = talloc_zero( + state, struct smb2_negotiate_contexts); + if (tevent_req_nomem(state->negotiate_contexts, req)) { + return tevent_req_post(req, ev); + } + + if (flags & CLI_FULL_CONNECTION_REQUEST_POSIX) { + NTSTATUS status; + + status = smb2_negotiate_context_add( + state->negotiate_contexts, + state->negotiate_contexts, + SMB2_POSIX_EXTENSIONS_AVAILABLE, + (const uint8_t *)SMB2_CREATE_TAG_POSIX, + strlen(SMB2_CREATE_TAG_POSIX)); + 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)) { @@ -2858,7 +2879,7 @@ static void cli_start_connection_connected(struct tevent_req *subreq) state->min_protocol, state->max_protocol, WINDOWS_CLIENT_PURE_SMB2_NEGPROT_INITIAL_CREDIT_ASK, - NULL); + state->negotiate_contexts); if (tevent_req_nomem(subreq, req)) { return; }