phosphor-sel-logger clears SEL

the SEL logger now clears the SEL and the option
'sel-logger-clears-sel' is removed.

This removes the ambiguity about who should clear it and provides
a single implementation.

Tested: together with the other topic changes. SEL Add/Clear works.

Change-Id: I9d228ac418406272caf220170a824735108b5599
Signed-off-by: Alexander Hansen <alexander.hansen@9elements.com>
diff --git a/dbus-sdr/storagecommands.cpp b/dbus-sdr/storagecommands.cpp
index 874e5b2..1ae0de2 100644
--- a/dbus-sdr/storagecommands.cpp
+++ b/dbus-sdr/storagecommands.cpp
@@ -58,25 +58,6 @@
 {
 static constexpr const char* selEraseTimestamp = "/var/lib/ipmi/sel_erase_time";
 
-void save()
-{
-    // open the file, creating it if necessary
-    int fd = open(selEraseTimestamp, O_WRONLY | O_CREAT | O_CLOEXEC, 0644);
-    if (fd < 0)
-    {
-        std::cerr << "Failed to open file\n";
-        return;
-    }
-
-    // update the file timestamp to the current time
-    if (futimens(fd, NULL) < 0)
-    {
-        std::cerr << "Failed to update timestamp: "
-                  << std::string(strerror(errno));
-    }
-    close(fd);
-}
-
 int get()
 {
     return getFileTimestamp(selEraseTimestamp);
@@ -1154,33 +1135,6 @@
     // cleared
     cancelSELReservation();
 
-#ifndef FEATURE_SEL_LOGGER_CLEARS_SEL
-    // Save the erase time
-    dynamic_sensors::ipmi::sel::erase_time::save();
-
-    // Clear the SEL by deleting the log files
-    std::vector<std::filesystem::path> selLogFiles;
-    if (getSELLogFiles(selLogFiles))
-    {
-        for (const std::filesystem::path& file : selLogFiles)
-        {
-            std::error_code ec;
-            std::filesystem::remove(file, ec);
-        }
-    }
-
-    // Reload rsyslog so it knows to start new log files
-    boost::system::error_code ec;
-    ctx->bus->yield_method_call<>(ctx->yield, ec, "org.freedesktop.systemd1",
-                                  "/org/freedesktop/systemd1",
-                                  "org.freedesktop.systemd1.Manager",
-                                  "ReloadUnit", "rsyslog.service", "replace");
-    if (ec)
-    {
-        std::cerr << "error in reload rsyslog: " << ec << std::endl;
-        return ipmi::responseUnspecifiedError();
-    }
-#else
     boost::system::error_code ec;
     ctx->bus->yield_method_call<>(ctx->yield, ec, selLoggerServiceName,
                                   "/xyz/openbmc_project/Logging/IPMI",
@@ -1191,9 +1145,6 @@
         return ipmi::responseUnspecifiedError();
     }
 
-    // Save the erase time
-    dynamic_sensors::ipmi::sel::erase_time::save();
-#endif
     return ipmi::responseSuccess(ipmi::sel::eraseComplete);
 }
 
diff --git a/meson.build b/meson.build
index c043d79..67c5caf 100644
--- a/meson.build
+++ b/meson.build
@@ -88,7 +88,6 @@
   'entity-manager-decorators'  : '-DUSING_ENTITY_MANAGER_DECORATORS',
   'hybrid-sensors'             : '-DFEATURE_HYBRID_SENSORS',
   'sensors-cache'              : '-DFEATURE_SENSORS_CACHE',
-  'sel-logger-clears-sel'      : '-DFEATURE_SEL_LOGGER_CLEARS_SEL',
   'dynamic-storages-only'      : '-DFEATURE_DYNAMIC_STORAGES_ONLY',
 }
 
diff --git a/meson.options b/meson.options
index 2553d89..c6d2425 100644
--- a/meson.options
+++ b/meson.options
@@ -64,9 +64,6 @@
 option('shortname-remove-suffix', type: 'feature', value: 'enabled', description: 'shortname-remove-suffix is enabled by default')
 option('shortname-replace-words', type: 'feature', value: 'disabled', description: 'shortname-replace-words is disabled by default')
 
-# SEL Logger
-option('sel-logger-clears-sel', type: 'feature', value: 'disabled', description: 'Clearing SEL through sel-logger is disabled by default; offer a way to enable it')
-
 # Generate configuration from Yaml
 option('sensor-yaml-gen', type: 'string', value: 'sensor-example.yaml')
 option('invsensor-yaml-gen', type: 'string', value: 'inventory-sensor-example.yaml')