OpenDNSSEC-signer 2.1.10
signercommands.c
Go to the documentation of this file.
1#include "config.h"
2
3#include "file.h"
4#include "str.h"
5#include "locks.h"
6#include "log.h"
7#include "status.h"
8#include "util.h"
9#include "daemon/engine.h"
10#include "cmdhandler.h"
11#include "signercommands.h"
12#include "clientpipe.h"
13
14static char const * cmdh_str = "cmdhandler";
15
16static const char*
17cmdargument(const char* cmd, const char* matchValue, const char* defaultValue)
18{
19 const char* s = cmd;
20 if (!s)
21 return defaultValue;
22 while(*s && !isspace(*s))
23 ++s;
24 while(*s && isspace(*s))
25 ++s;
26 if(matchValue) {
27 if (!strcmp(s,matchValue))
28 return s;
29 else
30 return defaultValue;
31 } else if(*s) {
32 return s;
33 } else {
34 return defaultValue;
35 }
36}
37
42static int
43cmdhandler_handle_cmd_help(int sockfd, cmdhandler_ctx_type* context, const char *cmd)
44{
45 char buf[ODS_SE_MAXLINE];
46
47 (void) snprintf(buf, ODS_SE_MAXLINE,
48 "Commands:\n"
49 "zones Show the currently known zones.\n"
50 "sign <zone> [--serial <nr>] Read zone and schedule for immediate "
51 "(re-)sign.\n"
52 " If a serial is given, that serial is used "
53 "in the output zone.\n"
54 "sign --all Read all zones and schedule all for "
55 "immediate (re-)sign.\n"
56 );
57 client_printf(sockfd, "%s", buf);
58
59 (void) snprintf(buf, ODS_SE_MAXLINE,
60 "clear <zone> Delete the internal storage of this "
61 "zone.\n"
62 " All signatures will be regenerated "
63 "on the next re-sign.\n"
64 "queue Show the current task queue.\n"
65 "flush Execute all scheduled tasks "
66 "immediately.\n"
67 );
68 client_printf(sockfd, "%s", buf);
69
70 (void) snprintf(buf, ODS_SE_MAXLINE,
71 "update <zone> Update this zone signer "
72 "configurations.\n"
73 "update [--all] Update zone list and all signer "
74 "configurations.\n"
75 "retransfer <zone> Retransfer the zone from the master.\n"
76 "start Start the engine.\n"
77 "running Check if the engine is running.\n"
78 "reload Reload the engine.\n"
79 "stop Stop the engine.\n"
80 "verbosity <nr> Set verbosity.\n"
81 );
82 client_printf(sockfd, "%s", buf);
83 return 0;
84}
85
86
91static int
92cmdhandler_handle_cmd_zones(int sockfd, cmdhandler_ctx_type* context, const char *cmd)
93{
94 engine_type* engine;
95 char buf[ODS_SE_MAXLINE];
96 size_t i;
97 ldns_rbnode_t* node = LDNS_RBTREE_NULL;
98 zone_type* zone = NULL;
99 engine = getglobalcontext(context);
100 if (!engine->zonelist || !engine->zonelist->zones) {
101 (void)snprintf(buf, ODS_SE_MAXLINE, "There are no zones configured\n");
102 client_printf(sockfd, "%s", buf);
103 return 0;
104 }
105 /* how many zones */
106 pthread_mutex_lock(&engine->zonelist->zl_lock);
107 (void)snprintf(buf, ODS_SE_MAXLINE, "There are %i zones configured\n",
108 (int) engine->zonelist->zones->count);
109 client_printf(sockfd, "%s", buf);
110 /* list zones */
111 node = ldns_rbtree_first(engine->zonelist->zones);
112 while (node && node != LDNS_RBTREE_NULL) {
113 zone = (zone_type*) node->data;
114 for (i=0; i < ODS_SE_MAXLINE; i++) {
115 buf[i] = 0;
116 }
117 (void)snprintf(buf, ODS_SE_MAXLINE, "- %s\n", zone->name);
118 client_printf(sockfd, "%s", buf);
119 node = ldns_rbtree_next(node);
120 }
121 pthread_mutex_unlock(&engine->zonelist->zl_lock);
122 return 0;
123}
124
125
130static int
131cmdhandler_handle_cmd_update(int sockfd, cmdhandler_ctx_type* context, const char *cmd)
132{
133 engine_type* engine;
134 char buf[ODS_SE_MAXLINE];
135 ods_status status = ODS_STATUS_OK;
136 zone_type* zone = NULL;
137 ods_status zl_changed = ODS_STATUS_OK;
138 engine = getglobalcontext(context);
139 ods_log_assert(engine->taskq);
140 if (cmdargument(cmd, "--all", NULL)) {
141 pthread_mutex_lock(&engine->zonelist->zl_lock);
142 zl_changed = zonelist_update(engine->zonelist,
143 engine->config->zonelist_filename);
144 if (zl_changed == ODS_STATUS_UNCHANGED) {
145 (void)snprintf(buf, ODS_SE_MAXLINE, "Zone list has not changed."
146 " Signer configurations updated.\n");
147 client_printf(sockfd, "%s", buf);
148 } else if (zl_changed == ODS_STATUS_OK) {
149 (void)snprintf(buf, ODS_SE_MAXLINE, "Zone list updated: %i "
150 "removed, %i added, %i updated.\n",
151 engine->zonelist->just_removed,
152 engine->zonelist->just_added,
153 engine->zonelist->just_updated);
154 client_printf(sockfd, "%s", buf);
155 } else {
156 pthread_mutex_unlock(&engine->zonelist->zl_lock);
157 (void)snprintf(buf, ODS_SE_MAXLINE, "Zone list has errors.\n");
158 client_printf(sockfd, "%s", buf);
159 }
160 if (zl_changed == ODS_STATUS_OK ||
161 zl_changed == ODS_STATUS_UNCHANGED) {
162 engine->zonelist->just_removed = 0;
163 engine->zonelist->just_added = 0;
164 engine->zonelist->just_updated = 0;
165 pthread_mutex_unlock(&engine->zonelist->zl_lock);
170 engine_update_zones(engine, ODS_STATUS_OK);
171 }
172 } else {
173 /* look up zone */
174 pthread_mutex_lock(&engine->zonelist->zl_lock);
175 zone = zonelist_lookup_zone_by_name(engine->zonelist, cmdargument(cmd, NULL, ""),
176 LDNS_RR_CLASS_IN);
177 /* If this zone is just added, don't update (it might not have a
178 * task yet) */
179 if (zone && zone->zl_status == ZONE_ZL_ADDED) {
180 zone = NULL;
181 }
182 pthread_mutex_unlock(&engine->zonelist->zl_lock);
183
184 if (!zone) {
185 (void)snprintf(buf, ODS_SE_MAXLINE, "Error: Zone %s not found.\n",
186 cmdargument(cmd, NULL, ""));
187 client_printf(sockfd, "%s", buf);
188 /* update all */
189 cmdhandler_handle_cmd_update(sockfd, context, "update --all");
190 return 1;
191 }
192
193 pthread_mutex_lock(&zone->zone_lock);
194 schedule_scheduletask(engine->taskq, TASK_FORCESIGNCONF, zone->name, zone, &zone->zone_lock, schedule_PROMPTLY);
195 pthread_mutex_unlock(&zone->zone_lock);
196
197 (void)snprintf(buf, ODS_SE_MAXLINE, "Zone %s config being updated.\n",
198 cmdargument(cmd, NULL, ""));
199 client_printf(sockfd, "%s", buf);
200 ods_log_verbose("[%s] zone %s scheduled for immediate update signconf",
201 cmdh_str, cmdargument(cmd, NULL, ""));
202 engine_wakeup_workers(engine);
203 }
204 return 0;
205}
206
207
212static int
213cmdhandler_handle_cmd_retransfer(int sockfd, cmdhandler_ctx_type* context, const char *cmd)
214{
215 engine_type* engine;
216 char buf[ODS_SE_MAXLINE];
217 zone_type* zone = NULL;
218 engine = getglobalcontext(context);
219 ods_log_assert(engine->taskq);
220 /* look up zone */
221 pthread_mutex_lock(&engine->zonelist->zl_lock);
222 zone = zonelist_lookup_zone_by_name(engine->zonelist, cmdargument(cmd, NULL, ""),
223 LDNS_RR_CLASS_IN);
224 /* If this zone is just added, don't retransfer (it might not have a
225 * task yet) */
226 if (zone && zone->zl_status == ZONE_ZL_ADDED) {
227 zone = NULL;
228 }
229 pthread_mutex_unlock(&engine->zonelist->zl_lock);
230
231 if (!zone) {
232 (void)snprintf(buf, ODS_SE_MAXLINE, "Error: Zone %s not found.\n",
233 cmdargument(cmd, NULL, ""));
234 client_printf(sockfd, "%s", buf);
235 } else if (zone->adinbound->type != ADAPTER_DNS) {
236 (void)snprintf(buf, ODS_SE_MAXLINE,
237 "Error: Zone %s not configured to use DNS input adapter.\n",
238 cmdargument(cmd, NULL, ""));
239 client_printf(sockfd, "%s", buf);
240 } else {
241 zone->xfrd->serial_retransfer = 1;
243 ods_log_debug("[%s] forward a notify", cmdh_str);
245 (uint8_t*) ODS_SE_NOTIFY_CMD, strlen(ODS_SE_NOTIFY_CMD));
246 (void)snprintf(buf, ODS_SE_MAXLINE, "Zone %s being re-transfered.\n", cmdargument(cmd, NULL, ""));
247 client_printf(sockfd, "%s", buf);
248 ods_log_verbose("[%s] zone %s being re-transfered", cmdh_str, cmdargument(cmd, NULL, ""));
249 }
250 return 0;
251}
252
253
254static uint32_t
255max(uint32_t a, uint32_t b)
256{
257 return (a<b?b:a);
258}
259
260static ods_status
261forceread(engine_type* engine, zone_type *zone, int force_serial, uint32_t serial, int sockfd)
262{
263 pthread_mutex_lock(&zone->zone_lock);
264 if (force_serial) {
265 ods_log_assert(zone->db);
266 if (!util_serial_gt(serial, max(zone->db->outserial,
267 zone->db->inbserial))) {
268 pthread_mutex_unlock(&zone->zone_lock);
269 client_printf(sockfd, "Error: Unable to enforce serial %u for zone %s.\n", serial, zone->name);
270 return 1;
271 }
272 zone->db->altserial = serial;
273 zone->db->force_serial = 1;
274 }
275 schedule_scheduletask(engine->taskq, TASK_FORCEREAD, zone->name, zone, &zone->zone_lock, schedule_IMMEDIATELY);
276 pthread_mutex_unlock(&zone->zone_lock);
277 return 0;
278}
279
284static int
285cmdhandler_handle_cmd_sign(int sockfd, cmdhandler_ctx_type* context, const char *cmd)
286{
287 engine_type* engine;
288 zone_type *zone = NULL;
289 ods_status status = ODS_STATUS_OK;
290 char buf[ODS_SE_MAXLINE];
291
292 engine = getglobalcontext(context);
293 ods_log_assert(engine->taskq);
294 if (cmdargument(cmd, "--all", NULL)) {
295 pthread_mutex_lock(&engine->zonelist->zl_lock);
296 ldns_rbnode_t* node;
297 for (node = ldns_rbtree_first(engine->zonelist->zones); node != LDNS_RBTREE_NULL && node != NULL; node = ldns_rbtree_next(node)) {
298 zone = (zone_type*)node->data;
299 forceread(engine, zone, 0, 0, sockfd);
300 }
301 pthread_mutex_unlock(&engine->zonelist->zl_lock);
302 engine_wakeup_workers(engine);
303 client_printf(sockfd, "All zones scheduled for immediate re-sign.\n");
304 } else {
305 char* delim1 = strchr(cmdargument(cmd, NULL, ""), ' ');
306 char* delim2 = NULL;
307 int force_serial = 0;
308 uint32_t serial = 0;
309 if (delim1) {
310 char* end = NULL;
312 if (strncmp(delim1+1, "--serial ", 9) != 0) {
313 (void)snprintf(buf, ODS_SE_MAXLINE, "Error: Expecting <zone> "
314 "--serial <nr>, got %s.\n", cmdargument(cmd, NULL, ""));
315 client_printf(sockfd, "%s", buf);
316 return -1;
317 }
318 delim2 = strchr(delim1+1, ' ');
319 if (!delim2) {
320 (void)snprintf(buf, ODS_SE_MAXLINE, "Error: Expecting serial.\n");
321 client_printf(sockfd, "%s", buf);
322 return -1;
323 }
324 serial = (uint32_t) strtol(delim2+1, &end, 10);
325 if (*end != '\0') {
326 (void)snprintf(buf, ODS_SE_MAXLINE, "Error: Expecting serial, "
327 "got %s.\n", delim2+1);
328 client_printf(sockfd, "%s", buf);
329 return -1;
330 }
331 force_serial = 1;
332 *delim1 = '\0';
333 }
334 pthread_mutex_lock(&engine->zonelist->zl_lock);
335 zone = zonelist_lookup_zone_by_name(engine->zonelist, cmdargument(cmd, NULL, ""),
336 LDNS_RR_CLASS_IN);
337 /* If this zone is just added, don't update (it might not have a task
338 * yet).
339 */
340 if (zone && zone->zl_status == ZONE_ZL_ADDED) {
341 zone = NULL;
342 }
343 pthread_mutex_unlock(&engine->zonelist->zl_lock);
344
345 if (!zone) {
346 (void)snprintf(buf, ODS_SE_MAXLINE, "Error: Zone %s not found.\n",
347 cmdargument(cmd, NULL, ""));
348 client_printf(sockfd, "%s", buf);
349 return 1;
350 }
351
352 forceread(engine, zone, force_serial, serial, sockfd);
353 engine_wakeup_workers(engine);
354 client_printf(sockfd, "Zone %s scheduled for immediate re-sign.\n", cmdargument(cmd, NULL, ""));
355 ods_log_verbose("zone %s scheduled for immediate re-sign", cmdargument(cmd, NULL, ""));
356 }
357 return 0;
358}
359
364static void
365unlink_backup_file(const char* filename, const char* extension)
366{
367 char* tmpname = ods_build_path(filename, extension, 0, 1);
368 if (tmpname) {
369 ods_log_debug("[%s] unlink file %s", cmdh_str, tmpname);
370 unlink(tmpname);
371 free((void*)tmpname);
372 }
373}
374
379static int
380cmdhandler_handle_cmd_clear(int sockfd, cmdhandler_ctx_type* context, const char *cmd)
381{
382 engine_type* engine;
383 char buf[ODS_SE_MAXLINE];
384 zone_type* zone = NULL;
385 uint32_t inbserial = 0;
386 uint32_t intserial = 0;
387 uint32_t outserial = 0;
388 engine = getglobalcontext(context);
389 unlink_backup_file(cmdargument(cmd, NULL, ""), ".inbound");
390 unlink_backup_file(cmdargument(cmd, NULL, ""), ".backup");
391 unlink_backup_file(cmdargument(cmd, NULL, ""), ".axfr");
392 unlink_backup_file(cmdargument(cmd, NULL, ""), ".ixfr");
393 pthread_mutex_lock(&engine->zonelist->zl_lock);
394 zone = zonelist_lookup_zone_by_name(engine->zonelist, cmdargument(cmd, NULL, ""),
395 LDNS_RR_CLASS_IN);
396 pthread_mutex_unlock(&engine->zonelist->zl_lock);
397 if (zone) {
398 pthread_mutex_lock(&zone->zone_lock);
399 inbserial = zone->db->inbserial;
400 intserial = zone->db->intserial;
401 outserial = zone->db->outserial;
402 namedb_cleanup(zone->db);
403 ixfr_cleanup(zone->ixfr);
405
406 zone->db = namedb_create((void*)zone);
407 zone->ixfr = ixfr_create();
408 zone->signconf = signconf_create();
409
410 if (!zone->signconf || !zone->ixfr || !zone->db) {
411 ods_fatal_exit("[%s] unable to clear zone %s: failed to recreate"
412 "signconf, ixfr of db structure (out of memory?)", cmdh_str, cmdargument(cmd, NULL, ""));
413 return 1;
414 }
415 /* restore serial management */
416 zone->db->inbserial = inbserial;
417 zone->db->intserial = intserial;
418 zone->db->outserial = outserial;
419 zone->db->have_serial = 1;
420
421 /* If a zone does not have a task we probably never read a signconf
422 * for it. Skip reschedule step */
423 schedule_scheduletask(engine->taskq, TASK_FORCESIGNCONF, zone->name, zone, &zone->zone_lock, schedule_IMMEDIATELY);
424 pthread_mutex_unlock(&zone->zone_lock);
425
426 (void)snprintf(buf, ODS_SE_MAXLINE, "Internal zone information about "
427 "%s cleared", cmdargument(cmd, NULL, ""));
428 ods_log_info("[%s] internal zone information about %s cleared",
429 cmdh_str, cmdargument(cmd, NULL, ""));
430 } else {
431 (void)snprintf(buf, ODS_SE_MAXLINE, "Cannot clear zone %s, zone not "
432 "found", cmdargument(cmd, NULL, ""));
433 ods_log_warning("[%s] cannot clear zone %s, zone not found",
434 cmdh_str, cmdargument(cmd, NULL, ""));
435 }
436 client_printf(sockfd, "%s", buf);
437 return 0;
438}
439
440
445static int
446cmdhandler_handle_cmd_queue(int sockfd, cmdhandler_ctx_type* context, const char *cmd)
447{
448 engine_type* engine;
449 char* strtime = NULL;
450 char buf[ODS_SE_MAXLINE];
451 char* taskdesc;
452 size_t i = 0;
453 time_t now = 0;
454 ldns_rbnode_t* node = LDNS_RBTREE_NULL;
455 task_type* task = NULL;
456 engine = getglobalcontext(context);
457 if (!engine->taskq || !engine->taskq->tasks) {
458 (void)snprintf(buf, ODS_SE_MAXLINE, "There are no tasks scheduled.\n");
459 client_printf(sockfd, "%s", buf);
460 return 0;
461 }
462 /* current time */
463 now = time_now();
464 strtime = ctime(&now);
465 (void)snprintf(buf, ODS_SE_MAXLINE, "It is now %s",
466 strtime?strtime:"(null)");
467 client_printf(sockfd, "%s", buf);
468 /* current work */
469 pthread_mutex_lock(&engine->taskq->schedule_lock);
470 /* how many tasks */
471 (void)snprintf(buf, ODS_SE_MAXLINE, "\nThere are %i tasks scheduled.\n",
472 (int) engine->taskq->tasks->count);
473 client_printf(sockfd, "%s", buf);
474 /* list tasks */
475 node = ldns_rbtree_first(engine->taskq->tasks);
476 while (node && node != LDNS_RBTREE_NULL) {
477 task = (task_type*) node->data;
478 for (i=0; i < ODS_SE_MAXLINE; i++) {
479 buf[i] = 0;
480 }
481 taskdesc = schedule_describetask(task);
482 client_printf(sockfd, "%s", taskdesc);
483 free(taskdesc);
484 node = ldns_rbtree_next(node);
485 }
486 pthread_mutex_unlock(&engine->taskq->schedule_lock);
487 return 0;
488}
489
490
495static int
496cmdhandler_handle_cmd_flush(int sockfd, cmdhandler_ctx_type* context, const char *cmd)
497{
498 engine_type* engine;
499 char buf[ODS_SE_MAXLINE];
500 engine = getglobalcontext(context);
501 ods_log_assert(engine->taskq);
502 schedule_flush(engine->taskq);
503 engine_wakeup_workers(engine);
504 (void)snprintf(buf, ODS_SE_MAXLINE, "All tasks scheduled immediately.\n");
505 client_printf(sockfd, "%s", buf);
506 ods_log_verbose("[%s] all tasks scheduled immediately", cmdh_str);
507 return 0;
508}
509
510
515static int
516cmdhandler_handle_cmd_reload(int sockfd, cmdhandler_ctx_type* context, const char *cmd)
517{
518 engine_type* engine;
519 char buf[ODS_SE_MAXLINE];
520 engine = getglobalcontext(context);
521 ods_log_error("signer instructed to reload due to explicit command");
522 engine->need_to_reload = 1;
523 pthread_mutex_lock(&engine->signal_lock);
524 pthread_cond_signal(&engine->signal_cond);
525 pthread_mutex_unlock(&engine->signal_lock);
526 (void)snprintf(buf, ODS_SE_MAXLINE, "Reloading engine.\n");
527 client_printf(sockfd, "%s", buf);
528 return 0;
529}
530
531
536static int
537cmdhandler_handle_cmd_stop(int sockfd, cmdhandler_ctx_type* context, const char *cmd)
538{
539 engine_type* engine;
540 char buf[ODS_SE_MAXLINE];
541 engine = getglobalcontext(context);
542 engine->need_to_exit = 1;
543 pthread_mutex_lock(&engine->signal_lock);
544 pthread_cond_signal(&engine->signal_cond);
545 pthread_mutex_unlock(&engine->signal_lock);
546 (void)snprintf(buf, ODS_SE_MAXLINE, ODS_SE_STOP_RESPONSE);
547 client_printf(sockfd, "%s", buf);
548 return 0;
549}
550
551
556static int
557cmdhandler_handle_cmd_start(int sockfd, cmdhandler_ctx_type* context, const char *cmd)
558{
559 char buf[ODS_SE_MAXLINE];
560 (void)snprintf(buf, ODS_SE_MAXLINE, "Engine already running.\n");
561 client_printf(sockfd, "%s", buf);
562 return 0;
563}
564
565
570static int
571cmdhandler_handle_cmd_running(int sockfd, cmdhandler_ctx_type* context, const char *cmd)
572{
573 char buf[ODS_SE_MAXLINE];
574 (void)snprintf(buf, ODS_SE_MAXLINE, "Engine running.\n");
575 client_printf(sockfd, "%s", buf);
576 return 0;
577}
578
579
584static int
585cmdhandler_handle_cmd_verbosity(int sockfd, cmdhandler_ctx_type* context, const char *cmd)
586{
587 char buf[ODS_SE_MAXLINE];
588 int val;
589 val = atoi(cmdargument(cmd, NULL, "1"));
590 ods_log_setverbosity(val);
591 (void)snprintf(buf, ODS_SE_MAXLINE, "Verbosity level set to %i.\n", val);
592 client_printf(sockfd, "%s", buf);
593 return 0;
594}
595
596
601static void
602cmdhandler_handle_cmd_error(int sockfd, cmdhandler_ctx_type* context, const char* str)
603{
604 char buf[ODS_SE_MAXLINE];
605 (void)snprintf(buf, ODS_SE_MAXLINE, "Error: %s.\n", str?str:"(null)");
606 client_printf(sockfd, "%s", buf);
607}
608
609
614static void
615cmdhandler_handle_cmd_unknown(int sockfd, cmdhandler_ctx_type* context, const char* str)
616{
617 char buf[ODS_SE_MAXLINE];
618 (void)snprintf(buf, ODS_SE_MAXLINE, "Unknown command %s.\n",
619 str?str:"(null)");
620 client_printf(sockfd, "%s", buf);
621}
622
623
628static int
629cmdhandler_handle_cmd_timeleap(int sockfd, cmdhandler_ctx_type* context, char *cmd)
630{
631 struct tm strtime_struct;
632 char strtime[64]; /* at least 26 according to docs plus a long integer */
633 time_t now = time_now();
634 time_t time_leap = 0;
635 time_t next_leap = 0;
636 struct tm tm;
637 int taskcount;
638 engine_type* engine = getglobalcontext(context);
639
640 /* skip "time" and "leap" */
641 while(isspace(*cmd)) ++cmd;
642 cmd = &cmd[4];
643 while(isspace(*cmd)) ++cmd;
644 cmd = &cmd[4];
645 while(isspace(*cmd)) ++cmd;
646
647 if (strptime(cmd, "%Y-%m-%d-%H:%M:%S", &tm)) {
648 tm.tm_isdst = -1;
649 time_leap = mktime(&tm);
650 client_printf(sockfd, "Using %s parameter value as time to leap to\n", cmd);
651 } else {
652 client_printf_err(sockfd, "Time leap: Error - could not convert '%s' to a time. Format is YYYY-MM-DD-HH:MM:SS \n", cmd);
653 return -1;
654 }
655 if (!engine->taskq || !engine->taskq->tasks) {
656 client_printf(sockfd, "There are no tasks scheduled.\n");
657 return 1;
658 }
659 schedule_info(engine->taskq, &next_leap, NULL, &taskcount);
660 now = time_now();
661 strftime(strtime, sizeof (strtime), "%c", localtime_r(&now, &strtime_struct));
662 client_printf(sockfd, "There are %i tasks scheduled.\nIt is now %s (%ld seconds since epoch)\n", taskcount, strtime, (long) now);
663 set_time_now(time_leap);
664 strftime(strtime, sizeof (strtime), "%c", localtime_r(&time_leap, &strtime_struct));
665 client_printf(sockfd, "Leaping to time %s (%ld seconds since epoch)\n", (strtime[0] ? strtime : "(null)"), (long) time_leap);
666 ods_log_info("Time leap: Leaping to time %s\n", strtime);
667 client_printf(sockfd, "Waking up workers\n");
668 engine_wakeup_workers(engine);
669 return 0;
670}
671
672struct cmd_func_block helpCmdDef = { "help", NULL, NULL, NULL, &cmdhandler_handle_cmd_help };
673struct cmd_func_block zonesCmdDef = { "zones", NULL, NULL, NULL, &cmdhandler_handle_cmd_zones };
674struct cmd_func_block signCmdDef = { "sign", NULL, NULL, NULL, &cmdhandler_handle_cmd_sign };
675struct cmd_func_block clearCmdDef = { "clear", NULL, NULL, NULL, &cmdhandler_handle_cmd_clear };
676struct cmd_func_block queueCmdDef = { "queue", NULL, NULL, NULL, &cmdhandler_handle_cmd_queue };
677struct cmd_func_block flushCmdDef = { "flush", NULL, NULL, NULL, &cmdhandler_handle_cmd_flush };
678struct cmd_func_block updateCmdDef = { "update", NULL, NULL, NULL, &cmdhandler_handle_cmd_update };
679struct cmd_func_block stopCmdDef = { "stop", NULL, NULL, NULL, &cmdhandler_handle_cmd_stop };
680struct cmd_func_block startCmdDef = { "start", NULL, NULL, NULL, &cmdhandler_handle_cmd_start };
681struct cmd_func_block reloadCmdDef = { "reload", NULL, NULL, NULL, &cmdhandler_handle_cmd_reload };
682struct cmd_func_block retransferCmdDef = { "retransfer", NULL, NULL, NULL, &cmdhandler_handle_cmd_retransfer };
683struct cmd_func_block runningCmdDef = { "running", NULL, NULL, NULL, &cmdhandler_handle_cmd_running };
684struct cmd_func_block verbosityCmdDef = { "verbosity", NULL, NULL, NULL, &cmdhandler_handle_cmd_verbosity };
685struct cmd_func_block timeleapCmdDef = { "time leap", NULL, NULL, NULL, &cmdhandler_handle_cmd_timeleap };
686
687struct cmd_func_block* signcommands[] = {
688 &helpCmdDef,
690 &signCmdDef,
695 &stopCmdDef,
702 NULL
703};
704struct cmd_func_block** signercommands = signcommands;
705
707getglobalcontext(cmdhandler_ctx_type* context)
708{
709 return (engine_type*) context->globalcontext;
710}
@ ADAPTER_DNS
Definition: adapter.h:42
void dnshandler_fwd_notify(dnshandler_type *dnshandler, uint8_t *pkt, size_t len)
Definition: dnshandler.c:231
#define ODS_SE_NOTIFY_CMD
Definition: dnshandler.h:48
void engine_wakeup_workers(engine_type *engine)
Definition: engine.c:290
void engine_update_zones(engine_type *engine, ods_status zl_changed)
Definition: engine.c:616
void ixfr_cleanup(ixfr_type *ixfr)
Definition: ixfr.c:279
ixfr_type * ixfr_create()
Definition: ixfr.c:91
namedb_type * namedb_create(void *zone)
Definition: namedb.c:121
void namedb_cleanup(namedb_type *db)
Definition: namedb.c:1131
void signconf_cleanup(signconf_type *sc)
Definition: signconf.c:470
signconf_type * signconf_create(void)
Definition: signconf.c:47
struct cmd_func_block zonesCmdDef
struct cmd_func_block verbosityCmdDef
struct cmd_func_block startCmdDef
struct cmd_func_block signCmdDef
struct cmd_func_block retransferCmdDef
struct cmd_func_block * signcommands[]
struct cmd_func_block flushCmdDef
struct cmd_func_block timeleapCmdDef
struct cmd_func_block clearCmdDef
struct cmd_func_block reloadCmdDef
struct cmd_func_block queueCmdDef
engine_type * getglobalcontext(cmdhandler_ctx_type *context)
struct cmd_func_block helpCmdDef
struct cmd_func_block ** signercommands
struct cmd_func_block stopCmdDef
struct cmd_func_block runningCmdDef
struct cmd_func_block updateCmdDef
adapter_mode type
Definition: adapter.h:58
zonelist_type * zonelist
Definition: engine.h:69
schedule_type * taskq
Definition: engine.h:54
pthread_mutex_t signal_lock
Definition: engine.h:67
pthread_cond_t signal_cond
Definition: engine.h:66
int need_to_reload
Definition: engine.h:63
int need_to_exit
Definition: engine.h:62
dnshandler_type * dnshandler
Definition: engine.h:70
engineconfig_type * config
Definition: engine.h:52
const char * zonelist_filename
Definition: cfg.h:49
unsigned have_serial
Definition: namedb.h:60
uint32_t intserial
Definition: namedb.h:54
uint32_t inbserial
Definition: namedb.h:53
uint32_t altserial
Definition: namedb.h:56
unsigned force_serial
Definition: namedb.h:59
uint32_t outserial
Definition: namedb.h:55
uint8_t serial_retransfer
Definition: xfrd.h:119
signconf_type * signconf
Definition: zone.h:77
namedb_type * db
Definition: zone.h:79
adapter_type * adinbound
Definition: zone.h:74
ixfr_type * ixfr
Definition: zone.h:80
zone_zl_status zl_status
Definition: zone.h:72
xfrd_type * xfrd
Definition: zone.h:82
const char * name
Definition: zone.h:69
pthread_mutex_t zone_lock
Definition: zone.h:86
int just_updated
Definition: zonelist.h:48
int just_removed
Definition: zonelist.h:49
pthread_mutex_t zl_lock
Definition: zonelist.h:50
ldns_rbtree_t * zones
Definition: zonelist.h:45
void xfrd_set_timer_now(xfrd_type *xfrd)
Definition: xfrd.c:454
@ ZONE_ZL_ADDED
Definition: zone.h:35
ods_status zonelist_update(zonelist_type *zl, const char *zlfile)
Definition: zonelist.c:342
zone_type * zonelist_lookup_zone_by_name(zonelist_type *zonelist, const char *name, ldns_rr_class klass)
Definition: zonelist.c:157