| |
@@ -3,6 +3,8 @@
|
| |
*/
|
| |
|
| |
#include "config.h"
|
| |
+ #define HAVE_TLS 1
|
| |
+ #define HAVE_THREAD_LOCAL 1
|
| |
|
| |
#include <dns/dyndb.h>
|
| |
#include <dns/diff.h>
|
| |
@@ -445,7 +447,10 @@
|
| |
auth_method_str);
|
| |
CLEANUP_WITH(ISC_R_FAILURE);
|
| |
}
|
| |
- CHECK(isc_string_printf(print_buff, PRINT_BUFF_SIZE, "%u", auth_method_enum));
|
| |
+ /* isc_string_printf has been removed */
|
| |
+ result = snprintf(print_buff, PRINT_BUFF_SIZE, "%u", auth_method_enum);
|
| |
+ RUNTIME_CHECK(result < PRINT_BUFF_SIZE);
|
| |
+
|
| |
CHECK(setting_set("auth_method_enum", inst->local_settings, print_buff));
|
| |
|
| |
/* check we have the right data when SASL/GSSAPI is selected */
|
| |
@@ -555,16 +560,16 @@
|
| |
ldap_inst->watcher = 0;
|
| |
CHECK(sync_ctx_init(ldap_inst->mctx, ldap_inst, &ldap_inst->sctx));
|
| |
|
| |
- isc_string_printf_truncate(settings_name, PRINT_BUFF_SIZE,
|
| |
- SETTING_SET_NAME_LOCAL " for database %s",
|
| |
- ldap_inst->db_name);
|
| |
+ snprintf(settings_name, PRINT_BUFF_SIZE,
|
| |
+ SETTING_SET_NAME_LOCAL " for database %s",
|
| |
+ ldap_inst->db_name);
|
| |
CHECK(settings_set_create(mctx, settings_local_default,
|
| |
sizeof(settings_local_default), settings_name,
|
| |
&settings_default_set, &ldap_inst->local_settings));
|
| |
|
| |
- isc_string_printf_truncate(settings_name, PRINT_BUFF_SIZE,
|
| |
- SETTING_SET_NAME_GLOBAL " for database %s",
|
| |
- ldap_inst->db_name);
|
| |
+ snprintf(settings_name, PRINT_BUFF_SIZE,
|
| |
+ SETTING_SET_NAME_GLOBAL " for database %s",
|
| |
+ ldap_inst->db_name);
|
| |
CHECK(settings_set_create(mctx, settings_global_default,
|
| |
sizeof(settings_global_default), settings_name,
|
| |
ldap_inst->local_settings, &ldap_inst->global_settings));
|
| |
@@ -576,7 +581,7 @@
|
| |
/* copy global forwarders setting for configuration roll back in
|
| |
* configure_zone_forwarders() */
|
| |
result = dns_fwdtable_find(ldap_inst->view->fwdtable, dns_rootname,
|
| |
- &named_conf_forwarders);
|
| |
+ NULL, &named_conf_forwarders);
|
| |
if (result == ISC_R_SUCCESS) {
|
| |
/* Copy forwarding config from named.conf into local_settings */
|
| |
CHECK(fwd_print_list_buff(mctx, named_conf_forwarders,
|
| |
@@ -629,13 +634,13 @@
|
| |
CHECK(setting_get_str("server_id", ldap_inst->local_settings,
|
| |
&server_id));
|
| |
if (strlen(server_id) == 0)
|
| |
- isc_string_printf_truncate(settings_name, PRINT_BUFF_SIZE,
|
| |
- SETTING_SET_NAME_SERVER
|
| |
- " for undefined server_id");
|
| |
+ snprintf(settings_name, PRINT_BUFF_SIZE,
|
| |
+ SETTING_SET_NAME_SERVER " for undefined server_id");
|
| |
+
|
| |
else
|
| |
- isc_string_printf_truncate(settings_name, PRINT_BUFF_SIZE,
|
| |
- SETTING_SET_NAME_SERVER
|
| |
- " for server id %s", server_id);
|
| |
+ snprintf(settings_name, PRINT_BUFF_SIZE,
|
| |
+ SETTING_SET_NAME_SERVER
|
| |
+ " for server id %s", server_id);
|
| |
|
| |
CHECK(settings_set_create(mctx, settings_server_ldap_default,
|
| |
sizeof(settings_server_ldap_default), settings_name,
|
| |
@@ -656,7 +661,8 @@
|
| |
CHECK(fwdr_create(ldap_inst->mctx, &ldap_inst->fwd_register));
|
| |
CHECK(mldap_new(mctx, &ldap_inst->mldapdb));
|
| |
|
| |
- CHECK(isc_mutex_init(&ldap_inst->kinit_lock));
|
| |
+ /* isc_mutex_init and isc_condition_init failures are now fatal */
|
| |
+ isc_mutex_init(&ldap_inst->kinit_lock);
|
| |
|
| |
CHECK(ldap_pool_create(mctx, connections, &ldap_inst->pool));
|
| |
CHECK(ldap_pool_connect(ldap_inst->pool, ldap_inst));
|
| |
@@ -666,13 +672,16 @@
|
| |
mctx, &ldap_inst->db_imp));
|
| |
|
| |
/* Start the watcher thread */
|
| |
- result = isc_thread_create(ldap_syncrepl_watcher, ldap_inst,
|
| |
- &ldap_inst->watcher);
|
| |
- if (result != ISC_R_SUCCESS) {
|
| |
- ldap_inst->watcher = 0;
|
| |
- log_error("Failed to create syncrepl watcher thread");
|
| |
- goto cleanup;
|
| |
- }
|
| |
+ /* isc_thread_create assert internally on failure */
|
| |
+ isc_thread_create(ldap_syncrepl_watcher, ldap_inst,
|
| |
+ &ldap_inst->watcher);
|
| |
+ /*
|
| |
+ * if (result != ISC_R_SUCCESS) {
|
| |
+ * ldap_inst->watcher = 0;
|
| |
+ * log_error("Failed to create syncrepl watcher thread");
|
| |
+ * goto cleanup;
|
| |
+ * }
|
| |
+ */
|
| |
|
| |
cleanup:
|
| |
if (forwarders_list != NULL)
|
| |
@@ -714,8 +723,8 @@
|
| |
"(already terminated?)");
|
| |
}
|
| |
|
| |
- RUNTIME_CHECK(isc_thread_join(ldap_inst->watcher, NULL)
|
| |
- == ISC_R_SUCCESS);
|
| |
+ /* isc_thread_join assert internally on failure */
|
| |
+ isc_thread_join(ldap_inst->watcher, NULL);
|
| |
}
|
| |
|
| |
void
|
| |
@@ -749,7 +758,8 @@
|
| |
if (ldap_inst->task != NULL)
|
| |
isc_task_detach(&ldap_inst->task);
|
| |
|
| |
- DESTROYLOCK(&ldap_inst->kinit_lock);
|
| |
+ /* isc_mutex_init and isc_condition_init failures are now fatal */
|
| |
+ isc_mutex_destroy(&ldap_inst->kinit_lock);
|
| |
|
| |
settings_set_free(&ldap_inst->global_settings);
|
| |
settings_set_free(&ldap_inst->local_settings);
|
| |
@@ -782,11 +792,14 @@
|
| |
CHECKED_MEM_GET_PTR(pool->mctx, ldap_conn);
|
| |
ZERO_PTR(ldap_conn);
|
| |
|
| |
- result = isc_mutex_init(&ldap_conn->lock);
|
| |
- if (result != ISC_R_SUCCESS) {
|
| |
- SAFE_MEM_PUT_PTR(pool->mctx, ldap_conn);
|
| |
- return result;
|
| |
- }
|
| |
+ /* isc_mutex_init and isc_condition_init failures are now fatal */
|
| |
+ isc_mutex_init(&ldap_conn->lock);
|
| |
+ /*
|
| |
+ * if (result != ISC_R_SUCCESS) {
|
| |
+ * SAFE_MEM_PUT_PTR(pool->mctx, ldap_conn);
|
| |
+ * return result;
|
| |
+ * }
|
| |
+ */
|
| |
|
| |
isc_mem_attach(pool->mctx, &ldap_conn->mctx);
|
| |
|
| |
@@ -811,7 +824,8 @@
|
| |
if (ldap_conn == NULL)
|
| |
return;
|
| |
|
| |
- DESTROYLOCK(&ldap_conn->lock);
|
| |
+ /* isc_mutex_init and isc_condition_init failures are now fatal */
|
| |
+ isc_mutex_destroy(&ldap_conn->lock);
|
| |
if (ldap_conn->handle != NULL)
|
| |
ldap_unbind_ext_s(ldap_conn->handle, NULL, NULL);
|
| |
|
| |
@@ -847,8 +861,9 @@
|
| |
namelen = strlen(filename);
|
| |
if (namelen > 4 && strcmp(filename + namelen - 4, ".jnl") == 0)
|
| |
namelen -= 4;
|
| |
- CHECK(isc_string_printf(bck_filename, sizeof(bck_filename),
|
| |
- "%.*s.jbk", namelen, filename));
|
| |
+ result = snprintf(bck_filename, sizeof(bck_filename),
|
| |
+ "%.*s.jbk", namelen, filename);
|
| |
+ RUNTIME_CHECK(result < sizeof(bck_filename));
|
| |
CHECK(fs_file_remove(bck_filename));
|
| |
|
| |
cleanup:
|
| |
@@ -941,7 +956,8 @@
|
| |
CHECK(zr_get_zone_path(mctx, ldap_instance_getsettings_local(inst),
|
| |
dns_zone_getorigin(zone),
|
| |
(issecure ? "signed" : "raw"), &file_name));
|
| |
- CHECK(dns_zone_setfile(zone, str_buf(file_name)));
|
| |
+ CHECK(dns_zone_setfile(zone, str_buf(file_name), dns_masterformat_text,
|
| |
+ &dns_master_style_default));
|
| |
if (issecure == true) {
|
| |
CHECK(zr_get_zone_path(mctx,
|
| |
ldap_instance_getsettings_local(inst),
|
| |
@@ -990,8 +1006,9 @@
|
| |
dns_zone_setclass(raw, dns_rdataclass_in);
|
| |
dns_zone_settype(raw, dns_zone_master);
|
| |
/* dns_zone_setview(raw, view); */
|
| |
- CHECK(dns_zone_setdbtype(raw, sizeof(ldap_argv)/sizeof(ldap_argv[0]),
|
| |
- ldap_argv));
|
| |
+ /* dns_zone_setdbtype is now void as it could no longer return */
|
| |
+ dns_zone_setdbtype(raw, sizeof(ldap_argv)/sizeof(ldap_argv[0]),
|
| |
+ ldap_argv);
|
| |
CHECK(configure_paths(inst->mctx, inst, raw, false));
|
| |
|
| |
if (want_secure == false) {
|
| |
@@ -1003,7 +1020,9 @@
|
| |
dns_zone_setclass(secure, dns_rdataclass_in);
|
| |
dns_zone_settype(secure, dns_zone_master);
|
| |
/* dns_zone_setview(secure, view); */
|
| |
- CHECK(dns_zone_setdbtype(secure, 1, rbt_argv));
|
| |
+ /* dns_zone_setdbtype is now void as it could no longer
|
| |
+ * return */
|
| |
+ dns_zone_setdbtype(secure, 1, rbt_argv);
|
| |
CHECK(dns_zonemgr_managezone(inst->zmgr, secure));
|
| |
CHECK(dns_zone_link(secure, raw));
|
| |
dns_zone_rekey(secure, true);
|
| |
@@ -1055,7 +1074,7 @@
|
| |
uint32_t serial;
|
| |
dns_zone_t *raw = NULL;
|
| |
|
| |
- result = dns_zone_load(zone);
|
| |
+ result = dns_zone_load(zone, false);
|
| |
if (result != ISC_R_SUCCESS && result != DNS_R_UPTODATE
|
| |
&& result != DNS_R_DYNAMIC && result != DNS_R_CONTINUE)
|
| |
goto cleanup;
|
| |
@@ -1067,11 +1086,11 @@
|
| |
zone = NULL;
|
| |
}
|
| |
|
| |
- CHECK(dns_zone_getserial2(raw, &serial));
|
| |
+ CHECK(dns_zone_getserial(raw, &serial));
|
| |
if (log == true)
|
| |
dns_zone_log(raw, ISC_LOG_INFO, "loaded serial %u", serial);
|
| |
if (zone != NULL) {
|
| |
- result = dns_zone_getserial2(zone, &serial);
|
| |
+ result = dns_zone_getserial(zone, &serial);
|
| |
if (result == ISC_R_SUCCESS && log == true)
|
| |
dns_zone_log(zone, ISC_LOG_INFO, "loaded serial %u",
|
| |
serial);
|
| |
@@ -1717,7 +1736,8 @@
|
| |
change.mod_op = LDAP_MOD_REPLACE;
|
| |
change.mod_type = "idnsSOAserial";
|
| |
change.mod_values = values;
|
| |
- CHECK(isc_string_printf(serial_char, MAX_SERIAL_LENGTH, "%u", serial));
|
| |
+ result = snprintf(serial_char, MAX_SERIAL_LENGTH, "%u", serial);
|
| |
+ RUNTIME_CHECK(result < MAX_SERIAL_LENGTH);
|
| |
|
| |
CHECK(ldap_modify_do(inst, str_buf(dn), changep, false));
|
| |
|
| |
@@ -3287,7 +3307,10 @@
|
| |
|
| |
CHECK(ldap_mod_create(mctx, &change));
|
| |
change->mod_op = LDAP_MOD_REPLACE;
|
| |
- CHECK(isc_string_copy(change->mod_type, LDAP_ATTR_FORMATSIZE, "dnsTTL"));
|
| |
+ /* isc_string_copy has been removed */
|
| |
+ if (strlcpy(change->mod_type, "dnsTTL", LDAP_ATTR_FORMATSIZE)
|
| |
+ >= LDAP_ATTR_FORMATSIZE)
|
| |
+ return ISC_R_NOSPACE;
|
| |
|
| |
CHECKED_MEM_ALLOCATE(mctx, vals, 2 * sizeof(char *));
|
| |
memset(vals, 0, 2 * sizeof(char *));
|
| |
@@ -3314,7 +3337,7 @@
|
| |
modify_soa_record(ldap_instance_t *ldap_inst, const char *zone_dn,
|
| |
dns_rdata_t *rdata)
|
| |
{
|
| |
- isc_result_t result;
|
| |
+ isc_result_t result = ISC_R_SUCCESS;
|
| |
dns_rdata_soa_t soa;
|
| |
LDAPMod change[5];
|
| |
LDAPMod *changep[6] = {
|
| |
@@ -3332,8 +3355,9 @@
|
| |
change[index].mod_values = alloca(2 * sizeof(char *)); \
|
| |
change[index].mod_values[0] = alloca(MAX_SOANUM_LENGTH); \
|
| |
change[index].mod_values[1] = NULL; \
|
| |
- CHECK(isc_string_printf(change[index].mod_values[0], \
|
| |
- MAX_SOANUM_LENGTH, "%u", soa.name));
|
| |
+ result = snprintf(change[index].mod_values[0], \
|
| |
+ MAX_SOANUM_LENGTH, "%u", soa.name); \
|
| |
+ RUNTIME_CHECK(result < MAX_SOANUM_LENGTH);
|
| |
|
| |
dns_rdata_tostruct(rdata, (void *)&soa, ldap_inst->mctx);
|
| |
|
| |
@@ -3347,7 +3371,6 @@
|
| |
|
| |
result = ldap_modify_do(ldap_inst, zone_dn, changep, false);
|
| |
|
| |
- cleanup:
|
| |
return result;
|
| |
|
| |
#undef MAX_SOANUM_LENGTH
|
| |
@@ -3500,8 +3523,9 @@
|
| |
change[0]->mod_vals.modv_strvals = NULL;
|
| |
CHECK(rdatatype_to_ldap_attribute(type, attr, sizeof(attr),
|
| |
unknown_type));
|
| |
- CHECK(isc_string_copy(change[0]->mod_type, LDAP_ATTR_FORMATSIZE,
|
| |
- attr));
|
| |
+ if (strlcpy(change[0]->mod_type, attr, LDAP_ATTR_FORMATSIZE)
|
| |
+ >= LDAP_ATTR_FORMATSIZE)
|
| |
+ return ISC_R_NOSPACE;
|
| |
CHECK(ldap_modify_do(ldap_inst, str_buf(dn), change, false));
|
| |
ldap_mod_free(ldap_inst->mctx, &change[0]);
|
| |
unknown_type = !unknown_type;
|
| |
@@ -3973,7 +3997,7 @@
|
| |
/* Check if the zone is loaded or not.
|
| |
* No other function above returns DNS_R_NOTLOADED. */
|
| |
if (sync_state == sync_finished)
|
| |
- result = dns_zone_getserial2(raw, &serial);
|
| |
+ result = dns_zone_getserial(raw, &serial);
|
| |
|
| |
cleanup:
|
| |
#ifdef RBTDB_DEBUG
|
| |
@@ -4010,7 +4034,7 @@
|
| |
"caused by change in %s",
|
| |
ldap_entry_logname(entry));
|
| |
zone_reloaded = true;
|
| |
- result = dns_zone_getserial2(raw, &serial);
|
| |
+ result = dns_zone_getserial(raw, &serial);
|
| |
if (result == ISC_R_SUCCESS)
|
| |
goto update_restart;
|
| |
} else {
|
| |
@@ -4620,14 +4644,17 @@
|
| |
|
| |
/* request idnsServerConfig object only if server_id is specified */
|
| |
CHECK(setting_get_str("server_id", inst->server_ldap_settings, &server_id));
|
| |
- if (strlen(server_id) == 0)
|
| |
- CHECK(isc_string_printf(filter, sizeof(filter), config_template,
|
| |
- "", "", "", filter_objcs));
|
| |
- else
|
| |
- CHECK(isc_string_printf(filter, sizeof(filter), config_template,
|
| |
- " (&(objectClass=idnsServerConfigObject)"
|
| |
- " (idnsServerId=", server_id, "))",
|
| |
- filter_objcs));
|
| |
+ if (strlen(server_id) == 0) {
|
| |
+ result = snprintf(filter, sizeof(filter), config_template,
|
| |
+ "", "", "", filter_objcs);
|
| |
+ RUNTIME_CHECK(result < sizeof(filter));
|
| |
+ } else {
|
| |
+ result = snprintf(filter, sizeof(filter), config_template,
|
| |
+ " (&(objectClass=idnsServerConfigObject)"
|
| |
+ " (idnsServerId=", server_id, "))",
|
| |
+ filter_objcs);
|
| |
+ RUNTIME_CHECK(result < sizeof(filter));
|
| |
+ }
|
| |
|
| |
result = ldap_sync_prepare(inst, inst->server_ldap_settings,
|
| |
filter, conn, &ldap_sync);
|
| |
@@ -4821,7 +4848,7 @@
|
| |
* (if it is even possible). */
|
| |
void
|
| |
ldap_instance_taint(ldap_instance_t *ldap_inst) {
|
| |
- isc_refcount_increment0(&ldap_inst->errors, NULL);
|
| |
+ isc_refcount_increment(&ldap_inst->errors);
|
| |
}
|
| |
|
| |
bool
|
| |
@@ -4852,7 +4879,8 @@
|
| |
ldap_instance_untaint_finish(ldap_instance_t *ldap_inst, unsigned int count) {
|
| |
unsigned int remaining = 0;
|
| |
while (count > 0) {
|
| |
- isc_refcount_decrement(&ldap_inst->errors, &remaining);
|
| |
+ /* isc_refcount_decrement now has one parameter */
|
| |
+ remaining = isc_refcount_decrement(&ldap_inst->errors);
|
| |
count--;
|
| |
}
|
| |
if (remaining != 0)
|
| |
isc_string_printf_truncate have been removed, replaced by normal c
functions
Functions that are now void and failures are fatal:
isc_buffer_allocate, isc_mutex_destroy, isc_mutex_init,
isc_thread_create, isc_thread_join, dns_zone_setdbtype,
isc_condition_init, isc_condition_destroy
dns_name_t now has to be const in several functions
second parameter
code