s3: VFS: vfs_snapper: Make chflags return errno = EROFS on a shadow copy path.
[Samba.git] / ctdb / event / event_config.c
blobd2826225c8048fbbcfb555b132421165e24a0db6
1 /*
2 CTDB event daemon - config handling
4 Copyright (C) Amitay Isaacs 2018
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, see <http://www.gnu.org/licenses/>.
20 #include "replace.h"
22 #include <talloc.h>
24 #include "common/conf.h"
25 #include "common/logging_conf.h"
26 #include "common/path.h"
28 #include "event/event_private.h"
29 #include "event/event_conf.h"
31 struct event_config {
32 char *config_file;
33 struct conf_context *conf;
35 const char *logging_location;
36 const char *logging_loglevel;
37 const char *debug_script;
40 int event_config_init(TALLOC_CTX *mem_ctx, struct event_config **result)
42 struct event_config *config;
43 int ret;
44 bool ok;
46 config = talloc_zero(mem_ctx, struct event_config);
47 if (config == NULL) {
48 return ENOMEM;
51 config->config_file = path_config(config);
52 if (config->config_file == NULL) {
53 talloc_free(config);
54 return ENOMEM;
57 ret = conf_init(config, &config->conf);
58 if (ret != 0) {
59 talloc_free(config);
60 return ret;
63 logging_conf_init(config->conf, NULL);
65 conf_assign_string_pointer(config->conf,
66 LOGGING_CONF_SECTION,
67 LOGGING_CONF_LOCATION,
68 &config->logging_location);
69 conf_assign_string_pointer(config->conf,
70 LOGGING_CONF_SECTION,
71 LOGGING_CONF_LOG_LEVEL,
72 &config->logging_loglevel);
74 event_conf_init(config->conf);
76 conf_assign_string_pointer(config->conf,
77 EVENT_CONF_SECTION,
78 EVENT_CONF_DEBUG_SCRIPT,
79 &config->debug_script);
81 ok = conf_valid(config->conf);
82 if (!ok) {
83 talloc_free(config);
84 return EINVAL;
87 ret = conf_load(config->conf, config->config_file, true);
88 if (ret != 0 && ret != ENOENT) {
89 talloc_free(config);
90 return ret;
93 *result = config;
94 return 0;
97 const char *event_config_log_location(struct event_config *config)
99 return config->logging_location;
102 const char *event_config_log_level(struct event_config *config)
104 return config->logging_loglevel;
107 const char *event_config_debug_script(struct event_config *config)
109 return config->debug_script;
112 int event_config_reload(struct event_config *config)
114 int ret;
116 ret = conf_reload(config->conf);
117 if (ret != 0 && ret != ENOENT) {
118 return ret;
121 return 0;