Info
Create a user with a single role that has the following privilege:
{ resource: {db: "test", collection: "x"}, actions: ["reIndex"] }
If the user tries to reIndex collection "x", the command fails as shown below:
> db.runCommand({reIndex: "x"})
{
"nIndexesWas" : 1,
"msg" : "indexes dropped for collection",
"errmsg" : "exception: invalid ns to index",
"code" : 10096,
"ok" : 0
}
On the other hand, if the user has the dbAdmin role, then the command works just fine:
> db.x.save({})
> db.runCommand({
... createUser: "testUser",
... pwd: "password",
... roles: ["dbAdmin"]
... })
{ "ok" : 1 }
> db.auth("testUser", "password")
1
> db.runCommand({reIndex: "x"})
{
"nIndexesWas" : 1,
"msg" : "indexes dropped for collection",
"nIndexes" : 1,
"indexes" : [
{
"key" : {
"_id" : 1
},
"ns" : "test.x",
"name" : "_id_"
}
],
"ok" : 1
}
Top User Comments
david.storch commented on Thu, 24 Oct 2013 14:44:35 +0000:
Yup, this was fixed by revision 2b16aca77cbd4486d780e21636b7043733e12765. Resolving.
spencer commented on Wed, 23 Oct 2013 23:07:39 +0000:
david.storch I cannot reproduce this. I think it may have been fixed by https://github.com/mongodb/mongo/commit/2b16aca77cbd4486d780e21636b7043733e12765. Can you re-test and see if you still see this?