smbd:smb2: successfully answer a DHnC request when the initial create was DH2Q
authorMichael Adam <obnox@samba.org>
Wed, 25 Sep 2013 21:20:18 +0000 (23:20 +0200)
committerStefan Metzmacher <metze@samba.org>
Sat, 5 Oct 2013 12:04:08 +0000 (14:04 +0200)
I.e. the durable reconnect attempt is v1 while the original create was durable
v2 including the create guid.

Implement this by skipping the create_guid verification when
the reconnect request is v1.

Signed-off-by: Michael Adam <obnox@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
source3/smbd/globals.h
source3/smbd/smb2_create.c
source3/smbd/smbXsrv_open.c

index 9ea5e25bc038a3eb144d4b82e014cb61f379baa9..6beee59e7bf501f2799fd1c9d35277e6a737e910 100644 (file)
@@ -457,7 +457,7 @@ NTSTATUS smb2srv_open_lookup(struct smbXsrv_connection *conn,
 NTSTATUS smb2srv_open_recreate(struct smbXsrv_connection *conn,
                               struct auth_session_info *session_info,
                               uint64_t persistent_id,
-                              struct GUID create_guid,
+                              const struct GUID *create_guid,
                               NTTIME now,
                               struct smbXsrv_open **_open);
 struct smbXsrv_open_global0;
index 93cccf844507535acef8730a6fca13738e833db1..fb9b56e36deae058cc7d9b7cd86fe863444e113f 100644 (file)
@@ -550,7 +550,8 @@ static struct tevent_req *smbd_smb2_create_send(TALLOC_CTX *mem_ctx,
                uint64_t allocation_size = 0;
                struct smb2_create_blob *twrp = NULL;
                struct smb2_create_blob *qfid = NULL;
-               struct GUID create_guid = GUID_zero();
+               struct GUID _create_guid = GUID_zero();
+               struct GUID *create_guid = NULL;
                bool update_open = false;
                bool durable_requested = false;
                uint32_t durable_timeout_msec = 0;
@@ -668,10 +669,11 @@ static struct tevent_req *smbd_smb2_create_send(TALLOC_CTX *mem_ctx,
                        create_guid_blob = data_blob_const(p + 16, 16);
 
                        status = GUID_from_ndr_blob(&create_guid_blob,
-                                                   &create_guid);
+                                                   &_create_guid);
                        if (tevent_req_nterror(req, status)) {
                                return tevent_req_post(req, ev);
                        }
+                       create_guid = &_create_guid;
                        /*
                         * we need to store the create_guid later
                         */
@@ -706,10 +708,11 @@ static struct tevent_req *smbd_smb2_create_send(TALLOC_CTX *mem_ctx,
                        create_guid_blob = data_blob_const(p + 16, 16);
 
                        status = GUID_from_ndr_blob(&create_guid_blob,
-                                                   &create_guid);
+                                                   &_create_guid);
                        if (tevent_req_nterror(req, status)) {
                                return tevent_req_post(req, ev);
                        }
+                       create_guid = &_create_guid;
 
                        do_durable_reconnect = true;
                }
@@ -940,7 +943,7 @@ static struct tevent_req *smbd_smb2_create_send(TALLOC_CTX *mem_ctx,
                }
 
                if (update_open) {
-                       op->global->create_guid = create_guid;
+                       op->global->create_guid = _create_guid;
 
                        status = smbXsrv_open_update(op);
                        DEBUG(10, ("smb2_create_send: smbXsrv_open_update "
index 27dd50c65a9cf895ccef81d61e0e6fd076f755cd..25dc6f7005377bda487b452e9fa84dc42e0eb5af 100644 (file)
@@ -1168,7 +1168,7 @@ NTSTATUS smb2srv_open_lookup(struct smbXsrv_connection *conn,
 NTSTATUS smb2srv_open_recreate(struct smbXsrv_connection *conn,
                               struct auth_session_info *session_info,
                               uint64_t persistent_id,
-                              struct GUID create_guid,
+                              const struct GUID *create_guid,
                               NTTIME now,
                               struct smbXsrv_open **_open)
 {
@@ -1207,7 +1207,15 @@ NTSTATUS smb2srv_open_recreate(struct smbXsrv_connection *conn,
                return status;
        }
 
-       if (!GUID_equal(&op->global->create_guid, &create_guid)) {
+       /*
+        * If the provided create_guid is NULL, this means that
+        * the reconnect request was a v1 request. In that case
+        * we should skipt the create GUID verification, since
+        * it is valid to v1-reconnect a v2-opened handle.
+        */
+       if ((create_guid != NULL) &&
+           !GUID_equal(&op->global->create_guid, create_guid))
+       {
                TALLOC_FREE(op);
                return NT_STATUS_OBJECT_NAME_NOT_FOUND;
        }