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ý <pfilipensky@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
Autobuild-User(master): Pavel Filipensky <pfilipensky@samba.org>
Autobuild-Date(master): Mon Mar 10 11:09:29 UTC 2025 on atb-devel-224
(cherry picked from commit
5cadaf91bc96cd2a8e0f6bcbd8a212e86b714180)
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;
" %s\n",
_("Usage:"),
_("Create (sync) new default keytab"));
- TALLOC_FREE(tmp_ctx);
return -1;
}
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;
}