diff options
Diffstat (limited to 'src/mongo')
-rw-r--r-- | src/mongo/db/audit.cpp | 6 | ||||
-rw-r--r-- | src/mongo/db/audit.h | 11 | ||||
-rw-r--r-- | src/mongo/db/catalog/drop_collection.cpp | 17 |
3 files changed, 30 insertions, 4 deletions
diff --git a/src/mongo/db/audit.cpp b/src/mongo/db/audit.cpp index c4880a92727..43eadc2954c 100644 --- a/src/mongo/db/audit.cpp +++ b/src/mongo/db/audit.cpp @@ -169,6 +169,12 @@ void mongo::audit::logDropIndex(Client* client, StringData indexname, StringData void mongo::audit::logDropCollection(Client* client, StringData nsname) {} +void mongo::audit::logDropView(Client* client, + StringData nsname, + StringData viewOn, + const std::vector<BSONObj>& pipeline, + ErrorCodes::Error code) {} + void mongo::audit::logDropDatabase(Client* client, StringData dbname) {} void mongo::audit::logRenameCollection(Client* client, StringData source, StringData target) {} diff --git a/src/mongo/db/audit.h b/src/mongo/db/audit.h index c01619ed580..5e2c0d633e5 100644 --- a/src/mongo/db/audit.h +++ b/src/mongo/db/audit.h @@ -308,11 +308,20 @@ void logCreateDatabase(Client* client, StringData dbname); void logDropIndex(Client* client, StringData indexname, StringData nsname); /** - * Logs the result of a dropCollection command. + * Logs the result of a dropCollection command on a collection. */ void logDropCollection(Client* client, StringData nsname); /** + * Logs the result of a dropCollection command on a view. + */ +void logDropView(Client* client, + StringData nsname, + StringData viewOn, + const std::vector<BSONObj>& pipeline, + ErrorCodes::Error code); + +/** * Logs the result of a dropDatabase command. */ void logDropDatabase(Client* client, StringData dbname); diff --git a/src/mongo/db/catalog/drop_collection.cpp b/src/mongo/db/catalog/drop_collection.cpp index 80584fb0e6d..fbcd3b19919 100644 --- a/src/mongo/db/catalog/drop_collection.cpp +++ b/src/mongo/db/catalog/drop_collection.cpp @@ -33,6 +33,7 @@ #include "mongo/db/catalog/drop_collection.h" +#include "mongo/db/audit.h" #include "mongo/db/catalog/index_catalog.h" #include "mongo/db/catalog/uncommitted_collections.h" #include "mongo/db/client.h" @@ -74,12 +75,16 @@ Status _dropView(OperationContext* opCtx, DropReply* reply, bool clearBucketCatalog = false) { if (!db) { - return Status(ErrorCodes::NamespaceNotFound, "ns not found"); + Status status = Status(ErrorCodes::NamespaceNotFound, "ns not found"); + audit::logDropView(&cc(), collectionName.ns(), "", {}, status.code()); + return status; } auto view = ViewCatalog::get(db)->lookupWithoutValidatingDurableViews(opCtx, collectionName.ns()); if (!view) { - return Status(ErrorCodes::NamespaceNotFound, "ns not found"); + Status status = Status(ErrorCodes::NamespaceNotFound, "ns not found"); + audit::logDropView(&cc(), collectionName.ns(), "", {}, status.code()); + return status; } // Validates the view or throws an "invalid view" error. @@ -110,6 +115,10 @@ Status _dropView(OperationContext* opCtx, } WriteUnitOfWork wunit(opCtx); + + audit::logDropView( + &cc(), collectionName.ns(), view->viewOn().ns(), view->pipeline(), ErrorCodes::OK); + Status status = db->dropView(opCtx, collectionName); if (!status.isOK()) { return status; @@ -325,7 +334,9 @@ Status dropCollection(OperationContext* opCtx, auto view = ViewCatalog::get(db)->lookupWithoutValidatingDurableViews( opCtx, collectionName.ns()); if (!view) { - return Status(ErrorCodes::NamespaceNotFound, "ns not found"); + Status status = Status(ErrorCodes::NamespaceNotFound, "ns not found"); + audit::logDropView(&cc(), collectionName.ns(), "", {}, status.code()); + return status; } if (!view->timeseries()) { |