diff options
-rw-r--r-- | phosphor-rsyslog-config/Makefile.am | 3 | ||||
-rw-r--r-- | phosphor-rsyslog-config/server-conf.cpp | 23 | ||||
-rw-r--r-- | test/remote_logging_test_config.cpp | 21 |
3 files changed, 7 insertions, 40 deletions
diff --git a/phosphor-rsyslog-config/Makefile.am b/phosphor-rsyslog-config/Makefile.am index 5453473..3a1aeff 100644 --- a/phosphor-rsyslog-config/Makefile.am +++ b/phosphor-rsyslog-config/Makefile.am @@ -15,8 +15,7 @@ phosphor_rsyslog_conf_LDADD = \ phosphor_rsyslog_conf_LDFLAGS = \ $(SDBUSPLUS_LIBS) \ - $(PHOSPHOR_DBUS_INTERFACES_LIBS) \ - -lstdc++fs + $(PHOSPHOR_DBUS_INTERFACES_LIBS) phosphor_rsyslog_conf_CXXFLAGS = \ $(SDBUSPLUS_CFLAGS) \ diff --git a/phosphor-rsyslog-config/server-conf.cpp b/phosphor-rsyslog-config/server-conf.cpp index 16955fc..716421b 100644 --- a/phosphor-rsyslog-config/server-conf.cpp +++ b/phosphor-rsyslog-config/server-conf.cpp @@ -15,19 +15,6 @@ #include <string> -#if __has_include(<filesystem>) -#include <filesystem> -#elif __has_include(<experimental/filesystem>) -#include <experimental/filesystem> -namespace std -{ -// splice experimental::filesystem into std -namespace filesystem = std::experimental::filesystem; -} // namespace std -#else -#error filesystem not available -#endif - namespace phosphor { namespace rsyslog_config @@ -36,7 +23,6 @@ namespace rsyslog_config namespace utils = phosphor::rsyslog_utils; using namespace phosphor::logging; using namespace sdbusplus::xyz::openbmc_project::Common::Error; -namespace fs = std::filesystem; std::string Server::address(std::string value) { @@ -108,7 +94,6 @@ uint16_t Server::port(uint16_t value) void Server::writeConfig(const std::string& serverAddress, uint16_t serverPort, const char* filePath) { - fs::create_directory(fs::path(filePath).parent_path()); std::fstream stream(filePath, std::fstream::out); if (serverPort && !serverAddress.empty()) @@ -118,7 +103,8 @@ void Server::writeConfig(const std::string& serverAddress, uint16_t serverPort, } else // this is a disable request { - fs::remove(filePath); + // write '*.* ~' - this causes rsyslog to discard all messages + stream << "*.* ~"; } restart(); @@ -144,11 +130,6 @@ bool Server::addressValid(const std::string& address) void Server::restore(const char* filePath) { - if (!fs::exists(filePath)) - { - return; - } - std::fstream stream(filePath, std::fstream::in); std::string line; diff --git a/test/remote_logging_test_config.cpp b/test/remote_logging_test_config.cpp index b34a43f..cba54ea 100644 --- a/test/remote_logging_test_config.cpp +++ b/test/remote_logging_test_config.cpp @@ -3,19 +3,6 @@ #include <fstream> #include <string> -#if __has_include(<filesystem>) -#include <filesystem> -#elif __has_include(<experimental/filesystem>) -#include <experimental/filesystem> -namespace std -{ -// splice experimental::filesystem into std -namespace filesystem = std::experimental::filesystem; -} // namespace std -#else -#error filesystem not available -#endif - namespace phosphor { namespace logging @@ -34,13 +21,13 @@ std::string getConfig(const char* filePath) TEST_F(TestRemoteLogging, testOnlyAddress) { config->address("1.1.1.1"); - EXPECT_EQ(fs::exists(configFilePath.c_str()), false); + EXPECT_EQ(getConfig(configFilePath.c_str()), "*.* ~"); } TEST_F(TestRemoteLogging, testOnlyPort) { config->port(100); - EXPECT_EQ(fs::exists(configFilePath.c_str()), false); + EXPECT_EQ(getConfig(configFilePath.c_str()), "*.* ~"); } TEST_F(TestRemoteLogging, testGoodConfig) @@ -56,7 +43,7 @@ TEST_F(TestRemoteLogging, testClearAddress) config->port(100); EXPECT_EQ(getConfig(configFilePath.c_str()), "*.* @@1.1.1.1:100"); config->address(""); - EXPECT_EQ(fs::exists(configFilePath.c_str()), false); + EXPECT_EQ(getConfig(configFilePath.c_str()), "*.* ~"); } TEST_F(TestRemoteLogging, testClearPort) @@ -65,7 +52,7 @@ TEST_F(TestRemoteLogging, testClearPort) config->port(100); EXPECT_EQ(getConfig(configFilePath.c_str()), "*.* @@1.1.1.1:100"); config->port(0); - EXPECT_EQ(fs::exists(configFilePath.c_str()), false); + EXPECT_EQ(getConfig(configFilePath.c_str()), "*.* ~"); } } // namespace test |