summaryrefslogtreecommitdiff
path: root/src/mongo/db
diff options
context:
space:
mode:
authorMaria van Keulen <maria@mongodb.com>2018-07-27 17:09:24 -0400
committerMaria van Keulen <maria@mongodb.com>2018-08-07 14:26:55 -0400
commit88a8b7b31ca41eca88e782d84e496911c93cc0ae (patch)
treef60e0bee8e351180ad2c256c3c8946ec35fadeb6 /src/mongo/db
parent4c16f0f336f4db77034e8aa594bbd4a5bac3f40c (diff)
downloadmongo-88a8b7b31ca41eca88e782d84e496911c93cc0ae.tar.gz
SERVER-36257 Remove copyDB and clone commands
Diffstat (limited to 'src/mongo/db')
-rw-r--r--src/mongo/db/catalog/collection.h1
-rw-r--r--src/mongo/db/cloner.cpp1
-rw-r--r--src/mongo/db/cloner.h2
-rw-r--r--src/mongo/db/commands/SConscript3
-rw-r--r--src/mongo/db/commands/clone.cpp144
-rw-r--r--src/mongo/db/commands/clone_collection.cpp1
-rw-r--r--src/mongo/db/commands/copydb.cpp232
-rw-r--r--src/mongo/db/commands/copydb.h46
-rw-r--r--src/mongo/db/commands/copydb_common.cpp112
-rw-r--r--src/mongo/db/commands/copydb_start_commands.cpp1
10 files changed, 1 insertions, 542 deletions
diff --git a/src/mongo/db/catalog/collection.h b/src/mongo/db/catalog/collection.h
index 5d5c5c368e2..deb0ceb3aad 100644
--- a/src/mongo/db/catalog/collection.h
+++ b/src/mongo/db/catalog/collection.h
@@ -426,7 +426,6 @@ public:
* real delete.
* 'loc' key to uniquely identify a record in a collection.
* 'opDebug' Optional argument. When not null, will be used to record operation statistics.
- * 'cappedOK' if true, allows deletes on capped collections (Cloner::copyDB uses this).
* 'noWarn' if unindexing the record causes an error, if noWarn is true the error
* will not be logged.
*/
diff --git a/src/mongo/db/cloner.cpp b/src/mongo/db/cloner.cpp
index 5208128d87d..2dce75495d9 100644
--- a/src/mongo/db/cloner.cpp
+++ b/src/mongo/db/cloner.cpp
@@ -46,7 +46,6 @@
#include "mongo/db/catalog/database_holder.h"
#include "mongo/db/catalog/index_create.h"
#include "mongo/db/commands.h"
-#include "mongo/db/commands/copydb.h"
#include "mongo/db/commands/list_collections_filter.h"
#include "mongo/db/commands/rename_collection.h"
#include "mongo/db/concurrency/write_conflict_exception.h"
diff --git a/src/mongo/db/cloner.h b/src/mongo/db/cloner.h
index 61c0694e8f3..4775eb00e33 100644
--- a/src/mongo/db/cloner.h
+++ b/src/mongo/db/cloner.h
@@ -58,7 +58,7 @@ public:
/**
* Copies an entire database from the specified host.
* clonedColls: when not-null, the function will return with this populated with a list of
- * the collections that were cloned. This is for the user-facing clone command.
+ * the collections that were cloned.
* collectionsToClone: When opts.createCollections is false, this list reflects the collections
* that are cloned. When opts.createCollections is true, this parameter is
* ignored and the collection list is fetched from the remote via _conn.
diff --git a/src/mongo/db/commands/SConscript b/src/mongo/db/commands/SConscript
index 6d391e461bf..0d195add230 100644
--- a/src/mongo/db/commands/SConscript
+++ b/src/mongo/db/commands/SConscript
@@ -91,7 +91,6 @@ env.Library(
env.Library(
target="core",
source=[
- "copydb_common.cpp",
"fail_point_cmd.cpp",
"find_and_modify_common.cpp",
"generic.cpp",
@@ -277,11 +276,9 @@ env.Library(
target="mongod",
source=[
"apply_ops_cmd.cpp",
- "clone.cpp",
"clone_collection.cpp",
"collection_to_capped.cpp",
"compact.cpp",
- "copydb.cpp",
"copydb_start_commands.cpp",
"cpuload.cpp",
"dbcheck.cpp",
diff --git a/src/mongo/db/commands/clone.cpp b/src/mongo/db/commands/clone.cpp
deleted file mode 100644
index 451632600ed..00000000000
--- a/src/mongo/db/commands/clone.cpp
+++ /dev/null
@@ -1,144 +0,0 @@
-/**
-* Copyright (C) 2008 10gen Inc.
-*
-* This program is free software: you can redistribute it and/or modify
-* it under the terms of the GNU Affero General Public License, version 3,
-* as published by the Free Software Foundation.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU Affero General Public License for more details.
-*
-* You should have received a copy of the GNU Affero General Public License
-* along with this program. If not, see <http://www.gnu.org/licenses/>.
-*
-* As a special exception, the copyright holders give permission to link the
-* code of portions of this program with the OpenSSL library under certain
-* conditions as described in each individual source file and distribute
-* linked combinations including the program with the OpenSSL library. You
-* must comply with the GNU Affero General Public License in all respects for
-* all of the code used other than as permitted herein. If you modify file(s)
-* with this exception, you may extend this exception to your version of the
-* file(s), but you are not obligated to do so. If you do not wish to do so,
-* delete this exception statement from your version. If you delete this
-* exception statement from all source files in the program, then also delete
-* it in the license file.
-*/
-
-#define MONGO_LOG_DEFAULT_COMPONENT ::mongo::logger::LogComponent::kCommand
-#include "mongo/platform/basic.h"
-
-#include "mongo/base/status.h"
-#include "mongo/db/auth/action_set.h"
-#include "mongo/db/auth/authorization_session.h"
-#include "mongo/db/auth/resource_pattern.h"
-#include "mongo/db/catalog/document_validation.h"
-#include "mongo/db/cloner.h"
-#include "mongo/db/commands.h"
-#include "mongo/db/concurrency/d_concurrency.h"
-#include "mongo/db/jsobj.h"
-#include "mongo/s/grid.h"
-#include "mongo/util/log.h"
-
-namespace {
-
-using namespace mongo;
-
-using std::set;
-using std::string;
-using std::stringstream;
-
-/* The clone command is deprecated. See http://dochub.mongodb.org/core/copydb-clone-deprecation.
- Usage:
- mydb.$cmd.findOne( { clone: "fromhost" } );
- Note: doesn't work with authentication enabled, except as internal operation or for
- old-style users for backwards compatibility.
-*/
-class CmdClone : public BasicCommand {
-public:
- CmdClone() : BasicCommand("clone") {}
-
- AllowedOnSecondary secondaryAllowed(ServiceContext*) const override {
- return AllowedOnSecondary::kNever;
- }
-
- virtual bool supportsWriteConcern(const BSONObj& cmd) const override {
- return true;
- }
-
- std::string help() const override {
- return "clone this database from an instance of the db on another host\n"
- "{clone: \"host13\"[, slaveOk: <bool>]}";
- }
-
- virtual Status checkAuthForCommand(Client* client,
- const std::string& dbname,
- const BSONObj& cmdObj) const {
- ActionSet actions;
- actions.addAction(ActionType::insert);
- actions.addAction(ActionType::createIndex);
- if (shouldBypassDocumentValidationForCommand(cmdObj)) {
- actions.addAction(ActionType::bypassDocumentValidation);
- }
-
- if (!AuthorizationSession::get(client)->isAuthorizedForActionsOnResource(
- ResourcePattern::forDatabaseName(dbname), actions)) {
- return Status(ErrorCodes::Unauthorized, "Unauthorized");
- }
- return Status::OK();
- }
-
- virtual bool run(OperationContext* opCtx,
- const string& dbname,
- const BSONObj& cmdObj,
- BSONObjBuilder& result) {
- const char* deprecationWarning =
- "Support for the clone command has been deprecated. See "
- "http://dochub.mongodb.org/core/copydb-clone-deprecation";
- warning() << deprecationWarning;
- result.append("note", deprecationWarning);
- boost::optional<DisableDocumentValidation> maybeDisableValidation;
- if (shouldBypassDocumentValidationForCommand(cmdObj)) {
- maybeDisableValidation.emplace(opCtx);
- }
-
- string from = cmdObj.getStringField("clone");
- if (from.empty())
- return false;
-
- CloneOptions opts;
- opts.fromDB = dbname;
- opts.slaveOk = cmdObj["slaveOk"].trueValue();
-
- // collsToIgnore is only used by movePrimary and contains a list of the
- // sharded collections.
- if (cmdObj["collsToIgnore"].type() == Array) {
- BSONObjIterator it(cmdObj["collsToIgnore"].Obj());
-
- while (it.more()) {
- BSONElement e = it.next();
- if (e.type() == String) {
- opts.shardedColls.insert(e.String());
- }
- }
- }
-
- // Clone the non-ignored collections.
- set<string> clonedColls;
- Lock::DBLock dbXLock(opCtx, dbname, MODE_X);
-
- Cloner cloner;
- Status status = cloner.copyDb(opCtx, dbname, from, opts, &clonedColls);
-
- BSONArrayBuilder barr;
- barr.append(clonedColls);
- result.append("clonedColls", barr.arr());
-
- uassertStatusOK(status);
- return true;
- }
-
-} cmdClone;
-
-} // namespace
diff --git a/src/mongo/db/commands/clone_collection.cpp b/src/mongo/db/commands/clone_collection.cpp
index 3aa2c3ddc9e..af8d26eb518 100644
--- a/src/mongo/db/commands/clone_collection.cpp
+++ b/src/mongo/db/commands/clone_collection.cpp
@@ -41,7 +41,6 @@
#include "mongo/db/catalog/document_validation.h"
#include "mongo/db/cloner.h"
#include "mongo/db/commands.h"
-#include "mongo/db/commands/copydb.h"
#include "mongo/db/commands/rename_collection.h"
#include "mongo/db/db.h"
#include "mongo/db/index_builder.h"
diff --git a/src/mongo/db/commands/copydb.cpp b/src/mongo/db/commands/copydb.cpp
deleted file mode 100644
index 7b799d10bbf..00000000000
--- a/src/mongo/db/commands/copydb.cpp
+++ /dev/null
@@ -1,232 +0,0 @@
-/**
-* Copyright (C) 2008 10gen Inc.
-*
-* This program is free software: you can redistribute it and/or modify
-* it under the terms of the GNU Affero General Public License, version 3,
-* as published by the Free Software Foundation.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU Affero General Public License for more details.
-*
-* You should have received a copy of the GNU Affero General Public License
-* along with this program. If not, see <http://www.gnu.org/licenses/>.
-*
-* As a special exception, the copyright holders give permission to link the
-* code of portions of this program with the OpenSSL library under certain
-* conditions as described in each individual source file and distribute
-* linked combinations including the program with the OpenSSL library. You
-* must comply with the GNU Affero General Public License in all respects for
-* all of the code used other than as permitted herein. If you modify file(s)
-* with this exception, you may extend this exception to your version of the
-* file(s), but you are not obligated to do so. If you do not wish to do so,
-* delete this exception statement from your version. If you delete this
-* exception statement from all source files in the program, then also delete
-* it in the license file.
-*/
-
-#define MONGO_LOG_DEFAULT_COMPONENT ::mongo::logger::LogComponent::kCommand
-#include "mongo/platform/basic.h"
-
-#include "mongo/base/status.h"
-#include "mongo/client/sasl_client_authenticate.h"
-#include "mongo/db/auth/action_set.h"
-#include "mongo/db/auth/authorization_session.h"
-#include "mongo/db/auth/resource_pattern.h"
-#include "mongo/db/auth/sasl_command_constants.h"
-#include "mongo/db/catalog/document_validation.h"
-#include "mongo/db/catalog_raii.h"
-#include "mongo/db/cloner.h"
-#include "mongo/db/commands.h"
-#include "mongo/db/commands/copydb.h"
-#include "mongo/db/commands/copydb_start_commands.h"
-#include "mongo/db/concurrency/d_concurrency.h"
-#include "mongo/db/jsobj.h"
-#include "mongo/db/namespace_string.h"
-#include "mongo/util/log.h"
-
-namespace {
-
-using namespace mongo;
-
-using std::string;
-using std::stringstream;
-
-/* The copydb command is deprecated. See http://dochub.mongodb.org/core/copydb-clone-deprecation.
- * Usage:
- * admindb.$cmd.findOne( { copydb: 1, fromhost: <connection string>, fromdb: <db>,
- * todb: <db>[, username: <username>, nonce: <nonce>, key: <key>] } );
- *
- * The "copydb" command is used to copy a database. Note that this is a very broad definition.
- * This means that the "copydb" command can be used in the following ways:
- *
- * 1. To copy a database within a single node
- * 2. To copy a database within a sharded cluster, possibly to another shard
- * 3. To copy a database from one cluster to another
- *
- * Note that in all cases both the target and source database must be unsharded.
- *
- * The "copydb" command gets sent by the client or the mongos to the destination of the copy
- * operation. The node, cluster, or shard that recieves the "copydb" command must then query
- * the source of the database to be copied for all the contents and metadata of the database.
- *
- *
- *
- * When used with auth, there are two different considerations.
- *
- * The first is authentication with the target. The only entity that needs to authenticate with
- * the target node is the client, so authentication works there the same as it would with any
- * other command.
- *
- * The second is the authentication of the target with the source, which is needed because the
- * target must query the source directly for the contents of the database. To do this, the
- * client must use the "copydbgetnonce" command, in which the target will get a nonce from the
- * source and send it back to the client. The client can then hash its password with the nonce,
- * send it to the target when it runs the "copydb" command, which can then use that information
- * to authenticate with the source.
- *
- * NOTE: mongos doesn't know how to call or handle the "copydbgetnonce" command. See
- * SERVER-6427.
- *
- * NOTE: Since internal cluster auth works differently, "copydb" currently doesn't work between
- * shards in a cluster when auth is enabled. See SERVER-13080.
- */
-class CmdCopyDb : public ErrmsgCommandDeprecated {
-public:
- CmdCopyDb() : ErrmsgCommandDeprecated("copydb") {}
-
- virtual bool adminOnly() const {
- return true;
- }
-
- AllowedOnSecondary secondaryAllowed(ServiceContext*) const override {
- return AllowedOnSecondary::kNever;
- }
-
- virtual bool supportsWriteConcern(const BSONObj& cmd) const override {
- return true;
- }
-
- virtual Status checkAuthForCommand(Client* client,
- const std::string& dbname,
- const BSONObj& cmdObj) const {
- return copydb::checkAuthForCopydbCommand(client, dbname, cmdObj);
- }
-
- std::string help() const override {
- return "copy a database from another host to this host\n"
- "usage: {copydb: 1, fromhost: <connection string>, fromdb: <db>, todb: <db>"
- "[, slaveOk: <bool>, username: <username>, nonce: <nonce>, key: <key>]}";
- }
-
- virtual bool errmsgRun(OperationContext* opCtx,
- const string& dbname,
- const BSONObj& cmdObj,
- string& errmsg,
- BSONObjBuilder& result) {
- const char* deprecationWarning =
- "Support for the copydb command has been deprecated. See "
- "http://dochub.mongodb.org/core/copydb-clone-deprecation";
- warning() << deprecationWarning;
- result.append("note", deprecationWarning);
- boost::optional<DisableDocumentValidation> maybeDisableValidation;
- if (shouldBypassDocumentValidationForCommand(cmdObj))
- maybeDisableValidation.emplace(opCtx);
-
- string fromhost = cmdObj.getStringField("fromhost");
- bool fromSelf = fromhost.empty();
- if (fromSelf) {
- /* copy from self */
- stringstream ss;
- ss << "localhost:" << serverGlobalParams.port;
- fromhost = ss.str();
- }
-
- CloneOptions cloneOptions;
- const auto fromdbElt = cmdObj["fromdb"];
- uassert(ErrorCodes::TypeMismatch,
- "'fromdb' must be of type String",
- fromdbElt.type() == BSONType::String);
- cloneOptions.fromDB = fromdbElt.str();
- cloneOptions.slaveOk = cmdObj["slaveOk"].trueValue();
- cloneOptions.useReplAuth = false;
-
- const auto todbElt = cmdObj["todb"];
- uassert(ErrorCodes::TypeMismatch,
- "'todb' must be of type String",
- todbElt.type() == BSONType::String);
- const std::string todb = todbElt.str();
-
- uassert(ErrorCodes::InvalidNamespace,
- str::stream() << "Invalid 'todb' name: " << todb,
- NamespaceString::validDBName(todb, NamespaceString::DollarInDbNameBehavior::Allow));
- uassert(ErrorCodes::InvalidNamespace,
- str::stream() << "Invalid 'fromdb' name: " << cloneOptions.fromDB,
- NamespaceString::validDBName(cloneOptions.fromDB,
- NamespaceString::DollarInDbNameBehavior::Allow));
-
- if (fromhost.empty()) {
- errmsg =
- "params missing - {copydb: 1, fromhost: <connection string>, "
- "fromdb: <db>, todb: <db>}";
- return false;
- }
-
- Cloner cloner;
-
- auto& authConn = CopyDbAuthConnection::forClient(opCtx->getClient());
-
- if (cmdObj.hasField(saslCommandConversationIdFieldName) &&
- cmdObj.hasField(saslCommandPayloadFieldName)) {
- uassert(25487, "must call copydbsaslstart first", authConn.get());
- BSONObj ret;
- if (!authConn->runCommand(
- cloneOptions.fromDB,
- BSON("saslContinue" << 1 << cmdObj[saslCommandConversationIdFieldName]
- << cmdObj[saslCommandPayloadFieldName]),
- ret)) {
- errmsg = "unable to login " + ret.toString();
- authConn.reset();
- return false;
- }
-
- if (!ret["done"].Bool()) {
- CommandHelpers::filterCommandReplyForPassthrough(ret, &result);
- return true;
- }
-
- result.append("done", true);
- cloner.setConnection(std::move(authConn));
- } else if (!fromSelf) {
- // If fromSelf leave the cloner's conn empty, it will use a DBDirectClient instead.
- const ConnectionString cs(uassertStatusOK(ConnectionString::parse(fromhost)));
-
- auto conn = cs.connect(StringData(), errmsg);
- if (!conn) {
- return false;
- }
- cloner.setConnection(std::move(conn));
- }
-
- // Either we didn't need the authConn (if we even had one), or we already moved it
- // into the cloner so just make sure we don't keep it around if we don't need it.
- authConn.reset();
-
- if (fromSelf) {
- // SERVER-4328 todo lock just the two db's not everything for the fromself case
- // SERVER-34431 TODO: Add calls to DatabaseShardingState::get().checkDbVersion()
- // for source databases.
- Lock::GlobalWrite lk(opCtx);
- uassertStatusOK(cloner.copyDb(opCtx, todb, fromhost, cloneOptions, NULL));
- } else {
- AutoGetDb autoDb(opCtx, todb, MODE_X);
- uassertStatusOK(cloner.copyDb(opCtx, todb, fromhost, cloneOptions, NULL));
- }
-
- return true;
- }
-
-} cmdCopyDB;
-
-} // namespace
diff --git a/src/mongo/db/commands/copydb.h b/src/mongo/db/commands/copydb.h
deleted file mode 100644
index 0f2cec12a72..00000000000
--- a/src/mongo/db/commands/copydb.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/**
- * Copyright (C) 2013 10gen Inc.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- * As a special exception, the copyright holders give permission to link the
- * code of portions of this program with the OpenSSL library under certain
- * conditions as described in each individual source file and distribute
- * linked combinations including the program with the OpenSSL library. You
- * must comply with the GNU Affero General Public License in all respects for
- * all of the code used other than as permitted herein. If you modify file(s)
- * with this exception, you may extend this exception to your version of the
- * file(s), but you are not obligated to do so. If you do not wish to do so,
- * delete this exception statement from your version. If you delete this
- * exception statement from all source files in the program, then also delete
- * it in the license file.
- */
-
-#pragma once
-
-#include <string>
-#include <vector>
-
-#include "mongo/db/auth/privilege.h"
-#include "mongo/db/jsobj.h"
-
-namespace mongo {
-
-class Client;
-
-namespace copydb {
-
-Status checkAuthForCopydbCommand(Client* client, const std::string& dbname, const BSONObj& cmdObj);
-
-} // namespace copydb
-} // namespace mongo
diff --git a/src/mongo/db/commands/copydb_common.cpp b/src/mongo/db/commands/copydb_common.cpp
deleted file mode 100644
index 583c4054cfc..00000000000
--- a/src/mongo/db/commands/copydb_common.cpp
+++ /dev/null
@@ -1,112 +0,0 @@
-/**
-* Copyright (C) 2013 10gen Inc.
-*
-* This program is free software: you can redistribute it and/or modify
-* it under the terms of the GNU Affero General Public License, version 3,
-* as published by the Free Software Foundation.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU Affero General Public License for more details.
-*
-* You should have received a copy of the GNU Affero General Public License
-* along with this program. If not, see <http://www.gnu.org/licenses/>.
-*
-* As a special exception, the copyright holders give permission to link the
-* code of portions of this program with the OpenSSL library under certain
-* conditions as described in each individual source file and distribute
-* linked combinations including the program with the OpenSSL library. You
-* must comply with the GNU Affero General Public License in all respects for
-* all of the code used other than as permitted herein. If you modify file(s)
-* with this exception, you may extend this exception to your version of the
-* file(s), but you are not obligated to do so. If you do not wish to do so,
-* delete this exception statement from your version. If you delete this
-* exception statement from all source files in the program, then also delete
-* it in the license file.
-*/
-
-#include "mongo/db/commands/copydb.h"
-
-#include <string>
-#include <vector>
-
-#include "mongo/db/auth/action_set.h"
-#include "mongo/db/auth/action_type.h"
-#include "mongo/db/auth/authorization_session.h"
-#include "mongo/db/auth/privilege.h"
-#include "mongo/db/catalog/document_validation.h"
-#include "mongo/db/client.h"
-#include "mongo/db/jsobj.h"
-#include "mongo/db/namespace_string.h"
-
-namespace mongo {
-namespace copydb {
-
-Status checkAuthForCopydbCommand(Client* client, const std::string& dbname, const BSONObj& cmdObj) {
- const auto fromdbElt = cmdObj["fromdb"];
- if (fromdbElt.type() != BSONType::String) {
- return Status(ErrorCodes::TypeMismatch, "'fromdb' must be of type String");
- }
- const auto todbElt = cmdObj["todb"];
- if (todbElt.type() != BSONType::String) {
- return Status(ErrorCodes::TypeMismatch, "'todb' must be of type String");
- }
-
- bool fromSelf = StringData(cmdObj.getStringField("fromhost")).empty();
- const StringData fromdb = fromdbElt.valueStringData();
- const StringData todb = todbElt.valueStringData();
-
- // get system collections
- std::vector<std::string> legalClientSystemCollections;
- legalClientSystemCollections.push_back("system.js");
- if (fromdb == "admin") {
- legalClientSystemCollections.push_back("system.users");
- legalClientSystemCollections.push_back("system.roles");
- legalClientSystemCollections.push_back("system.version");
- } else if (fromdb == "local") { // TODO(spencer): shouldn't be possible. See SERVER-11383
- legalClientSystemCollections.push_back("system.replset");
- }
-
- // Check authorization on destination db
- ActionSet actions;
- actions.addAction(ActionType::insert);
- actions.addAction(ActionType::createIndex);
- if (shouldBypassDocumentValidationForCommand(cmdObj)) {
- actions.addAction(ActionType::bypassDocumentValidation);
- }
-
- if (!AuthorizationSession::get(client)->isAuthorizedForActionsOnResource(
- ResourcePattern::forDatabaseName(todb), actions)) {
- return Status(ErrorCodes::Unauthorized, "Unauthorized");
- }
-
- actions.removeAllActions();
- actions.addAction(ActionType::insert);
- for (size_t i = 0; i < legalClientSystemCollections.size(); ++i) {
- if (!AuthorizationSession::get(client)->isAuthorizedForActionsOnNamespace(
- NamespaceString(todb, legalClientSystemCollections[i]), actions)) {
- return Status(ErrorCodes::Unauthorized, "Unauthorized");
- }
- }
-
- if (fromSelf) {
- // If copying from self, also require privileges on source db
- actions.removeAllActions();
- actions.addAction(ActionType::find);
- if (!AuthorizationSession::get(client)->isAuthorizedForActionsOnResource(
- ResourcePattern::forDatabaseName(fromdb), actions)) {
- return Status(ErrorCodes::Unauthorized, "Unauthorized");
- }
- for (size_t i = 0; i < legalClientSystemCollections.size(); ++i) {
- if (!AuthorizationSession::get(client)->isAuthorizedForActionsOnNamespace(
- NamespaceString(fromdb, legalClientSystemCollections[i]), actions)) {
- return Status(ErrorCodes::Unauthorized, "Unauthorized");
- }
- }
- }
- return Status::OK();
-}
-
-} // namespace copydb
-} // namespace mongo
diff --git a/src/mongo/db/commands/copydb_start_commands.cpp b/src/mongo/db/commands/copydb_start_commands.cpp
index e06116a9bd8..495e17093d8 100644
--- a/src/mongo/db/commands/copydb_start_commands.cpp
+++ b/src/mongo/db/commands/copydb_start_commands.cpp
@@ -41,7 +41,6 @@
#include "mongo/db/client.h"
#include "mongo/db/cloner.h"
#include "mongo/db/commands.h"
-#include "mongo/db/commands/copydb.h"
#include "mongo/db/jsobj.h"
#include "mongo/db/operation_context.h"
#include "mongo/rpc/get_status_from_command_result.h"