diff options
author | Günther Deschner <gd@samba.org> | 2014-09-26 03:35:43 +0200 |
---|---|---|
committer | Günther Deschner <gd@samba.org> | 2014-09-26 08:22:45 +0200 |
commit | 0aacbe78bb40d76b65087c2a197c92b0101e625e (patch) | |
tree | 55e9fdcdfb31a2ccb10e2aaba6f653494b5240d1 /source3 | |
parent | 7e0b8fcce5572c88d50993a1dbd90f65638ba90f (diff) | |
download | samba-0aacbe78bb40d76b65087c2a197c92b0101e625e.tar.gz samba-0aacbe78bb40d76b65087c2a197c92b0101e625e.tar.xz samba-0aacbe78bb40d76b65087c2a197c92b0101e625e.zip |
s3-libnet: Make sure we do not overwrite precreated SPNs.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=9984
Signed-off-by: Günther Deschner <gd@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
Autobuild-User(master): Günther Deschner <gd@samba.org>
Autobuild-Date(master): Fri Sep 26 08:22:45 CEST 2014 on sn-devel-104
Diffstat (limited to 'source3')
-rw-r--r-- | source3/libnet/libnet_join.c | 39 |
1 files changed, 36 insertions, 3 deletions
diff --git a/source3/libnet/libnet_join.c b/source3/libnet/libnet_join.c index 1612d64d54..381a59ce6c 100644 --- a/source3/libnet/libnet_join.c +++ b/source3/libnet/libnet_join.c @@ -390,8 +390,10 @@ static ADS_STATUS libnet_join_set_machine_spn(TALLOC_CTX *mem_ctx, ADS_STATUS status; ADS_MODLIST mods; fstring my_fqdn; - const char *spn_array[3] = {NULL, NULL, NULL}; + const char **spn_array = NULL; + size_t num_spns = 0; char *spn = NULL; + bool ok; /* Find our DN */ @@ -400,6 +402,14 @@ static ADS_STATUS libnet_join_set_machine_spn(TALLOC_CTX *mem_ctx, return status; } + status = libnet_join_get_machine_spns(mem_ctx, + r, + discard_const_p(char **, &spn_array), + &num_spns); + if (!ADS_ERR_OK(status)) { + DEBUG(5, ("Retrieving the servicePrincipalNames failed.\n")); + } + /* Windows only creates HOST/shortname & HOST/fqdn. */ spn = talloc_asprintf(mem_ctx, "HOST/%s", r->in.machine_name); @@ -409,7 +419,15 @@ static ADS_STATUS libnet_join_set_machine_spn(TALLOC_CTX *mem_ctx, if (!strupper_m(spn)) { return ADS_ERROR_LDAP(LDAP_NO_MEMORY); } - spn_array[0] = spn; + + ok = ads_element_in_array(spn_array, num_spns, spn); + if (!ok) { + ok = add_string_to_array(spn_array, spn, + &spn_array, (int *)&num_spns); + if (!ok) { + return ADS_ERROR_LDAP(LDAP_NO_MEMORY); + } + } if (!name_to_fqdn(my_fqdn, r->in.machine_name) || (strchr(my_fqdn, '.') == NULL)) { @@ -426,8 +444,23 @@ static ADS_STATUS libnet_join_set_machine_spn(TALLOC_CTX *mem_ctx, if (!spn) { return ADS_ERROR_LDAP(LDAP_NO_MEMORY); } - spn_array[1] = spn; + + ok = ads_element_in_array(spn_array, num_spns, spn); + if (!ok) { + ok = add_string_to_array(spn_array, spn, + &spn_array, (int *)&num_spns); + if (!ok) { + return ADS_ERROR_LDAP(LDAP_NO_MEMORY); + } + } + } + + /* make sure to NULL terminate the array */ + spn_array = talloc_realloc(mem_ctx, spn_array, const char *, num_spns + 1); + if (spn_array == NULL) { + return ADS_ERROR_LDAP(LDAP_NO_MEMORY); } + spn_array[num_spns] = NULL; mods = ads_init_mods(mem_ctx); if (!mods) { |