From: Samuel Cabrero Date: Thu, 26 May 2022 11:31:57 +0000 (+0200) Subject: s3:net: Refactor net_ads_keytab_create(), allocate a talloc context X-Git-Tag: tevent-0.13.0~256 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=04fa6e9882cf61e6d87ea30724b19cfa3a5e7f69;p=thirdparty%2Fsamba.git s3:net: Refactor net_ads_keytab_create(), allocate a talloc context ADS_STRUCT will be allocated in the talloc context. Signed-off-by: Samuel Cabrero Reviewed-by: Jeremy Allison --- diff --git a/source3/utils/net_ads.c b/source3/utils/net_ads.c index db011eb7f2f..5949ee96168 100644 --- a/source3/utils/net_ads.c +++ b/source3/utils/net_ads.c @@ -2981,8 +2981,10 @@ static int net_ads_keytab_add_update_ads(struct net_context *c, static int net_ads_keytab_create(struct net_context *c, int argc, const char **argv) { - ADS_STRUCT *ads; - int ret; + TALLOC_CTX *tmp_ctx = talloc_stackframe(); + ADS_STRUCT *ads = NULL; + ADS_STATUS status; + int ret = -1; if (c->display_usage) { d_printf( "%s\n" @@ -2990,6 +2992,7 @@ static int net_ads_keytab_create(struct net_context *c, int argc, const char **a " %s\n", _("Usage:"), _("Create new default keytab")); + TALLOC_FREE(tmp_ctx); return 0; } @@ -2997,11 +3000,15 @@ static int net_ads_keytab_create(struct net_context *c, int argc, const char **a net_use_krb_machine_account(c); } - if (!ADS_ERR_OK(ads_startup(c, true, &ads))) { - return -1; + status = ads_startup(c, true, &ads); + if (!ADS_ERR_OK(status)) { + goto out; } + ret = ads_keytab_create_default(ads); +out: ads_destroy(&ads); + TALLOC_FREE(tmp_ctx); return ret; }