Patches to make smb2.getinfo work

Volker Lendecke Volker.Lendecke at SerNet.DE
Fri Aug 23 08:22:52 MDT 2013


Hi!

Attached find a patchset that splits up the smb2.getinfo
torture tests and also make them work against Windows 2012.
W2012 seems pretty picky about the 1-byte suffix that the
SMB2_CREATE specifies if there is a 0-length filename and no
create blobs. Also, this makes it possible to run the
smb2.getinfo.buffercheck subtest in make test now. This will
be expanded soon.

Please review&push.

Thanks,

Volker

-- 
SerNet GmbH, Bahnhofsallee 1b, 37081 Göttingen
phone: +49-551-370000-0, fax: +49-551-370000-9
AG Göttingen, HRB 2816, GF: Dr. Johannes Loxen
http://www.sernet.de, mailto:kontakt at sernet.de
-------------- next part --------------
From 0aeefce1d6582396a3b422ccc348ff09bef95fc0 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Thu, 22 Aug 2013 15:19:32 +0000
Subject: [PATCH 1/7] smbd: Fix a debug message

Signed-off-by: Volker Lendecke <vl at samba.org>
---
 source3/smbd/trans2.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/source3/smbd/trans2.c b/source3/smbd/trans2.c
index 81f80c3..e7c0da1 100644
--- a/source3/smbd/trans2.c
+++ b/source3/smbd/trans2.c
@@ -3374,7 +3374,7 @@ cBytesSector=%u, cUnitTotal=%u, cUnitAvail=%d\n", (unsigned int)bsize, (unsigned
 
 			/* access check */
 			if (get_current_uid(conn) != 0) {
-				DEBUG(0,("set_user_quota: access_denied "
+				DEBUG(0,("get_user_quota: access_denied "
 					 "service [%s] user [%s]\n",
 					 lp_servicename(talloc_tos(), SNUM(conn)),
 					 conn->session_info->unix_info->unix_name));
-- 
1.7.9.5


From 7d5d8003b078146bdaba27583863720c530e6e3b Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Thu, 22 Aug 2013 11:19:33 +0000
Subject: [PATCH 2/7] torture: Remove an unused variable

Signed-off-by: Volker Lendecke <vl at samba.org>
---
 source4/torture/smb2/getinfo.c |    3 ---
 1 file changed, 3 deletions(-)

diff --git a/source4/torture/smb2/getinfo.c b/source4/torture/smb2/getinfo.c
index 16db715..f407acc 100644
--- a/source4/torture/smb2/getinfo.c
+++ b/source4/torture/smb2/getinfo.c
@@ -181,7 +181,6 @@ static bool torture_smb2_buffercheck(struct torture_context *tctx, struct smb2_t
 */
 bool torture_smb2_getinfo(struct torture_context *torture)
 {
-	TALLOC_CTX *mem_ctx = talloc_new(NULL);
 	struct smb2_tree *tree;
 	bool ret = true;
 	NTSTATUS status;
@@ -212,7 +211,5 @@ bool torture_smb2_getinfo(struct torture_context *torture)
 	ret &= torture_smb2_fsinfo(torture, tree);
 	ret &= torture_smb2_buffercheck(torture, tree);
 
-	talloc_free(mem_ctx);
-
 	return ret;
 }
-- 
1.7.9.5


From 70a69b6bfda07215ba7d52e8e0da376e4ccc571b Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Thu, 22 Aug 2013 15:04:03 +0000
Subject: [PATCH 3/7] libsmb2: Fix opening the rootdirectory, part 1

[MS-SMB2], 2.2.13 says: In the request, the Buffer field MUST be at least one
byte in length. Implement that for the 0-length filename without create blobs.

Signed-off-by: Volker Lendecke <vl at samba.org>
---
 source4/libcli/smb2/create.c |   15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/source4/libcli/smb2/create.c b/source4/libcli/smb2/create.c
index 1a7f02b..10fe4f7 100644
--- a/source4/libcli/smb2/create.c
+++ b/source4/libcli/smb2/create.c
@@ -294,6 +294,21 @@ struct smb2_request *smb2_create_send(struct smb2_tree *tree, struct smb2_create
 		return NULL;
 	}
 
+	if (((io->in.fname == NULL) || (strlen(io->in.fname) == 0)) &&
+	    (blob.length == 0)) {
+		struct smb2_request_buffer *buf = &req->out;
+
+		status = smb2_grow_buffer(buf, 1);
+		if (!NT_STATUS_IS_OK(status)) {
+			talloc_free(req);
+			return NULL;
+		}
+		buf->dynamic[0] = 0;
+		buf->dynamic += 1;
+		buf->body_size += 1;
+		buf->size += 1;
+	}
+
 	data_blob_free(&blob);
 
 	smb2_transport_send(req);
-- 
1.7.9.5


From 4169985f95ec94141ffd7196bb849ef27de482ee Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Thu, 22 Aug 2013 15:04:03 +0000
Subject: [PATCH 4/7] libsmb2: Fix opening the rootdirectory, part 2

smb2_push_o16s16_blob is wrong for the blob.data==NULL case. It does
not do the same magic that the rest of the routine does with regards to
padding_fix.  padding_fix is wrong in its own respect, with a 0-length
blob we end up with a negative padding fix. It's wrong, but it seems
to work.

Why am I doing this? I want to make smb2.getinfo work against
w2k12. smb2_util_roothandle() always gives NT_STATUS_INVALID_PARAMETER
without this and the preceding fix.

Signed-off-by: Volker Lendecke <vl at samba.org>
---
 source4/torture/smb2/util.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/source4/torture/smb2/util.c b/source4/torture/smb2/util.c
index cb9a527..4ffcfea 100644
--- a/source4/torture/smb2/util.c
+++ b/source4/torture/smb2/util.c
@@ -485,7 +485,7 @@ NTSTATUS smb2_util_roothandle(struct smb2_tree *tree, struct smb2_handle *handle
 	io.in.create_disposition = NTCREATEX_DISP_OPEN;
 	io.in.share_access = NTCREATEX_SHARE_ACCESS_READ|NTCREATEX_SHARE_ACCESS_DELETE;
 	io.in.create_options = NTCREATEX_OPTIONS_ASYNC_ALERT;
-	io.in.fname = NULL;
+	io.in.fname = "";
 
 	status = smb2_create(tree, tree, &io);
 	NT_STATUS_NOT_OK_RETURN(status);
-- 
1.7.9.5


From 76c4bbdc313c44444e042da3a24c0fcd1879c689 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Thu, 22 Aug 2013 11:06:59 +0000
Subject: [PATCH 5/7] torture: Change smb2.getinfo into a suite

Signed-off-by: Volker Lendecke <vl at samba.org>
---
 selftest/knownfail             |    4 ++--
 source4/torture/smb2/getinfo.c |   11 ++++++++++-
 source4/torture/smb2/smb2.c    |    2 +-
 3 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/selftest/knownfail b/selftest/knownfail
index c075ba6..1c1bff8 100644
--- a/selftest/knownfail
+++ b/selftest/knownfail
@@ -170,7 +170,7 @@
 ^samba4.smb2.oplock.batch10\(.*\)$ # samba 4 oplocks are a mess
 ^samba4.smb2.oplock.batch20\(.*\)$ # samba 4 oplocks are a mess
 ^samba4.smb2.oplock.stream1 # samba 4 oplocks are a mess
-^samba4.smb2.getinfo.getinfo # streams on directories does not work
+^samba4.smb2.getinfo.complex # streams on directories does not work
 ^samba4.ntvfs.cifs.krb5.base.createx_access.createx_access\(.*\)$
 ^samba4.rpc.lsa.forest.trust #Not fully provided by Samba4
 ^samba4.blackbox.kinit\(.*\).kinit with user password for expired password\(.*\) # We need to work out why this fails only during the pw change
@@ -206,7 +206,7 @@
 ^samba3.smb2.streams.rename
 ^samba3.smb2.streams.rename2
 ^samba3.smb2.streams.attributes
-^samba3.smb2.getinfo.getinfo
+^samba3.smb2.getinfo.complex
 ^samba3.smb2.setinfo.setinfo
 ^samba3.smb2.session.*reauth5 # some special anonymous checks?
 ^samba3.smb2.compound.interim2 # wrong return code (STATUS_CANCELLED)
diff --git a/source4/torture/smb2/getinfo.c b/source4/torture/smb2/getinfo.c
index f407acc..f60db95 100644
--- a/source4/torture/smb2/getinfo.c
+++ b/source4/torture/smb2/getinfo.c
@@ -179,7 +179,7 @@ static bool torture_smb2_buffercheck(struct torture_context *tctx, struct smb2_t
 
 /* basic testing of all SMB2 getinfo levels
 */
-bool torture_smb2_getinfo(struct torture_context *torture)
+static bool torture_smb2_getinfo(struct torture_context *torture)
 {
 	struct smb2_tree *tree;
 	bool ret = true;
@@ -213,3 +213,12 @@ bool torture_smb2_getinfo(struct torture_context *torture)
 
 	return ret;
 }
+
+struct torture_suite *torture_smb2_getinfo_init(void)
+{
+	struct torture_suite *suite = torture_suite_create(
+		talloc_autofree_context(), "getinfo");
+
+	torture_suite_add_simple_test(suite, "complex", torture_smb2_getinfo);
+	return suite;
+}
diff --git a/source4/torture/smb2/smb2.c b/source4/torture/smb2/smb2.c
index f6a3163..19d7e4a 100644
--- a/source4/torture/smb2/smb2.c
+++ b/source4/torture/smb2/smb2.c
@@ -148,7 +148,7 @@ NTSTATUS torture_smb2_init(void)
 	struct torture_suite *suite = torture_suite_create(talloc_autofree_context(), "smb2");
 	torture_suite_add_simple_test(suite, "connect", torture_smb2_connect);
 	torture_suite_add_suite(suite, torture_smb2_scan_init());
-	torture_suite_add_simple_test(suite, "getinfo", torture_smb2_getinfo);
+	torture_suite_add_suite(suite, torture_smb2_getinfo_init());
 	torture_suite_add_simple_test(suite, "setinfo", torture_smb2_setinfo);
 	torture_suite_add_suite(suite, torture_smb2_lock_init());
 	torture_suite_add_suite(suite, torture_smb2_read_init());
-- 
1.7.9.5


From a129e6af22b9e036baa42e8ba0b034838c7fe8b2 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Thu, 22 Aug 2013 11:23:22 +0000
Subject: [PATCH 6/7] torture: Split the buffercheck into a separate test

Signed-off-by: Volker Lendecke <vl at samba.org>
---
 source4/torture/smb2/getinfo.c |   11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/source4/torture/smb2/getinfo.c b/source4/torture/smb2/getinfo.c
index f60db95..7e37c88 100644
--- a/source4/torture/smb2/getinfo.c
+++ b/source4/torture/smb2/getinfo.c
@@ -152,13 +152,19 @@ static bool torture_smb2_fsinfo(struct torture_context *tctx, struct smb2_tree *
 /*
   test for buffer size handling
 */
-static bool torture_smb2_buffercheck(struct torture_context *tctx, struct smb2_tree *tree)
+static bool torture_smb2_buffercheck(struct torture_context *tctx)
 {
+	bool ret;
+	struct smb2_tree *tree;
 	NTSTATUS status;
 	struct smb2_handle handle;
 	struct smb2_getinfo b;
 
 	printf("Testing buffer size handling\n");
+
+	ret = torture_smb2_connection(tctx, &tree);
+	torture_assert(tctx, ret, "connection failed");
+
 	status = smb2_util_roothandle(tree, &handle);
 	torture_assert_ntstatus_ok(tctx, status, "Unable to create root handle");
 
@@ -209,7 +215,6 @@ static bool torture_smb2_getinfo(struct torture_context *torture)
 
 	ret &= torture_smb2_fileinfo(torture, tree);
 	ret &= torture_smb2_fsinfo(torture, tree);
-	ret &= torture_smb2_buffercheck(torture, tree);
 
 	return ret;
 }
@@ -220,5 +225,7 @@ struct torture_suite *torture_smb2_getinfo_init(void)
 		talloc_autofree_context(), "getinfo");
 
 	torture_suite_add_simple_test(suite, "complex", torture_smb2_getinfo);
+	torture_suite_add_simple_test(suite, "buffercheck",
+				      torture_smb2_buffercheck);
 	return suite;
 }
-- 
1.7.9.5


From cb1bdcc0477d9f3903919f44c9ae8694507d3d64 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Thu, 22 Aug 2013 11:47:21 +0000
Subject: [PATCH 7/7] torture: Split the fsinfo check into a separate test

Signed-off-by: Volker Lendecke <vl at samba.org>
---
 selftest/knownfail             |    1 +
 source4/torture/smb2/getinfo.c |   10 ++++++++--
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/selftest/knownfail b/selftest/knownfail
index 1c1bff8..dd536df 100644
--- a/selftest/knownfail
+++ b/selftest/knownfail
@@ -207,6 +207,7 @@
 ^samba3.smb2.streams.rename2
 ^samba3.smb2.streams.attributes
 ^samba3.smb2.getinfo.complex
+^samba3.smb2.getinfo.fsinfo # quotas don't work yet
 ^samba3.smb2.setinfo.setinfo
 ^samba3.smb2.session.*reauth5 # some special anonymous checks?
 ^samba3.smb2.compound.interim2 # wrong return code (STATUS_CANCELLED)
diff --git a/source4/torture/smb2/getinfo.c b/source4/torture/smb2/getinfo.c
index 7e37c88..10dd550 100644
--- a/source4/torture/smb2/getinfo.c
+++ b/source4/torture/smb2/getinfo.c
@@ -127,13 +127,19 @@ static bool torture_smb2_fileinfo(struct torture_context *tctx, struct smb2_tree
 /*
   test fsinfo levels
 */
-static bool torture_smb2_fsinfo(struct torture_context *tctx, struct smb2_tree *tree)
+static bool torture_smb2_fsinfo(struct torture_context *tctx)
 {
+	bool ret;
+	struct smb2_tree *tree;
 	int i;
 	NTSTATUS status;
 	struct smb2_handle handle;
 
 	printf("Testing fsinfo levels\n");
+
+	ret = torture_smb2_connection(tctx, &tree);
+	torture_assert(tctx, ret, "connection failed");
+
 	status = smb2_util_roothandle(tree, &handle);
 	torture_assert_ntstatus_ok(tctx, status, "Unable to create root handle");
 
@@ -214,7 +220,6 @@ static bool torture_smb2_getinfo(struct torture_context *torture)
 				   "setup complex dir " DNAME ":streamtwo");
 
 	ret &= torture_smb2_fileinfo(torture, tree);
-	ret &= torture_smb2_fsinfo(torture, tree);
 
 	return ret;
 }
@@ -225,6 +230,7 @@ struct torture_suite *torture_smb2_getinfo_init(void)
 		talloc_autofree_context(), "getinfo");
 
 	torture_suite_add_simple_test(suite, "complex", torture_smb2_getinfo);
+	torture_suite_add_simple_test(suite, "fsinfo",  torture_smb2_fsinfo);
 	torture_suite_add_simple_test(suite, "buffercheck",
 				      torture_smb2_buffercheck);
 	return suite;
-- 
1.7.9.5



More information about the samba-technical mailing list