34#include "cmdhandler.h"
38#include "clientpipe.h"
39#include "longgetopt.h"
46static const char *module_str =
"zonelist_import_cmd";
53 " [--remove-missing-zones] aka -r\n"
56 " [--file <absolute path>] aka -f\n"
64 "Import zones from zonelist.xml into enforcer database.\n"
66 "remove-missing-zones Remove any zones from database not existed in zonelist file\n"
67 "file File to import, instead of zonelist file configured in conf.xml\n\n"
72run(cmdhandler_ctx_type* context,
int argc,
char* argv[])
74 int sockfd = context->sockfd;
75 struct longgetopt optctx;
77 int ret, remove_missing_zones = 0;
78 int long_index = 0, opt = 0;
79 const char* zonelist_path = NULL;
83 static struct option long_options[] = {
84 {
"remove-missing-zones", no_argument, 0,
'r'},
85 {
"file", required_argument, 0,
'f'},
89 if (!engine || !engine->
config ||
95 for(opt = longgetopt(argc, argv,
"rf:", long_options, &long_index, &optctx); opt != -1;
96 opt = longgetopt(argc, argv, NULL, long_options, &long_index, &optctx)) {
99 remove_missing_zones = 1;
102 zonelist_path = optctx.optarg;
105 client_printf_err(sockfd,
"unknown arguments\n");
106 ods_log_error(
"[%s] unknown arguments for zonelist import command", module_str);
111 ret =
zonelist_import(sockfd, engine, dbconn, remove_missing_zones, zonelist_path);
118 if (snprintf(path,
sizeof(path),
"%s/%s", engine->
config->
working_dir, OPENDNSSEC_ENFORCER_ZONELIST) >= (
int)
sizeof(path)
121 ods_log_error(
"[%s] internal zonelist export failed", module_str);
122 client_printf_err(sockfd,
"Unable to export the internal zonelist %s, updates will not reach the Signer!\n", path);
125 ods_log_info(
"[%s] internal zonelist exported successfully", module_str);
135 "zonelist import", &usage, &help, NULL, NULL, &run, NULL
void enforce_task_flush_all(engine_type *engine, db_connection_t *dbconn)
db_connection_t * getconnectioncontext(cmdhandler_ctx_type *context)
engine_type * getglobalcontext(cmdhandler_ctx_type *context)
engineconfig_type * config
const char * zonelist_filename
int zonelist_export(int sockfd, db_connection_t *connection, const char *filename, int comment)
#define ZONELIST_EXPORT_OK
int zonelist_import(int sockfd, engine_type *engine, db_connection_t *dbconn, int do_delete, const char *zonelist_path)
#define ZONELIST_IMPORT_NO_CHANGE
#define ZONELIST_IMPORT_OK
struct cmd_func_block zonelist_import_funcblock