34 #include "cmdhandler.h"
38 #include "clientpipe.h"
45 static const char *module_str =
"zonelist_import_cmd";
52 " [--remove-missing-zones] aka -r\n"
55 " [--file <absolute path>] aka -f\n"
63 "Import zones from zonelist.xml into enforcer database.\n"
65 "remove-missing-zones Remove any zones from database not existed in zonelist file\n"
66 "file File to import, instead of zonelist file configured in conf.xml\n\n"
71 run(
int sockfd, cmdhandler_ctx_type* context,
const char *cmd)
73 char path[PATH_MAX], buf[ODS_SE_MAXLINE];
74 int ret, argc = 0, remove_missing_zones = 0;
76 int long_index = 0, opt = 0;
77 const char *argv[
NARGV];
78 const char* zonelist_path = NULL;
82 static struct option long_options[] = {
83 {
"remove-missing-zones", no_argument, 0,
'r'},
84 {
"file", required_argument, 0,
'f'},
90 if (!engine || !engine->
config ||
99 strncpy(buf, cmd,
sizeof(buf));
100 buf[
sizeof(buf)-1] =
'\0';
103 argc = ods_str_explode(buf,
NARGV, argv);
105 client_printf_err(sockfd,
"too many arguments\n");
106 ods_log_error(
"[%s] too many arguments for %s command",
112 while ((opt = getopt_long(argc, (
char*
const*)argv,
"rf:", long_options, &long_index)) != -1) {
115 remove_missing_zones = 1;
118 zonelist_path = optarg;
121 client_printf_err(sockfd,
"unknown arguments\n");
122 ods_log_error(
"[%s] unknown arguments for %s command",
128 ret =
zonelist_import(sockfd, engine, dbconn, remove_missing_zones, zonelist_path);
135 if (snprintf(path,
sizeof(path),
"%s/%s", engine->
config->
working_dir, OPENDNSSEC_ENFORCER_ZONELIST) >= (
int)
sizeof(path)
138 ods_log_error(
"[%s] internal zonelist export failed", module_str);
139 client_printf_err(sockfd,
"Unable to export the internal zonelist %s, updates will not reach the Signer!\n", path);
143 ods_log_info(
"[%s] internal zonelist exported successfully", module_str);
153 "zonelist import", &usage, &help, NULL, &run