summaryrefslogtreecommitdiff
path: root/src/mongo/db/ops
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/ops')
-rw-r--r--src/mongo/db/ops/insert.cpp8
-rw-r--r--src/mongo/db/ops/insert.h11
2 files changed, 16 insertions, 3 deletions
diff --git a/src/mongo/db/ops/insert.cpp b/src/mongo/db/ops/insert.cpp
index 131ebbc67b7..707bdfd4792 100644
--- a/src/mongo/db/ops/insert.cpp
+++ b/src/mongo/db/ops/insert.cpp
@@ -141,6 +141,14 @@ namespace mongo {
}
Status userAllowedWriteNS( const StringData& db, const StringData& coll ) {
+ if ( coll == "system.profile" ) {
+ return Status( ErrorCodes::BadValue,
+ str::stream() << "cannot write to '" << db << ".system.profile'" );
+ }
+ return userAllowedCreateNS( db, coll );
+ }
+
+ Status userAllowedCreateNS( const StringData& db, const StringData& coll ) {
// validity checking
if ( db.size() == 0 )
diff --git a/src/mongo/db/ops/insert.h b/src/mongo/db/ops/insert.h
index cc3082c2f4b..b449bfb6301 100644
--- a/src/mongo/db/ops/insert.h
+++ b/src/mongo/db/ops/insert.h
@@ -41,12 +41,17 @@ namespace mongo {
/**
- * check if this is a collection _any_ user can write to
- * does NOT to permission checking, that is elsewhere
- * for example, can't write to foo.system.bar
+ * Returns Status::OK() if this namespace is valid for user write operations. If not, returns
+ * an error Status.
*/
Status userAllowedWriteNS( const StringData& db, const StringData& coll );
Status userAllowedWriteNS( const StringData& ns );
Status userAllowedWriteNS( const NamespaceString& ns );
+ /**
+ * Returns Status::OK() if the namespace described by (db, coll) is valid for user create
+ * operations. If not, returns an error Status.
+ */
+ Status userAllowedCreateNS( const StringData& db, const StringData& coll );
+
}