OpenDNSSEC-enforcer  2.0.4
signconf_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 "signconf/signconf_task.h"
35 #include "file.h"
36 #include "log.h"
37 #include "str.h"
38 #include "clientpipe.h"
39 
40 #include "signconf/signconf_cmd.h"
41 
42 static const char *module_str = "signconf_cmd";
43 
44 static void
45 usage(int sockfd)
46 {
47  client_printf(sockfd,
48  "signconf\n"
49  );
50 }
51 
52 static void
53 help(int sockfd)
54 {
55  client_printf(sockfd,
56  "Force write of signer configuration files for all zones.\n\n"
57  );
58 }
59 
60 static int
61 handles(const char *cmd, ssize_t n)
62 {
63  return ods_check_command(cmd, n, signconf_funcblock()->cmdname) ? 1 : 0;
64 }
65 
66 static int
67 run(int sockfd, engine_type* engine, const char *cmd, ssize_t n,
68  db_connection_t *dbconn)
69 {
70  (void)engine; (void)cmd; (void)n;
71 
72  ods_log_debug("[%s] %s command", module_str, signconf_funcblock()->cmdname);
73 
74  return perform_signconf(sockfd, dbconn, 1);
75 }
76 
77 static struct cmd_func_block funcblock = {
78  "signconf", &usage, &help, &handles, &run
79 };
80 
81 struct cmd_func_block*
83 {
84  return &funcblock;
85 }
void(* help)(int sockfd)
Definition: cmdhandler.h:64
void ods_log_debug(const char *format,...)
Definition: log.c:41
struct cmd_func_block * signconf_funcblock(void)
Definition: signconf_cmd.c:82
int perform_signconf(int sockfd, const db_connection_t *dbconn, int force)
Definition: signconf_task.c:39
int(* run)(int sockfd, struct engine_struct *engine, const char *cmd, ssize_t n, db_connection_t *dbconn)
Definition: cmdhandler.h:79
void(* usage)(int sockfd)
Definition: cmdhandler.h:61
int(* handles)(const char *cmd, ssize_t n)
Definition: cmdhandler.h:67