From 1b07ac052dd87d5dd255ebc328e9b8e66fac21c5 Mon Sep 17 00:00:00 2001 From: Filipe David Borba Manana Date: Tue, 23 Nov 2010 11:35:39 +0000 Subject: Merged revision 1038067 from trunk: Replicator DB changes: - Added back the restriction that only the replicator can edit replication documents - this avoids lots of potential race conditions and confusion; - Added more tests; - More accurate log messages; - Don't ignore always replication documents already tagged with a replication_id property - this is necessary when replicating a replicator DB from one server to another server. git-svn-id: https://svn.apache.org/repos/asf/couchdb/branches/1.1.x@1038068 13f79535-47bb-0310-9956-ffa450edef68 --- src/couchdb/couch_js_functions.hrl | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'src/couchdb/couch_js_functions.hrl') diff --git a/src/couchdb/couch_js_functions.hrl b/src/couchdb/couch_js_functions.hrl index a2a40b3c..67f06686 100644 --- a/src/couchdb/couch_js_functions.hrl +++ b/src/couchdb/couch_js_functions.hrl @@ -99,14 +99,18 @@ -define(REP_DB_DOC_VALIDATE_FUN, <<" function(newDoc, oldDoc, userCtx) { - if (newDoc.user_ctx) { + function reportError(error_msg) { + log('Error writing document `' + newDoc._id + + '` to replicator DB: ' + error_msg); + throw({forbidden: error_msg}); + } - function reportError(error_msg) { - log('Error writing document ' + newDoc._id + - ' to replicator DB: ' + error_msg); - throw({forbidden: error_msg}); - } + var isReplicator = (userCtx.roles.indexOf('_replicator') >= 0); + if (oldDoc && !newDoc._deleted && !isReplicator) { + reportError('Only the replicator can edit replication documents.'); + } + if (newDoc.user_ctx) { var user_ctx = newDoc.user_ctx; if (typeof user_ctx !== 'object') { -- cgit v1.2.3