diff options
author | Samuel Cabrero <scabrero@samba.org> | 2022-05-24 12:01:13 +0200 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2022-06-27 15:50:29 +0000 |
commit | ee8ff51cfa8623c6c96754ee5cf941b0cb8b1608 (patch) | |
tree | f156f450af7b227210eaacf1b9647bb1c0348256 /source3/lib/netapi | |
parent | 577fdd0f97a6ae8e983d6b2eefe5cfc37d961161 (diff) | |
download | samba-ee8ff51cfa8623c6c96754ee5cf941b0cb8b1608.tar.gz |
s3:netapi: Allocate a temporary talloc context for NetGetJoinableOUs_l()
Prepare to allocate ADS_STRUCT under a talloc context.
Signed-off-by: Samuel Cabrero <scabrero@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Diffstat (limited to 'source3/lib/netapi')
-rw-r--r-- | source3/lib/netapi/joindomain.c | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/source3/lib/netapi/joindomain.c b/source3/lib/netapi/joindomain.c index 4fe5a3b8eef..7eba430d8a0 100644 --- a/source3/lib/netapi/joindomain.c +++ b/source3/lib/netapi/joindomain.c @@ -397,6 +397,8 @@ WERROR NetGetJoinableOUs_l(struct libnetapi_ctx *ctx, struct NetGetJoinableOUs *r) { #ifdef HAVE_ADS + TALLOC_CTX *tmp_ctx = talloc_stackframe(); + WERROR ret; NTSTATUS status; ADS_STATUS ads_status; ADS_STRUCT *ads = NULL; @@ -411,12 +413,13 @@ WERROR NetGetJoinableOUs_l(struct libnetapi_ctx *ctx, priv = talloc_get_type_abort(ctx->private_data, struct libnetapi_private_ctx); - status = dsgetdcname(ctx, priv->msg_ctx, r->in.domain, + status = dsgetdcname(tmp_ctx, priv->msg_ctx, r->in.domain, NULL, NULL, flags, &info); if (!NT_STATUS_IS_OK(status)) { libnetapi_set_error_string(ctx, "%s", get_friendly_nt_error_msg(status)); - return ntstatus_to_werror(status); + ret = ntstatus_to_werror(status); + goto out; } dc = strip_hostname(info->dc_unc); @@ -426,7 +429,8 @@ WERROR NetGetJoinableOUs_l(struct libnetapi_ctx *ctx, dc, ADS_SASL_PLAIN); if (!ads) { - return WERR_GEN_FAILURE; + ret = WERR_GEN_FAILURE; + goto out; } SAFE_FREE(ads->auth.user_name); @@ -456,19 +460,26 @@ WERROR NetGetJoinableOUs_l(struct libnetapi_ctx *ctx, ads_status = ads_connect_user_creds(ads); if (!ADS_ERR_OK(ads_status)) { ads_destroy(&ads); - return WERR_NERR_DEFAULTJOINREQUIRED; + ret = WERR_NERR_DEFAULTJOINREQUIRED; + goto out; } ads_status = ads_get_joinable_ous(ads, ctx, &p, &s); if (!ADS_ERR_OK(ads_status)) { ads_destroy(&ads); - return WERR_NERR_DEFAULTJOINREQUIRED; + ret = WERR_NERR_DEFAULTJOINREQUIRED; + goto out; } *r->out.ous = discard_const_p(const char *, p); *r->out.ou_count = s; ads_destroy(&ads); - return WERR_OK; + + ret = WERR_OK; +out: + TALLOC_FREE(tmp_ctx); + + return ret; #else return WERR_NOT_SUPPORTED; #endif |