summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJason Rassi <rassi@10gen.com>2015-04-25 12:57:35 -0400
committerJason Rassi <rassi@10gen.com>2015-04-28 17:02:18 -0400
commit7a2b2614d8a786de848ada2c42e74276d887df13 (patch)
tree81717d11c1f1a2001ed2a9ad8bf93e0733539547 /src
parente5ee7906615bae2824a838bd23f226b6cbdb9ff2 (diff)
downloadmongo-7a2b2614d8a786de848ada2c42e74276d887df13.tar.gz
SERVER-18111 Check userAllowedWriteNS() in findAndModify cmd parsing
(cherry picked from commit 4ea827d383156d36e666d05eb6dad8bbc2a75801)
Diffstat (limited to 'src')
-rw-r--r--src/mongo/db/commands/find_and_modify.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/mongo/db/commands/find_and_modify.cpp b/src/mongo/db/commands/find_and_modify.cpp
index ba0817bc9e5..a287ce1a301 100644
--- a/src/mongo/db/commands/find_and_modify.cpp
+++ b/src/mongo/db/commands/find_and_modify.cpp
@@ -39,6 +39,7 @@
#include "mongo/db/pagefault.h"
#include "mongo/db/projection.h"
#include "mongo/db/ops/delete.h"
+#include "mongo/db/ops/insert.h"
#include "mongo/db/ops/update.h"
#include "mongo/db/ops/update_lifecycle_impl.h"
#include "mongo/db/queryutil.h"
@@ -71,6 +72,10 @@ namespace mongo {
verify( cmdObj["sort"].eoo() );
string ns = dbname + '.' + cmdObj.firstElement().valuestr();
+ Status allowedWriteStatus = userAllowedWriteNS(ns);
+ if (!allowedWriteStatus.isOK()) {
+ return appendCommandStatus(result, allowedWriteStatus);
+ }
BSONObj query = cmdObj.getObjectField("query");
BSONObj fields = cmdObj.getObjectField("fields");
@@ -299,6 +304,10 @@ namespace mongo {
return runNoDirectClient( dbname , cmdObj , x, errmsg , result, y );
string ns = dbname + '.' + cmdObj.firstElement().valuestr();
+ Status allowedWriteStatus = userAllowedWriteNS(ns);
+ if (!allowedWriteStatus.isOK()) {
+ return appendCommandStatus(result, allowedWriteStatus);
+ }
BSONObj origQuery = cmdObj.getObjectField("query"); // defaults to {}
Query q (origQuery);