diff options
-rw-r--r-- | rpc/rpc-lib/src/rpcsvc-auth.c | 27 | ||||
-rw-r--r-- | rpc/rpc-lib/src/rpcsvc.c | 2 | ||||
-rw-r--r-- | rpc/rpc-lib/src/rpcsvc.h | 2 |
3 files changed, 30 insertions, 1 deletions
diff --git a/rpc/rpc-lib/src/rpcsvc-auth.c b/rpc/rpc-lib/src/rpcsvc-auth.c index 5cfa255ba95..be4004cc5f8 100644 --- a/rpc/rpc-lib/src/rpcsvc-auth.c +++ b/rpc/rpc-lib/src/rpcsvc-auth.c @@ -176,6 +176,32 @@ err: } int +rpcsvc_set_allow_insecure (rpcsvc_t *svc, dict_t *options) +{ + int ret = -1; + char *allow_insecure_str = NULL; + gf_boolean_t is_allow_insecure = _gf_false; + + GF_ASSERT (svc); + GF_ASSERT (options); + + ret = dict_get_str (options, "rpc-auth-allow-insecure", + &allow_insecure_str); + if (0 == ret) { + ret = gf_string2boolean (allow_insecure_str, + &is_allow_insecure); + if (0 == ret) { + if (_gf_true == is_allow_insecure) + svc->allow_insecure = 1; + else + svc->allow_insecure = 0; + } + } + + return 0; +} + +int rpcsvc_auth_init (rpcsvc_t *svc, dict_t *options) { int ret = -1; @@ -183,6 +209,7 @@ rpcsvc_auth_init (rpcsvc_t *svc, dict_t *options) if ((!svc) || (!options)) return -1; + (void) rpcsvc_set_allow_insecure (svc, options); ret = rpcsvc_auth_add_initers (svc); if (ret == -1) { gf_log (GF_RPCSVC, GF_LOG_ERROR, "Failed to add initers"); diff --git a/rpc/rpc-lib/src/rpcsvc.c b/rpc/rpc-lib/src/rpcsvc.c index d949677c35e..fc49a771268 100644 --- a/rpc/rpc-lib/src/rpcsvc.c +++ b/rpc/rpc-lib/src/rpcsvc.c @@ -963,7 +963,7 @@ rpcsvc_handle_rpc_call (rpcsvc_t *svc, rpc_transport_t *trans, gf_log ("rpcsvc", GF_LOG_TRACE, "Client port: %d", (int)port); - if (port > 1024) { //Non-privilaged user, fail request + if ((port > 1024) && (0 == svc->allow_insecure)) { //Non-privileged user, fail request gf_log ("glusterd", GF_LOG_ERROR, "Request received from non-" "privileged port. Failing request"); return -1; diff --git a/rpc/rpc-lib/src/rpcsvc.h b/rpc/rpc-lib/src/rpcsvc.h index 8625600db13..75a211c70a6 100644 --- a/rpc/rpc-lib/src/rpcsvc.h +++ b/rpc/rpc-lib/src/rpcsvc.h @@ -538,4 +538,6 @@ int rpcsvc_callback_submit (rpcsvc_t *rpc, rpc_transport_t *trans, rpcsvc_cbk_program_t *prog, int procnum, struct iovec *proghdr, int proghdrcount); +int +rpcsvc_set_allow_insecure (rpcsvc_t *svc, dict_t *options); #endif |