s3: smbd: Split out smb2_ioctl_smbtorture() into a separate file.
authorJeremy Allison <jra@samba.org>
Thu, 5 Aug 2021 20:14:16 +0000 (13:14 -0700)
committerJule Anger <janger@samba.org>
Tue, 17 Aug 2021 07:43:21 +0000 (07:43 +0000)
We will be adding async supporting code to this, and we don't want to
clutter up smb2_ioctl.c.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14769

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
(cherry picked from commit 6b6770c2ba83bf25da31623443c19a8de34e5ba4)

source3/smbd/smb2_ioctl.c
source3/smbd/smb2_ioctl_private.h
source3/smbd/smb2_ioctl_smbtorture.c [new file with mode: 0644]
source3/wscript_build

index d29ff5d0303bc4d5835dfda04b75f2bdaacedb45..8154d3d8bfaeb1b916b5ca4e7a5b467518ec1b9d 100644 (file)
@@ -381,74 +381,6 @@ static void smbd_smb2_request_ioctl_done(struct tevent_req *subreq)
        }
 }
 
-static struct tevent_req *smb2_ioctl_smbtorture(uint32_t ctl_code,
-                                       struct tevent_context *ev,
-                                       struct tevent_req *req,
-                                       struct smbd_smb2_ioctl_state *state)
-{
-       NTSTATUS status;
-       bool ok;
-
-       ok = lp_parm_bool(-1, "smbd", "FSCTL_SMBTORTURE", false);
-       if (!ok) {
-               goto not_supported;
-       }
-
-       switch (ctl_code) {
-       case FSCTL_SMBTORTURE_FORCE_UNACKED_TIMEOUT:
-               if (state->in_input.length != 0) {
-                       tevent_req_nterror(req, NT_STATUS_INVALID_PARAMETER);
-                       return tevent_req_post(req, ev);
-               }
-
-               state->smb2req->xconn->ack.force_unacked_timeout = true;
-               tevent_req_done(req);
-               return tevent_req_post(req, ev);
-
-       case FSCTL_SMBTORTURE_IOCTL_RESPONSE_BODY_PADDING8:
-               if (state->in_input.length != 0) {
-                       tevent_req_nterror(req, NT_STATUS_INVALID_PARAMETER);
-                       return tevent_req_post(req, ev);
-               }
-
-               if (state->in_max_output > 0) {
-                       uint32_t size = state->in_max_output;
-
-                       state->out_output = data_blob_talloc(state, NULL, size);
-                       if (tevent_req_nomem(state->out_output.data, req)) {
-                               return tevent_req_post(req, ev);
-                       }
-                       memset(state->out_output.data, 8, size);
-               }
-
-               state->body_padding = 8;
-               tevent_req_done(req);
-               return tevent_req_post(req, ev);
-
-       case FSCTL_SMBTORTURE_GLOBAL_READ_RESPONSE_BODY_PADDING8:
-               if (state->in_input.length != 0) {
-                       tevent_req_nterror(req, NT_STATUS_INVALID_PARAMETER);
-                       return tevent_req_post(req, ev);
-               }
-
-               state->smb2req->xconn->smb2.smbtorture.read_body_padding = 8;
-               tevent_req_done(req);
-               return tevent_req_post(req, ev);
-       default:
-               goto not_supported;
-       }
-
-not_supported:
-       if (IS_IPC(state->smbreq->conn)) {
-               status = NT_STATUS_FS_DRIVER_REQUIRED;
-       } else {
-               status = NT_STATUS_INVALID_DEVICE_REQUEST;
-       }
-
-       tevent_req_nterror(req, status);
-       return tevent_req_post(req, ev);
-}
-
 static struct tevent_req *smbd_smb2_ioctl_send(TALLOC_CTX *mem_ctx,
                                               struct tevent_context *ev,
                                               struct smbd_smb2_request *smb2req,
index 7a35f8f5d0baa54952418312b83433bfe75694d7..d653c107d3d1a4b05378a3668b573bcddc4bc6e3 100644 (file)
@@ -52,4 +52,9 @@ struct tevent_req *smb2_ioctl_network_fs(uint32_t,
                                         struct tevent_req *,
                                         struct smbd_smb2_ioctl_state *);
 
+struct tevent_req *smb2_ioctl_smbtorture(uint32_t ctl_code,
+                                        struct tevent_context *ev,
+                                        struct tevent_req *req,
+                                        struct smbd_smb2_ioctl_state *state);
+
 #endif
diff --git a/source3/smbd/smb2_ioctl_smbtorture.c b/source3/smbd/smb2_ioctl_smbtorture.c
new file mode 100644 (file)
index 0000000..cc2c8ac
--- /dev/null
@@ -0,0 +1,100 @@
+/*
+   Unix SMB/CIFS implementation.
+   Core SMB2 server
+
+   Copyright (C) Stefan Metzmacher 2009
+   Copyright (C) Jeremy Allison 2021
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "includes.h"
+#include "smbd/smbd.h"
+#include "smbd/globals.h"
+#include "../libcli/smb/smb_common.h"
+#include "../lib/util/tevent_ntstatus.h"
+#include "include/ntioctl.h"
+#include "smb2_ioctl_private.h"
+#include "librpc/gen_ndr/ioctl.h"
+
+#undef DBGC_CLASS
+#define DBGC_CLASS DBGC_SMB2
+
+struct tevent_req *smb2_ioctl_smbtorture(uint32_t ctl_code,
+                                        struct tevent_context *ev,
+                                        struct tevent_req *req,
+                                        struct smbd_smb2_ioctl_state *state)
+{
+       NTSTATUS status;
+       bool ok;
+
+       ok = lp_parm_bool(-1, "smbd", "FSCTL_SMBTORTURE", false);
+       if (!ok) {
+               goto not_supported;
+       }
+
+       switch (ctl_code) {
+       case FSCTL_SMBTORTURE_FORCE_UNACKED_TIMEOUT:
+               if (state->in_input.length != 0) {
+                       tevent_req_nterror(req, NT_STATUS_INVALID_PARAMETER);
+                       return tevent_req_post(req, ev);
+               }
+
+               state->smb2req->xconn->ack.force_unacked_timeout = true;
+               tevent_req_done(req);
+               return tevent_req_post(req, ev);
+
+       case FSCTL_SMBTORTURE_IOCTL_RESPONSE_BODY_PADDING8:
+               if (state->in_input.length != 0) {
+                       tevent_req_nterror(req, NT_STATUS_INVALID_PARAMETER);
+                       return tevent_req_post(req, ev);
+               }
+
+               if (state->in_max_output > 0) {
+                       uint32_t size = state->in_max_output;
+
+                       state->out_output = data_blob_talloc(state, NULL, size);
+                       if (tevent_req_nomem(state->out_output.data, req)) {
+                               return tevent_req_post(req, ev);
+                       }
+                       memset(state->out_output.data, 8, size);
+               }
+
+               state->body_padding = 8;
+               tevent_req_done(req);
+               return tevent_req_post(req, ev);
+
+       case FSCTL_SMBTORTURE_GLOBAL_READ_RESPONSE_BODY_PADDING8:
+               if (state->in_input.length != 0) {
+                       tevent_req_nterror(req, NT_STATUS_INVALID_PARAMETER);
+                       return tevent_req_post(req, ev);
+               }
+
+               state->smb2req->xconn->smb2.smbtorture.read_body_padding = 8;
+               tevent_req_done(req);
+               return tevent_req_post(req, ev);
+       default:
+               goto not_supported;
+       }
+
+not_supported:
+       if (IS_IPC(state->smbreq->conn)) {
+               status = NT_STATUS_FS_DRIVER_REQUIRED;
+       } else {
+               status = NT_STATUS_INVALID_DEVICE_REQUEST;
+       }
+
+       tevent_req_nterror(req, status);
+       return tevent_req_post(req, ev);
+}
index 55851c7b3a6c283bde77e0a49db146af2447c380..69febb537501ecb93de464b27f21fdc74e040151 100644 (file)
@@ -663,6 +663,7 @@ bld.SAMBA3_LIBRARY('smbd_base',
                           smbd/smb2_ioctl_filesys.c
                           smbd/smb2_ioctl_named_pipe.c
                           smbd/smb2_ioctl_network_fs.c
+                          smbd/smb2_ioctl_smbtorture.c
                           smbd/smb2_keepalive.c
                           smbd/smb2_query_directory.c
                           smbd/smb2_notify.c