OpenDNSSEC-enforcer 2.1.13
update_conf_cmd.c
Go to the documentation of this file.
1/*
2 * Copyright (c) 2014 .SE (The Internet Infrastructure Foundation).
3 * Copyright (c) 2014 OpenDNSSEC AB (svb)
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
19 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
21 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
23 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
24 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
25 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 *
27 */
28
29#include "daemon/engine.h"
30#include "cmdhandler.h"
32#include "log.h"
33#include "str.h"
34#include "clientpipe.h"
35#include "longgetopt.h"
36#include "utils/kc_helper.h"
37
39
40#include <pthread.h>
41
42
43static void
44usage(int sockfd)
45{
46 client_printf(sockfd,
47 "update conf\n");
48}
49
50static void
51help(int sockfd)
52{
53 client_printf(sockfd,
54 "Update the configuration from conf.xml and reload the Enforcer.\n\n"
55 );
56}
57
58static int
59run(cmdhandler_ctx_type* context, int argc, char* argv[])
60{
61 int sockfd = context->sockfd;
62 char *kasp = NULL;
63 char *zonelist = NULL;
64 char **repositories = NULL;
65 int repository_count = 0;
66 int i;
67 engine_type* engine = getglobalcontext(context);
68
69 if (check_conf(engine->config->cfg_filename, &kasp, &zonelist, &repositories, &repository_count, (ods_log_verbosity() >= 3))) {
70 client_printf_err(sockfd, "Unable to validate '%s' consistency.",
71 engine->config->cfg_filename);
72
73 free(kasp);
74 free(zonelist);
75 if (repositories) {
76 for (i = 0; i < repository_count; i++) {
77 free(repositories[i]);
78 }
79 free(repositories);
80 }
81 return 1;
82 }
83
84 free(kasp);
85 free(zonelist);
86 if (repositories) {
87 for (i = 0; i < repository_count; i++) {
88 free(repositories[i]);
89 }
90 free(repositories);
91 }
92
93 engine->need_to_reload = 1;
94 pthread_cond_signal(&engine->signal_cond);
95
96 return 0;
97}
98
99struct cmd_func_block update_conf_funcblock = {
100 "update conf", &usage, &help, NULL, NULL, &run, NULL
101};
engine_type * getglobalcontext(cmdhandler_ctx_type *context)
int check_conf(const char *conf, char **kasp, char **zonelist, char ***repo_listout, int *repo_countout, int verbose)
Definition: kc_helper.c:1418
pthread_cond_t signal_cond
Definition: engine.h:64
int need_to_reload
Definition: engine.h:56
engineconfig_type * config
Definition: engine.h:48
const char * cfg_filename
Definition: cfg.h:55
struct cmd_func_block update_conf_funcblock