From: Jeremy Allison Date: Thu, 5 Aug 2021 20:14:16 +0000 (-0700) Subject: s3: smbd: Split out smb2_ioctl_smbtorture() into a separate file. X-Git-Tag: ldb-2.5.0~992 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6b6770c2ba83bf25da31623443c19a8de34e5ba4;p=thirdparty%2Fsamba.git s3: smbd: Split out smb2_ioctl_smbtorture() into a separate file. 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 Reviewed-by: Ralph Boehme --- diff --git a/source3/smbd/smb2_ioctl.c b/source3/smbd/smb2_ioctl.c index d29ff5d0303..8154d3d8bfa 100644 --- a/source3/smbd/smb2_ioctl.c +++ b/source3/smbd/smb2_ioctl.c @@ -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, diff --git a/source3/smbd/smb2_ioctl_private.h b/source3/smbd/smb2_ioctl_private.h index 7a35f8f5d0b..d653c107d3d 100644 --- a/source3/smbd/smb2_ioctl_private.h +++ b/source3/smbd/smb2_ioctl_private.h @@ -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 index 00000000000..cc2c8ac55fe --- /dev/null +++ b/source3/smbd/smb2_ioctl_smbtorture.c @@ -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 . +*/ + +#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); +} diff --git a/source3/wscript_build b/source3/wscript_build index 8f5ce0e99ff..71e24ff3367 100644 --- a/source3/wscript_build +++ b/source3/wscript_build @@ -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