35 #include <libxml/parser.h> 44 #define AUTHOR_NAME "Matthijs Mekking, Yuri Schaeffer, René Post" 45 #define COPYRIGHT_STR "Copyright (C) 2010-2011 NLnet Labs OpenDNSSEC" 47 static const char* enforcerd_str =
"engine";
56 fprintf(out,
"Usage: %s [OPTIONS]\n",
"ods-enforcerd");
57 fprintf(out,
"Start the OpenDNSSEC key and signing policy enforcer " 59 fprintf(out,
"Supported options:\n");
60 fprintf(out,
" -c | --config <cfgfile> Read configuration from file.\n");
61 fprintf(out,
" -d | --no-daemon Do not daemonize the enforcer " 63 fprintf(out,
" -1 | --single-run Run once, then exit.\n");
64 fprintf(out,
" -h | --help Show this help and exit.\n");
65 fprintf(out,
" -i | --info Print configuration and exit.\n");
66 fprintf(out,
" -v | --verbose Increase verbosity.\n");
67 fprintf(out,
" -V | --version Show version and exit.\n");
68 fprintf(out,
" --set-time <time> Start daemon at specific time. " 69 "Notation \"YYYY-MM-DD-HH:MM:SS\" or seconds since Unix epoch.\n");
70 fprintf(out,
"\nBSD licensed, see LICENSE in source package for " 72 fprintf(out,
"Version %s. Report bugs to <%s>.\n",
73 PACKAGE_VERSION, PACKAGE_BUGREPORT);
84 fprintf(out,
"%s version %s\n", PACKAGE_NAME, PACKAGE_VERSION);
87 fprintf(out,
"See source files for more license information\n");
92 program_setup(
const char* cfgfile,
int cmdline_verbosity)
98 ods_log_verbose(
"[%s] starting enforcer", enforcerd_str);
132 int options_index = 0;
136 int cmdline_verbosity = 0;
137 char *time_arg = NULL;
138 const char* cfgfile = ODS_SE_CFGFILE;
139 static struct option long_options[] = {
140 {
"single-run", no_argument, 0,
'1'},
141 {
"config", required_argument, 0,
'c'},
142 {
"no-daemon", no_argument, 0,
'd'},
143 {
"help", no_argument, 0,
'h'},
144 {
"info", no_argument, 0,
'i'},
145 {
"verbose", no_argument, 0,
'v'},
146 {
"version", no_argument, 0,
'V'},
147 {
"set-time", required_argument, 0, 256},
151 if(argv[0][0] !=
'/') {
152 char *path = getcwd(NULL,0);
153 asprintf(&argv0,
"%s/%s", path, argv[0]);
156 argv0 = strdup(argv[0]);
160 while ((c=getopt_long(argc, argv,
"1c:dhivV",
161 long_options, &options_index)) != -1) {
200 if(set_time_now_str(time_arg)) {
201 fprintf(stderr,
"Error: Failed to interpret start time argument. Daemon not started.\n");
207 fprintf(stdout,
"OpenDNSSEC key and signing policy enforcer version %s\n",
210 ods_janitor_initialize(argv0);
211 program_setup(cfgfile, cmdline_verbosity);
214 ods_log_crit(
"Could not start engine");
236 ods_log_crit(
"[%s] cfgfile %s has errors", enforcerd_str, cfgfile);
254 ods_log_error(
"setup failed: %s", ods_status2str(status));
256 fprintf(stderr,
"setup failed: %s\n", ods_status2str(status));
267 ods_log_info(
"[%s] enforcer reloading", enforcerd_str);
270 ods_log_info(
"[engine] enforcer shutdown");
271 ods_log_info(
"[%s] enforcerd (pid: %lu) stopped with exitcode %d",
272 enforcerd_str, (
unsigned long) engine->
pid, returncode);
274 if (returncode && daemonize) {
275 fprintf(stderr,
"enforcerd stopped with exitcode %d\n",
void engine_config_cleanup(engineconfig_type *config)
void engine_config_print(FILE *out, engineconfig_type *config)
void engine_teardown(engine_type *engine)
engineconfig_type * engine_config(const char *cfgfile, int cmdline_verbosity, engineconfig_type *oldcfg)
int parse_conf_use_syslog(const char *cfgfile)
void autostart(engine_type *engine)
int engine_run(engine_type *engine, start_cb_t start, int single_run)
engineconfig_type * config
void engine_init(engine_type *engine, int daemonize)
const char * parse_conf_log_filename(const char *cfgfile)
ods_status engine_setup()
engine_type * engine_alloc(void)
int main(int argc, char *argv[])
ods_status engine_config_check(engineconfig_type *config)
int parse_conf_verbosity(const char *cfgfile)
void engine_dealloc(engine_type *engine)