diff --git a/src/lib/process/daemon.cc b/src/lib/process/daemon.cc index b6a61e7bc5..7069e1619e 100644 --- a/src/lib/process/daemon.cc +++ b/src/lib/process/daemon.cc @@ -231,9 +231,6 @@ Daemon::writeConfigFile(const std::string& config_file, isc_throw(Unexpected, "Can't write configuration: conversion to JSON failed"); } - // Remove rights for other from the umask. - Umask mask(S_IRWXO); - std::ofstream out(config_file, std::ios::trunc); if (!out.good()) { isc_throw(Unexpected, "Unable to open file " + config_file + " for writing"); diff --git a/src/lib/util/filesystem.cc b/src/lib/util/filesystem.cc index 657e1e1f46..4ff057466f 100644 --- a/src/lib/util/filesystem.cc +++ b/src/lib/util/filesystem.cc @@ -10,11 +10,11 @@ #include #include +#include #include #include #include #include -#include #include #include @@ -69,14 +69,6 @@ isFile(string const& path) { return ((statbuf.st_mode & S_IFMT) == S_IFREG); } -Umask::Umask(mode_t mask) : orig_umask_(umask(S_IWGRP | S_IWOTH)) { - umask(orig_umask_ | mask); -} - -Umask::~Umask() { - umask(orig_umask_); -} - bool isSocket(string const& path) { struct stat statbuf; diff --git a/src/lib/util/filesystem.h b/src/lib/util/filesystem.h index d726c3178c..ce5a276189 100644 --- a/src/lib/util/filesystem.h +++ b/src/lib/util/filesystem.h @@ -7,7 +7,6 @@ #ifndef KEA_UTIL_FILESYSTEM_H #define KEA_UTIL_FILESYSTEM_H -#include #include namespace isc { @@ -49,23 +48,6 @@ isDir(const std::string& path); bool isFile(const std::string& path); -/// @brief RAII device to limit access of created files. -struct Umask { - /// @brief Constructor - /// - /// Set wanted bits in umask. - Umask(mode_t mask); - - /// @brief Destructor. - /// - /// Restore umask. - ~Umask(); - -private: - /// @brief Original umask. - mode_t orig_umask_; -}; - bool isSocket(const std::string& path); diff --git a/src/lib/util/tests/filesystem_unittests.cc b/src/lib/util/tests/filesystem_unittests.cc index 2b8d0331eb..1b3e88168a 100644 --- a/src/lib/util/tests/filesystem_unittests.cc +++ b/src/lib/util/tests/filesystem_unittests.cc @@ -10,6 +10,7 @@ #include #include +#include #include #include #include @@ -70,18 +71,6 @@ TEST_F(FileUtilTest, isFile) { EXPECT_FALSE(isFile(TEST_DATA_BUILDDIR)); } -/// @brief Check Umask. -TEST_F(FileUtilTest, umask) { - // Protect the test itself assuming that Umask does what we expect... - Umask m0(0); - mode_t orig = umask(0); - { - Umask m(S_IROTH); - EXPECT_EQ(S_IROTH, umask(S_IRWXO)); - } - EXPECT_EQ(0, umask(orig)); -} - /// @brief Check that the components are split correctly. TEST(PathTest, components) { // Complete name @@ -141,7 +130,7 @@ TEST(PathTest, replaceParentPath) { // Verifies FileManager::validatePath() when enforce_path is true. TEST(FileManager, validatePathEnforcePath) { - std::string def_path(TEST_DATA_BUILDDIR + '/'); + std::string def_path = std::string(TEST_DATA_BUILDDIR) + "/"; struct Scenario { int line_; std::string lib_path_;