From 1808dd0a854f0cf95718da28a9fc58134af04d83 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Tue, 24 Aug 2010 20:10:20 +0200 Subject: s3: Make srv_send_smb take an sconn instead of a sock fd --- source3/include/proto.h | 2 +- source3/smbd/aio.c | 6 +++--- source3/smbd/blocking.c | 4 ++-- source3/smbd/ipc.c | 8 ++++---- source3/smbd/nttrans.c | 4 ++-- source3/smbd/oplock.c | 2 +- source3/smbd/pipes.c | 2 +- source3/smbd/process.c | 22 +++++++++++----------- source3/smbd/reply.c | 8 ++++---- source3/smbd/trans2.c | 4 ++-- 10 files changed, 31 insertions(+), 31 deletions(-) diff --git a/source3/include/proto.h b/source3/include/proto.h index 43a510b4b2..a3449799a8 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -5590,7 +5590,7 @@ struct security_descriptor *get_nt_acl_no_snum( TALLOC_CTX *ctx, const char *fna void smbd_setup_sig_term_handler(void); void smbd_setup_sig_hup_handler(struct tevent_context *ev, struct messaging_context *msg_ctx); -bool srv_send_smb(int fd, char *buffer, +bool srv_send_smb(struct smbd_server_connection *sconn, char *buffer, bool no_signing, uint32_t seqnum, bool do_encrypt, struct smb_perfcount_data *pcd); diff --git a/source3/smbd/aio.c b/source3/smbd/aio.c index 281c29679e..677fbb6764 100644 --- a/source3/smbd/aio.c +++ b/source3/smbd/aio.c @@ -357,7 +357,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->sock, + if (!srv_send_smb(aio_ex->smbreq->sconn, (char *)aio_ex->outbuf.data, true, aio_ex->smbreq->seqnum+1, IS_CONN_ENCRYPTED(fsp->conn), @@ -633,7 +633,7 @@ static int handle_aio_read_complete(struct aio_extra *aio_ex, int errcode) } smb_setlen(outbuf,outsize - 4); show_msg(outbuf); - if (!srv_send_smb(aio_ex->smbreq->sconn->sock, outbuf, + if (!srv_send_smb(aio_ex->smbreq->sconn, outbuf, true, aio_ex->smbreq->seqnum+1, IS_CONN_ENCRYPTED(aio_ex->fsp->conn), NULL)) { exit_server_cleanly("handle_aio_read_complete: srv_send_smb " @@ -722,7 +722,7 @@ static int handle_aio_write_complete(struct aio_extra *aio_ex, int errcode) } show_msg(outbuf); - if (!srv_send_smb(aio_ex->smbreq->sconn->sock, outbuf, + if (!srv_send_smb(aio_ex->smbreq->sconn, outbuf, true, aio_ex->smbreq->seqnum+1, IS_CONN_ENCRYPTED(fsp->conn), NULL)) { diff --git a/source3/smbd/blocking.c b/source3/smbd/blocking.c index ee5096351c..7a73ea9cca 100644 --- a/source3/smbd/blocking.c +++ b/source3/smbd/blocking.c @@ -312,7 +312,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->sock, (char *)blr->req->outbuf, + if (!srv_send_smb(blr->req->sconn, (char *)blr->req->outbuf, true, blr->req->seqnum+1, blr->req->encrypted, NULL)) { exit_server_cleanly("generic_blocking_lock_error: srv_send_smb failed."); @@ -395,7 +395,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->sock, + if (!srv_send_smb(blr->req->sconn, (char *)blr->req->outbuf, true, blr->req->seqnum+1, IS_CONN_ENCRYPTED(blr->fsp->conn), diff --git a/source3/smbd/ipc.c b/source3/smbd/ipc.c index c961fc4ab6..5dd0e5627e 100644 --- a/source3/smbd/ipc.c +++ b/source3/smbd/ipc.c @@ -135,7 +135,7 @@ void send_trans_reply(connection_struct *conn, } show_msg((char *)req->outbuf); - if (!srv_send_smb(sconn->sock, (char *)req->outbuf, + if (!srv_send_smb(sconn, (char *)req->outbuf, true, req->seqnum+1, IS_CONN_ENCRYPTED(conn), &req->pcd)) { exit_server_cleanly("send_trans_reply: srv_send_smb failed."); @@ -195,7 +195,7 @@ void send_trans_reply(connection_struct *conn, } show_msg((char *)req->outbuf); - if (!srv_send_smb(sconn->sock, (char *)req->outbuf, + if (!srv_send_smb(sconn, (char *)req->outbuf, true, req->seqnum+1, IS_CONN_ENCRYPTED(conn), &req->pcd)) exit_server_cleanly("send_trans_reply: srv_send_smb " @@ -313,7 +313,7 @@ static void api_dcerpc_cmd_write_done(struct tevent_req *subreq) send: if (!srv_send_smb( - req->sconn->sock, (char *)req->outbuf, + req->sconn, (char *)req->outbuf, true, req->seqnum+1, IS_CONN_ENCRYPTED(req->conn) || req->encrypted, &req->pcd)) { @@ -341,7 +341,7 @@ static void api_dcerpc_cmd_read_done(struct tevent_req *subreq) nt_errstr(status))); reply_nterror(req, status); - if (!srv_send_smb(req->sconn->sock, (char *)req->outbuf, + if (!srv_send_smb(req->sconn, (char *)req->outbuf, true, req->seqnum+1, IS_CONN_ENCRYPTED(req->conn) ||req->encrypted, &req->pcd)) { diff --git a/source3/smbd/nttrans.c b/source3/smbd/nttrans.c index 07df67d8a5..965d279183 100644 --- a/source3/smbd/nttrans.c +++ b/source3/smbd/nttrans.c @@ -74,7 +74,7 @@ void send_nt_replies(connection_struct *conn, __LINE__,__FILE__); } show_msg((char *)req->outbuf); - if (!srv_send_smb(sconn->sock, + if (!srv_send_smb(sconn, (char *)req->outbuf, true, req->seqnum+1, IS_CONN_ENCRYPTED(conn), @@ -243,7 +243,7 @@ void send_nt_replies(connection_struct *conn, /* Send the packet */ show_msg((char *)req->outbuf); - if (!srv_send_smb(sconn->sock, + if (!srv_send_smb(sconn, (char *)req->outbuf, true, req->seqnum+1, IS_CONN_ENCRYPTED(conn), diff --git a/source3/smbd/oplock.c b/source3/smbd/oplock.c index 44060d5d77..63a17e16a3 100644 --- a/source3/smbd/oplock.c +++ b/source3/smbd/oplock.c @@ -364,7 +364,7 @@ static void send_break_message_smb1(files_struct *fsp, int level) } show_msg(break_msg); - if (!srv_send_smb(fsp->conn->sconn->sock, + if (!srv_send_smb(fsp->conn->sconn, break_msg, false, 0, IS_CONN_ENCRYPTED(fsp->conn), NULL)) { diff --git a/source3/smbd/pipes.c b/source3/smbd/pipes.c index 8bdd8b22e3..dfe8756a19 100644 --- a/source3/smbd/pipes.c +++ b/source3/smbd/pipes.c @@ -240,7 +240,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->sock, (char *)req->outbuf, + if (!srv_send_smb(req->sconn, (char *)req->outbuf, true, req->seqnum+1, IS_CONN_ENCRYPTED(req->conn)||req->encrypted, &req->pcd)) { diff --git a/source3/smbd/process.c b/source3/smbd/process.c index 126b6b797e..b787674635 100644 --- a/source3/smbd/process.c +++ b/source3/smbd/process.c @@ -101,7 +101,7 @@ void smbd_unlock_socket(struct smbd_server_connection *sconn) Send an smb to a fd. ****************************************************************************/ -bool srv_send_smb(int fd, char *buffer, +bool srv_send_smb(struct smbd_server_connection *sconn, char *buffer, bool do_signing, uint32_t seqnum, bool do_encrypt, struct smb_perfcount_data *pcd) @@ -111,11 +111,11 @@ bool srv_send_smb(int fd, char *buffer, ssize_t ret; char *buf_out = buffer; - smbd_lock_socket(smbd_server_conn); + smbd_lock_socket(sconn); if (do_signing) { /* Sign the outgoing packet if required. */ - srv_calculate_sign_mac(smbd_server_conn, buf_out, seqnum); + srv_calculate_sign_mac(sconn, buf_out, seqnum); } if (do_encrypt) { @@ -130,7 +130,7 @@ bool srv_send_smb(int fd, char *buffer, len = smb_len(buf_out) + 4; - ret = write_data(fd,buf_out+nwritten,len - nwritten); + ret = write_data(sconn->sock, buf_out+nwritten, len - nwritten); if (ret <= 0) { char addr[INET6_ADDRSTRLEN]; @@ -140,7 +140,7 @@ bool srv_send_smb(int fd, char *buffer, */ DEBUG(0,("pid[%d] Error writing %d bytes to client %s. %d. (%s)\n", (int)sys_getpid(), (int)len, - get_peer_addr(fd, addr, sizeof(addr)), + get_peer_addr(sconn->sock, addr, sizeof(addr)), (int)ret, strerror(errno) )); srv_free_enc_buffer(buf_out); @@ -152,7 +152,7 @@ bool srv_send_smb(int fd, char *buffer, out: SMB_PERFCOUNT_END(pcd); - smbd_unlock_socket(smbd_server_conn); + smbd_unlock_socket(sconn); return true; } @@ -1620,7 +1620,7 @@ static void construct_reply(char *inbuf, int size, size_t unread_bytes, show_msg((char *)req->outbuf); } - if (!srv_send_smb(req->sconn->sock, + if (!srv_send_smb(req->sconn, (char *)req->outbuf, true, req->seqnum+1, IS_CONN_ENCRYPTED(conn)||req->encrypted, @@ -2059,7 +2059,7 @@ void chain_reply(struct smb_request *req) smb_setlen((char *)(req->chain_outbuf), talloc_get_size(req->chain_outbuf) - 4); - if (!srv_send_smb(req->sconn->sock, (char *)req->chain_outbuf, + if (!srv_send_smb(req->sconn, (char *)req->chain_outbuf, true, req->seqnum+1, IS_CONN_ENCRYPTED(req->conn) ||req->encrypted, @@ -2199,7 +2199,7 @@ void chain_reply(struct smb_request *req) show_msg((char *)(req->chain_outbuf)); - if (!srv_send_smb(req->sconn->sock, (char *)req->chain_outbuf, + if (!srv_send_smb(req->sconn, (char *)req->chain_outbuf, true, req->seqnum+1, IS_CONN_ENCRYPTED(req->conn)||req->encrypted, &req->pcd)) { @@ -2658,7 +2658,7 @@ static bool smbd_echo_reply(uint8_t *inbuf, size_t inbuf_len, out_len = smb_len(req.outbuf) + 4; - ok = srv_send_smb(req.sconn->sock, + ok = srv_send_smb(req.sconn, (char *)outbuf, true, seqnum+1, false, &req.pcd); @@ -2994,7 +2994,7 @@ void smbd_process(struct smbd_server_connection *sconn) 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->sock,(char *)buf, false, + (void)srv_send_smb(sconn,(char *)buf, false, 0, false, NULL); exit_server_cleanly("connection denied"); } diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c index 583c8960f9..0775b398d5 100644 --- a/source3/smbd/reply.c +++ b/source3/smbd/reply.c @@ -468,7 +468,7 @@ static bool netbios_session_retarget(struct smbd_server_connection *sconn, *(uint32_t *)(outbuf+4) = in_addr->sin_addr.s_addr; *(uint16_t *)(outbuf+8) = htons(retarget_port); - if (!srv_send_smb(sconn->sock, (char *)outbuf, false, 0, false, + if (!srv_send_smb(sconn, (char *)outbuf, false, 0, false, NULL)) { exit_server_cleanly("netbios_session_regarget: srv_send_smb " "failed."); @@ -574,7 +574,7 @@ void reply_special(struct smbd_server_connection *sconn, char *inbuf) DEBUG(5,("init msg_type=0x%x msg_flags=0x%x\n", msg_type, msg_flags)); - srv_send_smb(sconn->sock, outbuf, false, 0, false, NULL); + srv_send_smb(sconn, outbuf, false, 0, false, NULL); return; } @@ -3966,7 +3966,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->sock, + if (!srv_send_smb(req->sconn, buf, false, 0, /* no signing */ IS_CONN_ENCRYPTED(conn), @@ -5113,7 +5113,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->sock, + if (!srv_send_smb(req->sconn, (char *)req->outbuf, true, req->seqnum+1, IS_CONN_ENCRYPTED(conn)||req->encrypted, diff --git a/source3/smbd/trans2.c b/source3/smbd/trans2.c index ccc194b07f..24d66a6187 100644 --- a/source3/smbd/trans2.c +++ b/source3/smbd/trans2.c @@ -800,7 +800,7 @@ void send_trans2_replies(connection_struct *conn, if(params_to_send == 0 && data_to_send == 0) { reply_outbuf(req, 10, 0); show_msg((char *)req->outbuf); - if (!srv_send_smb(sconn->sock, + if (!srv_send_smb(sconn, (char *)req->outbuf, true, req->seqnum+1, IS_CONN_ENCRYPTED(conn), @@ -939,7 +939,7 @@ void send_trans2_replies(connection_struct *conn, /* Send the packet */ show_msg((char *)req->outbuf); - if (!srv_send_smb(sconn->sock, + if (!srv_send_smb(sconn, (char *)req->outbuf, true, req->seqnum+1, IS_CONN_ENCRYPTED(conn), -- cgit