diff options
author | Deepak Kodihalli <dkodihal@in.ibm.com> | 2019-01-11 03:47:25 -0600 |
---|---|---|
committer | Deepak Kodihalli <dkodihal@in.ibm.com> | 2019-01-11 06:53:33 -0600 |
commit | e165ea956c5557c2b470869d252c80744227b00f (patch) | |
tree | 3cf4331915cf21ac40ce4ea0e5c1f8560ab4d609 /phosphor-rsyslog-config/server-conf.cpp | |
parent | 3f9cb09427ddb0d4e885db2f81da65b724e0285e (diff) | |
download | phosphor-logging-e165ea956c5557c2b470869d252c80744227b00f.tar.gz phosphor-logging-e165ea956c5557c2b470869d252c80744227b00f.zip |
rsyslogd: don't start without actions
Rsyslog is currently used only for remote logging. The daemon would run
though (started by systemd) even when remote logging has not been
configured. In other words, it would run without any actions.
With Yocto 2.6, rsyslogd won't run without any actions. Hence, rsyslogd
is now started only on the condition that the remote logging config
file is present.
Change-Id: Iae11d6912e60765ecb774b663d44b4e3c6f381a3
Signed-off-by: Deepak Kodihalli <dkodihal@in.ibm.com>
Diffstat (limited to 'phosphor-rsyslog-config/server-conf.cpp')
-rw-r--r-- | phosphor-rsyslog-config/server-conf.cpp | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/phosphor-rsyslog-config/server-conf.cpp b/phosphor-rsyslog-config/server-conf.cpp index 836e83b..e8da82e 100644 --- a/phosphor-rsyslog-config/server-conf.cpp +++ b/phosphor-rsyslog-config/server-conf.cpp @@ -15,6 +15,19 @@ #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 @@ -23,6 +36,7 @@ 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) { @@ -103,8 +117,7 @@ void Server::writeConfig(const std::string& serverAddress, uint16_t serverPort, } else // this is a disable request { - // write '#*.* @@remote-host:port' - stream << "#*.* @@remote-host:port"; + fs::remove(filePath); } restart(); @@ -130,6 +143,11 @@ 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; |