s3:smbd: use fsp_persistent_id() as persistent_file_id part for SMB2 (bug #8995)
authorStefan Metzmacher <metze@samba.org>
Wed, 13 Jun 2012 10:13:01 +0000 (12:13 +0200)
committerKarolin Seeger <kseeger@samba.org>
Sun, 17 Jun 2012 19:01:28 +0000 (21:01 +0200)
It seems to be important to have unique persistent file ids,
because windows clients seem to index files by server_guid + persistent_file_id.
Which may break, if we just have a 16-bit range per connection
and the client connects multiple times.

Based on code from Ira Cooper. Use fsp->fh->gen_id as the persistent
fileid in SMB2.

metze

Autobuild-User(master): Stefan Metzmacher <metze@samba.org>
Autobuild-Date(master): Thu Jun 14 22:04:13 CEST 2012 on sn-devel-104

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

index 1031ccfecba2dd06199f414bac2704c02f0d6205..58c24a8e34c6a858dd44af0744cc3c3142c37f09 100644 (file)
@@ -595,15 +595,12 @@ struct files_struct *file_fsp_smb2(struct smbd_smb2_request *smb2req,
                                   uint64_t volatile_id)
 {
        struct files_struct *fsp;
+       uint64_t fsp_persistent;
 
        if (smb2req->compat_chain_fsp != NULL) {
                return smb2req->compat_chain_fsp;
        }
 
-       if (persistent_id != volatile_id) {
-               return NULL;
-       }
-
        if (volatile_id > UINT16_MAX) {
                return NULL;
        }
@@ -612,6 +609,11 @@ struct files_struct *file_fsp_smb2(struct smbd_smb2_request *smb2req,
        if (fsp == NULL) {
                return NULL;
        }
+       fsp_persistent = fsp_persistent_id(fsp);
+
+       if (persistent_id != fsp_persistent) {
+               return NULL;
+       }
 
        if (smb2req->tcon == NULL) {
                return NULL;
index 2eb234681968750644bc39f1571667fcb0d3f31a..4957a88e517255e0254ab66d9556f395ca0791a2 100644 (file)
@@ -237,6 +237,7 @@ void send_break_message_smb2(files_struct *fsp, int level)
                                SMB2_OPLOCK_LEVEL_II :
                                SMB2_OPLOCK_LEVEL_NONE;
        NTSTATUS status;
+       uint64_t fsp_persistent = fsp_persistent_id(fsp);
 
        DEBUG(10,("send_break_message_smb2: sending oplock break "
                "for file %s, fnum = %d, smb2 level %u\n",
@@ -245,7 +246,7 @@ void send_break_message_smb2(files_struct *fsp, int level)
                (unsigned int)smb2_oplock_level ));
 
        status = smbd_smb2_send_oplock_break(fsp->conn->sconn,
-                                       (uint64_t)fsp->fnum,
+                                       fsp_persistent,
                                        (uint64_t)fsp->fnum,
                                        smb2_oplock_level);
        if (!NT_STATUS_IS_OK(status)) {
index a98422c7ae944cf7b6f4979c172380e172b2de38..c6e3fc3006db212331895d598a200297b697ddaf 100644 (file)
@@ -827,7 +827,7 @@ static struct tevent_req *smbd_smb2_create_send(TALLOC_CTX *mem_ctx,
        if (state->out_file_attributes == 0) {
                state->out_file_attributes = FILE_ATTRIBUTE_NORMAL;
        }
-       state->out_file_id_persistent = result->fnum;
+       state->out_file_id_persistent = fsp_persistent_id(result);
        state->out_file_id_volatile = result->fnum;
        state->out_context_blobs = out_context_blobs;