You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ja...@apache.org on 2017/06/03 09:49:00 UTC

[1/2] couchdb-setup git commit: fix cluster setup: use same admin pq salt on all nodes

Repository: couchdb-setup
Updated Branches:
  refs/heads/master b2b93c177 -> c38d7aab0


fix cluster setup: use same admin pq salt on all nodes


Project: http://git-wip-us.apache.org/repos/asf/couchdb-setup/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-setup/commit/54623ce1
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-setup/tree/54623ce1
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-setup/diff/54623ce1

Branch: refs/heads/master
Commit: 54623ce17e49ee9b5a6b69f0a8314c61b870f866
Parents: e8d1e32
Author: Jan Lehnardt <ja...@apache.org>
Authored: Sat May 20 14:56:00 2017 +0200
Committer: Jan Lehnardt <ja...@apache.org>
Committed: Sat May 20 14:56:00 2017 +0200

----------------------------------------------------------------------
 src/setup.erl       | 23 +++++++++++------------
 src/setup_httpd.erl |  1 +
 2 files changed, 12 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-setup/blob/54623ce1/src/setup.erl
----------------------------------------------------------------------
diff --git a/src/setup.erl b/src/setup.erl
index b27c6c6..6657073 100644
--- a/src/setup.erl
+++ b/src/setup.erl
@@ -85,11 +85,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)}
     ]}),
@@ -119,7 +121,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
@@ -132,7 +137,7 @@ enable_cluster_int(Options, no) ->
         {undefined, undefined} ->
             ok;
         {Username, Password} ->
-            maybe_set_admin(Username, Password)
+            set_admin(Username, Password)
     end,
 
     case NewBindAddress of
@@ -154,14 +159,8 @@ enable_cluster_int(Options, no) ->
     couch_log:notice("Enable Cluster: ~p~n", [Options]).
     %cluster_state:set(enabled).
 
-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() ->

http://git-wip-us.apache.org/repos/asf/couchdb-setup/blob/54623ce1/src/setup_httpd.erl
----------------------------------------------------------------------
diff --git a/src/setup_httpd.erl b/src/setup_httpd.erl
index 006ed45..910fcb7 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">>},


[2/2] couchdb-setup git commit: Merge remote-tracking branch 'asf/salt-distribution'

Posted by ja...@apache.org.
Merge remote-tracking branch 'asf/salt-distribution'

* asf/salt-distribution:
  fix cluster setup: use same admin pq salt on all nodes


Project: http://git-wip-us.apache.org/repos/asf/couchdb-setup/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-setup/commit/c38d7aab
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-setup/tree/c38d7aab
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-setup/diff/c38d7aab

Branch: refs/heads/master
Commit: c38d7aab035bce5f88ed772de59187a39da2768f
Parents: b2b93c1 54623ce
Author: Jan Lehnardt <ja...@apache.org>
Authored: Sat Jun 3 11:48:56 2017 +0200
Committer: Jan Lehnardt <ja...@apache.org>
Committed: Sat Jun 3 11:48:56 2017 +0200

----------------------------------------------------------------------
 src/setup.erl       | 23 +++++++++++------------
 src/setup_httpd.erl |  1 +
 2 files changed, 12 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-setup/blob/c38d7aab/src/setup.erl
----------------------------------------------------------------------
diff --cc src/setup.erl
index acbeb2d,6657073..5a71004
--- a/src/setup.erl
+++ b/src/setup.erl
@@@ -93,11 -90,10 +95,11 @@@ enable_cluster_http(Options) -
  
      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)}
 +        {<<"port">>, couch_util:get_value(port, Options)},
 +        {<<"node_count">>, couch_util:get_value(node_count, Options)}
      ]}),
  
      Headers = [
@@@ -162,15 -157,10 +167,9 @@@ enable_cluster_int(Options, no) -
              config:set_integer("chttpd", "port", Port)
      end,
      couch_log:notice("Enable Cluster: ~p~n", [Options]).
 -    %cluster_state:set(enabled).
  
- 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() ->

http://git-wip-us.apache.org/repos/asf/couchdb-setup/blob/c38d7aab/src/setup_httpd.erl
----------------------------------------------------------------------