]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
smbd: Remove references to get_Protocol()
authorVolker Lendecke <vl@samba.org>
Thu, 25 May 2023 05:50:43 +0000 (07:50 +0200)
committerJeremy Allison <jra@samba.org>
Fri, 16 Jun 2023 16:14:30 +0000 (16:14 +0000)
We have that available in smbXsrv_connection that is available almost
everywhere.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/smbd/smb1_nttrans.c
source3/smbd/smb1_reply.c
source3/smbd/smb1_sesssetup.c
source3/smbd/smb1_trans2.c

index 660d5e820abecd871471879b0c119148f14be964..b9c9033649080347b4bcb7ea2e0e2e3960fa34f6 100644 (file)
@@ -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);
        }
index 7b6bd6c1f56e3066dd4d458ae724bf46550ccab2..18d12317a19dbec484948a1c0620c169026fd615 100644 (file)
@@ -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);
index 78dd09199aa047c84c265c320a0d0492d2482783..fe4519aef20b3984e330e176787b3cbe177baa9b 100644 (file)
@@ -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?? */
        }
index 8d62a0c0b9d64269a0a3f30d3fc5e8ffc8ea4459..cac0425723304ab5b90228579649a0008ed52507 100644 (file)
@@ -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);
        }