OpenDNSSEC-enforcer  2.0.2
keystate_ds_retract_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/cmdhandler.h"
33 #include "daemon/engine.h"
34 #include "enforcer/enforce_task.h"
35 #include "log.h"
36 #include "str.h"
37 #include "clientpipe.h"
38 #include "db/key_data.h"
39 #include "keystate/keystate_ds.h"
40 
42 
43 static void
44 usage(int sockfd)
45 {
46  client_printf(sockfd,
47  "key ds-retract\n"
48  " --zone <zone> aka -z\n"
49  " --keytag <keytag> | --cka_id <CKA_ID> aka -x | -k\n"
50 /* " [--force] (aka -f) force even if there is no configured\n"
51  " DelegationSignerSubmitCommand.\n" */
52  );
53 }
54 
55 static void
56 help(int sockfd)
57 {
58  client_printf(sockfd,
59  "Issue a ds-retract to the enforcer for a KSK.\n"
60  "(This command with no parameters lists eligible keys.)\n"
61  "\nOptions:\n"
62  "zone name of the zone\n"
63  "keytag|cka_id specify the keytag or the locator of the key\n\n");
64 }
65 
66 static int
67 handles(const char *cmd, ssize_t n)
68 {
69  return ods_check_command(cmd, n, key_ds_retract_funcblock()->cmdname)?1:0;
70 }
71 
72 static int
73 run(int sockfd, engine_type* engine, const char *cmd, ssize_t n,
74  db_connection_t *dbconn)
75 {
76  int error;
77  /* TODO, this changes the state, but sbmt cmd is not exec. */
78  error = run_ds_cmd(sockfd, cmd, n, dbconn,
81  if (error == 0) {
82  flush_enforce_task(engine, 0);
83  }
84  return error;
85 
86 }
87 
88 static struct cmd_func_block funcblock = {
89  "key ds-retract", &usage, &help, &handles, &run
90 };
91 
92 struct cmd_func_block*
94 {
95  return &funcblock;
96 }
void(* help)(int sockfd)
Definition: cmdhandler.h:64
int(* run)(int sockfd, struct engine_struct *engine, const char *cmd, ssize_t n, db_connection_t *dbconn)
Definition: cmdhandler.h:79
const char * cmdname
Definition: cmdhandler.h:59
void(* usage)(int sockfd)
Definition: cmdhandler.h:61
int run_ds_cmd(int sockfd, const char *cmd, ssize_t n, db_connection_t *dbconn, key_data_ds_at_parent_t state_from, key_data_ds_at_parent_t state_to, engine_type *engine)
Definition: keystate_ds.c:476
struct cmd_func_block * key_ds_retract_funcblock(void)
int(* handles)(const char *cmd, ssize_t n)
Definition: cmdhandler.h:67
int flush_enforce_task(engine_type *engine, bool enforce_all)
Definition: enforce_task.c:323