couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chewbra...@apache.org
Subject [1/2] chttpd commit: updated refs/heads/master to f86de50
Date Tue, 21 Jul 2015 20:51:30 GMT
Repository: couchdb-chttpd
Updated Branches:
  refs/heads/master 5022a94d3 -> f86de505a


Don't allow security updates during cassim migration


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

Branch: refs/heads/master
Commit: df0da709d09fef7676d9ab436b58a6543ce6b7c4
Parents: 5022a94
Author: Russell Branca <chewbranca@apache.org>
Authored: Fri Jun 26 22:30:23 2015 +0000
Committer: Russell Branca <chewbranca@apache.org>
Committed: Tue Jul 21 20:50:17 2015 +0000

----------------------------------------------------------------------
 src/chttpd.erl    |  3 +++
 src/chttpd_db.erl | 10 +++++++---
 2 files changed, 10 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/blob/df0da709/src/chttpd.erl
----------------------------------------------------------------------
diff --git a/src/chttpd.erl b/src/chttpd.erl
index 1b12db0..539eae1 100644
--- a/src/chttpd.erl
+++ b/src/chttpd.erl
@@ -767,6 +767,9 @@ error_info({missing_stub, Reason}) ->
     {412, <<"missing_stub">>, Reason};
 error_info(request_entity_too_large) ->
     {413, <<"too_large">>, <<"the request entity is too large">>};
+error_info({error, security_migration_updates_disabled}) ->
+    {503, <<"security_migration">>, <<"Updates to security docs are disabled
during "
+        "security migration.">>};
 error_info(not_implemented) ->
     {501, <<"not_implemented">>, <<"this feature is not yet implemented">>};
 error_info(timeout) ->

http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/blob/df0da709/src/chttpd_db.erl
----------------------------------------------------------------------
diff --git a/src/chttpd_db.erl b/src/chttpd_db.erl
index 207bc3f..97a70e5 100644
--- a/src/chttpd_db.erl
+++ b/src/chttpd_db.erl
@@ -1433,8 +1433,8 @@ demonitor_refs(Refs) when is_list(Refs) ->
 %% record makes it difficult to separate. This function should be refactored and
 %% moved into cassim once couch_doc_from_req and update_doc are reworked.
 put_security(#httpd{user_ctx=Ctx}=Req, Db, FetchRev) ->
-    case cassim:is_enabled() of
-        true ->
+    case {cassim:is_enabled(), cassim:metadata_db_exists()} of
+        {true, true} ->
             DbName = Db#db.name,
             DocId = cassim_metadata_cache:security_meta_id(DbName),
             {SecObj0} = chttpd:json_body(Req),
@@ -1464,7 +1464,11 @@ put_security(#httpd{user_ctx=Ctx}=Req, Db, FetchRev) ->
             HttpCode = http_code_from_status(Status),
             ResponseHeaders = [{"Etag", Etag}],
             send_json(Req, HttpCode, ResponseHeaders, Body);
-        false ->
+        {false, true} ->
+            throw({error, security_migration_updates_disabled});
+        %% handle completely disabled case and also cassim setting enabled but
+        %% metadata db does not exist.
+        _ ->
             SecObj = chttpd:json_body(Req),
             case fabric:set_security(Db, SecObj, [{user_ctx, Ctx}]) of
                 ok ->


Mime
View raw message