summaryrefslogtreecommitdiffstats
path: root/cli
diff options
context:
space:
mode:
authorJeff Darcy <jdarcy@redhat.com>2014-07-03 14:01:20 +0000
committerVijay Bellur <vbellur@redhat.com>2014-07-10 07:37:12 -0700
commitb42688786f25420de671ea06030edf4371058433 (patch)
tree33b4740179b4291222c0b2553b1527b8d8982be1 /cli
parent0f5719a3598ff4f72cef8b4fe1fcc2587ec39931 (diff)
socket/glusterd/client: enable SSL for management
The feature is controlled by presence of the following file: /var/lib/glusterd/secure-access See the comment near the definition of SECURE_ACCESS_FILE in glusterfs.h for the rationale. With this enabled, the following rules apply to connections: UNIX-domain sockets never have SSL. Management-port sockets (both connecting and accepting, in daemons and CLI) have SSL based on presence of the file. Other IP sockets have SSL based on the existing client.ssl and server.ssl volume options. Transport multi-threading is explicitly turned off in glusterd (it would otherwise be turned on when SSL is) due to multi-threading issues. Tests have been elided to avoid risk of leaving a file which will cause all subsequent tests to run with management SSL still enabled. IMPLEMENTATION NOTE The implementation is a bit messy, and consists of two stages. First we decide whether to set the relevant fields in our context structure, based on presence of the sentinel file OR a command-line override. Later we decide whether a particular connection should actually use SSL, based on the context flags plus what kind of connection we're making[1] and what kind of daemon we're in[2]. [1] inbound, outbound to glusterd port, other outbound [2] glusterd, glusterfsd, other TESTING NOTE Instead of just running one special test for this feature, the ideal would be to run all tests with management SSL enabled. However, it would be inappropriate or premature to set up an optional feature in the patch itself. Therefore, the method of choice is to submit a separate patch on top, which modifies "cleanup" in include.rc to recreate the secure-access file and associated SSL certificate/key files before each test. Change-Id: I0e04d6d08163893e24ec8c031748c5c447d7f780 BUG: 1114604 Signed-off-by: Jeff Darcy <jdarcy@redhat.com> Reviewed-on: http://review.gluster.org/8094 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Vijay Bellur <vbellur@redhat.com>
Diffstat (limited to 'cli')
-rw-r--r--cli/src/cli.c29
1 files changed, 25 insertions, 4 deletions
diff --git a/cli/src/cli.c b/cli/src/cli.c
index 745b0b45bf5..fa3c747d154 100644
--- a/cli/src/cli.c
+++ b/cli/src/cli.c
@@ -297,7 +297,8 @@ cli_rpc_notify (struct rpc_clnt *rpc, void *mydata, rpc_clnt_event_t event,
int
cli_opt_parse (char *opt, struct cli_state *state)
{
- char *oarg;
+ char *oarg = NULL;
+ gf_boolean_t secure_mgmt_tmp = 0;
if (strcmp (opt, "") == 0)
return 1;
@@ -370,6 +371,20 @@ cli_opt_parse (char *opt, struct cli_state *state)
return 0;
}
+ oarg = strtail (opt, "secure-mgmt=");
+ if (oarg) {
+ if (gf_string2boolean(oarg,&secure_mgmt_tmp) == 0) {
+ if (secure_mgmt_tmp) {
+ /* See declaration for why this is an int. */
+ state->ctx->secure_mgmt = 1;
+ }
+ }
+ else {
+ cli_err ("invalide secure-mgmt value (ignored)");
+ }
+ return 0;
+ }
+
return -1;
}
@@ -384,6 +399,11 @@ parse_cmdline (int argc, char *argv[], struct cli_state *state)
state->argc=argc-1;
state->argv=&argv[1];
+ /* Do this first so that an option can override. */
+ if (access(SECURE_ACCESS_FILE,F_OK) == 0) {
+ state->ctx->secure_mgmt = 1;
+ }
+
for (i = 0; i < state->argc; i++) {
opt = strtail (state->argv[i], "--");
if (opt) {
@@ -546,7 +566,6 @@ cli_rpc_init (struct cli_state *state)
int port = CLI_GLUSTERD_PORT;
xlator_t *this = NULL;
-
this = THIS;
cli_rpc_prog = &cli_prog;
options = dict_new ();
@@ -565,7 +584,8 @@ cli_rpc_init (struct cli_state *state)
0);
if (ret)
goto out;
- } else if (state->remote_host) {
+ }
+ else if (state->remote_host) {
gf_log ("cli", GF_LOG_INFO, "Connecting to remote glusterd at "
"%s", state->remote_host);
ret = dict_set_str (options, "remote-host", state->remote_host);
@@ -583,7 +603,8 @@ cli_rpc_init (struct cli_state *state)
"inet");
if (ret)
goto out;
- } else {
+ }
+ else {
gf_log ("cli", GF_LOG_DEBUG, "Connecting to glusterd using "
"default socket");
ret = rpc_transport_unix_options_build