libsmb: Use cli_smb2_query_info_fnum
[Samba.git] / ctdb / cluster / cluster_conf.c
blob540732d5b9191db9d404a2560bc5b2de04ca6598
1 /*
2 CTDB cluster config handling
4 Copyright (C) Martin Schwenke 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"
21 #include "system/network.h"
23 #include "lib/util/debug.h"
25 #include "common/conf.h"
27 #include "cluster_conf.h"
29 #define CLUSTER_TRANSPORT_DEFAULT "tcp"
32 * Ideally this wants to be a void function but it also used directly
33 * as a validation function
35 static bool check_static_string_change(const char *key,
36 const char *old_value,
37 const char *new_value,
38 enum conf_update_mode mode)
40 if (mode == CONF_MODE_RELOAD) {
41 if (strcmp(old_value, new_value) != 0) {
42 D_WARNING("Ignoring update of [%s] -> %s\n",
43 CLUSTER_CONF_SECTION,
44 key);
48 return true;
51 static bool validate_transport(const char *key,
52 const char *old_transport,
53 const char *new_transport,
54 enum conf_update_mode mode)
56 /* Don't allow "ib" for now. It is broken! */
57 if (strcmp(new_transport, CLUSTER_TRANSPORT_DEFAULT) != 0) {
58 D_ERR("Invalid value for [cluster] -> transport = %s\n",
59 new_transport);
60 return false;
63 /* This sometimes warns but always returns true */
64 return check_static_string_change(key,
65 old_transport,
66 new_transport,
67 mode);
70 static bool validate_node_address(const char *key,
71 const char *old_node_address,
72 const char *new_node_address,
73 enum conf_update_mode mode)
75 struct in_addr addr4;
76 struct in6_addr addr6;
77 int ret;
79 if (new_node_address == NULL) {
80 goto good;
83 ret = inet_pton(AF_INET, new_node_address, &addr4);
84 if (ret == 1) {
85 goto good;
88 ret = inet_pton(AF_INET6, new_node_address, &addr6);
89 if (ret == 1) {
90 goto good;
93 D_ERR("Invalid value for [cluster] -> node address = %s\n",
94 new_node_address);
95 return false;
97 good:
98 /* This sometimes warns but always returns true */
99 return check_static_string_change(key,
100 old_node_address,
101 new_node_address,
102 mode);
105 void cluster_conf_init(struct conf_context *conf)
107 conf_define_section(conf, CLUSTER_CONF_SECTION, NULL);
109 conf_define_string(conf,
110 CLUSTER_CONF_SECTION,
111 CLUSTER_CONF_TRANSPORT,
112 CLUSTER_TRANSPORT_DEFAULT,
113 validate_transport);
114 conf_define_string(conf,
115 CLUSTER_CONF_SECTION,
116 CLUSTER_CONF_NODE_ADDRESS,
117 NULL,
118 validate_node_address);
119 conf_define_string(conf,
120 CLUSTER_CONF_SECTION,
121 CLUSTER_CONF_RECOVERY_LOCK,
122 NULL,
123 check_static_string_change);