summaryrefslogtreecommitdiffstats
path: root/xlators/mgmt/glusterd
diff options
context:
space:
mode:
authorCsaba Henk <csaba@gluster.com>2011-04-13 01:46:08 +0000
committerAnand Avati <avati@gluster.com>2011-04-13 04:43:18 -0700
commit72f88e50dbf1f492db7bcc70b074bc64e6b994cb (patch)
tree73d08cfa721dabeb4fa46ea4a2286f3bf992303f /xlators/mgmt/glusterd
parentac27e6980869d52ea90b869de01538dec28620ae (diff)
glusterd: sanitize gsyncd config option validation
- rely on --config-check functionality of gsyncd to find out if option exists - maintain a list of those options with which we don't want the user to fiddle with (glusterd internals imply these so it' just the proper component for it) - fail if user does a set/del on these Signed-off-by: Csaba Henk <csaba@gluster.com> Signed-off-by: Anand Avati <avati@gluster.com> BUG: 2659 (gsync config-del option is not working properly) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=2659
Diffstat (limited to 'xlators/mgmt/glusterd')
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-op-sm.c59
1 files changed, 37 insertions, 22 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.c b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
index b9d63605ab9..4017dd91c11 100644
--- a/xlators/mgmt/glusterd/src/glusterd-op-sm.c
+++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
@@ -95,17 +95,11 @@ static char *glusterd_op_sm_event_names[] = {
"GD_OP_EVENT_INVALID"
};
-static char *gsync_opname[] = {
+static char *gsync_reserved_opts[] = {
"gluster-command",
- "gluster-log-file",
- "gluster-log-level",
+ "pid-file",
"log-file",
- "log-level",
- "remote-gsyncd",
- "ssh-command",
- "rsync-command",
- "timeout",
- "sync-jobs",
+ "state-file",
NULL
};
@@ -1829,9 +1823,12 @@ int
gsync_validate_config_option (dict_t *dict, int32_t config_type,
char **op_errstr)
{
+ char cmd[PATH_MAX] = {0,};
int ret = -1;
+ char **resopt = NULL;
int i = 0;
- char *op_name = NULL;
+ char *op_name = NULL;
+ gf_boolean_t banned = _gf_true;
if (config_type == GF_GSYNC_OPTION_TYPE_CONFIG_GET_ALL)
return 0;
@@ -1840,24 +1837,42 @@ gsync_validate_config_option (dict_t *dict, int32_t config_type,
if (ret < 0) {
gf_log ("", GF_LOG_WARNING, "option not specified");
*op_errstr = gf_strdup ("Please specify the option");
- goto out;
+ return -1;
}
- i = 0;
- while (gsync_opname[i] != NULL) {
- if (strcmp (gsync_opname[i], op_name) == 0) {
- ret = 0;
- goto out;
- }
- i++;
+ snprintf (cmd, PATH_MAX, GSYNCD_PREFIX"/gsyncd --config-check %s", op_name);
+ ret = system (cmd);
+ if (ret) {
+ gf_log ("", GF_LOG_WARNING, "Invalid option %s", op_name);
+ *op_errstr = gf_strdup ("Invalid option");
+
+ ret = -1;
}
- gf_log ("", GF_LOG_WARNING, "Invalid option");
- *op_errstr = gf_strdup ("Invalid option");
+ if (ret != -1 &&
+ (config_type == GF_GSYNC_OPTION_TYPE_CONFIG_SET ||
+ config_type == GF_GSYNC_OPTION_TYPE_CONFIG_DEL)) {
+ /* match option name against reserved options, modulo -/-
+ * difference
+ */
+ for (resopt = gsync_reserved_opts; *resopt; resopt++) {
+ banned = _gf_true;
+ for (i = 0; (*resopt)[i] && op_name[i]; i++) {
+ if ((*resopt)[i] == op_name[i] ||
+ ((*resopt)[i] == '-' && op_name[i] == '_'))
+ continue;
+ banned = _gf_false;
+ }
+ if (banned) {
+ gf_log ("", GF_LOG_WARNING, "Reserved option %s", op_name);
+ *op_errstr = gf_strdup ("Reserved option");
- ret = -1;
+ ret = -1;
+ break;
+ }
+ }
+ }
-out:
return ret;
}