From 02443793c6bf3453c7a937737f5159c060ef6504 Mon Sep 17 00:00:00 2001 From: shishir gowda Date: Tue, 31 May 2011 08:19:18 +0000 Subject: Introduce client-allow-insecure xlator-option. Allows glusterfs clients to bind to any port and does not restrict it to 1024. This is a xlator-option only, and is not supported in volume set cmd. The reason is, few clients may choose this, and few may not. Hence only supported as a xlator-option during mount time. For this to work with glusterfs, server.allow-insecure should be set to on Signed-off-by: shishir gowda Signed-off-by: Anand Avati BUG: 2868 (Add xlator-option to support insecure-bind for clients) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=2868 --- rpc/rpc-lib/src/rpc-transport.c | 16 ++++++++++++++++ rpc/rpc-lib/src/rpc-transport.h | 1 + rpc/rpc-transport/socket/src/name.c | 4 +++- xlators/protocol/client/src/client.c | 3 +++ 4 files changed, 23 insertions(+), 1 deletion(-) diff --git a/rpc/rpc-lib/src/rpc-transport.c b/rpc/rpc-lib/src/rpc-transport.c index e7ffb065f..8a33bdf2a 100644 --- a/rpc/rpc-lib/src/rpc-transport.c +++ b/rpc/rpc-lib/src/rpc-transport.c @@ -701,6 +701,7 @@ rpc_transport_load (glusterfs_ctx_t *ctx, dict_t *options, char *trans_name) int32_t ret = -1; int8_t is_tcp = 0, is_unix = 0, is_ibsdp = 0; volume_opt_list_t *vol_opt = NULL; + gf_boolean_t client_bind_insecure = _gf_false; GF_VALIDATE_OR_GOTO("rpc-transport", options, fail); GF_VALIDATE_OR_GOTO("rpc-transport", ctx, fail); @@ -762,6 +763,21 @@ rpc_transport_load (glusterfs_ctx_t *ctx, dict_t *options, char *trans_name) } } + ret = dict_get_str (options, "client-bind-insecure", &type); + if (ret == 0) { + ret = gf_string2boolean (type, &client_bind_insecure); + if (ret < 0) { + gf_log ("rcp-transport", GF_LOG_WARNING, + "client-bind-insecure option %s is not a" + " valid bool option", type); + goto fail; + } + if (_gf_true == client_bind_insecure) + trans->client_bind_insecure = 1; + } else { + trans->client_bind_insecure = 0; + } + ret = dict_get_str (options, "transport-type", &type); if (ret < 0) { gf_log ("rpc-transport", GF_LOG_ERROR, diff --git a/rpc/rpc-lib/src/rpc-transport.h b/rpc/rpc-lib/src/rpc-transport.h index 9db24c09f..52f0cb6f5 100644 --- a/rpc/rpc-lib/src/rpc-transport.h +++ b/rpc/rpc-lib/src/rpc-transport.h @@ -212,6 +212,7 @@ struct rpc_transport { uint64_t total_bytes_write; struct list_head list; + int client_bind_insecure; }; struct rpc_transport_ops { diff --git a/rpc/rpc-transport/socket/src/name.c b/rpc/rpc-transport/socket/src/name.c index 0667e4dbb..5e8b9d758 100644 --- a/rpc/rpc-transport/socket/src/name.c +++ b/rpc/rpc-transport/socket/src/name.c @@ -435,8 +435,10 @@ client_bind (rpc_transport_t *this, *sockaddr_len = sizeof (struct sockaddr_in); case AF_INET6: - ret = af_inet_bind_to_port_lt_ceiling (sock, sockaddr, + if (!this->client_bind_insecure) { + ret = af_inet_bind_to_port_lt_ceiling (sock, sockaddr, *sockaddr_len, CLIENT_PORT_CEILING); + } if (ret == -1) { gf_log (this->name, GF_LOG_DEBUG, "cannot bind inet socket (%d) to port less than %d (%s)", diff --git a/xlators/protocol/client/src/client.c b/xlators/protocol/client/src/client.c index 16ac4d212..4f7ee9cc1 100644 --- a/xlators/protocol/client/src/client.c +++ b/xlators/protocol/client/src/client.c @@ -2248,5 +2248,8 @@ struct volume_options options[] = { .min = 1, .max = 1013, }, + { .key = {"client-bind-insecure"}, + .type = GF_OPTION_TYPE_BOOL + }, { .key = {NULL} }, }; -- cgit