HACK FSCTL_LMR_REQ_RESILIENCY...
authorStefan Metzmacher <metze@samba.org>
Fri, 5 Sep 2014 22:11:03 +0000 (00:11 +0200)
committerMichael Adam <obnox@samba.org>
Sun, 7 Feb 2016 09:58:37 +0000 (10:58 +0100)
source3/librpc/idl/smbXsrv.idl
source3/smbd/smb2_ioctl_network_fs.c
source3/smbd/smb2_lock.c

index 50b984f..e4f2b12 100644 (file)
@@ -425,6 +425,7 @@ interface smbXsrv
                uint32                                  durable_timeout_msec;
                boolean8                                durable;
                DATA_BLOB                               backend_cookie;
+               boolean8                                is_resilient; //TODO
                [flag(NDR_PAHEX)] uint8                 lock_sequence_array[64];
                hyper channel_sequence;
        } smbXsrv_open_global0;
index d8590de..1adff1a 100644 (file)
@@ -620,6 +620,42 @@ static NTSTATUS fsctl_srv_req_resume_key(TALLOC_CTX *mem_ctx,
        return NT_STATUS_OK;
 }
 
+static NTSTATUS fsctl_network_resiliency(TALLOC_CTX *mem_ctx,
+                                        struct tevent_context *ev,
+                                        struct files_struct *in_fsp,
+                                        DATA_BLOB *in_input,
+                                        uint32_t in_max_output,
+                                        DATA_BLOB *out_output)
+{
+       NTSTATUS status;
+       uint32_t in_timeout;
+
+       *out_output = data_blob_null;
+
+       if (in_fsp == NULL) {
+               return NT_STATUS_FILE_CLOSED;
+       }
+
+       if (in_input->length < 8) {
+               return NT_STATUS_INVALID_PARAMETER;
+       }
+
+       in_timeout = IVAL(in_input->data, 0);
+       if (in_timeout > 300000) {
+               return NT_STATUS_INVALID_PARAMETER;
+       }
+
+       in_fsp->op->global->is_resilient = true;
+
+       status = smbXsrv_open_update(in_fsp->op);
+       if (!NT_STATUS_IS_OK(status)) {
+               in_fsp->op->global->is_resilient = false;
+               return status;
+       }
+
+       return NT_STATUS_OK;
+}
+
 static void smb2_ioctl_network_fs_copychunk_done(struct tevent_req *subreq);
 
 struct tevent_req *smb2_ioctl_network_fs(uint32_t ctl_code,
@@ -698,6 +734,17 @@ struct tevent_req *smb2_ioctl_network_fs(uint32_t ctl_code,
                }
                return tevent_req_post(req, ev);
                break;
+       case FSCTL_LMR_REQ_RESILIENCY:
+               status = fsctl_network_resiliency(state, ev,
+                                                 state->fsp,
+                                                 &state->in_input,
+                                                 state->in_max_output,
+                                                 &state->out_output);
+               if (!tevent_req_nterror(req, status)) {
+                       tevent_req_done(req);
+               }
+               return tevent_req_post(req, ev);
+               break;
        default: {
                uint8_t *out_data = NULL;
                uint32_t out_data_len = 0;
index d962c13..e0573ac 100644 (file)
@@ -216,11 +216,15 @@ static struct tevent_req *smbd_smb2_lock_send(TALLOC_CTX *mem_ctx,
                  fsp_str_dbg(fsp), fsp_fnum_dbg(fsp)));
 
        /*
-        * TODO: Windows sets check_lock_sequence = true
+        * Windows sets check_lock_sequence = true
         * only for resilient and persistent handles
         *
-        * What about other handles using multi-channel?
+        * TODO: What about other handles using multi-channel?
         */
+       if (fsp->op->global->is_resilient) {
+               check_lock_sequence = true;
+       }
+
        if (check_lock_sequence) {
                state->lock_sequence_value = in_lock_sequence & 0xF;
                lock_sequence_bucket = in_lock_sequence >> 4;