diff options
Diffstat (limited to 'src/mongo/db/commands')
36 files changed, 223 insertions, 171 deletions
diff --git a/src/mongo/db/commands/apply_ops_cmd.cpp b/src/mongo/db/commands/apply_ops_cmd.cpp index 12df18040a9..21947850f6c 100644 --- a/src/mongo/db/commands/apply_ops_cmd.cpp +++ b/src/mongo/db/commands/apply_ops_cmd.cpp @@ -43,16 +43,16 @@ #include "mongo/db/client.h" #include "mongo/db/commands.h" #include "mongo/db/commands/dbhash.h" -#include "mongo/db/db_raii.h" #include "mongo/db/concurrency/write_conflict_exception.h" +#include "mongo/db/db_raii.h" #include "mongo/db/dbdirectclient.h" -#include "mongo/db/service_context.h" #include "mongo/db/jsobj.h" #include "mongo/db/matcher/matcher.h" #include "mongo/db/operation_context.h" #include "mongo/db/repl/oplog.h" #include "mongo/db/repl/repl_client_info.h" #include "mongo/db/repl/replication_coordinator_global.h" +#include "mongo/db/service_context.h" #include "mongo/util/log.h" #include "mongo/util/scopeguard.h" @@ -147,8 +147,8 @@ private: // op - operation type BSONElement opElement = obj.getField("op"); if (opElement.eoo()) { - errmsg = str::stream() - << "op does not contain required \"op\" field: " << e.fieldName(); + errmsg = str::stream() << "op does not contain required \"op\" field: " + << e.fieldName(); return false; } if (opElement.type() != mongo::String) { @@ -166,8 +166,8 @@ private: // Only operations of type 'n' are allowed to have an empty namespace. BSONElement nsElement = obj.getField("ns"); if (nsElement.eoo()) { - errmsg = str::stream() - << "op does not contain required \"ns\" field: " << e.fieldName(); + errmsg = str::stream() << "op does not contain required \"ns\" field: " + << e.fieldName(); return false; } if (nsElement.type() != mongo::String) { @@ -179,8 +179,8 @@ private: return false; } if (*opType != 'n' && nsElement.String().empty()) { - errmsg = str::stream() - << "\"ns\" field value cannot be empty when op type is not 'n': " << e.fieldName(); + errmsg = str::stream() << "\"ns\" field value cannot be empty when op type is not 'n': " + << e.fieldName(); return false; } return true; diff --git a/src/mongo/db/commands/clone.cpp b/src/mongo/db/commands/clone.cpp index 9ce858feb3d..ddb251bc4c9 100644 --- a/src/mongo/db/commands/clone.cpp +++ b/src/mongo/db/commands/clone.cpp @@ -30,8 +30,8 @@ #include "mongo/base/status.h" #include "mongo/db/auth/action_set.h" -#include "mongo/db/auth/resource_pattern.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" diff --git a/src/mongo/db/commands/clone_collection.cpp b/src/mongo/db/commands/clone_collection.cpp index 87673050a2a..b8b475b6926 100644 --- a/src/mongo/db/commands/clone_collection.cpp +++ b/src/mongo/db/commands/clone_collection.cpp @@ -35,8 +35,8 @@ #include "mongo/bson/util/builder.h" #include "mongo/client/dbclientinterface.h" #include "mongo/db/auth/action_set.h" -#include "mongo/db/auth/resource_pattern.h" #include "mongo/db/auth/authorization_session.h" +#include "mongo/db/auth/resource_pattern.h" #include "mongo/db/catalog/collection.h" #include "mongo/db/catalog/document_validation.h" #include "mongo/db/cloner.h" @@ -48,8 +48,8 @@ #include "mongo/db/instance.h" #include "mongo/db/jsobj.h" #include "mongo/db/namespace_string.h" -#include "mongo/db/repl/isself.h" #include "mongo/db/ops/insert.h" +#include "mongo/db/repl/isself.h" #include "mongo/db/storage/storage_options.h" #include "mongo/util/log.h" diff --git a/src/mongo/db/commands/collection_to_capped.cpp b/src/mongo/db/commands/collection_to_capped.cpp index 59866778ab1..5484395cd6e 100644 --- a/src/mongo/db/commands/collection_to_capped.cpp +++ b/src/mongo/db/commands/collection_to_capped.cpp @@ -36,12 +36,12 @@ #include "mongo/db/client.h" #include "mongo/db/commands.h" #include "mongo/db/db_raii.h" -#include "mongo/db/service_context.h" #include "mongo/db/index_builder.h" #include "mongo/db/op_observer.h" #include "mongo/db/query/find.h" #include "mongo/db/query/internal_plans.h" #include "mongo/db/repl/replication_coordinator_global.h" +#include "mongo/db/service_context.h" namespace mongo { @@ -100,11 +100,12 @@ public: NamespaceString nss(dbname, to); if (!repl::getGlobalReplicationCoordinator()->canAcceptWritesFor(nss)) { - return appendCommandStatus(result, - Status(ErrorCodes::NotMaster, - str::stream() - << "Not primary while cloning collection " << from - << " to " << to << " (as capped)")); + return appendCommandStatus( + result, + Status(ErrorCodes::NotMaster, + str::stream() << "Not primary while cloning collection " << from << " to " + << to + << " (as capped)")); } Database* const db = autoDb.getDb(); diff --git a/src/mongo/db/commands/copydb.cpp b/src/mongo/db/commands/copydb.cpp index 7619c87a20d..92d721b70e1 100644 --- a/src/mongo/db/commands/copydb.cpp +++ b/src/mongo/db/commands/copydb.cpp @@ -31,8 +31,8 @@ #include "mongo/base/status.h" #include "mongo/client/sasl_client_authenticate.h" #include "mongo/db/auth/action_set.h" -#include "mongo/db/auth/resource_pattern.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" @@ -165,10 +165,11 @@ public: uassert(13008, "must call copydbgetnonce first", authConn.get()); BSONObj ret; { - if (!authConn->runCommand(cloneOptions.fromDB, - BSON("authenticate" << 1 << "user" << username << "nonce" - << nonce << "key" << key), - ret)) { + if (!authConn->runCommand( + cloneOptions.fromDB, + BSON("authenticate" << 1 << "user" << username << "nonce" << nonce << "key" + << key), + ret)) { errmsg = "unable to login " + ret.toString(); authConn.reset(); return false; @@ -179,11 +180,11 @@ public: 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)) { + if (!authConn->runCommand( + cloneOptions.fromDB, + BSON("saslContinue" << 1 << cmdObj[saslCommandConversationIdFieldName] + << cmdObj[saslCommandPayloadFieldName]), + ret)) { errmsg = "unable to login " + ret.toString(); authConn.reset(); return false; diff --git a/src/mongo/db/commands/copydb_common.cpp b/src/mongo/db/commands/copydb_common.cpp index 5f033aede73..2a690ae0a17 100644 --- a/src/mongo/db/commands/copydb_common.cpp +++ b/src/mongo/db/commands/copydb_common.cpp @@ -69,8 +69,8 @@ Status checkAuthForCopydbCommand(ClientBasic* client, actions.addAction(ActionType::bypassDocumentValidation); } - if (!AuthorizationSession::get(client) - ->isAuthorizedForActionsOnResource(ResourcePattern::forDatabaseName(todb), actions)) { + if (!AuthorizationSession::get(client)->isAuthorizedForActionsOnResource( + ResourcePattern::forDatabaseName(todb), actions)) { return Status(ErrorCodes::Unauthorized, "Unauthorized"); } diff --git a/src/mongo/db/commands/copydb_start_commands.cpp b/src/mongo/db/commands/copydb_start_commands.cpp index 609c1167184..8426b14d072 100644 --- a/src/mongo/db/commands/copydb_start_commands.cpp +++ b/src/mongo/db/commands/copydb_start_commands.cpp @@ -37,8 +37,8 @@ #include "mongo/client/dbclientinterface.h" #include "mongo/client/sasl_client_authenticate.h" #include "mongo/db/auth/action_set.h" -#include "mongo/db/auth/resource_pattern.h" #include "mongo/db/auth/authorization_session.h" +#include "mongo/db/auth/resource_pattern.h" #include "mongo/db/client.h" #include "mongo/db/cloner.h" #include "mongo/db/commands.h" diff --git a/src/mongo/db/commands/create_indexes.cpp b/src/mongo/db/commands/create_indexes.cpp index f18c15bce74..c7e42889772 100644 --- a/src/mongo/db/commands/create_indexes.cpp +++ b/src/mongo/db/commands/create_indexes.cpp @@ -41,13 +41,13 @@ #include "mongo/db/commands.h" #include "mongo/db/concurrency/write_conflict_exception.h" #include "mongo/db/curop.h" -#include "mongo/db/service_context.h" #include "mongo/db/op_observer.h" #include "mongo/db/ops/insert.h" #include "mongo/db/repl/repl_client_info.h" #include "mongo/db/repl/replication_coordinator_global.h" #include "mongo/db/s/collection_metadata.h" #include "mongo/db/s/sharding_state.h" +#include "mongo/db/service_context.h" #include "mongo/s/shard_key_pattern.h" #include "mongo/util/scopeguard.h" @@ -130,8 +130,8 @@ public: BSONElement e = it.next(); StringData fieldName(e.fieldName(), e.fieldNameSize()); if (std::find(keys.begin(), keys.end(), fieldName) != keys.end()) { - errmsg = str::stream() - << "duplicate keys detected in index spec: " << indexKey; + errmsg = str::stream() << "duplicate keys detected in index spec: " + << indexKey; return false; } keys.push_back(fieldName); @@ -286,7 +286,8 @@ public: Status(ErrorCodes::NotMaster, str::stream() << "Not primary while creating background indexes in " - << ns.ns() << ": cleaning up index build failure due to " + << ns.ns() + << ": cleaning up index build failure due to " << e.toString())); } } catch (...) { diff --git a/src/mongo/db/commands/distinct.cpp b/src/mongo/db/commands/distinct.cpp index 83aed3c3d0e..a280f059f23 100644 --- a/src/mongo/db/commands/distinct.cpp +++ b/src/mongo/db/commands/distinct.cpp @@ -127,8 +127,10 @@ public: return Status(ErrorCodes::TypeMismatch, str::stream() << "\"" << kQueryField << "\" had the wrong type. Expected " - << typeName(BSONType::Object) << " or " - << typeName(BSONType::jstNULL) << ", found " + << typeName(BSONType::Object) + << " or " + << typeName(BSONType::jstNULL) + << ", found " << typeName(queryElt.type())); } } @@ -142,7 +144,8 @@ public: return Status(ErrorCodes::TypeMismatch, str::stream() << "\"" << kCollationField << "\" had the wrong type. Expected " - << typeName(BSONType::Object) << ", found " + << typeName(BSONType::Object) + << ", found " << typeName(collationElt.type())); } collation = collationElt.embeddedObject(); @@ -198,8 +201,8 @@ public: { stdx::lock_guard<Client>(*txn->getClient()); - CurOp::get(txn) - ->setPlanSummary_inlock(Explain::getPlanSummary(executor.getValue().get())); + CurOp::get(txn)->setPlanSummary_inlock( + Explain::getPlanSummary(executor.getValue().get())); } string key = cmdObj[kKeyField].valuestrsafe(); diff --git a/src/mongo/db/commands/drop_indexes.cpp b/src/mongo/db/commands/drop_indexes.cpp index 9829ce29e3c..2b334a51e87 100644 --- a/src/mongo/db/commands/drop_indexes.cpp +++ b/src/mongo/db/commands/drop_indexes.cpp @@ -49,11 +49,11 @@ #include "mongo/db/curop.h" #include "mongo/db/db_raii.h" #include "mongo/db/dbdirectclient.h" -#include "mongo/db/service_context.h" #include "mongo/db/index/index_descriptor.h" #include "mongo/db/index_builder.h" #include "mongo/db/op_observer.h" #include "mongo/db/repl/replication_coordinator_global.h" +#include "mongo/db/service_context.h" #include "mongo/util/log.h" namespace mongo { diff --git a/src/mongo/db/commands/find_and_modify.cpp b/src/mongo/db/commands/find_and_modify.cpp index 0691b451f3e..dd1e04f311b 100644 --- a/src/mongo/db/commands/find_and_modify.cpp +++ b/src/mongo/db/commands/find_and_modify.cpp @@ -32,8 +32,8 @@ #include "mongo/db/commands/find_and_modify.h" -#include <memory> #include <boost/optional.hpp> +#include <memory> #include "mongo/base/status_with.h" #include "mongo/bson/bsonobj.h" @@ -127,7 +127,8 @@ StatusWith<boost::optional<BSONObj>> advanceExecutor(OperationContext* txn, const std::string opstr = isRemove ? "delete" : "update"; return {ErrorCodes::OperationFailed, str::stream() << "executor returned " << PlanExecutor::statestr(state) - << " while executing " << opstr}; + << " while executing " + << opstr}; } invariant(state == PlanExecutor::IS_EOF); @@ -376,8 +377,8 @@ public: // Attach the namespace and database profiling level to the current op. { stdx::lock_guard<Client> lk(*txn->getClient()); - CurOp::get(txn) - ->enter_inlock(nsString.ns().c_str(), autoDb.getDb()->getProfilingLevel()); + CurOp::get(txn)->enter_inlock(nsString.ns().c_str(), + autoDb.getDb()->getProfilingLevel()); } auto css = CollectionShardingState::get(txn, nsString); @@ -444,8 +445,8 @@ public: // Attach the namespace and database profiling level to the current op. { stdx::lock_guard<Client> lk(*txn->getClient()); - CurOp::get(txn) - ->enter_inlock(nsString.ns().c_str(), autoDb.getDb()->getProfilingLevel()); + CurOp::get(txn)->enter_inlock(nsString.ns().c_str(), + autoDb.getDb()->getProfilingLevel()); } auto css = CollectionShardingState::get(txn, nsString); diff --git a/src/mongo/db/commands/find_cmd.cpp b/src/mongo/db/commands/find_cmd.cpp index 547ebc4bfa1..5573e8fc819 100644 --- a/src/mongo/db/commands/find_cmd.cpp +++ b/src/mongo/db/commands/find_cmd.cpp @@ -41,16 +41,16 @@ #include "mongo/db/commands.h" #include "mongo/db/db_raii.h" #include "mongo/db/exec/working_set_common.h" -#include "mongo/db/service_context.h" #include "mongo/db/matcher/extensions_callback_real.h" -#include "mongo/db/repl/replication_coordinator.h" #include "mongo/db/query/cursor_response.h" #include "mongo/db/query/explain.h" #include "mongo/db/query/find.h" #include "mongo/db/query/find_common.h" #include "mongo/db/query/get_executor.h" +#include "mongo/db/repl/replication_coordinator.h" #include "mongo/db/s/collection_sharding_state.h" #include "mongo/db/server_parameters.h" +#include "mongo/db/service_context.h" #include "mongo/db/stats/counters.h" #include "mongo/util/log.h" diff --git a/src/mongo/db/commands/generic.cpp b/src/mongo/db/commands/generic.cpp index 05724e33705..941ac0d2503 100644 --- a/src/mongo/db/commands/generic.cpp +++ b/src/mongo/db/commands/generic.cpp @@ -281,9 +281,9 @@ public: if (it->first == it->second->getName()) commands.push_back(it->second); } - std::sort(commands.begin(), - commands.end(), - [](Command* lhs, Command* rhs) { return (lhs->getName()) < (rhs->getName()); }); + std::sort(commands.begin(), commands.end(), [](Command* lhs, Command* rhs) { + return (lhs->getName()) < (rhs->getName()); + }); BSONObjBuilder b(result.subobjStart("commands")); for (const auto& c : commands) { @@ -414,7 +414,8 @@ public: result, Status(ErrorCodes::TypeMismatch, str::stream() << "Argument to getLog must be of type String; found " - << val.toString(false) << " of type " + << val.toString(false) + << " of type " << typeName(val.type()))); } diff --git a/src/mongo/db/commands/getmore_cmd.cpp b/src/mongo/db/commands/getmore_cmd.cpp index 1ffc0342330..c2d4bd0da2f 100644 --- a/src/mongo/db/commands/getmore_cmd.cpp +++ b/src/mongo/db/commands/getmore_cmd.cpp @@ -49,8 +49,8 @@ #include "mongo/db/query/find_common.h" #include "mongo/db/query/getmore_request.h" #include "mongo/db/query/plan_summary_stats.h" -#include "mongo/db/repl/replication_coordinator_global.h" #include "mongo/db/repl/oplog.h" +#include "mongo/db/repl/replication_coordinator_global.h" #include "mongo/db/s/operation_sharding_state.h" #include "mongo/db/service_context.h" #include "mongo/db/stats/counters.h" @@ -137,8 +137,8 @@ public: } const GetMoreRequest& request = parseStatus.getValue(); - return AuthorizationSession::get(client) - ->checkAuthForGetMore(request.nss, request.cursorid, request.term.is_initialized()); + return AuthorizationSession::get(client)->checkAuthForGetMore( + request.nss, request.cursorid, request.term.is_initialized()); } bool run(OperationContext* txn, diff --git a/src/mongo/db/commands/group_cmd.cpp b/src/mongo/db/commands/group_cmd.cpp index 63308fc27ed..ba9ff7d2ead 100644 --- a/src/mongo/db/commands/group_cmd.cpp +++ b/src/mongo/db/commands/group_cmd.cpp @@ -94,8 +94,8 @@ private: const std::string& dbname, const BSONObj& cmdObj) { std::string ns = parseNs(dbname, cmdObj); - if (!AuthorizationSession::get(client) - ->isAuthorizedForActionsOnNamespace(NamespaceString(ns), ActionType::find)) { + if (!AuthorizationSession::get(client)->isAuthorizedForActionsOnNamespace( + NamespaceString(ns), ActionType::find)) { return Status(ErrorCodes::Unauthorized, "unauthorized"); } return Status::OK(); diff --git a/src/mongo/db/commands/index_filter_commands.cpp b/src/mongo/db/commands/index_filter_commands.cpp index ab8c0634747..ecf27a3f1d8 100644 --- a/src/mongo/db/commands/index_filter_commands.cpp +++ b/src/mongo/db/commands/index_filter_commands.cpp @@ -30,8 +30,8 @@ #include "mongo/platform/basic.h" -#include <string> #include <sstream> +#include <string> #include "mongo/base/init.h" #include "mongo/base/owned_pointer_vector.h" @@ -105,8 +105,8 @@ static Status getQuerySettingsAndPlanCache(OperationContext* txn, // available to the client. // -MONGO_INITIALIZER_WITH_PREREQUISITES(SetupIndexFilterCommands, - MONGO_NO_PREREQUISITES)(InitializerContext* context) { +MONGO_INITIALIZER_WITH_PREREQUISITES(SetupIndexFilterCommands, MONGO_NO_PREREQUISITES) +(InitializerContext* context) { new ListFilters(); new ClearFilters(); new SetFilter(); diff --git a/src/mongo/db/commands/index_filter_commands.h b/src/mongo/db/commands/index_filter_commands.h index 7ba1157bef7..80fed645c5e 100644 --- a/src/mongo/db/commands/index_filter_commands.h +++ b/src/mongo/db/commands/index_filter_commands.h @@ -29,8 +29,8 @@ #pragma once #include "mongo/db/commands.h" -#include "mongo/db/query/query_settings.h" #include "mongo/db/query/plan_cache.h" +#include "mongo/db/query/query_settings.h" namespace mongo { diff --git a/src/mongo/db/commands/index_filter_commands_test.cpp b/src/mongo/db/commands/index_filter_commands_test.cpp index 7f00a1521f4..765871ac134 100644 --- a/src/mongo/db/commands/index_filter_commands_test.cpp +++ b/src/mongo/db/commands/index_filter_commands_test.cpp @@ -308,13 +308,13 @@ TEST(IndexFilterCommandsTest, SetAndClearFilters) { addQueryShapeToPlanCache(txn.get(), &planCache, "{a: 1, b: 1}", "{a: -1}", "{_id: 0, a: 1}"); ASSERT_TRUE(planCacheContains(planCache, "{a: 1, b: 1}", "{a: -1}", "{_id: 0, a: 1}")); - ASSERT_OK(SetFilter::set(txn.get(), - &querySettings, - &planCache, - nss.ns(), - fromjson( - "{query: {a: 1, b: 1}, sort: {a: -1}, projection: {_id: 0, a: 1}, " - "indexes: [{a: 1}]}"))); + ASSERT_OK( + SetFilter::set(txn.get(), + &querySettings, + &planCache, + nss.ns(), + fromjson("{query: {a: 1, b: 1}, sort: {a: -1}, projection: {_id: 0, a: 1}, " + "indexes: [{a: 1}]}"))); vector<BSONObj> filters = getFilters(querySettings); ASSERT_EQUALS(filters.size(), 1U); @@ -328,13 +328,13 @@ TEST(IndexFilterCommandsTest, SetAndClearFilters) { // Replacing the hint for the same query shape ({a: 1, b: 1} and {b: 2, a: 3} // share same shape) should not change the query settings size. - ASSERT_OK(SetFilter::set(txn.get(), - &querySettings, - &planCache, - nss.ns(), - fromjson( - "{query: {b: 2, a: 3}, sort: {a: -1}, projection: {_id: 0, a: 1}, " - "indexes: [{a: 1, b: 1}]}"))); + ASSERT_OK( + SetFilter::set(txn.get(), + &querySettings, + &planCache, + nss.ns(), + fromjson("{query: {b: 2, a: 3}, sort: {a: -1}, projection: {_id: 0, a: 1}, " + "indexes: [{a: 1, b: 1}]}"))); filters = getFilters(querySettings); ASSERT_EQUALS(filters.size(), 1U); diff --git a/src/mongo/db/commands/list_indexes.cpp b/src/mongo/db/commands/list_indexes.cpp index f6d144de358..724c0f5f1f0 100644 --- a/src/mongo/db/commands/list_indexes.cpp +++ b/src/mongo/db/commands/list_indexes.cpp @@ -107,8 +107,8 @@ public: } return Status(ErrorCodes::Unauthorized, - str::stream() - << "Not authorized to list indexes on collection: " << ns.coll()); + str::stream() << "Not authorized to list indexes on collection: " + << ns.coll()); } CmdListIndexes() : Command("listIndexes") {} diff --git a/src/mongo/db/commands/mr.cpp b/src/mongo/db/commands/mr.cpp index 62d92ca1120..a55d60d0fb0 100644 --- a/src/mongo/db/commands/mr.cpp +++ b/src/mongo/db/commands/mr.cpp @@ -416,7 +416,9 @@ void State::prepTempCollection() { if (!status.isOK()) { uasserted(17305, str::stream() << "createIndex failed for mr incLong ns: " - << _config.incLong << " err: " << status.code()); + << _config.incLong + << " err: " + << status.code()); } wuow.commit(); } @@ -511,7 +513,9 @@ void State::appendResults(BSONObjBuilder& final) { BSONObj idKey = BSON("_id" << 1); if (!_db.runCommand("admin", BSON("splitVector" << _config.outputOptions.finalNamespace - << "keyPattern" << idKey << "maxChunkSizeBytes" + << "keyPattern" + << idKey + << "maxChunkSizeBytes" << _config.splitInfo), res)) { uasserted(15921, str::stream() << "splitVector failed: " << res); @@ -622,7 +626,8 @@ long long State::postProcessCollectionNonAtomic(OperationContext* txn, if (!_db.runCommand("admin", BSON("renameCollection" << _config.tempNamespace << "to" << _config.outputOptions.finalNamespace - << "stayTemp" << _config.shardedFirstPass), + << "stayTemp" + << _config.shardedFirstPass), info)) { uasserted(10076, str::stream() << "rename failed: " << info); } @@ -749,8 +754,10 @@ void State::_insertToInc(BSONObj& o) { if (o.objsize() > BSONObjMaxUserSize) { uasserted(ErrorCodes::BadValue, str::stream() << "object to insert too large for incremental collection" - << ". size in bytes: " << o.objsize() - << ", max size: " << BSONObjMaxUserSize); + << ". size in bytes: " + << o.objsize() + << ", max size: " + << BSONObjMaxUserSize); } // TODO: Consider whether to pass OpDebug for stats tracking under SERVER-23261. diff --git a/src/mongo/db/commands/mr_test.cpp b/src/mongo/db/commands/mr_test.cpp index d58ca5326f2..8987af00474 100644 --- a/src/mongo/db/commands/mr_test.cpp +++ b/src/mongo/db/commands/mr_test.cpp @@ -57,7 +57,11 @@ void _compareOutputOptionField(const std::string& dbname, if (actual == expected) return; FAIL(str::stream() << "parseOutputOptions(\"" << dbname << ", " << cmdObjStr << "): " - << fieldName << ": Expected: " << expected << ". Actual: " << actual); + << fieldName + << ": Expected: " + << expected + << ". Actual: " + << actual); } /** diff --git a/src/mongo/db/commands/oplog_note.cpp b/src/mongo/db/commands/oplog_note.cpp index bebf6d4d13c..784781405b4 100644 --- a/src/mongo/db/commands/oplog_note.cpp +++ b/src/mongo/db/commands/oplog_note.cpp @@ -32,13 +32,13 @@ #include "mongo/db/auth/action_type.h" #include "mongo/db/auth/authorization_session.h" #include "mongo/db/auth/resource_pattern.h" -#include "mongo/db/service_context.h" #include "mongo/db/commands.h" #include "mongo/db/jsobj.h" -#include "mongo/db/operation_context.h" #include "mongo/db/op_observer.h" +#include "mongo/db/operation_context.h" #include "mongo/db/repl/oplog.h" #include "mongo/db/repl/replication_coordinator_global.h" +#include "mongo/db/service_context.h" namespace mongo { diff --git a/src/mongo/db/commands/parallel_collection_scan.cpp b/src/mongo/db/commands/parallel_collection_scan.cpp index 425d5eb8791..2dfe8fdf614 100644 --- a/src/mongo/db/commands/parallel_collection_scan.cpp +++ b/src/mongo/db/commands/parallel_collection_scan.cpp @@ -28,6 +28,7 @@ #include "mongo/platform/basic.h" +#include "mongo/base/checked_cast.h" #include "mongo/db/auth/authorization_session.h" #include "mongo/db/catalog/collection.h" #include "mongo/db/catalog/database.h" @@ -38,7 +39,6 @@ #include "mongo/db/query/cursor_response.h" #include "mongo/db/service_context.h" #include "mongo/stdx/memory.h" -#include "mongo/base/checked_cast.h" namespace mongo { @@ -103,7 +103,8 @@ public: Status(ErrorCodes::BadValue, str::stream() << "numCursors has to be between 1 and 10000" - << " was: " << numCursors)); + << " was: " + << numCursors)); auto iterators = collection->getManyCursors(txn); if (iterators.size() < numCursors) { diff --git a/src/mongo/db/commands/parameters.cpp b/src/mongo/db/commands/parameters.cpp index c2a5bf23d91..acc8128536d 100644 --- a/src/mongo/db/commands/parameters.cpp +++ b/src/mongo/db/commands/parameters.cpp @@ -255,8 +255,8 @@ public: int newValue; if (!newValueElement.coerce(&newValue) || newValue < 0) return Status(ErrorCodes::BadValue, - mongoutils::str::stream() - << "Invalid value for logLevel: " << newValueElement); + mongoutils::str::stream() << "Invalid value for logLevel: " + << newValueElement); LogSeverity newSeverity = (newValue > 0) ? LogSeverity::Debug(newValue) : LogSeverity::Log(); globalLogDomain()->setMinimumLoggedSeverity(newSeverity); @@ -483,7 +483,8 @@ public: if (str != "disabled" && str != "allowSSL" && str != "preferSSL" && str != "requireSSL") { return Status(ErrorCodes::BadValue, mongoutils::str::stream() - << "Invalid value for sslMode via setParameter command: " << str); + << "Invalid value for sslMode via setParameter command: " + << str); } int oldMode = sslGlobalParams.sslMode.load(); @@ -495,7 +496,9 @@ public: return Status(ErrorCodes::BadValue, mongoutils::str::stream() << "Illegal state transition for sslMode, attempt to change from " - << sslModeStr() << " to " << str); + << sslModeStr() + << " to " + << str); } return Status::OK(); } @@ -566,7 +569,9 @@ public: #ifdef MONGO_CONFIG_SSL setInternalUserAuthParams( BSON(saslCommandMechanismFieldName - << "MONGODB-X509" << saslCommandUserDBFieldName << "$external" + << "MONGODB-X509" + << saslCommandUserDBFieldName + << "$external" << saslCommandUserFieldName << getSSLManager()->getSSLConfiguration().clientSubjectName)); #endif @@ -576,7 +581,9 @@ public: return Status(ErrorCodes::BadValue, mongoutils::str::stream() << "Illegal state transition for clusterAuthMode, change from " - << clusterAuthModeStr() << " to " << str); + << clusterAuthModeStr() + << " to " + << str); } return Status::OK(); } diff --git a/src/mongo/db/commands/pipeline_command.cpp b/src/mongo/db/commands/pipeline_command.cpp index c3154f96391..a2962ae712b 100644 --- a/src/mongo/db/commands/pipeline_command.cpp +++ b/src/mongo/db/commands/pipeline_command.cpp @@ -40,7 +40,6 @@ #include "mongo/db/db_raii.h" #include "mongo/db/exec/pipeline_proxy.h" #include "mongo/db/exec/working_set_common.h" -#include "mongo/db/service_context.h" #include "mongo/db/pipeline/accumulator.h" #include "mongo/db/pipeline/document.h" #include "mongo/db/pipeline/document_source.h" @@ -52,6 +51,7 @@ #include "mongo/db/query/find_common.h" #include "mongo/db/query/get_executor.h" #include "mongo/db/query/plan_summary_stats.h" +#include "mongo/db/service_context.h" #include "mongo/db/storage/storage_options.h" #include "mongo/stdx/memory.h" @@ -127,7 +127,9 @@ static bool handleCursorCommand(OperationContext* txn, msgasserted( 17391, str::stream() << "Aggregation has more results than fit in initial batch, but can't " - << "create cursor since collection " << ns << " doesn't exist"); + << "create cursor since collection " + << ns + << " doesn't exist"); } if (cursor) { diff --git a/src/mongo/db/commands/plan_cache_commands.cpp b/src/mongo/db/commands/plan_cache_commands.cpp index 440889255ba..0d4d11793f2 100644 --- a/src/mongo/db/commands/plan_cache_commands.cpp +++ b/src/mongo/db/commands/plan_cache_commands.cpp @@ -30,8 +30,8 @@ #include "mongo/platform/basic.h" -#include <string> #include <sstream> +#include <string> #include "mongo/base/init.h" #include "mongo/base/status.h" @@ -96,8 +96,8 @@ static Status getPlanCache(OperationContext* txn, // available to the client. // -MONGO_INITIALIZER_WITH_PREREQUISITES(SetupPlanCacheCommands, - MONGO_NO_PREREQUISITES)(InitializerContext* context) { +MONGO_INITIALIZER_WITH_PREREQUISITES(SetupPlanCacheCommands, MONGO_NO_PREREQUISITES) +(InitializerContext* context) { // PlanCacheCommand constructors refer to static ActionType instances. // Registering commands in a mongo static initializer ensures that // the ActionType construction will be completed first. diff --git a/src/mongo/db/commands/plan_cache_commands_test.cpp b/src/mongo/db/commands/plan_cache_commands_test.cpp index 21cbc937e73..bb8e2f0ad7e 100644 --- a/src/mongo/db/commands/plan_cache_commands_test.cpp +++ b/src/mongo/db/commands/plan_cache_commands_test.cpp @@ -202,8 +202,9 @@ TEST(PlanCacheCommandsTest, Canonicalize) { ASSERT_NOT_OK(PlanCacheCommand::canonicalize(&txn, nss.ns(), fromjson("{query: {}, sort: 1}")) .getStatus()); // Bad query (invalid sort order) - ASSERT_NOT_OK(PlanCacheCommand::canonicalize( - &txn, nss.ns(), fromjson("{query: {}, sort: {a: 0}}")).getStatus()); + ASSERT_NOT_OK( + PlanCacheCommand::canonicalize(&txn, nss.ns(), fromjson("{query: {}, sort: {a: 0}}")) + .getStatus()); // Valid parameters auto statusWithCQ = @@ -307,10 +308,12 @@ TEST(PlanCacheCommandsTest, planCacheClearOneKey) { // Check keys in cache before dropping {b: 1} vector<BSONObj> shapesBefore = getShapes(planCache); ASSERT_EQUALS(shapesBefore.size(), 2U); - BSONObj shapeA = BSON("query" << cqA->getQueryObj() << "sort" << cqA->getParsed().getSort() - << "projection" << cqA->getParsed().getProj()); - BSONObj shapeB = BSON("query" << cqB->getQueryObj() << "sort" << cqB->getParsed().getSort() - << "projection" << cqB->getParsed().getProj()); + BSONObj shapeA = + BSON("query" << cqA->getQueryObj() << "sort" << cqA->getParsed().getSort() << "projection" + << cqA->getParsed().getProj()); + BSONObj shapeB = + BSON("query" << cqB->getQueryObj() << "sort" << cqB->getParsed().getSort() << "projection" + << cqB->getParsed().getProj()); ASSERT_TRUE(std::find(shapesBefore.begin(), shapesBefore.end(), shapeA) != shapesBefore.end()); ASSERT_TRUE(std::find(shapesBefore.begin(), shapesBefore.end(), shapeB) != shapesBefore.end()); diff --git a/src/mongo/db/commands/rename_collection_cmd.cpp b/src/mongo/db/commands/rename_collection_cmd.cpp index 210e279607f..746aeb49db1 100644 --- a/src/mongo/db/commands/rename_collection_cmd.cpp +++ b/src/mongo/db/commands/rename_collection_cmd.cpp @@ -31,21 +31,21 @@ #include "mongo/client/dbclientcursor.h" #include "mongo/db/catalog/collection.h" #include "mongo/db/catalog/collection_catalog_entry.h" -#include "mongo/db/catalog/rename_collection.h" #include "mongo/db/catalog/database_holder.h" #include "mongo/db/catalog/index_catalog.h" #include "mongo/db/catalog/index_create.h" +#include "mongo/db/catalog/rename_collection.h" #include "mongo/db/client.h" #include "mongo/db/commands.h" #include "mongo/db/commands/rename_collection.h" #include "mongo/db/db_raii.h" -#include "mongo/db/service_context.h" #include "mongo/db/index/index_descriptor.h" #include "mongo/db/index_builder.h" #include "mongo/db/namespace_string.h" #include "mongo/db/op_observer.h" #include "mongo/db/ops/insert.h" #include "mongo/db/repl/replication_coordinator_global.h" +#include "mongo/db/service_context.h" #include "mongo/util/scopeguard.h" namespace mongo { diff --git a/src/mongo/db/commands/server_status.cpp b/src/mongo/db/commands/server_status.cpp index 9570b212f64..bbe7e9930a7 100644 --- a/src/mongo/db/commands/server_status.cpp +++ b/src/mongo/db/commands/server_status.cpp @@ -32,13 +32,13 @@ #include "mongo/platform/basic.h" +#include "mongo/config.h" #include "mongo/db/auth/action_set.h" #include "mongo/db/auth/action_type.h" #include "mongo/db/auth/authorization_manager.h" #include "mongo/db/auth/authorization_session.h" #include "mongo/db/auth/privilege.h" #include "mongo/db/client_basic.h" -#include "mongo/config.h" #include "mongo/db/commands.h" #include "mongo/db/commands/server_status.h" #include "mongo/db/commands/server_status_internal.h" diff --git a/src/mongo/db/commands/server_status.h b/src/mongo/db/commands/server_status.h index 1ebe57280d7..862cf1960e9 100644 --- a/src/mongo/db/commands/server_status.h +++ b/src/mongo/db/commands/server_status.h @@ -30,11 +30,11 @@ #pragma once -#include <string> #include "mongo/db/commands.h" #include "mongo/db/jsobj.h" #include "mongo/db/stats/counters.h" #include "mongo/platform/atomic_word.h" +#include <string> namespace mongo { diff --git a/src/mongo/db/commands/test_commands.cpp b/src/mongo/db/commands/test_commands.cpp index 5bcfe71e365..c32cc208090 100644 --- a/src/mongo/db/commands/test_commands.cpp +++ b/src/mongo/db/commands/test_commands.cpp @@ -41,11 +41,11 @@ #include "mongo/db/client.h" #include "mongo/db/commands.h" #include "mongo/db/db_raii.h" -#include "mongo/db/service_context.h" #include "mongo/db/index_builder.h" #include "mongo/db/op_observer.h" #include "mongo/db/query/internal_plans.h" #include "mongo/db/repl/replication_coordinator_global.h" +#include "mongo/db/service_context.h" #include "mongo/util/log.h" namespace mongo { @@ -263,11 +263,11 @@ public: for (int i = 0; i < n + 1; ++i) { PlanExecutor::ExecState state = exec->getNext(nullptr, &end); if (PlanExecutor::ADVANCED != state) { - return appendCommandStatus(result, - {ErrorCodes::IllegalOperation, - str::stream() - << "invalid n, collection contains fewer than " - << n << " documents"}); + return appendCommandStatus( + result, + {ErrorCodes::IllegalOperation, + str::stream() << "invalid n, collection contains fewer than " << n + << " documents"}); } } } diff --git a/src/mongo/db/commands/top_command.cpp b/src/mongo/db/commands/top_command.cpp index e4b788dc711..6f236de90da 100644 --- a/src/mongo/db/commands/top_command.cpp +++ b/src/mongo/db/commands/top_command.cpp @@ -33,10 +33,10 @@ #include "mongo/db/auth/action_type.h" #include "mongo/db/auth/privilege.h" #include "mongo/db/client.h" +#include "mongo/db/commands.h" #include "mongo/db/jsobj.h" #include "mongo/db/operation_context.h" #include "mongo/db/stats/top.h" -#include "mongo/db/commands.h" namespace { diff --git a/src/mongo/db/commands/user_management_commands.cpp b/src/mongo/db/commands/user_management_commands.cpp index 696339496eb..2bc8c1d1b51 100644 --- a/src/mongo/db/commands/user_management_commands.cpp +++ b/src/mongo/db/commands/user_management_commands.cpp @@ -95,7 +95,8 @@ BSONArray roleSetToBSONArray(const unordered_set<RoleName>& roles) { for (unordered_set<RoleName>::const_iterator it = roles.begin(); it != roles.end(); ++it) { const RoleName& role = *it; rolesArrayBuilder.append(BSON(AuthorizationManager::ROLE_NAME_FIELD_NAME - << role.getRole() << AuthorizationManager::ROLE_DB_FIELD_NAME + << role.getRole() + << AuthorizationManager::ROLE_DB_FIELD_NAME << role.getDB())); } return rolesArrayBuilder.arr(); @@ -106,7 +107,8 @@ BSONArray rolesVectorToBSONArray(const std::vector<RoleName>& roles) { for (std::vector<RoleName>::const_iterator it = roles.begin(); it != roles.end(); ++it) { const RoleName& role = *it; rolesArrayBuilder.append(BSON(AuthorizationManager::ROLE_NAME_FIELD_NAME - << role.getRole() << AuthorizationManager::ROLE_DB_FIELD_NAME + << role.getRole() + << AuthorizationManager::ROLE_DB_FIELD_NAME << role.getDB())); } return rolesArrayBuilder.arr(); @@ -172,9 +174,9 @@ Status checkOkayToGrantRolesToRole(OperationContext* txn, } if (role.getDB() != "admin" && roleToAdd.getDB() != role.getDB()) { - return Status(ErrorCodes::InvalidRoleModification, - str::stream() - << "Roles on the \'" << role.getDB() + return Status( + ErrorCodes::InvalidRoleModification, + str::stream() << "Roles on the \'" << role.getDB() << "\' database cannot be granted roles from other databases"); } @@ -195,11 +197,11 @@ Status checkOkayToGrantRolesToRole(OperationContext* txn, } if (sequenceContains(indirectRoles, role)) { - return Status(ErrorCodes::InvalidRoleModification, - mongoutils::str::stream() - << "Granting " << roleToAdd.getFullName() << " to " - << role.getFullName() - << " would introduce a cycle in the role graph."); + return Status( + ErrorCodes::InvalidRoleModification, + mongoutils::str::stream() << "Granting " << roleToAdd.getFullName() << " to " + << role.getFullName() + << " would introduce a cycle in the role graph."); } } return Status::OK(); @@ -421,13 +423,14 @@ Status insertRoleDocument(OperationContext* txn, const BSONObj& roleObj) { * Updates the given role object with the given update modifier. */ Status updateRoleDocument(OperationContext* txn, const RoleName& role, const BSONObj& updateObj) { - Status status = updateOneAuthzDocument( - txn, - AuthorizationManager::rolesCollectionNamespace, - BSON(AuthorizationManager::ROLE_NAME_FIELD_NAME - << role.getRole() << AuthorizationManager::ROLE_DB_FIELD_NAME << role.getDB()), - updateObj, - false); + Status status = updateOneAuthzDocument(txn, + AuthorizationManager::rolesCollectionNamespace, + BSON(AuthorizationManager::ROLE_NAME_FIELD_NAME + << role.getRole() + << AuthorizationManager::ROLE_DB_FIELD_NAME + << role.getDB()), + updateObj, + false); if (status.isOK()) { return status; } @@ -481,13 +484,14 @@ Status insertPrivilegeDocument(OperationContext* txn, const BSONObj& userObj) { Status updatePrivilegeDocument(OperationContext* txn, const UserName& user, const BSONObj& updateObj) { - Status status = updateOneAuthzDocument( - txn, - AuthorizationManager::usersCollectionNamespace, - BSON(AuthorizationManager::USER_NAME_FIELD_NAME - << user.getUser() << AuthorizationManager::USER_DB_FIELD_NAME << user.getDB()), - updateObj, - false); + Status status = updateOneAuthzDocument(txn, + AuthorizationManager::usersCollectionNamespace, + BSON(AuthorizationManager::USER_NAME_FIELD_NAME + << user.getUser() + << AuthorizationManager::USER_DB_FIELD_NAME + << user.getDB()), + updateObj, + false); if (status.isOK()) { return status; } @@ -554,7 +558,8 @@ Status requireAuthSchemaVersion26Final(OperationContext* txn, AuthorizationManag str::stream() << "User and role management commands require auth data to have " << "at least schema version " - << AuthorizationManager::schemaVersion26Final << " but found " + << AuthorizationManager::schemaVersion26Final + << " but found " << foundSchemaVersion); } return writeAuthSchemaVersionIfNeeded(txn, authzManager, foundSchemaVersion); @@ -577,7 +582,8 @@ Status requireAuthSchemaVersion26UpgradeOrFinal(OperationContext* txn, return Status(ErrorCodes::AuthSchemaIncompatible, str::stream() << "The usersInfo and rolesInfo commands require auth data to " << "have at least schema version " - << AuthorizationManager::schemaVersion26Upgrade << " but found " + << AuthorizationManager::schemaVersion26Upgrade + << " but found " << foundSchemaVersion); } return Status::OK(); @@ -1901,7 +1907,8 @@ public: ss << "Drops a single role. Before deleting the role completely it must remove it " "from any users or roles that reference it. If any errors occur in the middle " "of that process it's possible to be left in a state where the role has been " - "removed from some user/roles but otherwise still exists." << endl; + "removed from some user/roles but otherwise still exists." + << endl; } virtual Status checkAuthForCommand(ClientBasic* client, @@ -1967,11 +1974,12 @@ public: ErrorCodes::Error code = status.code() == ErrorCodes::UnknownError ? ErrorCodes::UserModificationFailed : status.code(); - return appendCommandStatus( - result, - Status(code, - str::stream() << "Failed to remove role " << roleName.getFullName() - << " from all users: " << status.reason())); + return appendCommandStatus(result, + Status(code, + str::stream() << "Failed to remove role " + << roleName.getFullName() + << " from all users: " + << status.reason())); } // Remove this role from all other roles @@ -2019,7 +2027,8 @@ public: Status(status.code(), str::stream() << "Removed role " << roleName.getFullName() << " from all users and roles but failed to actually delete" - " the role itself: " << status.reason())); + " the role itself: " + << status.reason())); } dassert(nMatched == 0 || nMatched == 1); @@ -2052,7 +2061,8 @@ public: "it must remove them from any users or other roles that reference them. If any " "errors occur in the middle of that process it's possible to be left in a state " "where the roles have been removed from some user/roles but otherwise still " - "exist." << endl; + "exist." + << endl; } virtual Status checkAuthForCommand(ClientBasic* client, @@ -2100,9 +2110,10 @@ public: : status.code(); return appendCommandStatus(result, Status(code, - str::stream() - << "Failed to remove roles from \"" << dbname - << "\" db from all users: " << status.reason())); + str::stream() << "Failed to remove roles from \"" + << dbname + << "\" db from all users: " + << status.reason())); } // Remove these roles from all other roles @@ -2125,9 +2136,10 @@ public: : status.code(); return appendCommandStatus(result, Status(code, - str::stream() - << "Failed to remove roles from \"" << dbname - << "\" db from all roles: " << status.reason())); + str::stream() << "Failed to remove roles from \"" + << dbname + << "\" db from all roles: " + << status.reason())); } audit::logDropAllRolesFromDatabase(ClientBasic::getCurrent(), dbname); @@ -2143,7 +2155,8 @@ public: str::stream() << "Removed roles from \"" << dbname << "\" db " " from all users and roles but failed to actually delete" - " those roles themselves: " << status.reason())); + " those roles themselves: " + << status.reason())); } result.append("n", nMatched); @@ -2535,7 +2548,9 @@ public: BSONObj query = db.empty() ? BSONObj() : BSON(AuthorizationManager::USER_DB_FIELD_NAME << db); BSONObj fields = BSON(AuthorizationManager::USER_NAME_FIELD_NAME - << 1 << AuthorizationManager::USER_DB_FIELD_NAME << 1); + << 1 + << AuthorizationManager::USER_DB_FIELD_NAME + << 1); Status status = queryAuthzDocument(txn, @@ -2613,7 +2628,9 @@ public: BSONObj query = db.empty() ? BSONObj() : BSON(AuthorizationManager::ROLE_DB_FIELD_NAME << db); BSONObj fields = BSON(AuthorizationManager::ROLE_NAME_FIELD_NAME - << 1 << AuthorizationManager::ROLE_DB_FIELD_NAME << 1); + << 1 + << AuthorizationManager::ROLE_DB_FIELD_NAME + << 1); Status status = queryAuthzDocument(txn, @@ -2741,7 +2758,8 @@ void updateUserCredentials(OperationContext* txn, mongoutils::str::stream() << "While preparing to upgrade user doc from " "2.6/3.0 user data schema to the 3.0+ SCRAM only schema, found a user doc " - "with missing or incorrectly formatted credentials: " << userDoc.toString(), + "with missing or incorrectly formatted credentials: " + << userDoc.toString(), credentialsElement.type() == Object); BSONObj credentialsObj = credentialsElement.Obj(); @@ -2758,7 +2776,8 @@ void updateUserCredentials(OperationContext* txn, mongoutils::str::stream() << "While preparing to upgrade user doc from " "2.6/3.0 user data schema to the 3.0+ SCRAM only schema, found a user doc " - "missing MONGODB-CR credentials :" << userDoc.toString(), + "missing MONGODB-CR credentials :" + << userDoc.toString(), !mongoCRElement.eoo()); std::string hashedPassword = mongoCRElement.String(); diff --git a/src/mongo/db/commands/user_management_commands_common.cpp b/src/mongo/db/commands/user_management_commands_common.cpp index 03a6a129fdc..292c21a8255 100644 --- a/src/mongo/db/commands/user_management_commands_common.cpp +++ b/src/mongo/db/commands/user_management_commands_common.cpp @@ -66,8 +66,8 @@ Status checkAuthorizedToGrantRoles(AuthorizationSession* authzSession, for (size_t i = 0; i < roles.size(); ++i) { if (!authzSession->isAuthorizedToGrantRole(roles[i])) { return Status(ErrorCodes::Unauthorized, - str::stream() - << "Not authorized to grant role: " << roles[i].getFullName()); + str::stream() << "Not authorized to grant role: " + << roles[i].getFullName()); } } @@ -91,8 +91,8 @@ Status checkAuthorizedToRevokeRoles(AuthorizationSession* authzSession, for (size_t i = 0; i < roles.size(); ++i) { if (!authzSession->isAuthorizedToRevokeRole(roles[i])) { return Status(ErrorCodes::Unauthorized, - str::stream() - << "Not authorized to revoke role: " << roles[i].getFullName()); + str::stream() << "Not authorized to revoke role: " + << roles[i].getFullName()); } } return Status::OK(); @@ -123,8 +123,8 @@ Status checkAuthForCreateUserCommand(ClientBasic* client, if (!authzSession->isAuthorizedForActionsOnResource( ResourcePattern::forDatabaseName(args.userName.getDB()), ActionType::createUser)) { return Status(ErrorCodes::Unauthorized, - str::stream() - << "Not authorized to create users on db: " << args.userName.getDB()); + str::stream() << "Not authorized to create users on db: " + << args.userName.getDB()); } return checkAuthorizedToGrantRoles(authzSession, args.roles); @@ -205,8 +205,8 @@ Status checkAuthForCreateRoleCommand(ClientBasic* client, if (!authzSession->isAuthorizedToCreateRole(args)) { return Status(ErrorCodes::Unauthorized, - str::stream() - << "Not authorized to create roles on db: " << args.roleName.getDB()); + str::stream() << "Not authorized to create roles on db: " + << args.roleName.getDB()); } status = checkAuthorizedToGrantRoles(authzSession, args.roles); @@ -441,7 +441,8 @@ Status checkAuthForRolesInfoCommand(ClientBasic* client, ActionType::viewRole)) { return Status(ErrorCodes::Unauthorized, str::stream() << "Not authorized to view roles from the " - << args.roleNames[i].getDB() << " database"); + << args.roleNames[i].getDB() + << " database"); } } } diff --git a/src/mongo/db/commands/write_commands/write_commands_common.cpp b/src/mongo/db/commands/write_commands/write_commands_common.cpp index 82f3ab4db67..aa208a1d3c7 100644 --- a/src/mongo/db/commands/write_commands/write_commands_common.cpp +++ b/src/mongo/db/commands/write_commands/write_commands_common.cpp @@ -33,9 +33,9 @@ #include <string> #include <vector> -#include "mongo/db/auth/privilege.h" #include "mongo/db/auth/action_set.h" #include "mongo/db/auth/action_type.h" +#include "mongo/db/auth/privilege.h" #include "mongo/db/catalog/document_validation.h" #include "mongo/util/assert_util.h" diff --git a/src/mongo/db/commands/write_commands/write_commands_common.h b/src/mongo/db/commands/write_commands/write_commands_common.h index cf47bdc02b1..53ba02aad05 100644 --- a/src/mongo/db/commands/write_commands/write_commands_common.h +++ b/src/mongo/db/commands/write_commands/write_commands_common.h @@ -28,9 +28,9 @@ #pragma once +#include "mongo/db/auth/authorization_session.h" #include "mongo/db/jsobj.h" #include "mongo/db/namespace_string.h" -#include "mongo/db/auth/authorization_session.h" #include "mongo/s/write_ops/batched_command_request.h" /** |