From 65bc97751a8202f9f9f6e7fc345ff3ebec562dc7 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 29 Apr 2021 13:25:36 -0700 Subject: [PATCH 1/2] selftest: Add test for SMB1 splopen/splwrite/splclose. Mark as knownfail. BUG: https://bugzilla.samba.org/show_bug.cgi?id=14696 Signed-off-by: Jeremy Allison --- selftest/knownfail.d/smb1spl | 1 + source3/selftest/tests.py | 5 +- source4/selftest/tests.py | 3 ++ source4/torture/raw/raw.c | 1 + source4/torture/raw/smb1spl.c | 98 +++++++++++++++++++++++++++++++++++ source4/torture/wscript_build | 2 +- 6 files changed, 108 insertions(+), 2 deletions(-) create mode 100644 selftest/knownfail.d/smb1spl create mode 100644 source4/torture/raw/smb1spl.c diff --git a/selftest/knownfail.d/smb1spl b/selftest/knownfail.d/smb1spl new file mode 100644 index 00000000000..f17884b68d2 --- /dev/null +++ b/selftest/knownfail.d/smb1spl @@ -0,0 +1 @@ +^samba3.raw.smb1spl.smb1spl\(fileserver_smb1\) diff --git a/source3/selftest/tests.py b/source3/selftest/tests.py index 11d0a41bda9..a1499504242 100755 --- a/source3/selftest/tests.py +++ b/source3/selftest/tests.py @@ -647,7 +647,8 @@ raw = ["raw.acls", "raw.chkpath", "raw.close", "raw.composite", "raw.context", " "raw.samba3caseinsensitive", "raw.samba3posixtimedlock", "raw.samba3rootdirfid", "raw.samba3rootdirfid2", "raw.sfileinfo.end-of-file", "raw.bench-oplock", "raw.bench-lock", "raw.bench-open", "raw.bench-tcon", - "raw.samba3checkfsp", "raw.samba3closeerr", "raw.samba3oplocklogoff", "raw.samba3badnameblob"] + "raw.samba3checkfsp", "raw.samba3closeerr", "raw.samba3oplocklogoff", "raw.samba3badnameblob", + "raw.smb1spl"] smb2 = smbtorture4_testsuites("smb2.") @@ -939,6 +940,8 @@ for t in tests: elif t in ["base.mangle", "base.tcon", "raw.mkdir"]: plansmbtorture4testsuite(t, "nt4_dc_smb1_done", '//$SERVER_IP/tmp -U$USERNAME%$PASSWORD') plansmbtorture4testsuite(t, "ad_dc_smb1_done", '//$SERVER/tmp -U$USERNAME%$PASSWORD') + elif t in ["raw.smb1spl"]: + plansmbtorture4testsuite(t, "fileserver_smb1", '//$SERVER_IP/print1 -U$USERNAME%$PASSWORD') else: plansmbtorture4testsuite(t, "nt4_dc", '//$SERVER_IP/tmp -U$USERNAME%$PASSWORD') plansmbtorture4testsuite(t, "ad_dc", '//$SERVER/tmp -U$USERNAME%$PASSWORD') diff --git a/source4/selftest/tests.py b/source4/selftest/tests.py index cdaced0e1c1..1f8fc6be571 100755 --- a/source4/selftest/tests.py +++ b/source4/selftest/tests.py @@ -380,6 +380,9 @@ base = smbtorture4_testsuites("base.") netapi = smbtorture4_testsuites("netapi.") for t in base + raw + smb2 + netapi: + if t in ["raw.smb1spl"]: + # No SMB1 printing tests here please. + continue; plansmbtorture4testsuite(t, "ad_dc_ntvfs", ['//$SERVER/tmp', '-U$USERNAME%$PASSWORD'] + ntvfsargs) libsmbclient = smbtorture4_testsuites("libsmbclient.") diff --git a/source4/torture/raw/raw.c b/source4/torture/raw/raw.c index b3716b6d0af..82fafb4057e 100644 --- a/source4/torture/raw/raw.c +++ b/source4/torture/raw/raw.c @@ -78,6 +78,7 @@ NTSTATUS torture_raw_init(TALLOC_CTX *ctx) torture_suite_add_1smb_test(suite, "samba3posixtimedlock", torture_samba3_posixtimedlock); torture_suite_add_simple_test(suite, "scan-eamax", torture_max_eas); + torture_suite_add_1smb_test(suite, "smb1spl", torture_raw_smb1spl); suite->description = talloc_strdup(suite, "Tests for the raw SMB interface"); diff --git a/source4/torture/raw/smb1spl.c b/source4/torture/raw/smb1spl.c new file mode 100644 index 00000000000..3eb3c47d966 --- /dev/null +++ b/source4/torture/raw/smb1spl.c @@ -0,0 +1,98 @@ +/* + Unix SMB/CIFS implementation. + SMBspl print test. + 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 "system/locale.h" +#include "libcli/raw/libcliraw.h" +#include "libcli/libcli.h" +#include "torture/util.h" +#include "torture/raw/proto.h" + +/* + Basic SMBsplwr test. +*/ +bool torture_raw_smb1spl(struct torture_context *torture, + struct smbcli_state *cli) +{ + NTSTATUS status; + bool ret = false; + union smb_open open_params; + union smb_write write_params; + union smb_close close_params; + uint8_t print_data[256] = {0}; + int fnum = -1; + + /* Open the print file. */ + ZERO_STRUCT(open_params); + open_params.generic.level = RAW_OPEN_SPLOPEN; + open_params.splopen.in.setup_length = 2; + open_params.splopen.in.mode = 0; + open_params.splopen.in.ident = ""; + status = smb_raw_open(cli->tree, torture, &open_params); + if (!NT_STATUS_IS_OK(status)) { + printf("RAW_OPEN_SPLOPEN failed %s\n", + smbcli_errstr(cli->tree)); + goto done; + } + + fnum = open_params.splopen.out.file.fnum; + + /* Write one byte. */ + ZERO_STRUCT(write_params); + write_params.generic.level = RAW_WRITE_SPLWRITE; + write_params.splwrite.in.file.fnum = fnum; + write_params.splwrite.in.count = 256; + write_params.splwrite.in.data = print_data; + status = smb_raw_write(cli->tree, &write_params); + if (!NT_STATUS_IS_OK(status)) { + printf("RAW_OPEN_SPLWRITE failed %s\n", + smbcli_errstr(cli->tree)); + goto done; + } + + /* Close the print file. */ + ZERO_STRUCT(close_params); + close_params.generic.level = RAW_CLOSE_SPLCLOSE; + close_params.splclose.in.file.fnum = fnum; + status = smb_raw_close(cli->tree, &close_params); + if (!NT_STATUS_IS_OK(status)) { + printf("RAW_CLOSE_SPLCLOSE failed %s\n", + smbcli_errstr(cli->tree)); + goto done; + } + + fnum = -1; + ret = true; + + done: + + if (ret == false) { + torture_fail(torture, "SMB1 SPL test failed\n"); + } + + if (fnum != -1) { + ZERO_STRUCT(close_params); + close_params.generic.level = RAW_CLOSE_SPLCLOSE; + close_params.splclose.in.file.fnum = fnum; + (void)smb_raw_close(cli->tree, &close_params); + } + smb_raw_exit(cli->session); + + return ret; +} diff --git a/source4/torture/wscript_build b/source4/torture/wscript_build index 1b781266e43..9211c4308ad 100644 --- a/source4/torture/wscript_build +++ b/source4/torture/wscript_build @@ -22,7 +22,7 @@ bld.SAMBA_MODULE('TORTURE_BASIC', bld.SAMBA_MODULE('TORTURE_RAW', - source='raw/qfsinfo.c raw/qfileinfo.c raw/setfileinfo.c raw/search.c raw/close.c raw/open.c raw/mkdir.c raw/oplock.c raw/notify.c raw/mux.c raw/ioctl.c raw/chkpath.c raw/unlink.c raw/read.c raw/context.c raw/session.c raw/write.c raw/lock.c raw/pingpong.c raw/lockbench.c raw/lookuprate.c raw/tconrate.c raw/openbench.c raw/rename.c raw/eas.c raw/streams.c raw/acls.c raw/seek.c raw/samba3hide.c raw/samba3misc.c raw/composite.c raw/raw.c raw/offline.c', + source='raw/qfsinfo.c raw/qfileinfo.c raw/setfileinfo.c raw/search.c raw/close.c raw/open.c raw/mkdir.c raw/oplock.c raw/notify.c raw/mux.c raw/ioctl.c raw/chkpath.c raw/unlink.c raw/read.c raw/context.c raw/session.c raw/write.c raw/lock.c raw/pingpong.c raw/lockbench.c raw/lookuprate.c raw/tconrate.c raw/openbench.c raw/rename.c raw/eas.c raw/streams.c raw/acls.c raw/seek.c raw/samba3hide.c raw/samba3misc.c raw/composite.c raw/raw.c raw/offline.c raw/smb1spl.c', autoproto='raw/proto.h', subsystem='smbtorture', init_function='torture_raw_init', -- 2.27.0 From be0b72bff53ba9e555ab9828e1c860d88d4d053a Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 29 Apr 2021 09:50:30 -0700 Subject: [PATCH 2/2] s3: smbd: SMB1 SMBsplwr doesn't send a reply packet on success. Missing call to set up req->outbuf means no reply is sent. BUG: https://bugzilla.samba.org/show_bug.cgi?id=14696 Signed-off-by: Jeremy Allison --- selftest/knownfail.d/smb1spl | 1 - source3/smbd/reply.c | 2 ++ 2 files changed, 2 insertions(+), 1 deletion(-) delete mode 100644 selftest/knownfail.d/smb1spl diff --git a/selftest/knownfail.d/smb1spl b/selftest/knownfail.d/smb1spl deleted file mode 100644 index f17884b68d2..00000000000 --- a/selftest/knownfail.d/smb1spl +++ /dev/null @@ -1 +0,0 @@ -^samba3.raw.smb1spl.smb1spl\(fileserver_smb1\) diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c index dcda32e8cc1..f7b0fe72f13 100644 --- a/source3/smbd/reply.c +++ b/source3/smbd/reply.c @@ -7059,6 +7059,8 @@ void reply_printwrite(struct smb_request *req) DEBUG(3, ("printwrite %s num=%d\n", fsp_fnum_dbg(fsp), numtowrite)); + reply_outbuf(req, 0, 0); + END_PROFILE(SMBsplwr); return; } -- 2.27.0