[PATCH] Fix bug 11452 - DOS Client Cannot Delete *.*
Jeremy Allison
jra at samba.org
Tue Oct 20 19:39:13 UTC 2015
On Tue, Oct 20, 2015 at 04:00:55PM +0200, Andreas Schneider wrote:
> On Monday 19 October 2015 16:24:18 Jeremy Allison wrote:
> > In the wildcard pathname delete code path
> > we forgot to map 0 -> FILE_ATTRIBUTE_NORMAL
> > as we do in the non-wildcard delete path.
> >
> > This breaks an old DOS client that depends
> > on this behavior. Includes regression test
> > I tested against Win2k12r2.
> >
> > Review and push welcome !
> >
> > Thanks,
> >
> > Jeremy.
>
> RB+ and pushed to autobuild
Ah - fails on source4/torture/raw/unlink.c,
but that test code is incorrect anyway (it adds
a special return check for NT_STATUS_NO_SUCH_FILE
if the server is Samba3 - Samba should return
NT_STATUS_OK here as Windows does).
That's kind of funny - as it means we already
had a proper test for this but instead of
noticing and fixing the bug in the server,
we hacked in a "if Samba3" workaround for
our incorrect response :-) :-).
Updated patch attached. Andreas if you
could just review the samba3.raw.unlink
fixup (last hunk of the patch) it's
good to go !
Cheers (and sorry about the error),
Jeremy.
-------------- next part --------------
From 6f6ee39d2cdf0fcb2b8f0b2fd12e61eec6be65df Mon Sep 17 00:00:00 2001
From: Jeremy Allison <jra at samba.org>
Date: Mon, 19 Oct 2015 16:04:02 -0700
Subject: [PATCH 1/3] s3: smbd: Fix old DOS client doing wildcard delete -
gives a attribute type of zero.
In the wildcard delete path we forgot to map 0 -> FILE_ATTRIBUTE_NORMAL
as we do in the non-wildcard delete path.
BUG:https://bugzilla.samba.org/show_bug.cgi?id=11452
Signed-off-by: Jeremy Allison <jra at samba.org>
Reviewed-by: Andreas Schneider <asn at samba.org>
---
source3/smbd/reply.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c
index bebb789..c796c00 100644
--- a/source3/smbd/reply.c
+++ b/source3/smbd/reply.c
@@ -2915,6 +2915,9 @@ NTSTATUS unlink_internals(connection_struct *conn, struct smb_request *req,
status = NT_STATUS_OBJECT_NAME_INVALID;
goto out;
}
+ if (dirtype == 0) {
+ dirtype = FILE_ATTRIBUTE_NORMAL;
+ }
if (strequal(fname_mask,"????????.???")) {
TALLOC_FREE(fname_mask);
--
2.6.0.rc2.230.g3dd15c0
From bd3f8f94efcce63de4648ceab1a2fe77245f85f0 Mon Sep 17 00:00:00 2001
From: Jeremy Allison <jra at samba.org>
Date: Mon, 19 Oct 2015 16:06:01 -0700
Subject: [PATCH 2/3] s3: torture: Add WILDDELETE test to smbtorture3 to test
old wildcard delete with zero attribute.
https://bugzilla.samba.org/show_bug.cgi?id=11452
Signed-off-by: Jeremy Allison <jra at samba.org>
Reviewed-by: Andreas Schneider <asn at samba.org>
---
source3/selftest/tests.py | 2 +-
source3/torture/torture.c | 67 +++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 68 insertions(+), 1 deletion(-)
diff --git a/source3/selftest/tests.py b/source3/selftest/tests.py
index ecbb368..6d740b7 100755
--- a/source3/selftest/tests.py
+++ b/source3/selftest/tests.py
@@ -48,7 +48,7 @@ tests = ["FDPASS", "LOCK1", "LOCK2", "LOCK3", "LOCK4", "LOCK5", "LOCK6", "LOCK7"
"UNLINK", "BROWSE", "ATTR", "TRANS2", "TORTURE",
"OPLOCK1", "OPLOCK2", "OPLOCK4", "STREAMERROR",
"DIR", "DIR1", "DIR-CREATETIME", "TCON", "TCONDEV", "RW1", "RW2", "RW3", "LARGE_READX", "RW-SIGNING",
- "OPEN", "XCOPY", "RENAME", "DELETE", "DELETE-LN", "PROPERTIES", "W2K",
+ "OPEN", "XCOPY", "RENAME", "DELETE", "DELETE-LN", "WILDDELETE", "PROPERTIES", "W2K",
"TCON2", "IOCTL", "CHKPATH", "FDSESS", "CHAIN1", "CHAIN2",
"CHAIN3",
"GETADDRINFO", "UID-REGRESSION-TEST", "SHORTNAME-TEST",
diff --git a/source3/torture/torture.c b/source3/torture/torture.c
index 21d2dd2..ef75d21 100644
--- a/source3/torture/torture.c
+++ b/source3/torture/torture.c
@@ -4409,6 +4409,72 @@ static bool run_deletetest(int dummy)
return correct;
}
+
+/*
+ Test wildcard delete.
+ */
+static bool run_wild_deletetest(int dummy)
+{
+ struct cli_state *cli = NULL;
+ const char *dname = "\\WTEST";
+ const char *fname = "\\WTEST\\A";
+ const char *wunlink_name = "\\WTEST\\*";
+ uint16_t fnum1 = (uint16_t)-1;
+ bool correct = false;
+ NTSTATUS status;
+
+ printf("starting wildcard delete test\n");
+
+ if (!torture_open_connection(&cli, 0)) {
+ return false;
+ }
+
+ smbXcli_conn_set_sockopt(cli->conn, sockops);
+
+ cli_unlink(cli, fname, 0);
+ cli_rmdir(cli, dname);
+ status = cli_mkdir(cli, dname);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("mkdir of %s failed %s!\n", dname, nt_errstr(status));
+ goto fail;
+ }
+ status = cli_openx(cli, fname, O_CREAT|O_RDONLY, DENY_NONE, &fnum1);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("open of %s failed %s!\n", fname, nt_errstr(status));
+ goto fail;
+ }
+ status = cli_close(cli, fnum1);
+ fnum1 = -1;
+
+ /*
+ * Note the unlink attribute-type of zero. This should
+ * map into FILE_ATTRIBUTE_NORMAL at the server even
+ * on a wildcard delete.
+ */
+
+ status = cli_unlink(cli, wunlink_name, 0);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("unlink of %s failed %s!\n",
+ wunlink_name, nt_errstr(status));
+ goto fail;
+ }
+
+ printf("finished wildcard delete test\n");
+
+ correct = true;
+
+ fail:
+
+ if (fnum1 != (uint16_t)-1) cli_close(cli, fnum1);
+ cli_unlink(cli, fname, 0);
+ cli_rmdir(cli, dname);
+
+ if (cli && !torture_close_connection(cli)) {
+ correct = false;
+ }
+ return correct;
+}
+
static bool run_deletetest_ln(int dummy)
{
struct cli_state *cli;
@@ -9548,6 +9614,7 @@ static struct {
{"XCOPY", run_xcopy, 0},
{"RENAME", run_rename, 0},
{"DELETE", run_deletetest, 0},
+ {"WILDDELETE", run_wild_deletetest, 0},
{"DELETE-LN", run_deletetest_ln, 0},
{"PROPERTIES", run_properties, 0},
{"MANGLE", torture_mangle, 0},
--
2.6.0.rc2.230.g3dd15c0
From 4de3af592a9c7f6ffd00be178f82fef04de29717 Mon Sep 17 00:00:00 2001
From: Jeremy Allison <jra at samba.org>
Date: Tue, 20 Oct 2015 12:31:03 -0700
Subject: [PATCH 3/3] s3: torture: Remove (incorrect) samba3-specific behavior
in samba3.raw.unlink now the server is correct.
https://bugzilla.samba.org/show_bug.cgi?id=11452
Signed-off-by: Jeremy Allison <jra at samba.org>
---
source4/torture/raw/unlink.c | 7 +------
1 file changed, 1 insertion(+), 6 deletions(-)
diff --git a/source4/torture/raw/unlink.c b/source4/torture/raw/unlink.c
index 25edb5e..4f198fa 100644
--- a/source4/torture/raw/unlink.c
+++ b/source4/torture/raw/unlink.c
@@ -178,12 +178,7 @@ static bool test_unlink(struct torture_context *tctx, struct smbcli_state *cli)
io.unlink.in.pattern = BASEDIR "\\*.tx?";
io.unlink.in.attrib = 0;
status = smb_raw_unlink(cli->tree, &io);
- if (torture_setting_bool(tctx, "samba3", false)) {
- CHECK_STATUS(status, NT_STATUS_NO_SUCH_FILE);
- }
- else {
- CHECK_STATUS(status, NT_STATUS_OK);
- }
+ CHECK_STATUS(status, NT_STATUS_OK);
status = smb_raw_unlink(cli->tree, &io);
CHECK_STATUS(status, NT_STATUS_NO_SUCH_FILE);
--
2.6.0.rc2.230.g3dd15c0
More information about the samba-technical
mailing list