From: Pavel Filipenský Date: Thu, 6 Mar 2025 14:24:05 +0000 (+0100) Subject: s3:utils: Remove call of ads_startup() from net_ads_keytab_create() X-Git-Tag: samba-4.22.1~44 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f8f85cf8533824e0c3fae7e4cac363c692f249c5;p=thirdparty%2Fsamba.git s3:utils: Remove call of ads_startup() from net_ads_keytab_create() Calling ads_startup() is not needed in net_ads_keytab_create. Keytab creation code in sync_pw2keytabs() decides if it needs to talk to DC or not and connects to AD accordingly. Fixing this, makes the bug below easier to reproduce using 'net ads keytab create'. BUG: https://bugzilla.samba.org/show_bug.cgi?id=15727 Signed-off-by: Pavel Filipenský Reviewed-by: Andreas Schneider Autobuild-User(master): Pavel Filipensky Autobuild-Date(master): Mon Mar 10 11:09:29 UTC 2025 on atb-devel-224 (cherry picked from commit 5cadaf91bc96cd2a8e0f6bcbd8a212e86b714180) --- diff --git a/source3/utils/net_ads.c b/source3/utils/net_ads.c index 0f1193d7ec0..0128f3eb7e8 100644 --- a/source3/utils/net_ads.c +++ b/source3/utils/net_ads.c @@ -2947,9 +2947,6 @@ out: static int net_ads_keytab_create(struct net_context *c, int argc, const char **argv) { - TALLOC_CTX *tmp_ctx = talloc_stackframe(); - ADS_STRUCT *ads = NULL; - ADS_STATUS status; NTSTATUS ntstatus; int ret = -1; @@ -2959,7 +2956,6 @@ static int net_ads_keytab_create(struct net_context *c, int argc, const char **a " %s\n", _("Usage:"), _("Create (sync) new default keytab")); - TALLOC_FREE(tmp_ctx); return -1; } @@ -2969,15 +2965,8 @@ static int net_ads_keytab_create(struct net_context *c, int argc, const char **a net_use_krb_machine_account(c); } - status = ads_startup(c, true, tmp_ctx, &ads); - if (!ADS_ERR_OK(status)) { - goto out; - } - ntstatus = sync_pw2keytabs(); ret = NT_STATUS_IS_OK(ntstatus) ? 0 : 1; -out: - TALLOC_FREE(tmp_ctx); return ret; }