[PATCH] s4/torture: make --unclist active with smb2 testcases

Volker Lendecke Volker.Lendecke at SerNet.DE
Thu Aug 24 10:17:13 UTC 2017


Hi, Peter!

Thanks for looking at that. This is really needed.

On Mon, Aug 21, 2017 at 12:46:54PM +0000, Peter Somogyi via samba-technical wrote:
> I'd like to make the --unclist option effective for smb2 testcases like 
> smb2.oplock (e.g. torture_suite_add_2smb2_test).
> Attaching the simplest and tested patch to achieve this.
> Please review.

A few cosmetic comments:

diff --git a/source4/torture/smb2/util.c b/source4/torture/smb2/util.c
index 52a63dd962a..bfa642cda06 100644
--- a/source4/torture/smb2/util.c
+++ b/source4/torture/smb2/util.c
@@ -385,6 +385,14 @@ bool torture_smb2_connection_ext(struct torture_context *tctx,
 	NTSTATUS status;
 	const char *host = torture_setting_string(tctx, "host", NULL);
 	const char *share = torture_setting_string(tctx, "share", NULL);
+	const char *p = torture_setting_string(tctx, "unclist", NULL);
+	bool ret = true;
+
+	if (p != NULL) {
+		if (!torture_get_conn_index(tctx->conn_index++, tctx, tctx,
+					    &host, &share))
+			return false;
+	}

We prefer a pattern of

	bool ok;
	ok = torture_get_conn_index( ... )
	if (!ok)

just because that's much easier to handle in a debugger.

Then, please put { } around all if-bodies to avoid something like
CVE-2014-1266.

 
 	status = smb2_connect_ext(tctx,
 				  host,
@@ -402,9 +410,15 @@ bool torture_smb2_connection_ext(struct torture_context *tctx,
 	if (!NT_STATUS_IS_OK(status)) {
 		torture_comment(tctx, "Failed to connect to SMB2 share \\\\%s\\%s - %s\n",
 		       host, share, nt_errstr(status));
-		return false;
+		ret = false;
 	}
-	return true;
+
+	if (p != NULL) {
+		talloc_free((void *)host);
+		talloc_free((void *)share);
+	}

For this you could create a separate talloc parent as an agument to
get_conn_index:

	TALLOC_CTX *mem_ctx = talloc_new(tctx);

	... allocate off mem_ctx

	TALLOC_FREE(mem_ctx);

Alternatively, you can use discard_const_p to avoid the explicit void
* casting to talloc_free.

With best regards,

Volker Lendecke

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



More information about the samba-technical mailing list