35 #include "clientpipe.h" 50 static const char *module_str =
"enforce_task";
57 ods_log_crit(
"[%s] failed to create %s task", module_str, what);
60 if (status != ODS_STATUS_OK) {
61 ods_log_crit(
"[%s] failed to create %s task", module_str, what);
62 client_printf(sockfd,
"Unable to schedule %s task.\n", what);
64 client_printf(sockfd,
"Scheduled %s task.\n", what);
70 reschedule_enforce(
task_type *task, time_t t_when,
const char *z_when)
72 ods_log_assert(task->
who);
74 task->
who = strdup(z_when);
80 perform_enforce(
int sockfd,
engine_type *engine,
int bForceUpdate,
88 time_t t_next, t_now = time_now(), t_reschedule = -1;
91 int bSignerConfNeedsWriting = 0;
92 int bSubmitToParent = 0;
93 int bRetractFromParent = 0;
132 client_printf(sockfd,
133 "Next update for zone %s NOT scheduled " 134 "because policy is missing !\n",
zone_name(zone));
148 bSignerConfNeedsWriting = 1;
154 t_next =
update(engine, dbconn, zone, policy, t_now, &zone_updated);
162 "with keytag %d for zone %s",
167 "with keytag %d for zone %s",
169 bRetractFromParent = 1;
175 client_printf(sockfd,
176 "Next update for zone %s NOT scheduled " 182 char tbuf[32] =
"date/time invalid\n";
183 ctime_r(&t_next, tbuf);
184 client_printf(sockfd,
185 "Next update for zone %s scheduled at %s",
225 reschedule_enforce(task, t_reschedule,
zone_name(firstzone));
233 if (bSignerConfNeedsWriting) {
236 enf_schedule_task(sockfd,engine,signconf,
"signconf");
238 ods_log_info(
"[%s] No changes to any signconf file required", module_str);
243 if (bSubmitToParent) {
246 enf_schedule_task(sockfd, engine, submit,
"ds-submit");
252 if (bRetractFromParent) {
255 enf_schedule_task(sockfd, engine, retract,
"ds-retract");
267 client_printf(sockfd,
"An other enforce task is already running." 268 " No action taken.\n");
271 returntime = perform_enforce(sockfd, engine, bForceUpdate, task,
299 if (return_time != -1)
return task;
308 const char *what =
"enforce";
309 const char *who =
"next zone";
317 what_id =
task_register(what, module_str, enforce_task_perform);
318 return task_create(what_id, time_now(), who, what, ctx,
319 enforce_task_clean_ctx);
339 if (status != ODS_STATUS_OK) {
void ods_log_debug(const char *format,...)
task_type * keystate_ds_submit_task(engine_type *engine)
int zone_update(zone_t *zone)
policy_t * zone_get_policy(const zone_t *zone)
void ods_fatal_exit(const char *format,...)
time_t perform_enforce_lock(int sockfd, engine_type *engine, int bForceUpdate, task_type *task, db_connection_t *dbconn)
void zone_list_free(zone_list_t *zone_list)
void ods_log_info(const char *format,...)
int zone_next_change(const zone_t *zone)
key_data_list_t * zone_get_keys(const zone_t *zone)
ods_status schedule_task(schedule_type *schedule, task_type *task)
int zone_set_signconf_needs_writing(zone_t *zone, unsigned int signconf_needs_writing)
void ods_log_error(const char *format,...)
bool task_id_from_long_name(const char *long_name, task_id *pwhat)
unsigned int key_data_keytag(const key_data_t *key_data)
unsigned int policy_passthrough(const policy_t *policy)
time_t update(engine_type *engine, db_connection_t *dbconn, zone_t *zone, policy_t *policy, time_t now, int *zone_updated)
enum task_id_enum task_id
void zone_free(zone_t *zone)
void ods_log_crit(const char *format,...)
task_type * enforce_task(engine_type *engine, bool all)
zone_list_t * zone_list_new(const db_connection_t *connection)
void policy_free(policy_t *policy)
int zone_set_next_change(zone_t *zone, int next_change)
unsigned int zone_signconf_needs_writing(const zone_t *zone)
const key_data_t * key_data_list_next(key_data_list_t *key_data_list)
void task_cleanup(task_type *task)
task_type * signconf_task(const db_connection_t *dbconn, const char *what, const char *who)
const char * zone_name(const zone_t *zone)
zone_t * zone_list_get_next(zone_list_t *zone_list)
pthread_mutex_t enforce_lock
int schedule_flush_type(schedule_type *schedule, task_id id)
void key_data_list_free(key_data_list_t *key_data_list)
task_type * keystate_ds_retract_task(engine_type *engine)
int zone_list_get(zone_list_t *zone_list)
task_id task_register(const char *short_name, const char *long_name, how_type how)
task_type * task_create(task_id what_id, time_t when, const char *who, const char *what, void *context, how_type clean_context)
void ods_log_warning(const char *format,...)
int flush_enforce_task(engine_type *engine, bool enforce_all)