Don't allow asynchronous creates to be canceled in SMB2.
authorJeremy Allison <jra@samba.org>
Fri, 29 Jun 2012 21:25:53 +0000 (14:25 -0700)
committerJeremy Allison <jra@samba.org>
Sat, 30 Jun 2012 02:10:02 +0000 (04:10 +0200)
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Sat Jun 30 04:10:02 CEST 2012 on sn-devel-104

source3/smbd/open.c
source3/smbd/proto.h
source3/smbd/smb2_create.c

index 467a69f0492eeaf12fc0dba6acfb3fdc310ec0c1..c2bf8edb7a6b7a45b60f75d80538614c6ed95d6c 100644 (file)
@@ -1684,6 +1684,17 @@ void remove_deferred_open_entry(struct file_id id, uint64_t mid,
        TALLOC_FREE(lck);
 }
 
+/****************************************************************************
+ Return true if this is a state pointer to an asynchronous create.
+****************************************************************************/
+
+bool is_deferred_open_async(const void *ptr)
+{
+       const struct deferred_open_record *state = (const struct deferred_open_record *)ptr;
+
+       return state->async_open;
+}
+
 /****************************************************************************
  Open a file with a share mode. Passed in an already created files_struct *.
 ****************************************************************************/
@@ -1788,18 +1799,18 @@ static NTSTATUS open_file_ntcreate(connection_struct *conn,
                if (get_deferred_open_message_state(req,
                                &request_time,
                                &ptr)) {
-
-                       struct deferred_open_record *state = (struct deferred_open_record *)ptr;
                        /* Remember the absolute time of the original
                           request with this mid. We'll use it later to
                           see if this has timed out. */
 
                        /* If it was an async create retry, the file
                           didn't exist. */
-                       if (state->async_open) {
+
+                       if (is_deferred_open_async(ptr)) {
                                SET_STAT_INVALID(smb_fname->st);
                                file_existed = false;
                        } else {
+                               struct deferred_open_record *state = (struct deferred_open_record *)ptr;
                                /* Remove the deferred open entry under lock. */
                                remove_deferred_open_entry(
                                        state->id, req->mid,
index f566b3258d21ed9f250d2b33642e04371ba96342..1b28c8b86b801e4322b68b839ecdaa296e9ad6d9 100644 (file)
@@ -616,6 +616,7 @@ bool open_match_attributes(connection_struct *conn,
                           mode_t *returned_unx_mode);
 void remove_deferred_open_entry(struct file_id id, uint64_t mid,
                                struct server_id pid);
+bool is_deferred_open_async(const void *ptr);
 NTSTATUS open_file_fchmod(connection_struct *conn,
                          struct smb_filename *smb_fname,
                          files_struct **result);
index b69f268c9e6886b7c849826999a141eb29aae516..7b5a26269b4056d3b95af7eda7403e1c91fd519c 100644 (file)
@@ -1162,6 +1162,11 @@ static bool smbd_smb2_create_cancel(struct tevent_req *req)
        smb2req = state->smb2req;
        mid = get_mid_from_smb2req(smb2req);
 
+       if (is_deferred_open_async(state->private_data.data)) {
+               /* Can't cancel an async create. */
+               return false;
+       }
+
        remove_deferred_open_entry(state->id, mid,
                                   messaging_server_id(smb2req->sconn->msg_ctx));
        remove_deferred_open_message_smb2_internal(smb2req, mid);