s3:smbd: pass smbXsrv_connection to srv_send_smb()
authorStefan Metzmacher <metze@samba.org>
Wed, 11 Jun 2014 10:55:24 +0000 (12:55 +0200)
committerMichael Adam <obnox@samba.org>
Fri, 19 Sep 2014 07:15:11 +0000 (09:15 +0200)
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
source3/smbd/aio.c
source3/smbd/blocking.c
source3/smbd/ipc.c
source3/smbd/nttrans.c
source3/smbd/oplock.c
source3/smbd/pipes.c
source3/smbd/process.c
source3/smbd/proto.h
source3/smbd/reply.c
source3/smbd/trans2.c

index f5e4cc6837730dbc0a2c75347b3b0fb672a9933c..56b4cfc33d0ff7e078b9b7c900ee3a393379111c 100644 (file)
@@ -305,7 +305,7 @@ static void aio_pread_smb1_done(struct tevent_req *req)
        }
        smb_setlen(outbuf, outsize - 4);
        show_msg(outbuf);
-       if (!srv_send_smb(aio_ex->smbreq->sconn, outbuf,
+       if (!srv_send_smb(aio_ex->smbreq->xconn, outbuf,
                          true, aio_ex->smbreq->seqnum+1,
                          IS_CONN_ENCRYPTED(fsp->conn), NULL)) {
                exit_server_cleanly("handle_aio_read_complete: srv_send_smb "
@@ -522,7 +522,7 @@ NTSTATUS schedule_aio_write_and_X(connection_struct *conn,
                SSVAL(aio_ex->outbuf.data,smb_vwv2,numtowrite);
                 SSVAL(aio_ex->outbuf.data,smb_vwv4,(numtowrite>>16)&1);
                show_msg((char *)aio_ex->outbuf.data);
-               if (!srv_send_smb(aio_ex->smbreq->sconn,
+               if (!srv_send_smb(aio_ex->smbreq->xconn,
                                (char *)aio_ex->outbuf.data,
                                true, aio_ex->smbreq->seqnum+1,
                                IS_CONN_ENCRYPTED(fsp->conn),
@@ -624,7 +624,7 @@ static void aio_pwrite_smb1_done(struct tevent_req *req)
        }
 
        show_msg(outbuf);
-       if (!srv_send_smb(aio_ex->smbreq->sconn, outbuf,
+       if (!srv_send_smb(aio_ex->smbreq->xconn, outbuf,
                          true, aio_ex->smbreq->seqnum+1,
                          IS_CONN_ENCRYPTED(fsp->conn),
                          NULL)) {
index 5d3672e78368730b5696d408fde7b5868a10baa8..942c4b3192a3a45cd6bc4f36050e07c6a385e34b 100644 (file)
@@ -277,7 +277,7 @@ static void reply_lockingX_success(struct blocking_lock_record *blr)
         * that here and must set up the chain info manually.
         */
 
-       if (!srv_send_smb(req->sconn,
+       if (!srv_send_smb(req->xconn,
                        (char *)req->outbuf,
                        true, req->seqnum+1,
                        IS_CONN_ENCRYPTED(req->conn)||req->encrypted,
@@ -318,7 +318,7 @@ static void generic_blocking_lock_error(struct blocking_lock_record *blr, NTSTAT
        }
 
        reply_nterror(blr->req, status);
-       if (!srv_send_smb(blr->req->sconn, (char *)blr->req->outbuf,
+       if (!srv_send_smb(blr->req->xconn, (char *)blr->req->outbuf,
                          true, blr->req->seqnum+1,
                          blr->req->encrypted, NULL)) {
                exit_server_cleanly("generic_blocking_lock_error: srv_send_smb failed.");
@@ -407,7 +407,7 @@ static void blocking_lock_reply_error(struct blocking_lock_record *blr, NTSTATUS
                 */
                SCVAL(blr->req->outbuf,smb_com,SMBtrans2);
 
-               if (!srv_send_smb(blr->req->sconn,
+               if (!srv_send_smb(blr->req->xconn,
                                  (char *)blr->req->outbuf,
                                  true, blr->req->seqnum+1,
                                  IS_CONN_ENCRYPTED(blr->fsp->conn),
index 9a07ba01115130e436cec585b9dc592aa6380c60..6f4c7e0f11c3d35d8c241e68bfda46178a58262d 100644 (file)
@@ -108,7 +108,6 @@ void send_trans_reply(connection_struct *conn,
        int ldata  = rdata  ? rdata_len : 0;
        int lparam = rparam ? rparam_len : 0;
        struct smbXsrv_connection *xconn = req->xconn;
-       struct smbd_server_connection *sconn = xconn->sconn;
        int max_send = xconn->smb1.sessions.max_send;
        /* HACK: make sure we send at least 128 byte in one go */
        int hdr_overhead = SMB_BUFFER_SIZE_MIN - 128;
@@ -152,7 +151,7 @@ void send_trans_reply(connection_struct *conn,
        }
 
        show_msg((char *)req->outbuf);
-       if (!srv_send_smb(sconn, (char *)req->outbuf,
+       if (!srv_send_smb(xconn, (char *)req->outbuf,
                          true, req->seqnum+1,
                          IS_CONN_ENCRYPTED(conn), &req->pcd)) {
                exit_server_cleanly("send_trans_reply: srv_send_smb failed.");
@@ -212,7 +211,7 @@ void send_trans_reply(connection_struct *conn,
                }
 
                show_msg((char *)req->outbuf);
-               if (!srv_send_smb(sconn, (char *)req->outbuf,
+               if (!srv_send_smb(xconn, (char *)req->outbuf,
                                  true, req->seqnum+1,
                                  IS_CONN_ENCRYPTED(conn), &req->pcd))
                        exit_server_cleanly("send_trans_reply: srv_send_smb "
@@ -342,7 +341,7 @@ static void api_dcerpc_cmd_write_done(struct tevent_req *subreq)
 
  send:
        if (!srv_send_smb(
-                   req->sconn, (char *)req->outbuf,
+                   req->xconn, (char *)req->outbuf,
                    true, req->seqnum+1,
                    IS_CONN_ENCRYPTED(req->conn) || req->encrypted,
                    &req->pcd)) {
@@ -375,7 +374,7 @@ static void api_dcerpc_cmd_read_done(struct tevent_req *subreq)
                           NT_STATUS_EQUAL(old, status)?"":nt_errstr(status)));
                reply_nterror(req, status);
 
-               if (!srv_send_smb(req->sconn, (char *)req->outbuf,
+               if (!srv_send_smb(req->xconn, (char *)req->outbuf,
                                  true, req->seqnum+1,
                                  IS_CONN_ENCRYPTED(req->conn)
                                  ||req->encrypted, &req->pcd)) {
index cf242730ee94e1a6e736a66657cd289952aba0f3..f03f6d353491219ef1f0f42b621611fc6636dc10 100644 (file)
@@ -68,7 +68,6 @@ static void send_nt_replies(connection_struct *conn,
        int alignment_offset = 1;
        int data_alignment_offset = 0;
        struct smbXsrv_connection *xconn = req->xconn;
-       struct smbd_server_connection *sconn = xconn->sconn;
        int max_send = xconn->smb1.sessions.max_send;
 
        /*
@@ -84,7 +83,7 @@ static void send_nt_replies(connection_struct *conn,
                                         __LINE__,__FILE__);
                }
                show_msg((char *)req->outbuf);
-               if (!srv_send_smb(sconn,
+               if (!srv_send_smb(xconn,
                                (char *)req->outbuf,
                                true, req->seqnum+1,
                                IS_CONN_ENCRYPTED(conn),
@@ -248,7 +247,7 @@ static void send_nt_replies(connection_struct *conn,
 
                /* Send the packet */
                show_msg((char *)req->outbuf);
-               if (!srv_send_smb(sconn,
+               if (!srv_send_smb(xconn,
                                (char *)req->outbuf,
                                true, req->seqnum+1,
                                IS_CONN_ENCRYPTED(conn),
index 02cd0bbc45b655369c56e14d53acf9a57fa2a9fe..d927d4c96b550be3f00f9cace83b67cbeb012595 100644 (file)
@@ -394,12 +394,13 @@ static void add_oplock_timeout_handler(files_struct *fsp)
 
 static void send_break_message_smb1(files_struct *fsp, int level)
 {
+       struct smbXsrv_connection *xconn = fsp->conn->sconn->conn;
        char break_msg[SMB1_BREAK_MESSAGE_LENGTH];
 
        new_break_message_smb1(fsp, level, break_msg);
 
        show_msg(break_msg);
-       if (!srv_send_smb(fsp->conn->sconn,
+       if (!srv_send_smb(xconn,
                        break_msg, false, 0,
                        IS_CONN_ENCRYPTED(fsp->conn),
                        NULL)) {
index 110951ca67cb4186d28c596033a00f5e690986be..f9390b4b558a4d8435bf33eabe1f3df4fcfccdb5 100644 (file)
@@ -246,7 +246,7 @@ static void pipe_write_done(struct tevent_req *subreq)
        DEBUG(3,("write-IPC nwritten=%d\n", (int)nwritten));
 
  send:
-       if (!srv_send_smb(req->sconn, (char *)req->outbuf,
+       if (!srv_send_smb(req->xconn, (char *)req->outbuf,
                          true, req->seqnum+1,
                          IS_CONN_ENCRYPTED(req->conn)||req->encrypted,
                          &req->pcd)) {
index a3a0ac417008043b03a75f261dac486a0e246c65..68bd3e4b61cac4454a246fb4a0748bbbfc29a881 100644 (file)
@@ -211,12 +211,11 @@ void smbd_unlock_socket(struct smbXsrv_connection *xconn)
  Send an smb to a fd.
 ****************************************************************************/
 
-bool srv_send_smb(struct smbd_server_connection *sconn, char *buffer,
+bool srv_send_smb(struct smbXsrv_connection *xconn, char *buffer,
                  bool do_signing, uint32_t seqnum,
                  bool do_encrypt,
                  struct smb_perfcount_data *pcd)
 {
-       struct smbXsrv_connection *xconn = sconn->conn;
        size_t len = 0;
        ssize_t ret;
        char *buf_out = buffer;
@@ -1698,6 +1697,7 @@ static void construct_reply_chain(struct smbd_server_connection *sconn,
                                  bool encrypted,
                                  struct smb_perfcount_data *deferred_pcd)
 {
+       struct smbXsrv_connection *xconn = sconn->conn;
        struct smb_request **reqs = NULL;
        struct smb_request *req;
        unsigned num_reqs;
@@ -1709,7 +1709,7 @@ static void construct_reply_chain(struct smbd_server_connection *sconn,
                char errbuf[smb_size];
                error_packet(errbuf, 0, 0, NT_STATUS_INVALID_PARAMETER,
                             __LINE__, __FILE__);
-               if (!srv_send_smb(sconn, errbuf, true, seqnum, encrypted,
+               if (!srv_send_smb(xconn, errbuf, true, seqnum, encrypted,
                                  NULL)) {
                        exit_server_cleanly("construct_reply_chain: "
                                            "srv_send_smb failed.");
@@ -1830,7 +1830,7 @@ void smb_request_done(struct smb_request *req)
                first_req->outbuf, talloc_get_size(first_req->outbuf) - 4);
 
 shipit:
-       if (!srv_send_smb(first_req->sconn,
+       if (!srv_send_smb(first_req->xconn,
                          (char *)first_req->outbuf,
                          true, first_req->seqnum+1,
                          IS_CONN_ENCRYPTED(req->conn)||first_req->encrypted,
@@ -1846,7 +1846,7 @@ error:
        {
                char errbuf[smb_size];
                error_packet(errbuf, 0, 0, status, __LINE__, __FILE__);
-               if (!srv_send_smb(req->sconn, errbuf, true,
+               if (!srv_send_smb(req->xconn, errbuf, true,
                                  req->seqnum+1, req->encrypted,
                                  NULL)) {
                        exit_server_cleanly("construct_reply_chain: "
@@ -3083,7 +3083,7 @@ static bool smbd_echo_reply(struct smbd_echo_state *state,
                memcpy(smb_buf(req.outbuf), req.buf, req.buflen);
        }
 
-       ok = srv_send_smb(req.sconn,
+       ok = srv_send_smb(req.xconn,
                          (char *)outbuf,
                          true, seqnum+1,
                          false, &req.pcd);
@@ -3727,7 +3727,7 @@ void smbd_process(struct tevent_context *ev_ctx,
                DEBUG( 1, ("Connection denied from %s to %s\n",
                           tsocket_address_string(remote_address, talloc_tos()),
                           tsocket_address_string(local_address, talloc_tos())));
-               (void)srv_send_smb(sconn,(char *)buf, false,
+               (void)srv_send_smb(xconn,(char *)buf, false,
                                   0, false, NULL);
                exit_server_cleanly("connection denied");
        }
index 3a5ebcce08fa6d028490dbe9f6b74b4dbe7a3a01..00f58c60e7a2b3fde6484b8ae2a50671300019c8 100644 (file)
@@ -741,7 +741,7 @@ int posix_sys_acl_blob_get_fd(vfs_handle_struct *handle,
 
 void smbd_setup_sig_term_handler(struct smbd_server_connection *sconn);
 void smbd_setup_sig_hup_handler(struct smbd_server_connection *sconn);
-bool srv_send_smb(struct smbd_server_connection *sconn, char *buffer,
+bool srv_send_smb(struct smbXsrv_connection *xconn, char *buffer,
                  bool no_signing, uint32_t seqnum,
                  bool do_encrypt,
                  struct smb_perfcount_data *pcd);
index 3c22bbb09a09d1d405a0269f3f100d045804ad24..5a742753244158e49cfff42933efc690582e7e58 100644 (file)
@@ -431,7 +431,6 @@ bool check_fsp_ntquota_handle(connection_struct *conn, struct smb_request *req,
 static bool netbios_session_retarget(struct smbXsrv_connection *xconn,
                                     const char *name, int name_type)
 {
-       struct smbd_server_connection *sconn = xconn->sconn;
        char *trim_name;
        char *trim_name_type;
        const char *retarget_parm;
@@ -509,7 +508,7 @@ static bool netbios_session_retarget(struct smbXsrv_connection *xconn,
        *(uint32_t *)(outbuf+4) = in_addr->sin_addr.s_addr;
        *(uint16_t *)(outbuf+8) = htons(retarget_port);
 
-       if (!srv_send_smb(sconn, (char *)outbuf, false, 0, false,
+       if (!srv_send_smb(xconn, (char *)outbuf, false, 0, false,
                          NULL)) {
                exit_server_cleanly("netbios_session_retarget: srv_send_smb "
                                    "failed.");
@@ -668,7 +667,7 @@ void reply_special(struct smbXsrv_connection *xconn, char *inbuf, size_t inbuf_s
        DEBUG(5,("init msg_type=0x%x msg_flags=0x%x\n",
                    msg_type, msg_flags));
 
-       srv_send_smb(sconn, outbuf, false, 0, false, NULL);
+       srv_send_smb(xconn, outbuf, false, 0, false, NULL);
 
        if (CVAL(outbuf, 0) != 0x82) {
                exit_server_cleanly("invalid netbios session");
@@ -4334,7 +4333,7 @@ void reply_writebraw(struct smb_request *req)
        SCVAL(buf,smb_com,SMBwritebraw);
        SSVALS(buf,smb_vwv0,0xFFFF);
        show_msg(buf);
-       if (!srv_send_smb(req->sconn,
+       if (!srv_send_smb(req->xconn,
                          buf,
                          false, 0, /* no signing */
                          IS_CONN_ENCRYPTED(conn),
@@ -5248,7 +5247,7 @@ static void do_smb1_close(struct tevent_req *req)
        } else {
                reply_nterror(smbreq, status);
        }
-       if (!srv_send_smb(smbreq->sconn,
+       if (!srv_send_smb(smbreq->xconn,
                        (char *)smbreq->outbuf,
                        true,
                        smbreq->seqnum+1,
@@ -5569,7 +5568,7 @@ void reply_echo(struct smb_request *req)
                SSVAL(req->outbuf,smb_vwv0,seq_num);
 
                show_msg((char *)req->outbuf);
-               if (!srv_send_smb(req->sconn,
+               if (!srv_send_smb(req->xconn,
                                (char *)req->outbuf,
                                true, req->seqnum+1,
                                IS_CONN_ENCRYPTED(conn)||req->encrypted,
index 44ff5fd18aab875d1b6a4d3de5dba797ac362cd0..a8043ce0a7ef5968883e124185f32a1b1f686fd5 100644 (file)
@@ -860,7 +860,6 @@ void send_trans2_replies(connection_struct *conn,
        int data_alignment_offset = 0;
        bool overflow = False;
        struct smbXsrv_connection *xconn = req->xconn;
-       struct smbd_server_connection *sconn = xconn->sconn;
        int max_send = xconn->smb1.sessions.max_send;
 
        /* Modify the data_to_send and datasize and set the error if
@@ -888,7 +887,7 @@ void send_trans2_replies(connection_struct *conn,
                                        __LINE__,__FILE__);
                }
                show_msg((char *)req->outbuf);
-               if (!srv_send_smb(sconn,
+               if (!srv_send_smb(xconn,
                                (char *)req->outbuf,
                                true, req->seqnum+1,
                                IS_CONN_ENCRYPTED(conn),
@@ -1028,7 +1027,7 @@ void send_trans2_replies(connection_struct *conn,
 
                /* Send the packet */
                show_msg((char *)req->outbuf);
-               if (!srv_send_smb(sconn,
+               if (!srv_send_smb(xconn,
                                (char *)req->outbuf,
                                true, req->seqnum+1,
                                IS_CONN_ENCRYPTED(conn),