summaryrefslogtreecommitdiff
path: root/src/mongo
diff options
context:
space:
mode:
authorDenis Khodyakov <dennis.khodyakov@mongodb.com>2018-04-25 12:25:46 +0300
committerHenrik Ingo <henrik.ingo@mongodb.com>2018-04-25 12:28:08 +0300
commitdb80e9fbd16df2ef3b357bad4c4c7d9212e57dcf (patch)
treedae7461d83620b6eb71ca74a93d9665588787b56 /src/mongo
parent8883a5bfeeb6f67d78946d054f37eccda47adbe4 (diff)
downloadmongo-db80e9fbd16df2ef3b357bad4c4c7d9212e57dcf.tar.gz
Revert "SERVER-28871 remove obsolete Command::isUserManagementCommand"
This reverts commit 76bc4f800ba2a103d67fa4600d3946f255927818.
Diffstat (limited to 'src/mongo')
-rw-r--r--src/mongo/db/commands.h8
-rw-r--r--src/mongo/db/commands/user_management_commands.cpp60
-rw-r--r--src/mongo/db/service_entry_point_mongod.cpp9
3 files changed, 77 insertions, 0 deletions
diff --git a/src/mongo/db/commands.h b/src/mongo/db/commands.h
index 432866c5dcd..564c1d1ef75 100644
--- a/src/mongo/db/commands.h
+++ b/src/mongo/db/commands.h
@@ -255,6 +255,14 @@ public:
}
/**
+ * Return true for "user management commands", a distinction that affects
+ * backward compatible output formatting.
+ */
+ virtual bool isUserManagementCommand() const {
+ return false;
+ }
+
+ /**
* Return true if only the admin ns has privileges to run this command.
*/
virtual bool adminOnly() const {
diff --git a/src/mongo/db/commands/user_management_commands.cpp b/src/mongo/db/commands/user_management_commands.cpp
index b38338e6f57..fd3519d4871 100644
--- a/src/mongo/db/commands/user_management_commands.cpp
+++ b/src/mongo/db/commands/user_management_commands.cpp
@@ -744,6 +744,10 @@ class CmdCreateUser : public BasicCommand {
public:
CmdCreateUser() : BasicCommand("createUser") {}
+ bool isUserManagementCommand() const override {
+ return true;
+ }
+
AllowedOnSecondary secondaryAllowed(ServiceContext*) const override {
return AllowedOnSecondary::kNever;
}
@@ -886,6 +890,10 @@ class CmdUpdateUser : public BasicCommand {
public:
CmdUpdateUser() : BasicCommand("updateUser") {}
+ bool isUserManagementCommand() const override {
+ return true;
+ }
+
AllowedOnSecondary secondaryAllowed(ServiceContext*) const override {
return AllowedOnSecondary::kNever;
}
@@ -1028,6 +1036,10 @@ class CmdDropUser : public BasicCommand {
public:
CmdDropUser() : BasicCommand("dropUser") {}
+ bool isUserManagementCommand() const override {
+ return true;
+ }
+
AllowedOnSecondary secondaryAllowed(ServiceContext*) const override {
return AllowedOnSecondary::kNever;
}
@@ -1095,6 +1107,10 @@ class CmdDropAllUsersFromDatabase : public BasicCommand {
public:
CmdDropAllUsersFromDatabase() : BasicCommand("dropAllUsersFromDatabase") {}
+ bool isUserManagementCommand() const override {
+ return true;
+ }
+
AllowedOnSecondary secondaryAllowed(ServiceContext*) const override {
return AllowedOnSecondary::kNever;
}
@@ -1151,6 +1167,10 @@ class CmdGrantRolesToUser : public BasicCommand {
public:
CmdGrantRolesToUser() : BasicCommand("grantRolesToUser") {}
+ bool isUserManagementCommand() const override {
+ return true;
+ }
+
AllowedOnSecondary secondaryAllowed(ServiceContext*) const override {
return AllowedOnSecondary::kNever;
}
@@ -1223,6 +1243,10 @@ class CmdRevokeRolesFromUser : public BasicCommand {
public:
CmdRevokeRolesFromUser() : BasicCommand("revokeRolesFromUser") {}
+ bool isUserManagementCommand() const override {
+ return true;
+ }
+
AllowedOnSecondary secondaryAllowed(ServiceContext*) const override {
return AllowedOnSecondary::kNever;
}
@@ -1458,6 +1482,10 @@ class CmdCreateRole : public BasicCommand {
public:
CmdCreateRole() : BasicCommand("createRole") {}
+ bool isUserManagementCommand() const override {
+ return true;
+ }
+
AllowedOnSecondary secondaryAllowed(ServiceContext*) const override {
return AllowedOnSecondary::kNever;
}
@@ -1579,6 +1607,10 @@ class CmdUpdateRole : public BasicCommand {
public:
CmdUpdateRole() : BasicCommand("updateRole") {}
+ bool isUserManagementCommand() const override {
+ return true;
+ }
+
AllowedOnSecondary secondaryAllowed(ServiceContext*) const override {
return AllowedOnSecondary::kNever;
}
@@ -1696,6 +1728,10 @@ class CmdGrantPrivilegesToRole : public BasicCommand {
public:
CmdGrantPrivilegesToRole() : BasicCommand("grantPrivilegesToRole") {}
+ bool isUserManagementCommand() const override {
+ return true;
+ }
+
AllowedOnSecondary secondaryAllowed(ServiceContext*) const override {
return AllowedOnSecondary::kNever;
}
@@ -1806,6 +1842,10 @@ class CmdRevokePrivilegesFromRole : public BasicCommand {
public:
CmdRevokePrivilegesFromRole() : BasicCommand("revokePrivilegesFromRole") {}
+ bool isUserManagementCommand() const override {
+ return true;
+ }
+
AllowedOnSecondary secondaryAllowed(ServiceContext*) const override {
return AllowedOnSecondary::kNever;
}
@@ -1918,6 +1958,10 @@ class CmdGrantRolesToRole : public BasicCommand {
public:
CmdGrantRolesToRole() : BasicCommand("grantRolesToRole") {}
+ bool isUserManagementCommand() const override {
+ return true;
+ }
+
AllowedOnSecondary secondaryAllowed(ServiceContext*) const override {
return AllowedOnSecondary::kNever;
}
@@ -2007,6 +2051,10 @@ class CmdRevokeRolesFromRole : public BasicCommand {
public:
CmdRevokeRolesFromRole() : BasicCommand("revokeRolesFromRole") {}
+ bool isUserManagementCommand() const override {
+ return true;
+ }
+
AllowedOnSecondary secondaryAllowed(ServiceContext*) const override {
return AllowedOnSecondary::kNever;
}
@@ -2091,6 +2139,10 @@ class CmdDropRole : public BasicCommand {
public:
CmdDropRole() : BasicCommand("dropRole") {}
+ bool isUserManagementCommand() const override {
+ return true;
+ }
+
AllowedOnSecondary secondaryAllowed(ServiceContext*) const override {
return AllowedOnSecondary::kNever;
}
@@ -2233,6 +2285,10 @@ class CmdDropAllRolesFromDatabase : public BasicCommand {
public:
CmdDropAllRolesFromDatabase() : BasicCommand("dropAllRolesFromDatabase") {}
+ bool isUserManagementCommand() const override {
+ return true;
+ }
+
AllowedOnSecondary secondaryAllowed(ServiceContext*) const override {
return AllowedOnSecondary::kNever;
}
@@ -2535,6 +2591,10 @@ class CmdMergeAuthzCollections : public BasicCommand {
public:
CmdMergeAuthzCollections() : BasicCommand("_mergeAuthzCollections") {}
+ bool isUserManagementCommand() const override {
+ return true;
+ }
+
AllowedOnSecondary secondaryAllowed(ServiceContext*) const override {
return AllowedOnSecondary::kNever;
}
diff --git a/src/mongo/db/service_entry_point_mongod.cpp b/src/mongo/db/service_entry_point_mongod.cpp
index 26cbd30d235..59267d2ad18 100644
--- a/src/mongo/db/service_entry_point_mongod.cpp
+++ b/src/mongo/db/service_entry_point_mongod.cpp
@@ -88,6 +88,15 @@ public:
mongo::waitForWriteConcern(opCtx, lastOpAfterRun, opCtx->getWriteConcern(), &res);
CommandHelpers::appendCommandWCStatus(commandResponseBuilder, waitForWCStatus, res);
+
+ // SERVER-22421: This code is to ensure error response backwards compatibility with the
+ // user management commands. This can be removed in 3.6.
+ if (!waitForWCStatus.isOK() && invocation->definition()->isUserManagementCommand()) {
+ BSONObj temp = commandResponseBuilder.asTempObj().copy();
+ commandResponseBuilder.resetToEmpty();
+ CommandHelpers::appendCommandStatus(commandResponseBuilder, waitForWCStatus);
+ commandResponseBuilder.appendElementsUnique(temp);
+ }
}
void waitForLinearizableReadConcern(OperationContext* opCtx) const override {