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:16 UTC
[couchdb] 01/01: feat: refuse startup with no server admin set up
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()