Return-Path: X-Original-To: apmail-couchdb-commits-archive@www.apache.org Delivered-To: apmail-couchdb-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 6B977102A0 for ; Fri, 16 Jan 2015 17:14:42 +0000 (UTC) Received: (qmail 13370 invoked by uid 500); 16 Jan 2015 17:14:44 -0000 Delivered-To: apmail-couchdb-commits-archive@couchdb.apache.org Received: (qmail 13326 invoked by uid 500); 16 Jan 2015 17:14:44 -0000 Mailing-List: contact commits-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@couchdb.apache.org Delivered-To: mailing list commits@couchdb.apache.org Received: (qmail 13317 invoked by uid 99); 16 Jan 2015 17:14:44 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 16 Jan 2015 17:14:44 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 6C91FE03BD; Fri, 16 Jan 2015 17:14:43 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: mikewallace@apache.org To: commits@couchdb.apache.org Message-Id: <4fdc8333f27c455ab97ea0d4798236db@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: couch commit: updated refs/heads/2452-users-db-security-on-clustered-interface to 633b7f1 Date: Fri, 16 Jan 2015 17:14:43 +0000 (UTC) Repository: couchdb-couch Updated Branches: refs/heads/2452-users-db-security-on-clustered-interface 4e24b4cae -> 633b7f1ee [squash] Move users DB check into its own fun The chain of orelse statements combined with the indentation was pretty hard to read. This commit moves the checks into their own function and uses lists:any (which also shortcircuits). Project: http://git-wip-us.apache.org/repos/asf/couchdb-couch/repo Commit: http://git-wip-us.apache.org/repos/asf/couchdb-couch/commit/633b7f1e Tree: http://git-wip-us.apache.org/repos/asf/couchdb-couch/tree/633b7f1e Diff: http://git-wip-us.apache.org/repos/asf/couchdb-couch/diff/633b7f1e Branch: refs/heads/2452-users-db-security-on-clustered-interface Commit: 633b7f1ee9e76cf9a8520b5878b87e0170d9f1a6 Parents: 4e24b4c Author: Mike Wallace Authored: Fri Jan 16 15:10:40 2015 +0000 Committer: Mike Wallace Committed: Fri Jan 16 15:24:24 2015 +0000 ---------------------------------------------------------------------- src/couch_server.erl | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/633b7f1e/src/couch_server.erl ---------------------------------------------------------------------- diff --git a/src/couch_server.erl b/src/couch_server.erl index 9e6ea70..024ab4d 100644 --- a/src/couch_server.erl +++ b/src/couch_server.erl @@ -116,6 +116,14 @@ create(DbName, Options0) -> delete(DbName, Options) -> gen_server:call(couch_server, {delete, DbName, Options}, infinity). +is_users_db(DbName) -> + IsUsersDbPreds = [ + fun() -> DbName == config:get("couch_httpd_auth", "authentication_db", "_users") end, + fun() -> path_ends_with(DbName, <<"_users">>) end, + fun() -> binary_to_list(mem3:dbname(DbName)) == config:get("chttpd_auth", "authentication_db", "_users") end + ], + lists:any(fun(F) -> F() end, IsUsersDbPreds). + maybe_add_sys_db_callbacks(DbName, Options) when is_binary(DbName) -> maybe_add_sys_db_callbacks(?b2l(DbName), Options); maybe_add_sys_db_callbacks(DbName, Options) -> @@ -123,10 +131,7 @@ maybe_add_sys_db_callbacks(DbName, Options) -> NodesDbName = config:get("mem3", "shard_db", "nodes"), IsReplicatorDb = DbName == config:get("replicator", "db", "_replicator") orelse path_ends_with(DbName, <<"_replicator">>), - IsUsersDb = DbName ==config:get("couch_httpd_auth", "authentication_db", "_users") orelse - path_ends_with(DbName, <<"_users">>) orelse - binary_to_list(mem3:dbname(DbName)) == - config:get("chttpd_auth", "authentication_db", "_users"), + IsUsersDb = is_users_db(DbName), if DbName == DbsDbName -> [sys_db | Options];