s3:smb2_find: make use of file_fsp_smb2()
authorStefan Metzmacher <metze@samba.org>
Fri, 8 Jun 2012 08:42:43 +0000 (10:42 +0200)
committerKarolin Seeger <kseeger@samba.org>
Sun, 17 Jun 2012 19:01:09 +0000 (21:01 +0200)
metze

Signed-off-by: Jeremy Allison <jra@samba.org>
source3/smbd/smb2_find.c

index 3dcc76862b02750eeddbdbecb79b32c4d8ecb87d..59e5b66e7d24694cfd8a8c671f160647a254c537 100644 (file)
 static struct tevent_req *smbd_smb2_find_send(TALLOC_CTX *mem_ctx,
                                              struct tevent_context *ev,
                                              struct smbd_smb2_request *smb2req,
+                                             struct files_struct *in_fsp,
                                              uint8_t in_file_info_class,
                                              uint8_t in_flags,
                                              uint32_t in_file_index,
-                                             uint64_t in_file_id_volatile,
                                              uint32_t in_output_buffer_length,
                                              const char *in_file_name);
 static NTSTATUS smbd_smb2_find_recv(struct tevent_req *req,
@@ -49,6 +49,7 @@ NTSTATUS smbd_smb2_request_process_find(struct smbd_smb2_request *req)
        uint32_t in_file_index;
        uint64_t in_file_id_persistent;
        uint64_t in_file_id_volatile;
+       struct files_struct *in_fsp;
        uint16_t in_file_name_offset;
        uint16_t in_file_name_length;
        DATA_BLOB in_file_name_buffer;
@@ -115,19 +116,16 @@ NTSTATUS smbd_smb2_request_process_find(struct smbd_smb2_request *req)
                return smbd_smb2_request_error(req, NT_STATUS_OBJECT_NAME_INVALID);
        }
 
-       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_find_send(req,
-                                    req->sconn->smb2.event_ctx,
-                                    req,
+       subreq = smbd_smb2_find_send(req, req->sconn->smb2.event_ctx,
+                                    req, in_fsp,
                                     in_file_info_class,
                                     in_flags,
                                     in_file_index,
-                                    in_file_id_volatile,
                                     in_output_buffer_length,
                                     in_file_name_string);
        if (subreq == NULL) {
@@ -207,10 +205,10 @@ struct smbd_smb2_find_state {
 static struct tevent_req *smbd_smb2_find_send(TALLOC_CTX *mem_ctx,
                                              struct tevent_context *ev,
                                              struct smbd_smb2_request *smb2req,
+                                             struct files_struct *fsp,
                                              uint8_t in_file_info_class,
                                              uint8_t in_flags,
                                              uint32_t in_file_index,
-                                             uint64_t in_file_id_volatile,
                                              uint32_t in_output_buffer_length,
                                              const char *in_file_name)
 {
@@ -218,7 +216,6 @@ static struct tevent_req *smbd_smb2_find_send(TALLOC_CTX *mem_ctx,
        struct smbd_smb2_find_state *state;
        struct smb_request *smbreq;
        connection_struct *conn = smb2req->tcon->compat_conn;
-       files_struct *fsp;
        NTSTATUS status;
        NTSTATUS empty_status;
        uint32_t info_level;
@@ -241,28 +238,14 @@ static struct tevent_req *smbd_smb2_find_send(TALLOC_CTX *mem_ctx,
        state->smb2req = smb2req;
        state->out_output_buffer = data_blob_null;
 
-       DEBUG(10,("smbd_smb2_find_send: file_id[0x%016llX]\n",
-                 (unsigned long long)in_file_id_volatile));
+       DEBUG(10,("smbd_smb2_find_send: %s - fnum[%d]\n",
+                 fsp_str_dbg(fsp), fsp->fnum));
 
        smbreq = smbd_smb2_fake_smb_request(smb2req);
        if (tevent_req_nomem(smbreq, req)) {
                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 (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 (!fsp->is_directory) {
                tevent_req_nterror(req, NT_STATUS_NOT_SUPPORTED);
                return tevent_req_post(req, ev);