[PATCH 4/4] libnet: Fix error path of libnet_join_lookup_dc_rpc().
Andreas Schneider
asn at samba.org
Wed Nov 7 06:30:42 MST 2012
Signed-off-by: Andreas Schneider <asn at samba.org>
---
source3/libnet/libnet_join.c | 26 +++++++++++++++++++++-----
1 file changed, 21 insertions(+), 5 deletions(-)
diff --git a/source3/libnet/libnet_join.c b/source3/libnet/libnet_join.c
index d6aa793..b9b73f2 100644
--- a/source3/libnet/libnet_join.c
+++ b/source3/libnet/libnet_join.c
@@ -721,7 +721,8 @@ static NTSTATUS libnet_join_lookup_dc_rpc(TALLOC_CTX *mem_ctx,
{
struct rpc_pipe_client *pipe_hnd = NULL;
struct policy_handle lsa_pol;
- NTSTATUS status, result;
+ NTSTATUS status;
+ NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
union lsa_PolicyInformation *info = NULL;
struct dcerpc_binding_handle *b;
@@ -731,9 +732,11 @@ static NTSTATUS libnet_join_lookup_dc_rpc(TALLOC_CTX *mem_ctx,
r->in.use_kerberos,
cli);
if (!NT_STATUS_IS_OK(status)) {
- goto done;
+ return status;
}
+ ZERO_STRUCT(lsa_pol);
+
status = cli_rpc_pipe_open_noauth(*cli, &ndr_table_lsarpc.syntax_id,
&pipe_hnd);
if (!NT_STATUS_IS_OK(status)) {
@@ -755,6 +758,11 @@ static NTSTATUS libnet_join_lookup_dc_rpc(TALLOC_CTX *mem_ctx,
LSA_POLICY_INFO_DNS,
&info,
&result);
+ if (!NT_STATUS_IS_OK(status)) {
+ DEBUG(1, ("Failed to call dcerpc_lsa_QueryInfoPolicy2 for %s, "
+ "error: %s\n",
+ pipe_hnd->desthost, nt_errstr(status)));
+ }
if (NT_STATUS_IS_OK(status) && NT_STATUS_IS_OK(result)) {
r->out.domain_is_ad = true;
r->out.netbios_domain_name = info->dns.name.string;
@@ -764,17 +772,23 @@ static NTSTATUS libnet_join_lookup_dc_rpc(TALLOC_CTX *mem_ctx,
NT_STATUS_HAVE_NO_MEMORY(r->out.domain_sid);
}
- if (!NT_STATUS_IS_OK(status)) {
+ if (!NT_STATUS_IS_OK(result)) {
status = dcerpc_lsa_QueryInfoPolicy(b, mem_ctx,
&lsa_pol,
LSA_POLICY_INFO_ACCOUNT_DOMAIN,
&info,
&result);
if (!NT_STATUS_IS_OK(status)) {
+ DEBUG(1, ("Failed to call dcerpc_lsa_QueryInfoPolicy "
+ "for %s, error: %s\n",
+ pipe_hnd->desthost, nt_errstr(status)));
goto done;
}
if (!NT_STATUS_IS_OK(result)) {
status = result;
+ DEBUG(1, ("Failed to call dcerpc_lsa_QueryInfoPolicy "
+ "for %s, error: %s\n",
+ pipe_hnd->desthost, nt_errstr(status)));
goto done;
}
@@ -783,10 +797,12 @@ static NTSTATUS libnet_join_lookup_dc_rpc(TALLOC_CTX *mem_ctx,
NT_STATUS_HAVE_NO_MEMORY(r->out.domain_sid);
}
- dcerpc_lsa_Close(b, mem_ctx, &lsa_pol, &result);
+done:
+ if (is_valid_policy_hnd(&lsa_pol)) {
+ dcerpc_lsa_Close(b, mem_ctx, &lsa_pol, &result);
+ }
TALLOC_FREE(pipe_hnd);
- done:
return status;
}
--
1.8.0
More information about the samba-technical
mailing list