summaryrefslogtreecommitdiff
path: root/src/mongo
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo')
-rw-r--r--src/mongo/db/storage/storage_engine_lock_file_posix.cpp6
-rw-r--r--src/mongo/db/storage/storage_engine_lock_file_test.cpp82
-rw-r--r--src/mongo/db/storage/storage_engine_lock_file_windows.cpp6
3 files changed, 0 insertions, 94 deletions
diff --git a/src/mongo/db/storage/storage_engine_lock_file_posix.cpp b/src/mongo/db/storage/storage_engine_lock_file_posix.cpp
index cb78d518e15..fd4d987f6c2 100644
--- a/src/mongo/db/storage/storage_engine_lock_file_posix.cpp
+++ b/src/mongo/db/storage/storage_engine_lock_file_posix.cpp
@@ -101,12 +101,6 @@ Status StorageEngineLockFile::open() {
::open(_filespec.c_str(), O_RDWR | O_CREAT, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
if (lockFile < 0) {
int errorcode = errno;
- if (errorcode == EACCES) {
- return Status(ErrorCodes::IllegalOperation,
- str::stream()
- << "Attempted to create a lock file on a read-only directory: "
- << _dbpath << " - did you mean to start with --readOnly?");
- }
return Status(ErrorCodes::DBPathInUse,
str::stream() << "Unable to create/open lock file: " << _filespec << ' '
<< errnoWithDescription(errorcode)
diff --git a/src/mongo/db/storage/storage_engine_lock_file_test.cpp b/src/mongo/db/storage/storage_engine_lock_file_test.cpp
index cd3f1a1ef80..9312b7f7c3a 100644
--- a/src/mongo/db/storage/storage_engine_lock_file_test.cpp
+++ b/src/mongo/db/storage/storage_engine_lock_file_test.cpp
@@ -37,10 +37,6 @@
#include "mongo/unittest/temp_dir.h"
#include "mongo/unittest/unittest.h"
-#ifndef _WIN32
-#include <sys/stat.h>
-#endif
-
namespace {
using std::string;
@@ -173,82 +169,4 @@ TEST(StorageEngineLockFileTest, ClearPidAndUnlock) {
ASSERT_EQUALS(0U, boost::filesystem::file_size(lockFile.getFilespec()));
}
-class ScopedReadOnlyDirectory {
-public:
- ScopedReadOnlyDirectory(const std::string& path) : _path(std::move(path)) {
- _applyToPathRecursive(_path, makePathReadOnly);
- }
-
- ~ScopedReadOnlyDirectory() {
- _applyToPathRecursive(_path, makePathWritable);
- }
-
-private:
- const std::string& _path;
-
- static void makePathReadOnly(const boost::filesystem::path& path) {
-#ifdef _WIN32
- ::SetFileAttributes(path.c_str(), FILE_ATTRIBUTE_READONLY);
-#else
- ::chmod(path.c_str(), 0544);
-#endif
- }
-
- static void makePathWritable(const boost::filesystem::path& path) {
-#ifdef _WIN32
- ::SetFileAttributes(path.c_str(), FILE_ATTRIBUTE_NORMAL);
-#else
- ::chmod(path.c_str(), 0777);
-#endif
- }
-
- template <typename Func>
- static void _applyToPathRecursive(const boost::filesystem::path& path, Func func) {
- func(path);
-
- using rdi = boost::filesystem::recursive_directory_iterator;
- for (auto iter = rdi{path}; iter != rdi(); ++iter) {
- func(*iter);
- }
- }
-};
-
-#ifndef _WIN32
-
-// Windows has no concept of read only directories - only read only files.
-TEST(StorageEngineLockFileTest, ReadOnlyDirectory) {
- TempDir tempDir("StorageEngineLockFileTest_ReadOnlyDirectory");
-
- // Make tempDir read-only.
- ScopedReadOnlyDirectory srod(tempDir.path());
-
- StorageEngineLockFile lockFile(tempDir.path());
-
- auto openStatus = lockFile.open();
-
- ASSERT_NOT_OK(openStatus);
- ASSERT_EQ(openStatus, ErrorCodes::IllegalOperation);
-}
-
-#endif
-
-TEST(StorageEngineLockFileTest, ReadOnlyDirectoryWithLockFile) {
- TempDir tempDir("StorageEngineLockFileTest_ReadOnlyDirectoryWithLockFile");
-
- StorageEngineLockFile lockFile(tempDir.path());
- ASSERT_OK(lockFile.open());
- ASSERT_OK(lockFile.writePid());
-
- // Make tempDir read-only.
- ScopedReadOnlyDirectory srod(tempDir.path());
-
- // Try to create a new lock file.
- StorageEngineLockFile lockFile2(tempDir.path());
-
- auto openStatus = lockFile2.open();
-
- ASSERT_NOT_OK(openStatus);
- ASSERT_EQ(openStatus, ErrorCodes::IllegalOperation);
-}
-
} // namespace
diff --git a/src/mongo/db/storage/storage_engine_lock_file_windows.cpp b/src/mongo/db/storage/storage_engine_lock_file_windows.cpp
index e38b2752bad..6a3d69a3e2a 100644
--- a/src/mongo/db/storage/storage_engine_lock_file_windows.cpp
+++ b/src/mongo/db/storage/storage_engine_lock_file_windows.cpp
@@ -122,12 +122,6 @@ Status StorageEngineLockFile::open() {
if (lockFileHandle == INVALID_HANDLE_VALUE) {
int errorcode = GetLastError();
- if (errorcode == ERROR_ACCESS_DENIED) {
- return Status(ErrorCodes::IllegalOperation,
- str::stream()
- << "Attempted to create a lock file on a read-only directory: "
- << _dbpath << " - did you mean to start with --readOnly?");
- }
return Status(ErrorCodes::DBPathInUse,
str::stream() << "Unable to create/open lock file: " << _filespec << ' '
<< errnoWithDescription(errorcode)