]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3:libads: make use of kerberos_secrets_fetch_salt_princ() in ads_keytab_add_entry()
authorStefan Metzmacher <metze@samba.org>
Fri, 19 May 2017 15:08:24 +0000 (17:08 +0200)
committerStefan Metzmacher <metze@samba.org>
Thu, 13 Jul 2017 08:51:18 +0000 (10:51 +0200)
BUG: https://bugzilla.samba.org/show_bug.cgi?id=12782

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
(cherry picked from commit b0928a2687a9ffe92ebdce7b5252781d62e7e02d)

source3/libads/kerberos_keytab.c

index 160b58396a4caf7aa4286550a0c396ffb480c492..d4aa9101937293e19c6096b35ab210b9416d154c 100644 (file)
@@ -188,10 +188,14 @@ int ads_keytab_add_entry(ADS_STRUCT *ads, const char *srvPrinc)
                goto out;
        }
 
+       salt_princ_s = kerberos_secrets_fetch_salt_princ();
+       if (salt_princ_s == NULL) {
+               DBG_WARNING("kerberos_secrets_fetch_salt_princ() failed\n");
+               ret = -1;
+               goto out;
+       }
+
        for (i = 0; enctypes[i]; i++) {
-               salt_princ_s = kerberos_fetch_salt_princ_for_host_princ(context,
-                                                                       princ_s,
-                                                                       enctypes[i]);
 
                /* add the fqdn principal to the keytab */
                ret = smb_krb5_kt_add_entry(context,
@@ -205,7 +209,6 @@ int ads_keytab_add_entry(ADS_STRUCT *ads, const char *srvPrinc)
                                            false);
                if (ret) {
                        DEBUG(1, (__location__ ": Failed to add entry to keytab\n"));
-                       SAFE_FREE(salt_princ_s);
                        goto out;
                }
 
@@ -223,14 +226,13 @@ int ads_keytab_add_entry(ADS_STRUCT *ads, const char *srvPrinc)
                        if (ret) {
                                DEBUG(1, (__location__
                                          ": Failed to add short entry to keytab\n"));
-                               SAFE_FREE(salt_princ_s);
                                goto out;
                        }
                }
-               SAFE_FREE(salt_princ_s);
        }
 
 out:
+       SAFE_FREE(salt_princ_s);
        TALLOC_FREE(tmpctx);
 
        if (keytab) {