1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-12 09:18:10 +03:00

s3:net: Refactor net_ads_check_int(), allocate a talloc context

ADS_STRUCT will be allocated in the talloc context.

Signed-off-by: Samuel Cabrero <scabrero@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
This commit is contained in:
Samuel Cabrero 2022-05-26 15:13:02 +02:00 committed by Jeremy Allison
parent d005418005
commit 50934b85ff

View File

@ -768,35 +768,43 @@ ADS_STATUS ads_startup_nobind(struct net_context *c,
ads_startup() stores the password in opt_password if it needs to so
that rpc or rap can use it without re-prompting.
*/
static int net_ads_check_int(const char *realm, const char *workgroup, const char *host)
static int net_ads_check_int(struct net_context *c,
const char *realm,
const char *workgroup,
const char *host)
{
TALLOC_CTX *tmp_ctx = talloc_stackframe();
ADS_STRUCT *ads;
ADS_STATUS status;
int ret = -1;
ads = ads_init(realm, workgroup, host, ADS_SASL_PLAIN);
if (ads == NULL ) {
return -1;
if (ads == NULL) {
goto out;
}
ads->auth.flags |= ADS_AUTH_NO_BIND;
status = ads_connect(ads);
if ( !ADS_ERR_OK(status) ) {
return -1;
goto out;
}
ret = 0;
out:
ads_destroy(&ads);
return 0;
TALLOC_FREE(tmp_ctx);
return ret;
}
int net_ads_check_our_domain(struct net_context *c)
{
return net_ads_check_int(lp_realm(), lp_workgroup(), NULL);
return net_ads_check_int(c, lp_realm(), lp_workgroup(), NULL);
}
int net_ads_check(struct net_context *c)
{
return net_ads_check_int(NULL, c->opt_workgroup, c->opt_host);
return net_ads_check_int(c, NULL, c->opt_workgroup, c->opt_host);
}
/*