diff options
author | Richard Marian Thomaiyar <richard.marian.thomaiyar@linux.intel.com> | 2019-11-11 09:18:09 +0300 |
---|---|---|
committer | Thomaiyar, Richard Marian <richard.marian.thomaiyar@intel.com> | 2019-11-18 19:39:10 +0300 |
commit | d095ccea8df74f9de228ab83b658d80b4fb79460 (patch) | |
tree | d2f85643fa86d28cc646883b6756163eba0b47cf /special-mode-mgr/src/specialmodemgr.cpp | |
parent | c559e2c659b0d3b6ca76e1553c68ab1960d461d0 (diff) | |
download | provingground-d095ccea8df74f9de228ab83b658d80b4fb79460.tar.xz |
Update special mode mgr as per D-Bus interface
Updated special-mode-mgr service to expose the property as
per the D-Bus interface SpecialMode in the community
Tested
1. Verified that manufacturing mode entered as per 15 second power
buttong press during AC cycle
2. Verified that expired based on timeout or restriction mode property
change
3. Verified validation unsecure features works as expected
Change-Id: I87b67424f657a1a19545b4dc18a80a2fddf8ee44
Signed-off-by: Richard Marian Thomaiyar <richard.marian.thomaiyar@linux.intel.com>
Diffstat (limited to 'special-mode-mgr/src/specialmodemgr.cpp')
-rw-r--r-- | special-mode-mgr/src/specialmodemgr.cpp | 46 |
1 files changed, 32 insertions, 14 deletions
diff --git a/special-mode-mgr/src/specialmodemgr.cpp b/special-mode-mgr/src/specialmodemgr.cpp index 44f12cc..b685550 100644 --- a/special-mode-mgr/src/specialmodemgr.cpp +++ b/special-mode-mgr/src/specialmodemgr.cpp @@ -22,6 +22,8 @@ #include <phosphor-logging/log.hpp> #include <string> +namespace specialMode +{ static constexpr const char* specialModeMgrService = "xyz.openbmc_project.SpecialMode"; static constexpr const char* specialModeIntf = @@ -42,18 +44,21 @@ using VariantValue = std::variant<bool, uint8_t, int16_t, uint16_t, int32_t, uint32_t, int64_t, uint64_t, double, std::string>; +namespace secCtrl = sdbusplus::xyz::openbmc_project::Control::Security::server; + SpecialModeMgr::SpecialModeMgr( boost::asio::io_service& io_, sdbusplus::asio::object_server& srv_, std::shared_ptr<sdbusplus::asio::connection>& conn_) : io(io_), server(srv_), conn(conn_), - timer(std::make_unique<boost::asio::steady_timer>(io)) + timer(std::make_unique<boost::asio::steady_timer>(io)), + specialMode(secCtrl::SpecialMode::Modes::None) { #ifdef BMC_VALIDATION_UNSECURE_FEATURE if (std::filesystem::exists(validationModeFile)) { - specialMode = validationUnsecure; + specialMode = secCtrl::SpecialMode::Modes::ValidationUnsecure; addSpecialModeProperty(); return; } @@ -131,7 +136,7 @@ SpecialModeMgr::SpecialModeMgr( { phosphor::logging::log<phosphor::logging::level::INFO>( "Mode is not provisioning"); - setSpecialModeValue(manufacturingExpired); + setSpecialModeValue(secCtrl::SpecialMode::Modes::None); } }); @@ -182,7 +187,7 @@ void SpecialModeMgr::checkAndAddSpecialModeProperty(const std::string& provMode) int specialModeLockoutSeconds = 0; if (mtmAllowedTime > sysInfo.uptime) { - specialMode = manufacturingMode; + specialMode = secCtrl::SpecialMode::Modes::Manufacturing; specialModeLockoutSeconds = mtmAllowedTime - sysInfo.uptime; sd_journal_send("MESSAGE=%s", "Manufacturing mode - Entered", "PRIORITY=%i", LOG_INFO, "REDFISH_MESSAGE_ID=%s", @@ -201,32 +206,41 @@ void SpecialModeMgr::addSpecialModeProperty() // Add path to server object iface = server.add_interface(specialModePath, specialModeIntf); iface->register_property( - strSpecialMode, specialMode, + strSpecialMode, secCtrl::convertForMessage(specialMode), // Ignore set - [this](const uint8_t& req, uint8_t& propertyValue) { + [this](const std::string& req, std::string& propertyValue) { + secCtrl::SpecialMode::Modes mode = + secCtrl::SpecialMode::convertModesFromString(req); #ifdef BMC_VALIDATION_UNSECURE_FEATURE - if ((req == validationUnsecure) && (specialMode != req)) + if ((mode == secCtrl::SpecialMode::Modes::ValidationUnsecure) && + (specialMode != mode)) { std::ofstream output(validationModeFile); output.close(); - specialMode = req; + specialMode = mode; propertyValue = req; return 1; } #endif - if (req == manufacturingExpired && specialMode != req) + if (mode == secCtrl::SpecialMode::Modes::None && + specialMode != mode) { - specialMode = req; +#ifdef BMC_VALIDATION_UNSECURE_FEATURE + std::remove(validationModeFile.c_str()); +#endif + specialMode = mode; propertyValue = req; return 1; } return 0; }, // Override get - [this](const uint8_t& mode) { return specialMode; }); + [this](const std::string& mode) { + return secCtrl::convertForMessage(specialMode); + }); iface->register_method("ResetTimer", [this]() { - if (specialMode == manufacturingMode) + if (specialMode == secCtrl::SpecialMode::Modes::Manufacturing) { updateTimer(mtmAllowedTime); } @@ -250,16 +264,20 @@ void SpecialModeMgr::updateTimer(int countInSeconds) "Error in special mode timer"); return; } - iface->set_property(strSpecialMode, - static_cast<uint8_t>(manufacturingExpired)); + iface->set_property( + strSpecialMode, + secCtrl::convertForMessage(secCtrl::SpecialMode::Modes::None)); sd_journal_send("MESSAGE=%s", "Manufacturing mode - Exited", "PRIORITY=%i", LOG_INFO, "REDFISH_MESSAGE_ID=%s", "OpenBMC.0.1.ManufacturingModeExited", NULL); }); } +} // namespace specialMode + int main() { + using namespace specialMode; boost::asio::io_service io; auto conn = std::make_shared<sdbusplus::asio::connection>(io); conn->request_name(specialModeMgrService); |