Open global changes db with admin context 43665-open-db-with-admin-ctx
authorRobert Newson <rnewson@apache.org>
Fri, 23 Jan 2015 16:33:33 +0000 (16:33 +0000)
committerRobert Newson <rnewson@apache.org>
Fri, 23 Jan 2015 16:33:33 +0000 (16:33 +0000)
The global changes feed should work even if the security object says otherwise.

BugzID: 43665

src/global_changes_server.erl

index 812d6dab00d7aff5f8c1c45afe53d58a8ba4adfd..b69b17a0a7cbc4bf95f3fb43a2e65ba0ef5dfcb7 100644 (file)
@@ -36,6 +36,7 @@
 -include_lib("couch/include/couch_db.hrl").
 -include_lib("mem3/include/mem3.hrl").
 
+-define(ADMIN_CTX, {user_ctx, #user_ctx{roles = [<<"_admin">>]}}).
 
 -record(state, {
     update_db,
@@ -151,7 +152,7 @@ flush_updates(State) ->
     try group_ids_by_shard(State#state.dbname, DocIds) of
     GroupedIds ->
         Docs = dict:fold(fun(ShardName, Ids, DocInfoAcc) ->
-            {ok, Shard} = couch_db:open(ShardName, []),
+            {ok, Shard} = couch_db:open(ShardName, [?ADMIN_CTX]),
             try
                 GroupedDocs = get_docs_locally(Shard, Ids),
                 GroupedDocs ++ DocInfoAcc