1
0
mirror of https://github.com/samba-team/samba.git synced 2025-03-24 10:50:22 +03:00

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 <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
This commit is contained in:
Jeremy Allison 2021-08-05 13:14:16 -07:00 committed by Ralph Boehme
parent 4354823c51
commit 6b6770c2ba
4 changed files with 106 additions and 68 deletions

View 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,

View 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

View File

@ -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);
}

View 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