s3:smb2_flush: make use of file_fsp_smb2()
authorStefan Metzmacher <metze@samba.org>
Fri, 15 Jun 2012 19:55:52 +0000 (12:55 -0700)
committerKarolin Seeger <kseeger@samba.org>
Sun, 17 Jun 2012 19:01:04 +0000 (21:01 +0200)
metze
Signed-off-by: Jeremy Allison <jra@samba.org>
source3/smbd/smb2_flush.c

index 5f3c42a9d8ba4549b47a4060da6dd2ee5e7a9b2e..d24cb864aabfe57079cec0e58cc7980bdf593c96 100644 (file)
@@ -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);