35 #include "cmdhandler.h"
40 #include "clientpipe.h"
44 static const char *module_str =
"rollover_list_cmd";
61 return strdup(
"waiting for ds-submit");
63 return strdup(
"waiting for ds-seen");
65 return strdup(
"waiting for ds-retract");
67 return strdup(
"waiting for ds-gone");
77 if (!t)
return strdup(
"No roll scheduled");
79 localtime_r(&t, &srtm);
80 strftime(ct, 26,
"%Y-%m-%d %H:%M:%S", &srtm);
85 print_zone(
int sockfd,
const char* fmt,
const zone_db_t* zone)
92 char *tchange = map_keytime(zone, key);
109 perform_rollover_list(
int sockfd,
const char *listed_zone,
115 const char* fmt =
"%-31s %-8s %-30s\n";
123 if (listed_zone && !zone) {
124 ods_log_error(
"[%s] zone '%s' not found", module_str, listed_zone);
125 client_printf(sockfd,
"zone '%s' not found\n", listed_zone);
129 if (!zone && !zonelist) {
130 ods_log_error(
"[%s] error enumerating zones", module_str);
131 client_printf(sockfd,
"error enumerating zones\n");
135 client_printf(sockfd,
"Keys:\n");
136 client_printf(sockfd, fmt,
"Zone:",
"Keytype:",
"Rollover expected:");
139 print_zone(sockfd, fmt, zone);
145 print_zone(sockfd, fmt, zone_walk);
154 client_printf(sockfd,
156 " [--zone <zone>] aka -z\n"
163 client_printf(sockfd,
164 "List the expected dates and times of upcoming rollovers. This can be used to get an idea of upcoming works.\n"
166 "zone name of the zone\n\n");
170 run(
int sockfd, cmdhandler_ctx_type* context,
const char *cmd)
173 char buf[ODS_SE_MAXLINE];
174 const char *argv[
NARGV];
175 int argc = 0, long_index = 0, opt = 0;
176 const char *zone = NULL;
179 static struct option long_options[] = {
180 {
"zone", required_argument, 0,
'z'},
187 strncpy(buf, cmd,
sizeof(buf));
188 buf[
sizeof(buf)-1] =
'\0';
191 argc = ods_str_explode(buf,
NARGV, argv);
193 client_printf_err(sockfd,
"too many arguments\n");
194 ods_log_error(
"[%s] too many arguments for %s command",
200 while ((opt = getopt_long(argc, (
char*
const*)argv,
"z:", long_options, &long_index)) != -1) {
206 client_printf_err(sockfd,
"unknown arguments\n");
207 ods_log_error(
"[%s] unknown arguments for %s command",
212 return perform_rollover_list(sockfd, zone, dbconn);
216 "rollover list", &usage, &help, NULL, &run
db_connection_t * getconnectioncontext(cmdhandler_ctx_type *context)
const key_data_t * key_data_list_next(key_data_list_t *key_data_list)
const char * key_data_role_text(const key_data_t *key_data)
void key_data_list_free(key_data_list_t *key_data_list)
@ KEY_DATA_DS_AT_PARENT_SUBMITTED
@ KEY_DATA_DS_AT_PARENT_RETRACT
@ KEY_DATA_DS_AT_PARENT_SUBMIT
@ KEY_DATA_DS_AT_PARENT_RETRACTED
struct cmd_func_block rollover_list_funcblock
zone_list_db_t * zone_list_db_new_get(const db_connection_t *connection)
void zone_db_free(zone_db_t *zone)
const char * zone_db_name(const zone_db_t *zone)
unsigned int zone_db_next_ksk_roll(const zone_db_t *zone)
unsigned int zone_db_next_csk_roll(const zone_db_t *zone)
const zone_db_t * zone_list_db_next(zone_list_db_t *zone_list)
unsigned int zone_db_next_zsk_roll(const zone_db_t *zone)
void zone_list_db_free(zone_list_db_t *zone_list)
zone_db_t * zone_db_new_get_by_name(const db_connection_t *connection, const char *name)
key_data_list_t * zone_db_get_keys(const zone_db_t *zone)