]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3:utils: Remove call of ads_startup() from net_ads_keytab_create()
authorPavel Filipenský <pfilipensky@samba.org>
Thu, 6 Mar 2025 14:24:05 +0000 (15:24 +0100)
committerJule Anger <janger@samba.org>
Thu, 13 Mar 2025 16:03:20 +0000 (16:03 +0000)
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)

source3/utils/net_ads.c

index 0f1193d7ec0d70878aae6bb000b7b866f3a070eb..0128f3eb7e8df9a6c4b2b63a38d76e9a187f63da 100644 (file)
@@ -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;
 }