summaryrefslogtreecommitdiff
path: root/special-mode-mgr
diff options
context:
space:
mode:
authorRichard Marian Thomaiyar <richard.marian.thomaiyar@linux.intel.com>2019-06-29 19:14:41 +0300
committerRichard Marian Thomaiyar <richard.marian.thomaiyar@linux.intel.com>2019-07-02 06:59:14 +0300
commitcc139f59c75c91598becdc2b291e3621fd185152 (patch)
treeb51cad7a0ea43035840c3395cecca99aa75b34bc /special-mode-mgr
parent92245d95fbc417e386c737a52c535f8d892c8ab6 (diff)
downloadprovingground-cc139f59c75c91598becdc2b291e3621fd185152.tar.xz
Fix: Remove PFail query & enable special-mode-mgr
1. AC failure bit is read from command line parameter, and hence the old code which reads it from PFail property is not applicable anymore and removed. 2. Enabled special mode manager service. Tested: 1. Made sure after boot special-mode-mgr service is working fine without crashing 2. Able to reflect the special-mode-mgr mode properties as expected Change-Id: I0a369bf4db63fa3cb22650a457f5dc6bd4300823 Signed-off-by: Richard Marian Thomaiyar <richard.marian.thomaiyar@linux.intel.com>
Diffstat (limited to 'special-mode-mgr')
-rw-r--r--special-mode-mgr/CMakeLists.txt2
-rw-r--r--special-mode-mgr/specialmodemgr.service7
-rw-r--r--special-mode-mgr/src/specialmodemgr.cpp111
3 files changed, 49 insertions, 71 deletions
diff --git a/special-mode-mgr/CMakeLists.txt b/special-mode-mgr/CMakeLists.txt
index 5b62f86..cefe6ff 100644
--- a/special-mode-mgr/CMakeLists.txt
+++ b/special-mode-mgr/CMakeLists.txt
@@ -31,7 +31,7 @@ pkg_check_modules(LOGGING phosphor-logging REQUIRED)
add_executable(${PROJECT_NAME} ${SRC_FILES})
target_link_libraries(${PROJECT_NAME} systemd)
-target_link_libraries(${PROJECT_NAME} sdbusplus -lstdc++fs)
+target_link_libraries(${PROJECT_NAME} sdbusplus)
target_link_libraries(${PROJECT_NAME} ${Boost_LIBRARIES})
target_link_libraries(${PROJECT_NAME} phosphor_logging)
diff --git a/special-mode-mgr/specialmodemgr.service b/special-mode-mgr/specialmodemgr.service
index d1471b3..680d828 100644
--- a/special-mode-mgr/specialmodemgr.service
+++ b/special-mode-mgr/specialmodemgr.service
@@ -1,12 +1,15 @@
[Unit]
Description=Special mode manager
+Wants=mapper-wait@-xyz-openbmc_project-control-security-restriction_mode.service
+After=mapper-wait@-xyz-openbmc_project-control-security-restriction_mode.service
[Service]
Restart=always
RestartSec=2
ExecStart=/usr/bin/specialmodemgr
StartLimitInterval=0
-Type=simple
+Type=dbus
+BusName=xyz.openbmc_project.SpecialMode
[Install]
-#WantedBy=default.target
+WantedBy=multi-user.target
diff --git a/special-mode-mgr/src/specialmodemgr.cpp b/special-mode-mgr/src/specialmodemgr.cpp
index 3d8e559..f66c175 100644
--- a/special-mode-mgr/src/specialmodemgr.cpp
+++ b/special-mode-mgr/src/specialmodemgr.cpp
@@ -72,75 +72,50 @@ SpecialModeMgr::SpecialModeMgr(
AddSpecialModeProperty();
return;
}
- conn->async_method_call(
- [this](boost::system::error_code ec,
- const VariantValue& pwrFailValue) {
- if (ec)
- {
- phosphor::logging::log<
- phosphor::logging::level::INFO>(
- "ERROR with async_method_call");
- AddSpecialModeProperty();
- return;
- }
- if (std::get<bool>(pwrFailValue) == false)
- {
- AddSpecialModeProperty();
- return;
- }
- struct sysinfo sysInfo = {};
- int ret = sysinfo(&sysInfo);
- if (ret != 0)
- {
- phosphor::logging::log<
- phosphor::logging::level::INFO>(
- "ERROR in getting sysinfo",
- phosphor::logging::entry("RET = %d", ret));
- AddSpecialModeProperty();
- return;
- }
- constexpr int mtmAllowedTime = 12 * 60 * 60; // 12 hours
- int specialModeLockoutSeconds = 0;
- if (mtmAllowedTime > sysInfo.uptime)
- {
- specialMode = ManufacturingMode;
- specialModeLockoutSeconds =
- mtmAllowedTime - sysInfo.uptime;
- }
- AddSpecialModeProperty();
- if (!specialModeLockoutSeconds)
- {
- return;
- }
- timer->expires_from_now(boost::posix_time::seconds(
- specialModeLockoutSeconds));
- timer->async_wait(
- [this](const boost::system::error_code& ec) {
- if (ec == boost::asio::error::operation_aborted)
- {
- // timer aborted
- return;
- }
- else if (ec)
- {
- phosphor::logging::log<
- phosphor::logging::level::ERR>(
- "Error in special mode "
- "timer");
- return;
- }
- iface->set_property(
- "SpecialMode",
- static_cast<uint8_t>(ManufacturingExpired));
- });
- },
- "xyz.openbmc_project.Chassis.Control.Power",
- "/xyz/openbmc_project/Chassis/Control/Power0",
- "org.freedesktop.DBus.Properties", "Get",
- "xyz.openbmc_project.Chassis.Control.Power", "PFail");
+ struct sysinfo sysInfo = {};
+ int ret = sysinfo(&sysInfo);
+ if (ret != 0)
+ {
+ phosphor::logging::log<phosphor::logging::level::INFO>(
+ "ERROR in getting sysinfo",
+ phosphor::logging::entry("RET = %d", ret));
+ AddSpecialModeProperty();
+ return;
+ }
+ constexpr int mtmAllowedTime = 12 * 60 * 60; // 12 hours
+ int specialModeLockoutSeconds = 0;
+ if (mtmAllowedTime > sysInfo.uptime)
+ {
+ specialMode = ManufacturingMode;
+ specialModeLockoutSeconds = mtmAllowedTime - sysInfo.uptime;
+ }
+ AddSpecialModeProperty();
+ if (!specialModeLockoutSeconds)
+ {
+ return;
+ }
+ timer->expires_from_now(
+ boost::posix_time::seconds(specialModeLockoutSeconds));
+ timer->async_wait([this](const boost::system::error_code& ec) {
+ if (ec == boost::asio::error::operation_aborted)
+ {
+ // timer aborted
+ return;
+ }
+ else if (ec)
+ {
+ phosphor::logging::log<phosphor::logging::level::ERR>(
+ "Error in special mode "
+ "timer");
+ return;
+ }
+ iface->set_property(
+ "SpecialMode",
+ static_cast<uint8_t>(ManufacturingExpired));
+ });
},
- "xyz.openbmc_project.Settings",
- "/xyz/openbmc_project/control/host0/restriction_mode",
+ "xyz.openbmc_project.RestrictionMode.Manager",
+ "/xyz/openbmc_project/control/security/restriction_mode",
"org.freedesktop.DBus.Properties", "Get",
"xyz.openbmc_project.Control.Security.RestrictionMode",
"RestrictionMode");