OpenDNSSEC-enforcer  2.1.12
autostart_cmd.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2011 Surfnet
3  * Copyright (c) 2011 .SE (The Internet Infrastructure Foundation).
4  * Copyright (c) 2011 OpenDNSSEC AB (svb)
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  * 1. Redistributions of source code must retain the above copyright
11  * notice, this list of conditions and the following disclaimer.
12  * 2. Redistributions in binary form must reproduce the above copyright
13  * notice, this list of conditions and the following disclaimer in the
14  * documentation and/or other materials provided with the distribution.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19  * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
20  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
22  * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
24  * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
25  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
26  * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  *
28  */
29 
30 #include "config.h"
31 
32 #include "daemon/engine.h"
33 #include "enforcer/enforce_task.h"
35 #include "duration.h"
36 #include "status.h"
37 #include "log.h"
38 #include "hsmkey/hsm_key_factory.h"
39 
40 #include "enforcer/autostart_cmd.h"
41 
42 static const char *module_str = "autostart_cmd";
43 
44 void
46 {
47  ods_status status;
48  db_connection_t* dbconn;
49 
50  ods_log_debug("[%s] autostart", module_str);
51  dbconn = get_database_connection(engine);
52 
53  schedule_purge(engine->taskq); /* Remove old tasks in queue */
54 
55  if (!engine->config->manual_keygen)
57  status = flush_resalt_task_all(engine, dbconn);
58 
59  if (status != ODS_STATUS_OK)
60  ods_log_crit("[%s] failed to create resalt task", module_str);
61 
62  enforce_task_flush_all(engine, dbconn);
63  db_connection_free(dbconn);
64 }
void autostart(engine_type *engine)
Definition: autostart_cmd.c:45
void db_connection_free(db_connection_t *connection)
Definition: db_connection.c:45
void enforce_task_flush_all(engine_type *engine, db_connection_t *dbconn)
Definition: enforce_task.c:179
db_connection_t * get_database_connection(engine_type *engine)
Definition: engine.c:226
int hsm_key_factory_schedule_generate_all(engine_type *engine, time_t duration)
int flush_resalt_task_all(engine_type *engine, db_connection_t *dbconn)
schedule_type * taskq
Definition: engine.h:60
engineconfig_type * config
Definition: engine.h:48
int manual_keygen
Definition: cfg.h:74