]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#3832] Checkpoint: removed #3050 and fixes
authorFrancis Dupont <fdupont@isc.org>
Tue, 29 Apr 2025 08:54:02 +0000 (10:54 +0200)
committerAndrei Pavel <andrei@isc.org>
Fri, 16 May 2025 09:20:43 +0000 (12:20 +0300)
src/lib/process/daemon.cc
src/lib/util/filesystem.cc
src/lib/util/filesystem.h
src/lib/util/tests/filesystem_unittests.cc

index b6a61e7bc5cdc9d9423adfb29dd5febf06e9a7db..7069e1619eca3d64cb2bd67f4ecdd1a8fd9ccd4d 100644 (file)
@@ -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");
index 657e1e1f46a10f8bdf3fc0278196d55f718b57e0..4ff057466f01409109919c3753c4544107fb8cde 100644 (file)
 #include <util/filesystem.h>
 #include <util/str.h>
 
+#include <sys/stat.h>
 #include <cstdio>
 #include <cstdlib>
 #include <fstream>
 #include <string>
-#include <filesystem>
 #include <iostream>
 
 #include <dirent.h>
@@ -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;
index d726c3178cc6dff72eeed462abb30ca4986ddd40..ce5a2761890c881a33eeb30ea4f9c1f0982f2ff7 100644 (file)
@@ -7,7 +7,6 @@
 #ifndef KEA_UTIL_FILESYSTEM_H
 #define KEA_UTIL_FILESYSTEM_H
 
-#include <sys/stat.h>
 #include <string>
 
 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);
 
index 2b8d0331eb0337a0c67aaa040001a9db6534b0c3..1b3e88168a74b214d6827b3dfca995c5caf13c10 100644 (file)
@@ -10,6 +10,7 @@
 #include <testutils/gtest_utils.h>
 #include <util/filesystem.h>
 
+#include <sys/stat.h>
 #include <fstream>
 #include <list>
 #include <string>
@@ -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_;