From 3ade9604f92dc48d2ac12ff14b4ee0504e3fdf4a Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 15 Jun 2012 12:55:52 -0700 Subject: [PATCH] s3:smb2_flush: make use of file_fsp_smb2() metze Signed-off-by: Jeremy Allison --- source3/smbd/smb2_flush.c | 35 +++++++++-------------------------- 1 file changed, 9 insertions(+), 26 deletions(-) diff --git a/source3/smbd/smb2_flush.c b/source3/smbd/smb2_flush.c index 5f3c42a9d8b..d24cb864aab 100644 --- a/source3/smbd/smb2_flush.c +++ b/source3/smbd/smb2_flush.c @@ -27,7 +27,7 @@ static struct tevent_req *smbd_smb2_flush_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev, struct smbd_smb2_request *smb2req, - uint64_t in_file_id_volatile); + struct files_struct *fsp); static NTSTATUS smbd_smb2_flush_recv(struct tevent_req *req); static void smbd_smb2_request_flush_done(struct tevent_req *subreq); @@ -38,6 +38,7 @@ NTSTATUS smbd_smb2_request_process_flush(struct smbd_smb2_request *req) int i = req->current_idx; uint64_t in_file_id_persistent; uint64_t in_file_id_volatile; + struct files_struct *in_fsp; struct tevent_req *subreq; status = smbd_smb2_request_verify_sizes(req, 0x18); @@ -49,16 +50,13 @@ NTSTATUS smbd_smb2_request_process_flush(struct smbd_smb2_request *req) in_file_id_persistent = BVAL(inbody, 0x08); in_file_id_volatile = BVAL(inbody, 0x10); - if (req->compat_chain_fsp) { - /* skip check */ - } else if (in_file_id_persistent != in_file_id_volatile) { + in_fsp = file_fsp_smb2(req, in_file_id_persistent, in_file_id_volatile); + if (in_fsp == NULL) { return smbd_smb2_request_error(req, NT_STATUS_FILE_CLOSED); } - subreq = smbd_smb2_flush_send(req, - req->sconn->smb2.event_ctx, - req, - in_file_id_volatile); + subreq = smbd_smb2_flush_send(req, req->sconn->smb2.event_ctx, + req, in_fsp); if (subreq == NULL) { return smbd_smb2_request_error(req, NT_STATUS_NO_MEMORY); } @@ -116,13 +114,12 @@ struct smbd_smb2_flush_state { static struct tevent_req *smbd_smb2_flush_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev, struct smbd_smb2_request *smb2req, - uint64_t in_file_id_volatile) + struct files_struct *fsp) { struct tevent_req *req; struct smbd_smb2_flush_state *state; NTSTATUS status; struct smb_request *smbreq; - files_struct *fsp; req = tevent_req_create(mem_ctx, &state, struct smbd_smb2_flush_state); @@ -131,8 +128,8 @@ static struct tevent_req *smbd_smb2_flush_send(TALLOC_CTX *mem_ctx, } state->smb2req = smb2req; - DEBUG(10,("smbd_smb2_flush: file_id[0x%016llX]\n", - (unsigned long long)in_file_id_volatile)); + DEBUG(10,("smbd_smb2_flush: %s - fnum[%d]\n", + fsp_str_dbg(fsp), fsp->fnum)); smbreq = smbd_smb2_fake_smb_request(smb2req); if (tevent_req_nomem(smbreq, req)) { @@ -144,20 +141,6 @@ static struct tevent_req *smbd_smb2_flush_send(TALLOC_CTX *mem_ctx, return tevent_req_post(req, ev); } - fsp = file_fsp(smbreq, (uint16_t)in_file_id_volatile); - if (fsp == NULL) { - tevent_req_nterror(req, NT_STATUS_FILE_CLOSED); - return tevent_req_post(req, ev); - } - if (smbreq->conn != fsp->conn) { - tevent_req_nterror(req, NT_STATUS_FILE_CLOSED); - return tevent_req_post(req, ev); - } - if (smb2req->session->vuid != fsp->vuid) { - tevent_req_nterror(req, NT_STATUS_FILE_CLOSED); - return tevent_req_post(req, ev); - } - if (!CHECK_WRITE(fsp)) { tevent_req_nterror(req, NT_STATUS_ACCESS_DENIED); return tevent_req_post(req, ev); -- 2.34.1