|
|
21ab4e |
From 8c0c34f0ae724a68e4a9921e11968f6e26ad5146 Mon Sep 17 00:00:00 2001
|
|
|
21ab4e |
From: Amar Tumballi <amarts@redhat.com>
|
|
|
21ab4e |
Date: Mon, 16 Oct 2017 11:44:59 +0530
|
|
|
21ab4e |
Subject: [PATCH 626/626] protocol-auth: use the proper validation method
|
|
|
21ab4e |
|
|
|
21ab4e |
Currently, server protocol's init and glusterd's option
|
|
|
21ab4e |
validation methods are different, causing an issue. They
|
|
|
21ab4e |
should be same for having consistent behavior
|
|
|
21ab4e |
|
|
|
21ab4e |
> Upstream:
|
|
|
21ab4e |
> Change-Id: Ibbf9a18c7192b2d77f9b7675ae7da9b8d2fe5de4
|
|
|
21ab4e |
> URL: https://review.gluster.org/#/c/18489/
|
|
|
21ab4e |
|
|
|
21ab4e |
Change-Id: Id595a1032b14233ca8f31d20813dca98476b2468
|
|
|
21ab4e |
Signed-off-by: Amar Tumballi <amarts@redhat.com>
|
|
|
21ab4e |
BUG: 1500720
|
|
|
21ab4e |
Reviewed-on: https://code.engineering.redhat.com/gerrit/120558
|
|
|
21ab4e |
Tested-by: RHGS Build Bot <nigelb@redhat.com>
|
|
|
21ab4e |
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
|
|
|
21ab4e |
---
|
|
|
21ab4e |
libglusterfs/src/options.c | 4 ++--
|
|
|
21ab4e |
libglusterfs/src/options.h | 5 +++++
|
|
|
21ab4e |
tests/features/subdir-mount.t | 4 ++++
|
|
|
21ab4e |
xlators/protocol/server/src/server.c | 40 +++++++-----------------------------
|
|
|
21ab4e |
4 files changed, 18 insertions(+), 35 deletions(-)
|
|
|
21ab4e |
|
|
|
21ab4e |
diff --git a/libglusterfs/src/options.c b/libglusterfs/src/options.c
|
|
|
21ab4e |
index 0ad4e53..e41aa5c 100644
|
|
|
21ab4e |
--- a/libglusterfs/src/options.c
|
|
|
21ab4e |
+++ b/libglusterfs/src/options.c
|
|
|
21ab4e |
@@ -590,7 +590,7 @@ xlator_option_validate_addr (xlator_t *xl, const char *key, const char *value,
|
|
|
21ab4e |
return ret;
|
|
|
21ab4e |
}
|
|
|
21ab4e |
|
|
|
21ab4e |
-static int
|
|
|
21ab4e |
+int
|
|
|
21ab4e |
xlator_option_validate_addr_list (xlator_t *xl, const char *key,
|
|
|
21ab4e |
const char *value, volume_option_t *opt,
|
|
|
21ab4e |
char **op_errstr)
|
|
|
21ab4e |
@@ -668,7 +668,7 @@ xlator_option_validate_addr_list (xlator_t *xl, const char *key,
|
|
|
21ab4e |
out:
|
|
|
21ab4e |
if (ret) {
|
|
|
21ab4e |
snprintf (errstr, sizeof (errstr), "option %s %s: '%s' is not "
|
|
|
21ab4e |
- "a valid internet-address-list", key, value, value);
|
|
|
21ab4e |
+ "a valid internet-address-list", key, value, value);
|
|
|
21ab4e |
gf_msg (xl->name, GF_LOG_ERROR, 0, LG_MSG_INVALID_ENTRY, "%s",
|
|
|
21ab4e |
errstr);
|
|
|
21ab4e |
if (op_errstr)
|
|
|
21ab4e |
diff --git a/libglusterfs/src/options.h b/libglusterfs/src/options.h
|
|
|
21ab4e |
index 3154dce..d259d44 100644
|
|
|
21ab4e |
--- a/libglusterfs/src/options.h
|
|
|
21ab4e |
+++ b/libglusterfs/src/options.h
|
|
|
21ab4e |
@@ -87,6 +87,11 @@ int xlator_options_validate_list (xlator_t *xl, dict_t *options,
|
|
|
21ab4e |
int xlator_option_validate (xlator_t *xl, char *key, char *value,
|
|
|
21ab4e |
volume_option_t *opt, char **op_errstr);
|
|
|
21ab4e |
int xlator_options_validate (xlator_t *xl, dict_t *options, char **errstr);
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+int xlator_option_validate_addr_list (xlator_t *xl, const char *key,
|
|
|
21ab4e |
+ const char *value, volume_option_t *opt,
|
|
|
21ab4e |
+ char **op_errstr);
|
|
|
21ab4e |
+
|
|
|
21ab4e |
volume_option_t *
|
|
|
21ab4e |
xlator_volume_option_get (xlator_t *xl, const char *key);
|
|
|
21ab4e |
|
|
|
21ab4e |
diff --git a/tests/features/subdir-mount.t b/tests/features/subdir-mount.t
|
|
|
21ab4e |
index 2fb0be4..ab7ef35 100644
|
|
|
21ab4e |
--- a/tests/features/subdir-mount.t
|
|
|
21ab4e |
+++ b/tests/features/subdir-mount.t
|
|
|
21ab4e |
@@ -78,6 +78,10 @@ TEST ! $CLI volume set $V0 auth.allow "subdir2\(1.2.3.4\)"
|
|
|
21ab4e |
# support subdir inside subdir
|
|
|
21ab4e |
TEST $CLI volume set $V0 auth.allow '/subdir1/subdir1.1/subdir1.2/\(1.2.3.4\|::1\),/\(192.168.10.1\|192.168.11.1\),/subdir2\(1.2.3.4\)'
|
|
|
21ab4e |
|
|
|
21ab4e |
+TEST $CLI volume stop $V0
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+TEST $CLI volume start $V0
|
|
|
21ab4e |
+
|
|
|
21ab4e |
# /subdir2 has not allowed IP
|
|
|
21ab4e |
TEST $GFS --subdir-mount /subdir2 -s $H0 --volfile-id $V0 $M1
|
|
|
21ab4e |
TEST stat $M1
|
|
|
21ab4e |
diff --git a/xlators/protocol/server/src/server.c b/xlators/protocol/server/src/server.c
|
|
|
21ab4e |
index 71b25bc..96aa012 100644
|
|
|
21ab4e |
--- a/xlators/protocol/server/src/server.c
|
|
|
21ab4e |
+++ b/xlators/protocol/server/src/server.c
|
|
|
21ab4e |
@@ -394,9 +394,6 @@ _check_for_auth_option (dict_t *d, char *k, data_t *v,
|
|
|
21ab4e |
int ret = 0;
|
|
|
21ab4e |
xlator_t *xl = NULL;
|
|
|
21ab4e |
char *tail = NULL;
|
|
|
21ab4e |
- char *tmp_addr_list = NULL;
|
|
|
21ab4e |
- char *addr = NULL;
|
|
|
21ab4e |
- char *tmp_str = NULL;
|
|
|
21ab4e |
|
|
|
21ab4e |
xl = tmp;
|
|
|
21ab4e |
|
|
|
21ab4e |
@@ -425,38 +422,15 @@ _check_for_auth_option (dict_t *d, char *k, data_t *v,
|
|
|
21ab4e |
* valid auth.allow.<xlator>
|
|
|
21ab4e |
* Now we verify the ip address
|
|
|
21ab4e |
*/
|
|
|
21ab4e |
- if (!strcmp (v->data, "*")) {
|
|
|
21ab4e |
- ret = 0;
|
|
|
21ab4e |
- goto out;
|
|
|
21ab4e |
- }
|
|
|
21ab4e |
-
|
|
|
21ab4e |
- /* TODO-SUBDIR-MOUNT: fix the format */
|
|
|
21ab4e |
- tmp_addr_list = gf_strdup (v->data);
|
|
|
21ab4e |
- addr = strtok_r (tmp_addr_list, ",", &tmp_str);
|
|
|
21ab4e |
- if (!addr)
|
|
|
21ab4e |
- addr = v->data;
|
|
|
21ab4e |
-
|
|
|
21ab4e |
- while (addr) {
|
|
|
21ab4e |
- if (valid_internet_address (addr, _gf_true)) {
|
|
|
21ab4e |
- ret = 0;
|
|
|
21ab4e |
- } else {
|
|
|
21ab4e |
- ret = -1;
|
|
|
21ab4e |
- gf_msg (xl->name, GF_LOG_ERROR, 0,
|
|
|
21ab4e |
- PS_MSG_INTERNET_ADDR_ERROR,
|
|
|
21ab4e |
- "internet address '%s'"
|
|
|
21ab4e |
- " does not conform to"
|
|
|
21ab4e |
- " standards.", addr);
|
|
|
21ab4e |
- goto out;
|
|
|
21ab4e |
- }
|
|
|
21ab4e |
- if (tmp_str)
|
|
|
21ab4e |
- addr = strtok_r (NULL, ",", &tmp_str);
|
|
|
21ab4e |
- else
|
|
|
21ab4e |
- addr = NULL;
|
|
|
21ab4e |
- }
|
|
|
21ab4e |
+ ret = xlator_option_validate_addr_list (xl, "auth-*", v->data,
|
|
|
21ab4e |
+ NULL, NULL);
|
|
|
21ab4e |
+ if (ret)
|
|
|
21ab4e |
+ gf_msg (xl->name, GF_LOG_ERROR, 0,
|
|
|
21ab4e |
+ PS_MSG_INTERNET_ADDR_ERROR,
|
|
|
21ab4e |
+ "internet address '%s' does not conform "
|
|
|
21ab4e |
+ "to standards.", v->data);
|
|
|
21ab4e |
}
|
|
|
21ab4e |
out:
|
|
|
21ab4e |
- GF_FREE (tmp_addr_list);
|
|
|
21ab4e |
-
|
|
|
21ab4e |
return ret;
|
|
|
21ab4e |
}
|
|
|
21ab4e |
|
|
|
21ab4e |
--
|
|
|
21ab4e |
1.8.3.1
|
|
|
21ab4e |
|