1 |
diff -uNrp bind-9.8.4-P1.dyndb/bin/named/main.c bind-9.8.4-P1/bin/named/main.c |
2 |
--- bind-9.8.4-P1.dyndb/bin/named/main.c 2012-10-26 00:52:55.000000000 -0400 |
3 |
+++ bind-9.8.4-P1/bin/named/main.c 2012-12-05 09:23:59.165685537 -0500 |
4 |
@@ -45,6 +45,7 @@ |
5 |
#include <isccc/result.h> |
6 |
|
7 |
#include <dns/dispatch.h> |
8 |
+#include <dns/dynamic_db.h> |
9 |
#include <dns/name.h> |
10 |
#include <dns/result.h> |
11 |
#include <dns/view.h> |
12 |
@@ -903,6 +904,8 @@ setup(void) { |
13 |
|
14 |
static void |
15 |
cleanup(void) { |
16 |
+ dns_dynamic_db_cleanup(ISC_TRUE); |
17 |
+ |
18 |
destroy_managers(); |
19 |
|
20 |
ns_server_destroy(&ns_g_server); |
21 |
diff -uNrp bind-9.8.4-P1.dyndb/bin/named/server.c bind-9.8.4-P1/bin/named/server.c |
22 |
--- bind-9.8.4-P1.dyndb/bin/named/server.c 2012-10-26 00:52:55.000000000 -0400 |
23 |
+++ bind-9.8.4-P1/bin/named/server.c 2012-12-05 09:23:59.185685535 -0500 |
24 |
@@ -61,6 +61,7 @@ |
25 |
#include <dns/db.h> |
26 |
#include <dns/dispatch.h> |
27 |
#include <dns/dlz.h> |
28 |
+#include <dns/dynamic_db.h> |
29 |
#include <dns/dns64.h> |
30 |
#include <dns/forward.h> |
31 |
#include <dns/journal.h> |
32 |
@@ -1151,6 +1152,72 @@ configure_peer(const cfg_obj_t *cpeer, i |
33 |
} |
34 |
|
35 |
static isc_result_t |
36 |
+configure_dynamic_db(const cfg_obj_t *dynamic_db, isc_mem_t *mctx, |
37 |
+ const dns_dyndb_arguments_t *dyndb_args) |
38 |
+{ |
39 |
+ isc_result_t result; |
40 |
+ const cfg_obj_t *obj; |
41 |
+ const cfg_obj_t *options; |
42 |
+ const cfg_listelt_t *element; |
43 |
+ const char *name; |
44 |
+ const char *libname; |
45 |
+ const char **argv = NULL; |
46 |
+ unsigned int i; |
47 |
+ unsigned int len; |
48 |
+ |
49 |
+ /* Get the name of the database. */ |
50 |
+ obj = cfg_tuple_get(dynamic_db, "name"); |
51 |
+ name = cfg_obj_asstring(obj); |
52 |
+ |
53 |
+ /* Get options. */ |
54 |
+ options = cfg_tuple_get(dynamic_db, "options"); |
55 |
+ |
56 |
+ /* Get library name. */ |
57 |
+ obj = NULL; |
58 |
+ CHECK(cfg_map_get(options, "library", &obj)); |
59 |
+ libname = cfg_obj_asstring(obj); |
60 |
+ |
61 |
+ /* Create a list of arguments. */ |
62 |
+ obj = NULL; |
63 |
+ result = cfg_map_get(options, "arg", &obj); |
64 |
+ if (result == ISC_R_NOTFOUND) |
65 |
+ len = 0; |
66 |
+ else if (result == ISC_R_SUCCESS) |
67 |
+ len = cfg_list_length(obj, isc_boolean_false); |
68 |
+ else |
69 |
+ goto cleanup; |
70 |
+ |
71 |
+ /* Account for the last terminating NULL. */ |
72 |
+ len++; |
73 |
+ |
74 |
+ argv = isc_mem_allocate(mctx, len * sizeof(const char *)); |
75 |
+ if (argv == NULL) { |
76 |
+ result = ISC_R_NOMEMORY; |
77 |
+ goto cleanup; |
78 |
+ } |
79 |
+ for (element = cfg_list_first(obj), i = 0; |
80 |
+ element != NULL; |
81 |
+ element = cfg_list_next(element), i++) |
82 |
+ { |
83 |
+ REQUIRE(i < len); |
84 |
+ |
85 |
+ obj = cfg_listelt_value(element); |
86 |
+ argv[i] = cfg_obj_asstring(obj); |
87 |
+ } |
88 |
+ REQUIRE(i < len); |
89 |
+ argv[i] = NULL; |
90 |
+ |
91 |
+ CHECK(dns_dynamic_db_load(libname, name, mctx, argv, dyndb_args)); |
92 |
+ |
93 |
+cleanup: |
94 |
+ if (argv != NULL) |
95 |
+ isc_mem_free(mctx, argv); |
96 |
+ |
97 |
+ return result; |
98 |
+} |
99 |
+ |
100 |
+ |
101 |
+static isc_result_t |
102 |
disable_algorithms(const cfg_obj_t *disabled, dns_resolver_t *resolver) { |
103 |
isc_result_t result; |
104 |
const cfg_obj_t *algorithms; |
105 |
@@ -1576,6 +1643,7 @@ configure_view(dns_view_t *view, cfg_obj |
106 |
const cfg_obj_t *dlz; |
107 |
unsigned int dlzargc; |
108 |
char **dlzargv; |
109 |
+ const cfg_obj_t *dynamic_db_list; |
110 |
const cfg_obj_t *disabled; |
111 |
const cfg_obj_t *obj; |
112 |
const cfg_listelt_t *element; |
113 |
@@ -1807,6 +1875,37 @@ configure_view(dns_view_t *view, cfg_obj |
114 |
} |
115 |
|
116 |
/* |
117 |
+ * Configure dynamic databases. |
118 |
+ */ |
119 |
+ dynamic_db_list = NULL; |
120 |
+ if (voptions != NULL) |
121 |
+ (void)cfg_map_get(voptions, "dynamic-db", &dynamic_db_list); |
122 |
+ else |
123 |
+ (void)cfg_map_get(config, "dynamic-db", &dynamic_db_list); |
124 |
+ element = cfg_list_first(dynamic_db_list); |
125 |
+ if (element != NULL) { |
126 |
+ dns_dyndb_arguments_t *args; |
127 |
+ |
128 |
+ args = dns_dyndb_arguments_create(mctx); |
129 |
+ if (args == NULL) { |
130 |
+ result = ISC_R_NOMEMORY; |
131 |
+ goto cleanup; |
132 |
+ } |
133 |
+ dns_dyndb_set_view(args, view); |
134 |
+ dns_dyndb_set_zonemgr(args, ns_g_server->zonemgr); |
135 |
+ dns_dyndb_set_task(args, ns_g_server->task); |
136 |
+ dns_dyndb_set_timermgr(args, ns_g_timermgr); |
137 |
+ while (element != NULL) { |
138 |
+ obj = cfg_listelt_value(element); |
139 |
+ CHECK(configure_dynamic_db(obj, mctx, args)); |
140 |
+ |
141 |
+ element = cfg_list_next(element); |
142 |
+ } |
143 |
+ |
144 |
+ dns_dyndb_arguments_destroy(mctx, args); |
145 |
+ } |
146 |
+ |
147 |
+ /* |
148 |
* Obtain configuration parameters that affect the decision of whether |
149 |
* we can reuse/share an existing cache. |
150 |
*/ |
151 |
@@ -5218,6 +5317,7 @@ load_zones(ns_server_t *server, isc_bool |
152 |
result = isc_task_beginexclusive(server->task); |
153 |
RUNTIME_CHECK(result == ISC_R_SUCCESS); |
154 |
|
155 |
+ dns_dynamic_db_cleanup(ISC_FALSE); |
156 |
/* |
157 |
* Load zone data from disk. |
158 |
*/ |
159 |
@@ -5761,6 +5861,8 @@ loadconfig(ns_server_t *server) { |
160 |
static isc_result_t |
161 |
reload(ns_server_t *server) { |
162 |
isc_result_t result; |
163 |
+ |
164 |
+ dns_dynamic_db_cleanup(ISC_FALSE); |
165 |
CHECK(loadconfig(server)); |
166 |
|
167 |
result = load_zones(server, ISC_FALSE); |
168 |
diff -uNrp bind-9.8.4-P1.dyndb/lib/dns/dynamic_db.c bind-9.8.4-P1/lib/dns/dynamic_db.c |
169 |
--- bind-9.8.4-P1.dyndb/lib/dns/dynamic_db.c 1969-12-31 19:00:00.000000000 -0500 |
170 |
+++ bind-9.8.4-P1/lib/dns/dynamic_db.c 2012-12-05 09:23:59.185685535 -0500 |
171 |
@@ -0,0 +1,364 @@ |
172 |
+/* |
173 |
+ * Copyright (C) 2008-2009 Red Hat, Inc. |
174 |
+ * |
175 |
+ * Permission to use, copy, modify, and/or distribute this software for any |
176 |
+ * purpose with or without fee is hereby granted, provided that the above |
177 |
+ * copyright notice and this permission notice appear in all copies. |
178 |
+ * |
179 |
+ * THE SOFTWARE IS PROVIDED "AS IS" AND Red Hat DISCLAIMS ALL WARRANTIES WITH |
180 |
+ * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY |
181 |
+ * AND FITNESS. IN NO EVENT SHALL Red Hat BE LIABLE FOR ANY SPECIAL, DIRECT, |
182 |
+ * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM |
183 |
+ * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE |
184 |
+ * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR |
185 |
+ * PERFORMANCE OF THIS SOFTWARE. |
186 |
+ */ |
187 |
+ |
188 |
+ |
189 |
+#include <config.h> |
190 |
+ |
191 |
+#include <isc/buffer.h> |
192 |
+#include <isc/mem.h> |
193 |
+#include <isc/mutex.h> |
194 |
+#include <isc/once.h> |
195 |
+#include <isc/result.h> |
196 |
+#include <isc/region.h> |
197 |
+#include <isc/task.h> |
198 |
+#include <isc/types.h> |
199 |
+#include <isc/util.h> |
200 |
+ |
201 |
+#include <dns/dynamic_db.h> |
202 |
+#include <dns/log.h> |
203 |
+#include <dns/types.h> |
204 |
+#include <dns/view.h> |
205 |
+#include <dns/zone.h> |
206 |
+ |
207 |
+#include <string.h> |
208 |
+ |
209 |
+#if HAVE_DLFCN_H |
210 |
+#include <dlfcn.h> |
211 |
+#endif |
212 |
+ |
213 |
+#ifndef DYNDB_LIBDIR |
214 |
+#define DYNDB_LIBDIR "" |
215 |
+#endif |
216 |
+ |
217 |
+#define CHECK(op) \ |
218 |
+ do { result = (op); \ |
219 |
+ if (result != ISC_R_SUCCESS) goto cleanup; \ |
220 |
+ } while (0) |
221 |
+ |
222 |
+ |
223 |
+typedef isc_result_t (*register_func_t)(isc_mem_t *mctx, const char *name, |
224 |
+ const char * const *argv, dns_dyndb_arguments_t *dyndb_args); |
225 |
+typedef void (*destroy_func_t)(void); |
226 |
+ |
227 |
+typedef struct dyndb_implementation dyndb_implementation_t; |
228 |
+ |
229 |
+struct dyndb_implementation { |
230 |
+ isc_mem_t *mctx; |
231 |
+ void *handle; |
232 |
+ register_func_t register_function; |
233 |
+ destroy_func_t destroy_function; |
234 |
+ LINK(dyndb_implementation_t) link; |
235 |
+}; |
236 |
+ |
237 |
+struct dns_dyndb_arguments { |
238 |
+ dns_view_t *view; |
239 |
+ dns_zonemgr_t *zmgr; |
240 |
+ isc_task_t *task; |
241 |
+ isc_timermgr_t *timermgr; |
242 |
+}; |
243 |
+ |
244 |
+/* List of implementations. Locked by dyndb_lock. */ |
245 |
+static LIST(dyndb_implementation_t) dyndb_implementations; |
246 |
+/* Locks dyndb_implementations. */ |
247 |
+static isc_mutex_t dyndb_lock; |
248 |
+static isc_once_t once = ISC_ONCE_INIT; |
249 |
+ |
250 |
+static void |
251 |
+dyndb_initialize(void) { |
252 |
+ RUNTIME_CHECK(isc_mutex_init(&dyndb_lock) == ISC_R_SUCCESS); |
253 |
+ INIT_LIST(dyndb_implementations); |
254 |
+} |
255 |
+ |
256 |
+ |
257 |
+#if HAVE_DLFCN_H |
258 |
+static isc_result_t |
259 |
+load_symbol(void *handle, const char *symbol_name, void **symbolp) |
260 |
+{ |
261 |
+ const char *errmsg; |
262 |
+ void *symbol; |
263 |
+ |
264 |
+ REQUIRE(handle != NULL); |
265 |
+ REQUIRE(symbolp != NULL && *symbolp == NULL); |
266 |
+ |
267 |
+ symbol = dlsym(handle, symbol_name); |
268 |
+ if (symbol == NULL) { |
269 |
+ errmsg = dlerror(); |
270 |
+ if (errmsg == NULL) |
271 |
+ errmsg = "returned function pointer is NULL"; |
272 |
+ isc_log_write(dns_lctx, DNS_LOGCATEGORY_DATABASE, |
273 |
+ DNS_LOGMODULE_DYNDB, ISC_LOG_ERROR, |
274 |
+ "failed to lookup symbol %s: %s", |
275 |
+ symbol_name, errmsg); |
276 |
+ return ISC_R_FAILURE; |
277 |
+ } |
278 |
+ dlerror(); |
279 |
+ |
280 |
+ *symbolp = symbol; |
281 |
+ |
282 |
+ return ISC_R_SUCCESS; |
283 |
+} |
284 |
+ |
285 |
+static isc_result_t |
286 |
+load_library(isc_mem_t *mctx, const char *filename, dyndb_implementation_t **impp) |
287 |
+{ |
288 |
+ isc_result_t result; |
289 |
+ size_t module_size; |
290 |
+ isc_buffer_t *module_buf = NULL; |
291 |
+ isc_region_t module_region; |
292 |
+ void *handle; |
293 |
+ dyndb_implementation_t *imp; |
294 |
+ register_func_t register_function = NULL; |
295 |
+ destroy_func_t destroy_function = NULL; |
296 |
+ |
297 |
+ REQUIRE(impp != NULL && *impp == NULL); |
298 |
+ |
299 |
+ /* Build up the full path. */ |
300 |
+ module_size = strlen(DYNDB_LIBDIR) + strlen(filename) + 1; |
301 |
+ CHECK(isc_buffer_allocate(mctx, &module_buf, module_size)); |
302 |
+ isc_buffer_putstr(module_buf, DYNDB_LIBDIR); |
303 |
+ isc_buffer_putstr(module_buf, filename); |
304 |
+ isc_buffer_putuint8(module_buf, 0); |
305 |
+ isc_buffer_region(module_buf, &module_region); |
306 |
+ |
307 |
+ handle = dlopen((char *)module_region.base, RTLD_LAZY); |
308 |
+ if (handle == NULL) { |
309 |
+ isc_log_write(dns_lctx, DNS_LOGCATEGORY_DATABASE, |
310 |
+ DNS_LOGMODULE_DYNDB, ISC_LOG_ERROR, |
311 |
+ "failed to dynamically load driver '%s': %s", |
312 |
+ filename, dlerror()); |
313 |
+ result = ISC_R_FAILURE; |
314 |
+ goto cleanup; |
315 |
+ } |
316 |
+ dlerror(); |
317 |
+ |
318 |
+ CHECK(load_symbol(handle, "dynamic_driver_init", |
319 |
+ (void **)®ister_function)); |
320 |
+ CHECK(load_symbol(handle, "dynamic_driver_destroy", |
321 |
+ (void **)&destroy_function)); |
322 |
+ |
323 |
+ imp = isc_mem_get(mctx, sizeof(dyndb_implementation_t)); |
324 |
+ if (imp == NULL) { |
325 |
+ result = ISC_R_NOMEMORY; |
326 |
+ goto cleanup; |
327 |
+ } |
328 |
+ |
329 |
+ imp->mctx = NULL; |
330 |
+ isc_mem_attach(mctx, &imp->mctx); |
331 |
+ imp->handle = handle; |
332 |
+ imp->register_function = register_function; |
333 |
+ imp->destroy_function = destroy_function; |
334 |
+ INIT_LINK(imp, link); |
335 |
+ |
336 |
+ *impp = imp; |
337 |
+ |
338 |
+cleanup: |
339 |
+ if (result != ISC_R_SUCCESS && handle != NULL) |
340 |
+ dlclose(handle); |
341 |
+ if (module_buf != NULL) |
342 |
+ isc_buffer_free(&module_buf); |
343 |
+ |
344 |
+ return result; |
345 |
+} |
346 |
+ |
347 |
+static void |
348 |
+unload_library(dyndb_implementation_t **impp) |
349 |
+{ |
350 |
+ dyndb_implementation_t *imp; |
351 |
+ |
352 |
+ REQUIRE(impp != NULL && *impp != NULL); |
353 |
+ |
354 |
+ imp = *impp; |
355 |
+ |
356 |
+ isc_mem_putanddetach(&imp->mctx, imp, sizeof(dyndb_implementation_t)); |
357 |
+ |
358 |
+ *impp = NULL; |
359 |
+} |
360 |
+ |
361 |
+#else /* HAVE_DLFCN_H */ |
362 |
+static isc_result_t |
363 |
+load_library(isc_mem_t *mctx, const char *filename, dyndb_implementation_t **impp) |
364 |
+{ |
365 |
+ UNUSED(mctx); |
366 |
+ UNUSED(filename); |
367 |
+ UNUSED(impp); |
368 |
+ |
369 |
+ isc_log_write(dns_lctx, DNS_LOGCATEGORY_DATABASE, DNS_LOGMODULE_DYNDB, |
370 |
+ ISC_LOG_ERROR, |
371 |
+ "dynamic database support is not implemented") |
372 |
+ |
373 |
+ return ISC_R_NOTIMPLEMENTED; |
374 |
+} |
375 |
+ |
376 |
+static void |
377 |
+unload_library(dyndb_implementation_t **impp) |
378 |
+{ |
379 |
+ dyndb_implementation_t *imp; |
380 |
+ |
381 |
+ REQUIRE(impp != NULL && *impp != NULL); |
382 |
+ |
383 |
+ imp = *impp; |
384 |
+ |
385 |
+ isc_mem_putanddetach(&imp->mctx, imp, sizeof(dyndb_implementation_t)); |
386 |
+ |
387 |
+ *impp = NULL; |
388 |
+} |
389 |
+#endif /* HAVE_DLFCN_H */ |
390 |
+ |
391 |
+isc_result_t |
392 |
+dns_dynamic_db_load(const char *libname, const char *name, isc_mem_t *mctx, |
393 |
+ const char * const *argv, dns_dyndb_arguments_t *dyndb_args) |
394 |
+{ |
395 |
+ isc_result_t result; |
396 |
+ dyndb_implementation_t *implementation = NULL; |
397 |
+ |
398 |
+ RUNTIME_CHECK(isc_once_do(&once, dyndb_initialize) == ISC_R_SUCCESS); |
399 |
+ |
400 |
+ CHECK(load_library(mctx, libname, &implementation)); |
401 |
+ CHECK(implementation->register_function(mctx, name, argv, dyndb_args)); |
402 |
+ |
403 |
+ LOCK(&dyndb_lock); |
404 |
+ APPEND(dyndb_implementations, implementation, link); |
405 |
+ UNLOCK(&dyndb_lock); |
406 |
+ |
407 |
+ return ISC_R_SUCCESS; |
408 |
+ |
409 |
+cleanup: |
410 |
+ if (implementation != NULL) |
411 |
+ unload_library(&implementation); |
412 |
+ |
413 |
+ return result; |
414 |
+} |
415 |
+ |
416 |
+void |
417 |
+dns_dynamic_db_cleanup(isc_boolean_t exiting) |
418 |
+{ |
419 |
+ dyndb_implementation_t *elem; |
420 |
+ dyndb_implementation_t *prev; |
421 |
+ |
422 |
+ RUNTIME_CHECK(isc_once_do(&once, dyndb_initialize) == ISC_R_SUCCESS); |
423 |
+ |
424 |
+ LOCK(&dyndb_lock); |
425 |
+ elem = TAIL(dyndb_implementations); |
426 |
+ while (elem != NULL) { |
427 |
+ prev = PREV(elem, link); |
428 |
+ UNLINK(dyndb_implementations, elem, link); |
429 |
+ elem->destroy_function(); |
430 |
+ unload_library(&elem); |
431 |
+ elem = prev; |
432 |
+ } |
433 |
+ UNLOCK(&dyndb_lock); |
434 |
+ |
435 |
+ if (exiting == ISC_TRUE) |
436 |
+ isc_mutex_destroy(&dyndb_lock); |
437 |
+} |
438 |
+ |
439 |
+dns_dyndb_arguments_t * |
440 |
+dns_dyndb_arguments_create(isc_mem_t *mctx) |
441 |
+{ |
442 |
+ dns_dyndb_arguments_t *args; |
443 |
+ |
444 |
+ args = isc_mem_get(mctx, sizeof(*args)); |
445 |
+ if (args != NULL) |
446 |
+ memset(args, 0, sizeof(*args)); |
447 |
+ |
448 |
+ return args; |
449 |
+} |
450 |
+ |
451 |
+void |
452 |
+dns_dyndb_arguments_destroy(isc_mem_t *mctx, dns_dyndb_arguments_t *args) |
453 |
+{ |
454 |
+ REQUIRE(args != NULL); |
455 |
+ |
456 |
+ dns_dyndb_set_view(args, NULL); |
457 |
+ dns_dyndb_set_zonemgr(args, NULL); |
458 |
+ dns_dyndb_set_task(args, NULL); |
459 |
+ dns_dyndb_set_timermgr(args, NULL); |
460 |
+ |
461 |
+ isc_mem_put(mctx, args, sizeof(*args)); |
462 |
+} |
463 |
+ |
464 |
+void |
465 |
+dns_dyndb_set_view(dns_dyndb_arguments_t *args, dns_view_t *view) |
466 |
+{ |
467 |
+ REQUIRE(args != NULL); |
468 |
+ |
469 |
+ if (args->view != NULL) |
470 |
+ dns_view_detach(&args->view); |
471 |
+ if (view != NULL) |
472 |
+ dns_view_attach(view, &args->view); |
473 |
+} |
474 |
+ |
475 |
+dns_view_t * |
476 |
+dns_dyndb_get_view(dns_dyndb_arguments_t *args) |
477 |
+{ |
478 |
+ REQUIRE(args != NULL); |
479 |
+ |
480 |
+ return args->view; |
481 |
+} |
482 |
+ |
483 |
+void |
484 |
+dns_dyndb_set_zonemgr(dns_dyndb_arguments_t *args, dns_zonemgr_t *zmgr) |
485 |
+{ |
486 |
+ REQUIRE(args != NULL); |
487 |
+ |
488 |
+ if (args->zmgr != NULL) |
489 |
+ dns_zonemgr_detach(&args->zmgr); |
490 |
+ if (zmgr != NULL) |
491 |
+ dns_zonemgr_attach(zmgr, &args->zmgr); |
492 |
+} |
493 |
+ |
494 |
+dns_zonemgr_t * |
495 |
+dns_dyndb_get_zonemgr(dns_dyndb_arguments_t *args) |
496 |
+{ |
497 |
+ REQUIRE(args != NULL); |
498 |
+ |
499 |
+ return args->zmgr; |
500 |
+} |
501 |
+ |
502 |
+void |
503 |
+dns_dyndb_set_task(dns_dyndb_arguments_t *args, isc_task_t *task) |
504 |
+{ |
505 |
+ REQUIRE(args != NULL); |
506 |
+ |
507 |
+ if (args->task != NULL) |
508 |
+ isc_task_detach(&args->task); |
509 |
+ if (task != NULL) |
510 |
+ isc_task_attach(task, &args->task); |
511 |
+} |
512 |
+ |
513 |
+isc_task_t * |
514 |
+dns_dyndb_get_task(dns_dyndb_arguments_t *args) |
515 |
+{ |
516 |
+ REQUIRE(args != NULL); |
517 |
+ |
518 |
+ return args->task; |
519 |
+} |
520 |
+ |
521 |
+void |
522 |
+dns_dyndb_set_timermgr(dns_dyndb_arguments_t *args, isc_timermgr_t *timermgr) |
523 |
+{ |
524 |
+ REQUIRE(args != NULL); |
525 |
+ |
526 |
+ args->timermgr = timermgr; |
527 |
+} |
528 |
+ |
529 |
+isc_timermgr_t * |
530 |
+dns_dyndb_get_timermgr(dns_dyndb_arguments_t *args) |
531 |
+{ |
532 |
+ REQUIRE(args != NULL); |
533 |
+ |
534 |
+ return args->timermgr; |
535 |
+} |
536 |
diff -uNrp bind-9.8.4-P1.dyndb/lib/dns/include/dns/dynamic_db.h bind-9.8.4-P1/lib/dns/include/dns/dynamic_db.h |
537 |
--- bind-9.8.4-P1.dyndb/lib/dns/include/dns/dynamic_db.h 1969-12-31 19:00:00.000000000 -0500 |
538 |
+++ bind-9.8.4-P1/lib/dns/include/dns/dynamic_db.h 2012-12-05 09:23:59.185685535 -0500 |
539 |
@@ -0,0 +1,50 @@ |
540 |
+/* |
541 |
+ * Copyright (C) 2008-2009 Red Hat, Inc. |
542 |
+ * |
543 |
+ * Permission to use, copy, modify, and/or distribute this software for any |
544 |
+ * purpose with or without fee is hereby granted, provided that the above |
545 |
+ * copyright notice and this permission notice appear in all copies. |
546 |
+ * |
547 |
+ * THE SOFTWARE IS PROVIDED "AS IS" AND Red Hat DISCLAIMS ALL WARRANTIES WITH |
548 |
+ * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY |
549 |
+ * AND FITNESS. IN NO EVENT SHALL Red Hat BE LIABLE FOR ANY SPECIAL, DIRECT, |
550 |
+ * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM |
551 |
+ * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE |
552 |
+ * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR |
553 |
+ * PERFORMANCE OF THIS SOFTWARE. |
554 |
+ */ |
555 |
+ |
556 |
+ |
557 |
+#ifndef DYNAMIC_DB_H |
558 |
+#define DYNAMIC_DB_H |
559 |
+ |
560 |
+#include <isc/types.h> |
561 |
+ |
562 |
+#include <dns/types.h> |
563 |
+ |
564 |
+/* |
565 |
+ * TODO: |
566 |
+ * Reformat the prototypes. |
567 |
+ * Add annotated comments. |
568 |
+ */ |
569 |
+ |
570 |
+isc_result_t dns_dynamic_db_load(const char *libname, const char *name, |
571 |
+ isc_mem_t *mctx, const char * const *argv, |
572 |
+ dns_dyndb_arguments_t *dyndb_args); |
573 |
+ |
574 |
+void dns_dynamic_db_cleanup(isc_boolean_t exiting); |
575 |
+ |
576 |
+dns_dyndb_arguments_t *dns_dyndb_arguments_create(isc_mem_t *mctx); |
577 |
+void dns_dyndb_arguments_destroy(isc_mem_t *mctx, dns_dyndb_arguments_t *args); |
578 |
+ |
579 |
+void dns_dyndb_set_view(dns_dyndb_arguments_t *args, dns_view_t *view); |
580 |
+dns_view_t *dns_dyndb_get_view(dns_dyndb_arguments_t *args); |
581 |
+void dns_dyndb_set_zonemgr(dns_dyndb_arguments_t *args, dns_zonemgr_t *zmgr); |
582 |
+dns_zonemgr_t *dns_dyndb_get_zonemgr(dns_dyndb_arguments_t *args); |
583 |
+void dns_dyndb_set_task(dns_dyndb_arguments_t *args, isc_task_t *task); |
584 |
+isc_task_t *dns_dyndb_get_task(dns_dyndb_arguments_t *args); |
585 |
+void dns_dyndb_set_timermgr(dns_dyndb_arguments_t *args, |
586 |
+ isc_timermgr_t *timermgr); |
587 |
+isc_timermgr_t *dns_dyndb_get_timermgr(dns_dyndb_arguments_t *args); |
588 |
+ |
589 |
+#endif |
590 |
diff -uNrp bind-9.8.4-P1.dyndb/lib/dns/include/dns/log.h bind-9.8.4-P1/lib/dns/include/dns/log.h |
591 |
--- bind-9.8.4-P1.dyndb/lib/dns/include/dns/log.h 2012-10-26 00:52:55.000000000 -0400 |
592 |
+++ bind-9.8.4-P1/lib/dns/include/dns/log.h 2012-12-05 09:24:45.305684490 -0500 |
593 |
@@ -76,6 +76,7 @@ LIBDNS_EXTERNAL_DATA extern isc_logmodul |
594 |
#define DNS_LOGMODULE_DLZ (&dns_modules[26]) |
595 |
#define DNS_LOGMODULE_DNSSEC (&dns_modules[27]) |
596 |
#define DNS_LOGMODULE_CRYPTO (&dns_modules[28]) |
597 |
+#define DNS_LOGMODULE_DYNDB (&dns_modules[29]) |
598 |
|
599 |
ISC_LANG_BEGINDECLS |
600 |
|
601 |
diff -uNrp bind-9.8.4-P1.dyndb/lib/dns/include/dns/Makefile.in bind-9.8.4-P1/lib/dns/include/dns/Makefile.in |
602 |
--- bind-9.8.4-P1.dyndb/lib/dns/include/dns/Makefile.in 2012-10-26 00:52:55.000000000 -0400 |
603 |
+++ bind-9.8.4-P1/lib/dns/include/dns/Makefile.in 2012-12-05 09:23:59.185685535 -0500 |
604 |
@@ -22,7 +22,7 @@ top_srcdir = @top_srcdir@ |
605 |
@BIND9_VERSION@ |
606 |
|
607 |
HEADERS = acl.h adb.h byaddr.h cache.h callbacks.h cert.h compress.h \ |
608 |
- db.h dbiterator.h dbtable.h diff.h dispatch.h dlz.h \ |
609 |
+ db.h dbiterator.h dbtable.h diff.h dispatch.h dlz.h dynamic_db.h \ |
610 |
dnssec.h ds.h events.h fixedname.h iptable.h journal.h \ |
611 |
keyflags.h keytable.h keyvalues.h lib.h log.h \ |
612 |
master.h masterdump.h message.h name.h ncache.h nsec.h \ |
613 |
diff -uNrp bind-9.8.4-P1.dyndb/lib/dns/include/dns/types.h bind-9.8.4-P1/lib/dns/include/dns/types.h |
614 |
--- bind-9.8.4-P1.dyndb/lib/dns/include/dns/types.h 2012-10-26 00:52:55.000000000 -0400 |
615 |
+++ bind-9.8.4-P1/lib/dns/include/dns/types.h 2012-12-05 09:23:59.195685534 -0500 |
616 |
@@ -60,6 +60,7 @@ typedef struct dns_dbtable dns_dbtable |
617 |
typedef void dns_dbversion_t; |
618 |
typedef struct dns_dlzimplementation dns_dlzimplementation_t; |
619 |
typedef struct dns_dlzdb dns_dlzdb_t; |
620 |
+typedef struct dns_dyndb_arguments dns_dyndb_arguments_t; |
621 |
typedef struct dns_sdlzimplementation dns_sdlzimplementation_t; |
622 |
typedef struct dns_decompress dns_decompress_t; |
623 |
typedef struct dns_dispatch dns_dispatch_t; |
624 |
diff -uNrp bind-9.8.4-P1.dyndb/lib/dns/log.c bind-9.8.4-P1/lib/dns/log.c |
625 |
--- bind-9.8.4-P1.dyndb/lib/dns/log.c 2012-10-26 00:52:55.000000000 -0400 |
626 |
+++ bind-9.8.4-P1/lib/dns/log.c 2012-12-05 09:25:30.955673615 -0500 |
627 |
@@ -82,6 +82,7 @@ LIBDNS_EXTERNAL_DATA isc_logmodule_t dns |
628 |
{ "dns/dlz", 0 }, |
629 |
{ "dns/dnssec", 0 }, |
630 |
{ "dns/crypto", 0 }, |
631 |
+ { "dns/dynamic_db", 0 }, |
632 |
{ NULL, 0 } |
633 |
}; |
634 |
|
635 |
diff -uNrp bind-9.8.4-P1.dyndb/lib/dns/Makefile.in bind-9.8.4-P1/lib/dns/Makefile.in |
636 |
--- bind-9.8.4-P1.dyndb/lib/dns/Makefile.in 2012-10-26 00:52:55.000000000 -0400 |
637 |
+++ bind-9.8.4-P1/lib/dns/Makefile.in 2012-12-05 09:23:59.195685534 -0500 |
638 |
@@ -59,7 +59,7 @@ DNSOBJS = acache.@O@ acl.@O@ adb.@O@ bya |
639 |
cache.@O@ callbacks.@O@ compress.@O@ \ |
640 |
db.@O@ dbiterator.@O@ dbtable.@O@ diff.@O@ dispatch.@O@ \ |
641 |
dlz.@O@ dns64.@O@ dnssec.@O@ ds.@O@ forward.@O@ iptable.@O@ \ |
642 |
- journal.@O@ keydata.@O@ keytable.@O@ \ |
643 |
+ dynamic_db.@O@ journal.@O@ keydata.@O@ keytable.@O@ \ |
644 |
lib.@O@ log.@O@ lookup.@O@ \ |
645 |
master.@O@ masterdump.@O@ message.@O@ \ |
646 |
name.@O@ ncache.@O@ nsec.@O@ nsec3.@O@ order.@O@ peer.@O@ \ |
647 |
@@ -88,7 +88,7 @@ DNSSRCS = acache.c acl.c adb.c byaddr.c |
648 |
cache.c callbacks.c compress.c \ |
649 |
db.c dbiterator.c dbtable.c diff.c dispatch.c \ |
650 |
dlz.c dns64.c dnssec.c ds.c forward.c iptable.c journal.c \ |
651 |
- keydata.c keytable.c lib.c log.c lookup.c \ |
652 |
+ dynamic_db.c keydata.c keytable.c lib.c log.c lookup.c \ |
653 |
master.c masterdump.c message.c \ |
654 |
name.c ncache.c nsec.c nsec3.c order.c peer.c portlist.c \ |
655 |
rbt.c rbtdb.c rbtdb64.c rcode.c rdata.c rdatalist.c \ |
656 |
@@ -119,6 +119,11 @@ version.@O@: version.c |
657 |
-DLIBAGE=${LIBAGE} \ |
658 |
-c ${srcdir}/version.c |
659 |
|
660 |
+dynamic_db.@O@: dynamic_db.c |
661 |
+ ${LIBTOOL_MODE_COMPILE} ${CC} ${ALL_CFLAGS} \ |
662 |
+ -DDYNDB_LIBDIR=\"@libdir@/bind/\" \ |
663 |
+ -c ${srcdir}/dynamic_db.c |
664 |
+ |
665 |
libdns.@SA@: ${OBJS} |
666 |
${AR} ${ARFLAGS} $@ ${OBJS} |
667 |
${RANLIB} $@ |
668 |
diff -uNrp bind-9.8.4-P1.dyndb/lib/isccfg/namedconf.c bind-9.8.4-P1/lib/isccfg/namedconf.c |
669 |
--- bind-9.8.4-P1.dyndb/lib/isccfg/namedconf.c 2012-10-26 00:52:55.000000000 -0400 |
670 |
+++ bind-9.8.4-P1/lib/isccfg/namedconf.c 2012-12-05 09:23:59.205685533 -0500 |
671 |
@@ -89,6 +89,7 @@ static cfg_type_t cfg_type_controls; |
672 |
static cfg_type_t cfg_type_controls_sockaddr; |
673 |
static cfg_type_t cfg_type_destinationlist; |
674 |
static cfg_type_t cfg_type_dialuptype; |
675 |
+static cfg_type_t cfg_type_dynamic_db; |
676 |
static cfg_type_t cfg_type_ixfrdifftype; |
677 |
static cfg_type_t cfg_type_key; |
678 |
static cfg_type_t cfg_type_logfile; |
679 |
@@ -860,6 +861,7 @@ namedconf_or_view_clauses[] = { |
680 |
{ "zone", &cfg_type_zone, CFG_CLAUSEFLAG_MULTI }, |
681 |
/* only 1 DLZ per view allowed */ |
682 |
{ "dlz", &cfg_type_dynamically_loadable_zones, 0 }, |
683 |
+ { "dynamic-db", &cfg_type_dynamic_db, CFG_CLAUSEFLAG_MULTI }, |
684 |
{ "server", &cfg_type_server, CFG_CLAUSEFLAG_MULTI }, |
685 |
{ "trusted-keys", &cfg_type_dnsseckeys, CFG_CLAUSEFLAG_MULTI }, |
686 |
{ "managed-keys", &cfg_type_managedkeys, CFG_CLAUSEFLAG_MULTI }, |
687 |
@@ -1966,6 +1968,40 @@ static cfg_type_t cfg_type_dialuptype = |
688 |
&cfg_rep_string, dialup_enums |
689 |
}; |
690 |
|
691 |
+/* |
692 |
+ * Dynamic database clauses. |
693 |
+ */ |
694 |
+ |
695 |
+static cfg_clausedef_t |
696 |
+dynamic_db_clauses[] = { |
697 |
+ { "library", &cfg_type_qstring, 0 }, |
698 |
+ { "arg", &cfg_type_qstring, CFG_CLAUSEFLAG_MULTI }, |
699 |
+ { NULL, NULL, 0 } |
700 |
+}; |
701 |
+ |
702 |
+static cfg_clausedef_t * |
703 |
+dynamic_db_clausesets[] = { |
704 |
+ dynamic_db_clauses, |
705 |
+ NULL |
706 |
+}; |
707 |
+ |
708 |
+static cfg_type_t cfg_type_dynamic_db_opts = { |
709 |
+ "dynamically_loadable_zones_opts", cfg_parse_map, |
710 |
+ cfg_print_map, cfg_doc_map, &cfg_rep_map, |
711 |
+ dynamic_db_clausesets |
712 |
+}; |
713 |
+ |
714 |
+static cfg_tuplefielddef_t dynamic_db_fields[] = { |
715 |
+ { "name", &cfg_type_astring, 0 }, |
716 |
+ { "options", &cfg_type_dynamic_db_opts, 0 }, |
717 |
+ { NULL, NULL, 0 } |
718 |
+}; |
719 |
+ |
720 |
+static cfg_type_t cfg_type_dynamic_db = { |
721 |
+ "dynamic_db", cfg_parse_tuple, cfg_print_tuple, cfg_doc_tuple, |
722 |
+ &cfg_rep_tuple, dynamic_db_fields |
723 |
+}; |
724 |
+ |
725 |
static const char *notify_enums[] = { "explicit", "master-only", NULL }; |
726 |
static isc_result_t |
727 |
parse_notify_type(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret) { |