[SERVER-11085] renameCollection must be run on the admin database on mongod but can be run on any database through mongos Created: 08/Oct/13  Updated: 30/Oct/15  Resolved: 08/Nov/13

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: 2.5.4

Type: Bug Priority: Minor - P4
Reporter: David Storch Assignee: Spencer Brody (Inactive)
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
is duplicated by SERVER-9475 renameCollection is marked as admin o... Closed
Related
is related to SERVER-9233 Add jstests for role-based access con... Closed
Backwards Compatibility: Minor Change
Operating System: ALL
Steps To Reproduce:

MongoDB shell version: 2.5.3-pre-
connecting to: 127.0.0.1:30999/test
mongos> use admin
switched to db admin
mongos> db.addUser({user: "admin", pwd: "password", roles: ["userAdminAnyDatabase", "readWriteAnyDatabase", "clusterAdmin"]})
{
	"user" : "admin",
	"roles" : [
		"userAdminAnyDatabase",
		"readWriteAnyDatabase",
		"clusterAdmin"
	]
}
mongos> db.auth("admin", "password")
1
mongos> use test
switched to db test
mongos> db.x.save({})
mongos> db.addUser({user: "x", pwd: "x", roles: ["readWriteAnyDatabase"]})
{ "user" : "x", "roles" : [ "readWriteAnyDatabase" ] }
mongos> db.auth("x", "x")
1
mongos> db.runCommand({renameCollection: "test.x", to: "test.y"})
{ "ok" : 1 }

The final command above should give the error "renameCollection may only be run against the admin database."

Participants:

 Description   

The renameCollection command must be run on the admin database through mongod. When connected to mongos, however, the renameCollection command may be run on any database. We should make this consistent, probably by making it so that even on mongos renameCollection must be run on the admin database.

Tested against githash c70a72b151fcfab26d0db5e8ceeb7c04a96ce449



 Comments   
Comment by auto [ 08/Nov/13 ]

Author:

{u'username': u'stbrody', u'name': u'Spencer T Brody', u'email': u'spencer@10gen.com'}

Message: SERVER-11085 Make renameCollection adminOnly on mongos, to match behavior on mongod
Branch: master
https://github.com/mongodb/mongo/commit/c5682b4510724fe275a20476fd23667025844d93

Comment by David Storch [ 08/Oct/13 ]

It is not a regression; the same behavior exists in 2.4.

Comment by Spencer Brody (Inactive) [ 08/Oct/13 ]

Is this a regression, or was this true in 2.4 also?

Generated at Thu Feb 08 03:24:51 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.