summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Lehnardt <jan@apache.org>2017-06-03 11:48:56 +0200
committerJan Lehnardt <jan@apache.org>2017-06-03 11:48:56 +0200
commitc38d7aab035bce5f88ed772de59187a39da2768f (patch)
tree9f1a3de40181e656974698599d87a21961e2a342
parentb2b93c17754cb4169bf9e922d9be702eb6d0f0d5 (diff)
parent54623ce17e49ee9b5a6b69f0a8314c61b870f866 (diff)
downloadcouchdb-c38d7aab035bce5f88ed772de59187a39da2768f.tar.gz
Merge remote-tracking branch 'asf/salt-distribution'
* asf/salt-distribution: fix cluster setup: use same admin pq salt on all nodes
-rw-r--r--src/setup.erl23
-rw-r--r--src/setup_httpd.erl1
2 files changed, 12 insertions, 12 deletions
diff --git a/src/setup.erl b/src/setup.erl
index acbeb2d78..5a7100491 100644
--- a/src/setup.erl
+++ b/src/setup.erl
@@ -90,11 +90,13 @@ get_remote_request_options(Options) ->
enable_cluster_http(Options) ->
% POST to nodeB/_setup
RequestOptions = get_remote_request_options(Options),
+ AdminUsername = couch_util:get_value(username, Options),
+ AdminPasswordHash = config:get("admins", binary_to_list(AdminUsername)),
Body = ?JSON_ENCODE({[
{<<"action">>, <<"enable_cluster">>},
- {<<"username">>, couch_util:get_value(username, Options)},
- {<<"password">>, couch_util:get_value(password, Options)},
+ {<<"username">>, AdminUsername},
+ {<<"password_hash">>, ?l2b(AdminPasswordHash)},
{<<"bind_address">>, couch_util:get_value(bind_address, Options)},
{<<"port">>, couch_util:get_value(port, Options)},
{<<"node_count">>, couch_util:get_value(node_count, Options)}
@@ -125,7 +127,10 @@ enable_cluster_int(Options, no) ->
CurrentAdmins = config:get("admins"),
NewCredentials = {
proplists:get_value(username, Options),
- proplists:get_value(password, Options)
+ case proplists:get_value(password_hash, Options) of
+ undefined -> proplists:get_value(password, Options);
+ Pw -> Pw
+ end
},
% if bind_address == 127.0.0.1 and no bind_address in req -> error
@@ -138,7 +143,7 @@ enable_cluster_int(Options, no) ->
{undefined, undefined} ->
ok;
{Username, Password} ->
- maybe_set_admin(Username, Password)
+ set_admin(Username, Password)
end,
case NewBindAddress of
@@ -163,14 +168,8 @@ enable_cluster_int(Options, no) ->
end,
couch_log:notice("Enable Cluster: ~p~n", [Options]).
-maybe_set_admin(Username, Password) ->
- case couch_auth_cache:get_admin(Username) of
- nil ->
- HashedPassword = couch_passwords:hash_admin_password(Password),
- config:set("admins", binary_to_list(Username), binary_to_list(HashedPassword));
- _Else ->
- ok
- end.
+set_admin(Username, Password) ->
+ config:set("admins", binary_to_list(Username), binary_to_list(Password)).
finish_cluster() ->
diff --git a/src/setup_httpd.erl b/src/setup_httpd.erl
index 73ce147e3..a23a3e21d 100644
--- a/src/setup_httpd.erl
+++ b/src/setup_httpd.erl
@@ -57,6 +57,7 @@ handle_action("enable_cluster", Setup) ->
Options = get_options([
{username, <<"username">>},
{password, <<"password">>},
+ {password_hash, <<"password_hash">>},
{bind_address, <<"bind_address">>},
{port, <<"port">>},
{remote_node, <<"remote_node">>},