| |
@@ -3,6 +3,8 @@
|
| |
*/
|
| |
|
| |
#include "config.h"
|
| |
+ #define HAVE_TLS 1
|
| |
+ #define HAVE_THREAD_LOCAL 1
|
| |
|
| |
#include <dns/dyndb.h>
|
| |
#include <dns/diff.h>
|
| |
@@ -91,6 +93,16 @@
|
| |
} \
|
| |
} while (0)
|
| |
|
| |
+ #if LIBDNS_VERSION_MAJOR < 1600
|
| |
+ #define dns_fwdtable_find dns_fwdtable_find2
|
| |
+ #define dns_zone_getserial dns_zone_getserial2
|
| |
+ #define dns_zone_load(zone, newonly) dns_zone_load((zone))
|
| |
+ #define dns_zone_setfile dns_zone_setfile3
|
| |
+ typedef dns_name_t node_name_t;
|
| |
+ #else
|
| |
+ typedef const dns_name_t node_name_t;
|
| |
+ #endif
|
| |
+
|
| |
/*
|
| |
* LDAP related typedefs and structs.
|
| |
*/
|
| |
@@ -371,6 +383,12 @@
|
| |
zone_master_reconfigure_nsec3param(settings_set_t *zone_settings,
|
| |
dns_zone_t *secure);
|
| |
|
| |
+ /* external function from ldap_driver.c */
|
| |
+ isc_result_t
|
| |
+ ldapdb_associate(isc_mem_t *mctx, node_name_t *name, dns_dbtype_t type,
|
| |
+ dns_rdataclass_t rdclass, unsigned int argc, char *argv[],
|
| |
+ void *driverarg, dns_db_t **dbp) ATTR_NONNULL(1,2,7,8);
|
| |
+
|
| |
#define PRINT_BUFF_SIZE 10 /* for unsigned int 2^32 */
|
| |
isc_result_t
|
| |
validate_local_instance_settings(ldap_instance_t *inst, settings_set_t *set) {
|
| |
@@ -390,6 +408,7 @@
|
| |
char print_buff[PRINT_BUFF_SIZE];
|
| |
const char *auth_method_str = NULL;
|
| |
ldap_auth_t auth_method_enum = AUTH_INVALID;
|
| |
+ int s_len;
|
| |
|
| |
if (strlen(inst->db_name) <= 0) {
|
| |
log_error("LDAP instance name cannot be empty");
|
| |
@@ -445,7 +464,12 @@
|
| |
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 */
|
| |
+ s_len = snprintf(print_buff, PRINT_BUFF_SIZE, "%u", auth_method_enum);
|
| |
+ if (s_len < 0 || s_len >= PRINT_BUFF_SIZE) {
|
| |
+ CLEANUP_WITH(ISC_R_NOSPACE);
|
| |
+ }
|
| |
+
|
| |
CHECK(setting_set("auth_method_enum", inst->local_settings, print_buff));
|
| |
|
| |
/* check we have the right data when SASL/GSSAPI is selected */
|
| |
@@ -543,11 +567,11 @@
|
| |
|
| |
REQUIRE(ldap_instp != NULL && *ldap_instp == NULL);
|
| |
|
| |
- CHECKED_MEM_GET_PTR(mctx, ldap_inst);
|
| |
+ ldap_inst = isc_mem_get(mctx, sizeof(*(ldap_inst)));
|
| |
ZERO_PTR(ldap_inst);
|
| |
- CHECK(isc_refcount_init(&ldap_inst->errors, 0));
|
| |
+ isc_refcount_init(&ldap_inst->errors, 0);
|
| |
isc_mem_attach(mctx, &ldap_inst->mctx);
|
| |
- CHECKED_MEM_STRDUP(mctx, db_name, ldap_inst->db_name);
|
| |
+ ldap_inst->db_name = isc_mem_strdup(mctx, db_name);
|
| |
dns_view_attach(dctx->view, &ldap_inst->view);
|
| |
dns_zonemgr_attach(dctx->zmgr, &ldap_inst->zmgr);
|
| |
isc_task_attach(dctx->task, &ldap_inst->task);
|
| |
@@ -555,16 +579,18 @@
|
| |
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);
|
| |
+ /* truncation is allowed */
|
| |
+ 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);
|
| |
+ /* truncation is allowed */
|
| |
+ 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 +602,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,
|
| |
@@ -602,8 +628,6 @@
|
| |
empty_zone_handle_globalfwd_ev,
|
| |
ldap_inst->view->zonetable,
|
| |
sizeof(ldap_globalfwd_handleez_t));
|
| |
- if (gfwdevent == NULL)
|
| |
- CLEANUP_WITH(ISC_R_NOMEMORY);
|
| |
/* policy == first does not override automatic empty zones */
|
| |
gfwdevent->warn_only = (named_conf_forwarders->fwdpolicy
|
| |
== dns_fwdpolicy_first);
|
| |
@@ -628,14 +652,16 @@
|
| |
/* zero-length server_id means undefined value */
|
| |
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");
|
| |
- else
|
| |
- isc_string_printf_truncate(settings_name, PRINT_BUFF_SIZE,
|
| |
- SETTING_SET_NAME_SERVER
|
| |
- " for server id %s", server_id);
|
| |
+ if (strlen(server_id) == 0) {
|
| |
+ /* truncation is allowed */
|
| |
+ snprintf(settings_name, PRINT_BUFF_SIZE,
|
| |
+ SETTING_SET_NAME_SERVER " for undefined server_id");
|
| |
+ } else {
|
| |
+ /* truncation is allowed */
|
| |
+ 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 +682,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 +693,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 +744,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 +779,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);
|
| |
@@ -773,31 +804,28 @@
|
| |
static isc_result_t ATTR_NONNULLS ATTR_CHECKRESULT
|
| |
new_ldap_connection(ldap_pool_t *pool, ldap_connection_t **ldap_connp)
|
| |
{
|
| |
- isc_result_t result;
|
| |
ldap_connection_t *ldap_conn;
|
| |
|
| |
REQUIRE(pool != NULL);
|
| |
REQUIRE(ldap_connp != NULL && *ldap_connp == NULL);
|
| |
|
| |
- CHECKED_MEM_GET_PTR(pool->mctx, ldap_conn);
|
| |
+ ldap_conn = isc_mem_get(pool->mctx, sizeof(*(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);
|
| |
|
| |
*ldap_connp = ldap_conn;
|
| |
|
| |
return ISC_R_SUCCESS;
|
| |
-
|
| |
- cleanup:
|
| |
- destroy_ldap_connection(&ldap_conn);
|
| |
-
|
| |
- return result;
|
| |
}
|
| |
|
| |
static void
|
| |
@@ -811,7 +839,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);
|
| |
|
| |
@@ -825,6 +854,7 @@
|
| |
const char *filename = NULL;
|
| |
dns_zone_t *raw = NULL;
|
| |
int namelen;
|
| |
+ int s_len;
|
| |
char bck_filename[PATH_MAX];
|
| |
|
| |
dns_zone_getraw(zone, &raw);
|
| |
@@ -847,8 +877,11 @@
|
| |
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));
|
| |
+ s_len = snprintf(bck_filename, sizeof(bck_filename),
|
| |
+ "%.*s.jbk", namelen, filename);
|
| |
+ if (s_len < 0 || (unsigned)s_len >= sizeof(bck_filename)) {
|
| |
+ CLEANUP_WITH(ISC_R_NOSPACE);
|
| |
+ }
|
| |
CHECK(fs_file_remove(bck_filename));
|
| |
|
| |
cleanup:
|
| |
@@ -941,7 +974,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 +1024,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 +1038,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 +1092,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 +1104,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);
|
| |
@@ -1708,6 +1745,7 @@
|
| |
LDAPMod change;
|
| |
LDAPMod *changep[2] = { &change, NULL };
|
| |
ld_string_t *dn = NULL;
|
| |
+ int s_len;
|
| |
|
| |
REQUIRE(inst != NULL);
|
| |
|
| |
@@ -1717,7 +1755,10 @@
|
| |
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));
|
| |
+ s_len = snprintf(serial_char, MAX_SERIAL_LENGTH, "%u", serial);
|
| |
+ if (s_len < 0 || (unsigned)s_len >= MAX_SERIAL_LENGTH) {
|
| |
+ CLEANUP_WITH(ISC_R_NOSPACE);
|
| |
+ }
|
| |
|
| |
CHECK(ldap_modify_do(inst, str_buf(dn), changep, false));
|
| |
|
| |
@@ -2250,7 +2291,7 @@
|
| |
|
| |
result = ldapdb_rdatalist_findrdatatype(rdatalist, rdtype, &rdlist);
|
| |
if (result != ISC_R_SUCCESS) {
|
| |
- CHECKED_MEM_GET_PTR(mctx, rdlist);
|
| |
+ rdlist = isc_mem_get(mctx, sizeof(*(rdlist)));
|
| |
|
| |
dns_rdatalist_init(rdlist);
|
| |
rdlist->rdclass = rdclass;
|
| |
@@ -2371,7 +2412,7 @@
|
| |
CLEANUP_WITH(ISC_R_UNEXPECTED);
|
| |
|
| |
CHECK(str_new(mctx, &replaced));
|
| |
- CHECKED_MEM_STRDUP(mctx, str_buf(orig_val), tmp);
|
| |
+ tmp = isc_mem_strdup(mctx, str_buf(orig_val));
|
| |
|
| |
while (regexec(®ex, tmp + processed,
|
| |
sizeof(matches)/sizeof(regmatch_t),
|
| |
@@ -2419,9 +2460,7 @@
|
| |
result = ISC_R_SUCCESS;
|
| |
|
| |
cleanup:
|
| |
- if (tmp != NULL)
|
| |
- isc_mem_free(mctx, tmp);
|
| |
-
|
| |
+ isc_mem_free(mctx, tmp);
|
| |
str_destroy(&replaced);
|
| |
return result;
|
| |
}
|
| |
@@ -2659,11 +2698,11 @@
|
| |
CHECK(dns_rdata_fromtext(NULL, rdclass, rdtype, entry->lex, origin,
|
| |
0, mctx, &entry->rdata_target, NULL));
|
| |
|
| |
- CHECKED_MEM_GET_PTR(mctx, rdata);
|
| |
+ rdata = isc_mem_get(mctx, sizeof(*(rdata)));
|
| |
dns_rdata_init(rdata);
|
| |
|
| |
rdatamem.length = isc_buffer_usedlength(&entry->rdata_target);
|
| |
- CHECKED_MEM_GET(mctx, rdatamem.base, rdatamem.length);
|
| |
+ rdatamem.base = isc_mem_get(mctx, rdatamem.length);
|
| |
|
| |
memcpy(rdatamem.base, isc_buffer_base(&entry->rdata_target),
|
| |
rdatamem.length);
|
| |
@@ -3144,22 +3183,15 @@
|
| |
ldap_mod_create(isc_mem_t *mctx, LDAPMod **changep)
|
| |
{
|
| |
LDAPMod *change = NULL;
|
| |
- isc_result_t result;
|
| |
|
| |
REQUIRE(changep != NULL && *changep == NULL);
|
| |
|
| |
- CHECKED_MEM_GET_PTR(mctx, change);
|
| |
+ change = isc_mem_get(mctx, sizeof(*(change)));
|
| |
ZERO_PTR(change);
|
| |
- CHECKED_MEM_GET(mctx, change->mod_type, LDAP_ATTR_FORMATSIZE);
|
| |
+ change->mod_type = isc_mem_get(mctx, LDAP_ATTR_FORMATSIZE);
|
| |
|
| |
*changep = change;
|
| |
return ISC_R_SUCCESS;
|
| |
-
|
| |
- cleanup:
|
| |
- if (change != NULL)
|
| |
- SAFE_MEM_PUT_PTR(mctx, change);
|
| |
-
|
| |
- return result;
|
| |
}
|
| |
|
| |
/**
|
| |
@@ -3204,7 +3236,7 @@
|
| |
ldap_rdata_to_char_array(isc_mem_t *mctx, dns_rdata_t *rdata_head,
|
| |
bool unknown, char ***valsp)
|
| |
{
|
| |
- isc_result_t result;
|
| |
+ isc_result_t result = ISC_R_FAILURE;
|
| |
char **vals;
|
| |
unsigned int i;
|
| |
unsigned int rdata_count = 0;
|
| |
@@ -3219,7 +3251,7 @@
|
| |
|
| |
vals_size = (rdata_count + 1) * sizeof(char *);
|
| |
|
| |
- CHECKED_MEM_ALLOCATE(mctx, vals, vals_size);
|
| |
+ vals = isc_mem_allocate(mctx, vals_size);
|
| |
memset(vals, 0, vals_size);
|
| |
|
| |
rdata = rdata_head;
|
| |
@@ -3237,7 +3269,7 @@
|
| |
isc_buffer_usedregion(&buffer, ®ion);
|
| |
|
| |
/* Now allocate the string with the right size. */
|
| |
- CHECKED_MEM_ALLOCATE(mctx, vals[i], region.length + 1);
|
| |
+ vals[i] = isc_mem_allocate(mctx, region.length + 1);
|
| |
memcpy(vals[i], region.base, region.length);
|
| |
vals[i][region.length] = '\0';
|
| |
|
| |
@@ -3287,13 +3319,17 @@
|
| |
|
| |
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) {
|
| |
+ CLEANUP_WITH(ISC_R_NOSPACE);
|
| |
+ }
|
| |
|
| |
- CHECKED_MEM_ALLOCATE(mctx, vals, 2 * sizeof(char *));
|
| |
+ vals = isc_mem_allocate(mctx, 2 * sizeof(char *));
|
| |
memset(vals, 0, 2 * sizeof(char *));
|
| |
change->mod_values = vals;
|
| |
|
| |
- CHECKED_MEM_ALLOCATE(mctx, vals[0], str_len(ttlval) + 1);
|
| |
+ vals[0] = isc_mem_allocate(mctx, str_len(ttlval) + 1);
|
| |
memcpy(vals[0], str_buf(ttlval), str_len(ttlval) + 1);
|
| |
|
| |
*changep = change;
|
| |
@@ -3314,8 +3350,9 @@
|
| |
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;
|
| |
+ int s_len;
|
| |
LDAPMod change[5];
|
| |
LDAPMod *changep[6] = {
|
| |
&change[0], &change[1], &change[2], &change[3], &change[4],
|
| |
@@ -3332,8 +3369,11 @@
|
| |
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));
|
| |
+ s_len = snprintf(change[index].mod_values[0], MAX_SOANUM_LENGTH, \
|
| |
+ "%u", soa.name); \
|
| |
+ if (s_len < 0 || s_len >= MAX_SOANUM_LENGTH) { \
|
| |
+ CLEANUP_WITH(ISC_R_NOSPACE); \
|
| |
+ }
|
| |
|
| |
dns_rdata_tostruct(rdata, (void *)&soa, ldap_inst->mctx);
|
| |
|
| |
@@ -3500,8 +3540,10 @@
|
| |
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) {
|
| |
+ CLEANUP_WITH(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;
|
| |
@@ -3561,13 +3603,13 @@
|
| |
|
| |
REQUIRE(poolp != NULL && *poolp == NULL);
|
| |
|
| |
- CHECKED_MEM_GET(mctx, pool, sizeof(*pool));
|
| |
+ pool = isc_mem_get(mctx, sizeof(*pool));
|
| |
ZERO_PTR(pool);
|
| |
isc_mem_attach(mctx, &pool->mctx);
|
| |
|
| |
CHECK(semaphore_init(&pool->conn_semaphore, connections));
|
| |
- CHECKED_MEM_GET(mctx, pool->conns,
|
| |
- connections * sizeof(ldap_connection_t *));
|
| |
+ pool->conns = isc_mem_get(mctx,
|
| |
+ connections * sizeof(ldap_connection_t *));
|
| |
memset(pool->conns, 0, connections * sizeof(ldap_connection_t *));
|
| |
pool->connections = connections;
|
| |
|
| |
@@ -3973,7 +4015,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 +4052,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 {
|
| |
@@ -4146,7 +4188,7 @@
|
| |
|
| |
/* This code is disabled because we don't have UUID->DN database yet.
|
| |
if (SYNCREPL_MODDN(chgtype)) {
|
| |
- CHECKED_MEM_STRDUP(mctx, prevdn_ldap, prevdn);
|
| |
+ prevdn = isc_mem_strdup(mctx, prevdn_ldap);
|
| |
}
|
| |
*/
|
| |
|
| |
@@ -4171,11 +4213,6 @@
|
| |
action, NULL,
|
| |
sizeof(ldap_syncreplevent_t));
|
| |
|
| |
- if (pevent == NULL) {
|
| |
- result = ISC_R_NOMEMORY;
|
| |
- goto cleanup;
|
| |
- }
|
| |
-
|
| |
pevent->mctx = NULL;
|
| |
isc_mem_attach(inst->mctx, &pevent->mctx);
|
| |
pevent->inst = inst;
|
| |
@@ -4607,6 +4644,7 @@
|
| |
const char * const filter_objcs, int mode) {
|
| |
isc_result_t result;
|
| |
int ret;
|
| |
+ int s_len;
|
| |
ldap_sync_t *ldap_sync = NULL;
|
| |
const char *err_hint = "";
|
| |
char filter[1024];
|
| |
@@ -4620,14 +4658,22 @@
|
| |
|
| |
/* 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) {
|
| |
+ s_len = snprintf(filter, sizeof(filter),
|
| |
+ config_template, "", "", "", filter_objcs);
|
| |
+ if (s_len < 0 || (unsigned)s_len >= sizeof(filter)) {
|
| |
+ CLEANUP_WITH(ISC_R_NOSPACE);
|
| |
+ }
|
| |
+ } else {
|
| |
+ s_len = snprintf(filter, sizeof(filter),
|
| |
+ config_template,
|
| |
+ " (&(objectClass=idnsServerConfigObject)"
|
| |
+ " (idnsServerId=", server_id, "))",
|
| |
+ filter_objcs);
|
| |
+ if (s_len < 0 || (unsigned)s_len >= sizeof(filter)) {
|
| |
+ CLEANUP_WITH(ISC_R_NOSPACE);
|
| |
+ }
|
| |
+ }
|
| |
|
| |
result = ldap_sync_prepare(inst, inst->server_ldap_settings,
|
| |
filter, conn, &ldap_sync);
|
| |
@@ -4821,7 +4867,11 @@
|
| |
* (if it is even possible). */
|
| |
void
|
| |
ldap_instance_taint(ldap_instance_t *ldap_inst) {
|
| |
+ #if LIBDNS_VERSION_MAJOR < 1600
|
| |
isc_refcount_increment0(&ldap_inst->errors, NULL);
|
| |
+ #else
|
| |
+ isc_refcount_increment0(&ldap_inst->errors);
|
| |
+ #endif
|
| |
}
|
| |
|
| |
bool
|
| |
@@ -4850,13 +4900,16 @@
|
| |
*/
|
| |
isc_result_t
|
| |
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);
|
| |
+ #if LIBDNS_VERSION_MAJOR < 1600
|
| |
+ isc_refcount_decrement(&ldap_inst->errors, NULL);
|
| |
+ #else
|
| |
+ (void)isc_refcount_decrement(&ldap_inst->errors);
|
| |
+ #endif
|
| |
count--;
|
| |
}
|
| |
- if (remaining != 0)
|
| |
- return DNS_R_CONTINUE;
|
| |
- else
|
| |
+ if (isc_refcount_current(&ldap_inst->errors) == 0) {
|
| |
return ISC_R_SUCCESS;
|
| |
+ }
|
| |
+ return DNS_R_CONTINUE;
|
| |
}
|
| |
Additional updates to slev's branch. Add compatibility macros for compilation on BIND 9.11. Support for db change in 9.16.6.