From: Volker Lendecke Date: Thu, 25 May 2023 05:50:43 +0000 (+0200) Subject: smbd: Remove references to get_Protocol() X-Git-Tag: talloc-2.4.1~349 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1d6f6f9529b137fac89688cd2a63887caeb579f8;p=thirdparty%2Fsamba.git smbd: Remove references to get_Protocol() We have that available in smbXsrv_connection that is available almost everywhere. Signed-off-by: Volker Lendecke Reviewed-by: Jeremy Allison --- diff --git a/source3/smbd/smb1_nttrans.c b/source3/smbd/smb1_nttrans.c index 660d5e820ab..b9c90336490 100644 --- a/source3/smbd/smb1_nttrans.c +++ b/source3/smbd/smb1_nttrans.c @@ -2282,7 +2282,9 @@ static void handle_nttrans(connection_struct *conn, struct trans_state *state, struct smb_request *req) { - if (get_Protocol() >= PROTOCOL_NT1) { + struct smbXsrv_connection *xconn = req->xconn; + + if (xconn->protocol >= PROTOCOL_NT1) { req->flags2 |= 0x40; /* IS_LONG_NAME */ SSVAL(discard_const_p(uint8_t, req->inbuf),smb_flg2,req->flags2); } diff --git a/source3/smbd/smb1_reply.c b/source3/smbd/smb1_reply.c index 7b6bd6c1f56..18d12317a19 100644 --- a/source3/smbd/smb1_reply.c +++ b/source3/smbd/smb1_reply.c @@ -470,7 +470,7 @@ void reply_tcon_and_X(struct smb_request *req) else server_devicetype = "A:"; - if (get_Protocol() < PROTOCOL_NT1) { + if (xconn->protocol < PROTOCOL_NT1) { reply_smb1_outbuf(req, 2, 0); if (message_push_string(&req->outbuf, server_devicetype, STR_TERMINATE|STR_ASCII) == -1) { @@ -768,6 +768,7 @@ void reply_checkpath(struct smb_request *req) void reply_getatr(struct smb_request *req) { + struct smbXsrv_connection *xconn = req->xconn; connection_struct *conn = req->conn; struct smb_filename *smb_fname = NULL; char *fname = NULL; @@ -869,7 +870,7 @@ void reply_getatr(struct smb_request *req) } SIVAL(req->outbuf,smb_vwv3,(uint32_t)size); - if (get_Protocol() >= PROTOCOL_NT1) { + if (xconn->protocol >= PROTOCOL_NT1) { SSVAL(req->outbuf, smb_flg2, SVAL(req->outbuf, smb_flg2) | FLAGS2_IS_LONG_NAME); } @@ -1007,6 +1008,7 @@ void reply_setatr(struct smb_request *req) void reply_dskattr(struct smb_request *req) { + struct smbXsrv_connection *xconn = req->xconn; connection_struct *conn = req->conn; uint64_t ret; uint64_t dfree,dsize,bsize; @@ -1049,7 +1051,7 @@ void reply_dskattr(struct smb_request *req) reply_smb1_outbuf(req, 5, 0); - if (get_Protocol() <= PROTOCOL_LANMAN2) { + if (xconn->protocol <= PROTOCOL_LANMAN2) { double total_space, free_space; /* we need to scale this to a number that DOS6 can handle. We use floating point so we can handle large drives on systems @@ -2834,12 +2836,14 @@ static void reply_readbraw_error(struct smbXsrv_connection *xconn) Ensure we don't use sendfile if server smb signing is active. ********************************************************************/ -static bool lp_use_sendfile(int snum, struct smb1_signing_state *signing_state) +static bool lp_use_sendfile(struct smbXsrv_connection *xconn, + int snum, + struct smb1_signing_state *signing_state) { bool sign_active = false; /* Using sendfile blows the brains out of any DOS or Win9x TCP stack... JRA. */ - if (get_Protocol() < PROTOCOL_NT1) { + if (xconn->protocol < PROTOCOL_NT1) { return false; } if (signing_state) { @@ -2874,7 +2878,7 @@ static void send_file_readbraw(connection_struct *conn, if ( !req_is_in_chain(req) && (nread > 0) && !fsp_is_alternate_stream(fsp) && - lp_use_sendfile(SNUM(conn), xconn->smb1.signing_state) ) { + lp_use_sendfile(xconn, SNUM(conn), xconn->smb1.signing_state) ) { ssize_t sendfile_read = -1; char header[4]; DATA_BLOB header_blob; @@ -3458,7 +3462,7 @@ static void send_file_readX(connection_struct *conn, struct smb_request *req, if (!req_is_in_chain(req) && !req->encrypted && !fsp_is_alternate_stream(fsp) && - lp_use_sendfile(SNUM(conn), xconn->smb1.signing_state) ) { + lp_use_sendfile(xconn, SNUM(conn), xconn->smb1.signing_state) ) { uint8_t headerbuf[smb_size + 12 * 2 + 1 /* padding byte */]; DATA_BLOB header; @@ -3941,7 +3945,7 @@ void reply_writebraw(struct smb_request *req) /* We have to deal with slightly different formats depending on whether we are using the core+ or lanman1.0 protocol */ - if(get_Protocol() <= PROTOCOL_COREPLUS) { + if(xconn->protocol <= PROTOCOL_COREPLUS) { numtowrite = SVAL(smb_buf_const(req->inbuf),-2); data = smb_buf_const(req->inbuf); } else { @@ -4006,7 +4010,7 @@ void reply_writebraw(struct smb_request *req) * it to send more bytes */ memcpy(buf, req->inbuf, smb_size); - srv_smb1_set_message(buf,get_Protocol()>PROTOCOL_COREPLUS?1:0,0,True); + srv_smb1_set_message(buf,xconn->protocol>PROTOCOL_COREPLUS?1:0,0,True); SCVAL(buf,smb_com,SMBwritebraw); SSVALS(buf,smb_vwv0,0xFFFF); show_msg(buf); diff --git a/source3/smbd/smb1_sesssetup.c b/source3/smbd/smb1_sesssetup.c index 78dd09199aa..fe4519aef20 100644 --- a/source3/smbd/smb1_sesssetup.c +++ b/source3/smbd/smb1_sesssetup.c @@ -655,7 +655,7 @@ void reply_sesssetup_and_X(struct smb_request *req) smb_bufsize = SVAL(req->vwv+2, 0); - if (get_Protocol() < PROTOCOL_NT1) { + if (xconn->protocol < PROTOCOL_NT1) { uint16_t passlen1 = SVAL(req->vwv+7, 0); /* Never do NT status codes with protocols before NT1 as we @@ -959,7 +959,7 @@ void reply_sesssetup_and_X(struct smb_request *req) SSVAL(req->outbuf, smb_vwv0, 0xff); /* andx chain ends */ SSVAL(req->outbuf, smb_vwv1, 0); /* no andx offset */ - if (get_Protocol() >= PROTOCOL_NT1) { + if (xconn->protocol >= PROTOCOL_NT1) { push_signature(&req->outbuf); /* perhaps grab OS version here?? */ } diff --git a/source3/smbd/smb1_trans2.c b/source3/smbd/smb1_trans2.c index 8d62a0c0b9d..cac04257233 100644 --- a/source3/smbd/smb1_trans2.c +++ b/source3/smbd/smb1_trans2.c @@ -847,6 +847,7 @@ static void call_trans2findfirst(connection_struct *conn, struct ea_list *ea_list = NULL; NTSTATUS ntstatus = NT_STATUS_OK; bool ask_sharemode; + struct smbXsrv_connection *xconn = req->xconn; struct smbd_server_connection *sconn = req->sconn; uint32_t ucf_flags = ucf_flags_from_smb_request(req); bool backup_priv = false; @@ -1194,7 +1195,7 @@ static void call_trans2findfirst(connection_struct *conn, if (fsp != NULL) { close_file_free(NULL, &fsp, NORMAL_CLOSE); } - if (get_Protocol() < PROTOCOL_NT1) { + if (xconn->protocol < PROTOCOL_NT1) { reply_force_doserror(req, ERRDOS, ERRnofiles); goto out; } else { @@ -5218,7 +5219,9 @@ static void call_trans2ioctl(connection_struct *conn, static void handle_trans2(connection_struct *conn, struct smb_request *req, struct trans_state *state) { - if (get_Protocol() >= PROTOCOL_NT1) { + struct smbXsrv_connection *xconn = req->xconn; + + if (xconn->protocol >= PROTOCOL_NT1) { req->flags2 |= 0x40; /* IS_LONG_NAME */ SSVAL((discard_const_p(uint8_t, req->inbuf)),smb_flg2,req->flags2); }