The branch, master has been updated via 106ea7a Minor cleanup to libnet_join_member via 4a3954a tests/blackbox/smbcontrol: ping tests names ping target upon failure via be96147 text/python/blackbox: allow optional message in ProcessError from 1ed6934 ldb tests: fix null test on incorrect variable
https://git.samba.org/?p=samba.git;a=shortlog;h=master - Log ----------------------------------------------------------------- commit 106ea7a1bcde3f5aa4fbb4ff8beb0cb44cf0e0ed Author: Swen Schillig <s...@vnet.ibm.com> Date: Thu Jan 25 11:18:50 2018 +0100 Minor cleanup to libnet_join_member Prevent code duplication by consolidating cleanup task at the end of the function. Signed-off-by: Swen Schillig <s...@vnet.ibm.com> Reviewed-by: Christof Schmitt <c...@samba.org> Reviewed-by: Andreas Schneider <a...@samba.org> Autobuild-User(master): Jeremy Allison <j...@samba.org> Autobuild-Date(master): Sat Feb 24 23:19:05 CET 2018 on sn-devel-144 commit 4a3954adedf89a186268fea272675687524325ff Author: Douglas Bagnall <douglas.bagn...@catalyst.net.nz> Date: Thu Feb 22 14:20:51 2018 +1300 tests/blackbox/smbcontrol: ping tests names ping target upon failure Signed-off-by: Douglas Bagnall <douglas.bagn...@catalyst.net.nz> Reviewed-by: Jeremy Allison <j...@samba.org> commit be96147e6966ac7b68418e1889e55b38874c1561 Author: Douglas Bagnall <douglas.bagn...@catalyst.net.nz> Date: Thu Feb 22 14:19:11 2018 +1300 text/python/blackbox: allow optional message in ProcessError Signed-off-by: Douglas Bagnall <douglas.bagn...@catalyst.net.nz> Reviewed-by: Jeremy Allison <j...@samba.org> ----------------------------------------------------------------------- Summary of changes: python/samba/tests/__init__.py | 20 +++++++++----- python/samba/tests/blackbox/smbcontrol.py | 3 +- source4/libnet/libnet_join.c | 46 +++++++++++++------------------ 3 files changed, 34 insertions(+), 35 deletions(-) Changeset truncated at 500 lines: diff --git a/python/samba/tests/__init__.py b/python/samba/tests/__init__.py index b6293df..935a087 100644 --- a/python/samba/tests/__init__.py +++ b/python/samba/tests/__init__.py @@ -328,15 +328,20 @@ class BlackboxProcessError(Exception): (S.stderr) """ - def __init__(self, returncode, cmd, stdout, stderr): + def __init__(self, returncode, cmd, stdout, stderr, msg=None): self.returncode = returncode self.cmd = cmd self.stdout = stdout self.stderr = stderr + self.msg = msg def __str__(self): - return "Command '%s'; exit status %d; stdout: '%s'; stderr: '%s'" % (self.cmd, self.returncode, - self.stdout, self.stderr) + s = ("Command '%s'; exit status %d; stdout: '%s'; stderr: '%s'" % + (self.cmd, self.returncode, self.stdout, self.stderr)) + if self.msg is not None: + s = "%s; message: %s" % (s, self.msg) + + return s class BlackboxTestCase(TestCaseInTempDir): """Base test case for blackbox tests.""" @@ -349,10 +354,10 @@ class BlackboxTestCase(TestCaseInTempDir): line = " ".join(parts) return line - def check_run(self, line): - self.check_exit_code(line, 0) + def check_run(self, line, msg=None): + self.check_exit_code(line, 0, msg=msg) - def check_exit_code(self, line, expected): + def check_exit_code(self, line, expected, msg=None): line = self._make_cmdline(line) p = subprocess.Popen(line, stdout=subprocess.PIPE, @@ -364,7 +369,8 @@ class BlackboxTestCase(TestCaseInTempDir): raise BlackboxProcessError(retcode, line, stdoutdata, - stderrdata) + stderrdata, + msg) def check_output(self, line): line = self._make_cmdline(line) diff --git a/python/samba/tests/blackbox/smbcontrol.py b/python/samba/tests/blackbox/smbcontrol.py index e151761..eca6cc5 100644 --- a/python/samba/tests/blackbox/smbcontrol.py +++ b/python/samba/tests/blackbox/smbcontrol.py @@ -47,4 +47,5 @@ class SmbcontrolBlockboxTests(BlackboxTestCase): for p in processes: for id in p.ids: if p.name != "samba": - self.check_run("%s %d %s" % (COMMAND, id.pid, PING)) + self.check_run("%s %d %s" % (COMMAND, id.pid, PING), + msg="trying to ping %s" % p.name) diff --git a/source4/libnet/libnet_join.c b/source4/libnet/libnet_join.c index 6cd18e0..245485f 100644 --- a/source4/libnet/libnet_join.c +++ b/source4/libnet/libnet_join.c @@ -940,11 +940,10 @@ NTSTATUS libnet_Join_member(struct libnet_context *ctx, r2 = talloc_zero(tmp_mem, struct libnet_JoinDomain); if (!r2) { - r->out.error_string = NULL; - talloc_free(tmp_mem); - return NT_STATUS_NO_MEMORY; + status = NT_STATUS_NO_MEMORY; + goto out; } - + acct_type = ACB_WSTRUST; if (r->in.netbios_name != NULL) { @@ -952,19 +951,17 @@ NTSTATUS libnet_Join_member(struct libnet_context *ctx, } else { netbios_name = talloc_strdup(tmp_mem, lpcfg_netbios_name(ctx->lp_ctx)); if (!netbios_name) { - r->out.error_string = NULL; - talloc_free(tmp_mem); - return NT_STATUS_NO_MEMORY; + status = NT_STATUS_NO_MEMORY; + goto out; } } account_name = talloc_asprintf(tmp_mem, "%s$", netbios_name); if (!account_name) { - r->out.error_string = NULL; - talloc_free(tmp_mem); - return NT_STATUS_NO_MEMORY; + status = NT_STATUS_NO_MEMORY; + goto out; } - + /* * join the domain */ @@ -978,16 +975,14 @@ NTSTATUS libnet_Join_member(struct libnet_context *ctx, status = libnet_JoinDomain(ctx, r2, r2); if (!NT_STATUS_IS_OK(status)) { r->out.error_string = talloc_steal(mem_ctx, r2->out.error_string); - talloc_free(tmp_mem); - return status; + goto out; } set_secrets = talloc_zero(tmp_mem, struct provision_store_self_join_settings); if (!set_secrets) { - r->out.error_string = NULL; - talloc_free(tmp_mem); - return NT_STATUS_NO_MEMORY; + status = NT_STATUS_NO_MEMORY; + goto out; } set_secrets->domain_name = r2->out.domain_name; @@ -997,7 +992,7 @@ NTSTATUS libnet_Join_member(struct libnet_context *ctx, set_secrets->machine_password = r2->out.join_password; set_secrets->key_version_number = r2->out.kvno; set_secrets->domain_sid = r2->out.domain_sid; - + status = provision_store_self_join(ctx, ctx->lp_ctx, ctx->event_ctx, set_secrets, &error_string); if (!NT_STATUS_IS_OK(status)) { if (error_string) { @@ -1008,19 +1003,16 @@ NTSTATUS libnet_Join_member(struct libnet_context *ctx, "provision_store_self_join failed with %s", nt_errstr(status)); } - talloc_free(tmp_mem); - return status; + goto out; } /* move all out parameter to the callers TALLOC_CTX */ - r->out.error_string = NULL; - r->out.join_password = r2->out.join_password; - talloc_reparent(r2, mem_ctx, r2->out.join_password); - r->out.domain_sid = r2->out.domain_sid; - talloc_reparent(r2, mem_ctx, r2->out.domain_sid); - r->out.domain_name = r2->out.domain_name; - talloc_reparent(r2, mem_ctx, r2->out.domain_name); + r->out.join_password = talloc_move(mem_ctx, &r2->out.join_password); + r->out.domain_sid = talloc_move(mem_ctx, &r2->out.domain_sid); + r->out.domain_name = talloc_move(mem_ctx, &r2->out.domain_name); + status = NT_STATUS_OK; +out: talloc_free(tmp_mem); - return NT_STATUS_OK; + return status; } -- Samba Shared Repository