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 2020/01/03 18:29:15 UTC

[couchdb] branch feat/disable-launch-without-admin-password created (now d39a380)

This is an automated email from the ASF dual-hosted git repository.

jan pushed a change to branch feat/disable-launch-without-admin-password
in repository https://gitbox.apache.org/repos/asf/couchdb.git.


      at d39a380  feat: refuse startup with no server admin set up

This branch includes the following new commits:

     new d39a380  feat: refuse startup with no server admin set up

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[couchdb] 01/01: feat: refuse startup with no server admin set up

Posted by ja...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

jan pushed a commit to branch feat/disable-launch-without-admin-password
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit d39a380564cba39409a044bf9fc1ad085f945b47
Author: Jan Lehnardt <ja...@apache.org>
AuthorDate: Fri Jan 3 19:27:23 2020 +0100

    feat: refuse startup with no server admin set up
---
 src/couch/src/couch_sup.erl | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/src/couch/src/couch_sup.erl b/src/couch/src/couch_sup.erl
index 8dcaf1d..daa888f 100644
--- a/src/couch/src/couch_sup.erl
+++ b/src/couch/src/couch_sup.erl
@@ -28,6 +28,7 @@
 
 
 start_link() ->
+    assert_admins(),
     write_pidfile(),
     notify_starting(),
 
@@ -87,6 +88,20 @@ handle_config_change(_, _, _, _, _) ->
 handle_config_terminate(_Server, _Reason, _State) ->
     ok.
 
+assert_admins() ->
+    couch_log:info("Preflight check: Asserting Admin Account~n", []),
+    case config:get("admins") of
+        [] ->
+            couch_log:info("~n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%~n"
+                          ++ "  No Admin Account Found, aborting startup.                  ~n"
+                          ++ "  Please configure an admin account in your local.ini file.  ~n"
+                          ++ "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%~n", []),
+            % Wait a second so the log message can make it to the log
+            timer:sleep(1000),
+            throw(admin_account_required);
+        _ -> ok
+    end.
+
 notify_starting() ->
     couch_log:info("Apache CouchDB ~s is starting.~n", [
         couch_server:get_version()