diff options
author | Rajesh Amaravathi <rajesh@redhat.com> | 2012-02-21 13:39:29 +0530 |
---|---|---|
committer | Vijay Bellur <vijay@gluster.com> | 2012-02-21 03:19:02 -0800 |
commit | 0344a8a12e7675bee24c770d71eff52db6b2d128 (patch) | |
tree | f3213af53d3434813c1c3919428d5af802f224f7 /xlators/mgmt | |
parent | 6a6abb5367f46bab4a7363db9e181c845a334cdb (diff) |
glusterd/auth: 3.2.x compatibility
volumes created with GlusterFS 3.2.x will be compatible
with GlusterFS 3.3 w.r.t auth.allow enhancements
Change-Id: I615e46d648e1270a7b856cd71fab24cfe791ddb8
BUG: 795634
Signed-off-by: Rajesh Amaravathi <rajesh@redhat.com>
Reviewed-on: http://review.gluster.com/2779
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Krishnan Parthasarathi <kp@gluster.com>
Reviewed-by: Vijay Bellur <vijay@gluster.com>
Diffstat (limited to 'xlators/mgmt')
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-handshake.c | 3 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-store.c | 24 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-utils.c | 26 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-volgen.c | 71 |
4 files changed, 72 insertions, 52 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-handshake.c b/xlators/mgmt/glusterd/src/glusterd-handshake.c index dd41330b6..64945a716 100644 --- a/xlators/mgmt/glusterd/src/glusterd-handshake.c +++ b/xlators/mgmt/glusterd/src/glusterd-handshake.c @@ -89,6 +89,9 @@ build_volfile_path (const char *volname, char *path, goto out; } + if (!glusterd_auth_get_username (volinfo)) + trusted_str = NULL; + ret = snprintf (path, path_len, "%s/vols/%s/%s.vol", priv->workdir, volinfo->volname, volname); if (ret == -1) diff --git a/xlators/mgmt/glusterd/src/glusterd-store.c b/xlators/mgmt/glusterd/src/glusterd-store.c index 900c12a82..56b75ec90 100644 --- a/xlators/mgmt/glusterd/src/glusterd-store.c +++ b/xlators/mgmt/glusterd/src/glusterd-store.c @@ -566,6 +566,8 @@ void _storeopts (dict_t *this, char *key, data_t *value, void *data) int32_t glusterd_volume_exclude_options_write (int fd, glusterd_volinfo_t *volinfo) { + char *str = NULL; + GF_ASSERT (fd > 0); GF_ASSERT (volinfo); @@ -631,15 +633,23 @@ glusterd_volume_exclude_options_write (int fd, glusterd_volinfo_t *volinfo) if (ret) goto out; - ret = glusterd_store_save_value (fd, GLUSTERD_STORE_KEY_USERNAME, - glusterd_auth_get_username (volinfo)); - if (ret) + str = glusterd_auth_get_username (volinfo); + if (str) { + ret = glusterd_store_save_value (fd, + GLUSTERD_STORE_KEY_USERNAME, + str); + if (ret) goto out; + } - ret = glusterd_store_save_value (fd, GLUSTERD_STORE_KEY_PASSWORD, - glusterd_auth_get_password (volinfo)); - if (ret) - goto out; + str = glusterd_auth_get_password (volinfo); + if (str) { + ret = glusterd_store_save_value (fd, + GLUSTERD_STORE_KEY_PASSWORD, + str); + if (ret) + goto out; + } out: if (ret) diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c index 117e5e8f3..f122acbf6 100644 --- a/xlators/mgmt/glusterd/src/glusterd-utils.c +++ b/xlators/mgmt/glusterd/src/glusterd-utils.c @@ -584,7 +584,6 @@ char * glusterd_auth_get_username (glusterd_volinfo_t *volinfo) { GF_ASSERT (volinfo); - GF_ASSERT (volinfo->auth.username); return volinfo->auth.username; } @@ -593,7 +592,6 @@ char * glusterd_auth_get_password (glusterd_volinfo_t *volinfo) { GF_ASSERT (volinfo); - GF_ASSERT (volinfo->auth.password); return volinfo->auth.password; } @@ -2118,28 +2116,20 @@ glusterd_import_volinfo (dict_t *vols, int count, memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "volume%d.username", count); ret = dict_get_str (vols, key, &str); - if (ret) { - snprintf (msg, sizeof (msg), - "%s missing in payload for %s", - key, volname); - goto out; + if (!ret) { + ret = glusterd_auth_set_username (new_volinfo, str); + if (ret) + goto out; } - ret = glusterd_auth_set_username (new_volinfo, str); - if (ret) - goto out; memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "volume%d.password", count); ret = dict_get_str (vols, key, &str); - if (ret) { - snprintf (msg, sizeof (msg), - "%s missing in payload for %s", - key, volname); - goto out; + if (!ret) { + ret = glusterd_auth_set_password (new_volinfo, str); + if (ret) + goto out; } - ret = glusterd_auth_set_password (new_volinfo, str); - if (ret) - goto out; memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "volume%d.transport_type", count); diff --git a/xlators/mgmt/glusterd/src/glusterd-volgen.c b/xlators/mgmt/glusterd/src/glusterd-volgen.c index 9bd1a2d1b..bc856bebf 100644 --- a/xlators/mgmt/glusterd/src/glusterd-volgen.c +++ b/xlators/mgmt/glusterd/src/glusterd-volgen.c @@ -1552,6 +1552,8 @@ server_graph_builder (volgen_graph_t *graph, glusterd_volinfo_t *volinfo, int ret = 0; char *xlator = NULL; char *loglevel = NULL; + char *username = NULL; + char *password = NULL; char index_basepath[PATH_MAX] = {0}; char key[1024] = {0}; @@ -1635,6 +1637,10 @@ server_graph_builder (volgen_graph_t *graph, glusterd_volinfo_t *volinfo, ret = pump = 0; if (ret) return -1; + + username = glusterd_auth_get_username (volinfo); + password = glusterd_auth_get_password (volinfo); + if (pump) { txl = first_of (graph); @@ -1647,15 +1653,17 @@ server_graph_builder (volgen_graph_t *graph, glusterd_volinfo_t *volinfo, if (NULL == ptranst) return -1; - ret = xlator_set_option (rbxl, "username", - glusterd_auth_get_username (volinfo)); - if (ret) - return -1; + if (username) { + ret = xlator_set_option (rbxl, "username", username); + if (ret) + return -1; + } - ret = xlator_set_option (rbxl, "password", - glusterd_auth_get_password (volinfo)); - if (ret) - return -1; + if (password) { + ret = xlator_set_option (rbxl, "password", password); + if (ret) + return -1; + } ret = xlator_set_option (rbxl, "transport-type", ptranst); GF_FREE (ptranst); @@ -1702,21 +1710,24 @@ server_graph_builder (volgen_graph_t *graph, glusterd_volinfo_t *volinfo, if (ret) return -1; - memset (key, 0, sizeof (key)); - snprintf (key, sizeof (key), "auth.login.%s.allow", path); - ret = xlator_set_option (xl, key, - glusterd_auth_get_username (volinfo)); - if (ret) - return -1; + if (username) { + memset (key, 0, sizeof (key)); + snprintf (key, sizeof (key), "auth.login.%s.allow", path); - memset (key, 0, sizeof (key)); - snprintf (key, sizeof (key), "auth.login.%s.password", - glusterd_auth_get_username (volinfo)); + ret = xlator_set_option (xl, key, username); + if (ret) + return -1; + } - ret = xlator_set_option (xl, key, - glusterd_auth_get_password (volinfo)); - if (ret) - return -1; + if (password) { + memset (key, 0, sizeof (key)); + snprintf (key, sizeof (key), "auth.login.%s.password", + username); + + ret = xlator_set_option (xl, key, password); + if (ret) + return -1; + } ret = volgen_graph_set_options_generic (graph, set_dict, (xlator && loglevel) ? (void *)set_dict : volinfo, @@ -2099,14 +2110,20 @@ volgen_graph_build_clients (volgen_graph_t *graph, glusterd_volinfo_t *volinfo, if (!ret && client_type == GF_CLIENT_TRUSTED) { str = glusterd_auth_get_username (volinfo); - ret = xlator_set_option (xl, "username", str); - if (ret) - goto out; + if (str) { + ret = xlator_set_option (xl, "username", + str); + if (ret) + goto out; + } str = glusterd_auth_get_password (volinfo); - ret = xlator_set_option (xl, "password", str); - if (ret) - goto out; + if (str) { + ret = xlator_set_option (xl, "password", + str); + if (ret) + goto out; + } } i++; |