Update mfg mode query to D-Bus interface
Updated manufacturing mode query to be based on D-Bus interface
instead of uint8_t as earlier. This is done to be in sync
with common D-Bus interface
Tested:
With updated special-mode-mgr daemon, which follows the
D-Bus interface
1. Verified that manufacturing mode commands are executed as
before, when in manufacturing mode.
Change-Id: I1828739751272b8d9151e2ab4a32c4861bbe90d7
Signed-off-by: Richard Marian Thomaiyar <richard.marian.thomaiyar@linux.intel.com>
diff --git a/include/manufacturingcommands.hpp b/include/manufacturingcommands.hpp
index 7bd7280..f68142e 100644
--- a/include/manufacturingcommands.hpp
+++ b/include/manufacturingcommands.hpp
@@ -63,17 +63,6 @@
static constexpr const char* specialModeIntf =
"xyz.openbmc_project.Security.SpecialMode";
-/** @enum MtmLvl
-.*
- * Manufacturing command access levels
- */
-enum class MtmLvl
-{
- mtmNotRunning = 0x00,
- mtmExpired = 0x01,
- mtmAvailable = 0x02,
-};
-
enum class SmActionGet : uint8_t
{
sample = 0,
@@ -244,21 +233,21 @@
void revertTimerHandler();
- MtmLvl getAccessLvl(void)
+ bool isMfgMode(void)
{
- static MtmLvl mtmMode = MtmLvl::mtmNotRunning;
- if (mtmMode != MtmLvl::mtmExpired)
+ ipmi::Value mode;
+ if (getProperty(specialModeService, specialModeObjPath, specialModeIntf,
+ "SpecialMode", &mode) != 0)
{
- ipmi::Value mode;
- if (getProperty(specialModeService, specialModeObjPath,
- specialModeIntf, "SpecialMode", &mode) != 0)
- {
- mtmMode = MtmLvl::mtmExpired;
- return mtmMode;
- }
- mtmMode = static_cast<MtmLvl>(std::get<std::uint8_t>(mode));
+ return false;
}
- return mtmMode;
+ if (std::get<std::string>(mode) ==
+ "xyz.openbmc_project.Control.Security.SpecialMode.Modes."
+ "Manufacturing")
+ {
+ return true;
+ }
+ return false;
}
bool revertFanPWM = false;
diff --git a/src/manufacturingcommands.cpp b/src/manufacturingcommands.cpp
index 9d81930..8b3d846 100644
--- a/src/manufacturingcommands.cpp
+++ b/src/manufacturingcommands.cpp
@@ -668,7 +668,7 @@
if (request->payload.size() > 4)
{
// Allow write data count > 1, only if it is in MFG mode
- if (mtm.getAccessLvl() != MtmLvl::mtmAvailable)
+ if (!mtm.isMfgMode())
{
return ipmi::ccInsufficientPrivilege;
}
@@ -687,7 +687,7 @@
case makeCmdKey(ipmi::netFnStorage, ipmi::storage::cmdWriteFruData):
// Check for MTM mode
- if (mtm.getAccessLvl() != MtmLvl::mtmAvailable)
+ if (!mtm.isMfgMode())
{
return ipmi::ccInvalidCommand;
}
@@ -820,7 +820,7 @@
// only in MFG mode.
if (writeCount > 1)
{
- if (mtm.getAccessLvl() < MtmLvl::mtmAvailable)
+ if (!mtm.isMfgMode())
{
return ipmi::responseInsufficientPrivilege();
}
@@ -861,8 +861,7 @@
std::vector<uint8_t> writeData = {0x60, 0x1};
std::vector<uint8_t> readBuf(0);
- // TODO Needs to enhance the below security checking
- if (mtm.getAccessLvl() < MtmLvl::mtmAvailable)
+ if (!mtm.isMfgMode())
{
return ipmi::responseInsufficientPrivilege();
}
diff --git a/src/oemcommands.cpp b/src/oemcommands.cpp
index a6eb4a1..9c1a70d 100644
--- a/src/oemcommands.cpp
+++ b/src/oemcommands.cpp
@@ -44,6 +44,7 @@
#include <xyz/openbmc_project/Control/Boot/Source/server.hpp>
#include <xyz/openbmc_project/Control/PowerSupplyRedundancy/server.hpp>
#include <xyz/openbmc_project/Control/Security/RestrictionMode/server.hpp>
+#include <xyz/openbmc_project/Control/Security/SpecialMode/server.hpp>
namespace ipmi
{
@@ -2573,10 +2574,11 @@
restrictionModeValue = static_cast<uint8_t>(
securityNameSpace::RestrictionMode::convertModesFromString(
std::get<std::string>(varRestrMode)));
- auto varSpecialMode = ctx->bus->yield_method_call<std::variant<uint8_t>>(
- ctx->yield, ec, specialModeService, specialModeBasePath,
- dBusPropertyIntf, dBusPropertyGetMethod, specialModeIntf,
- specialModeProperty);
+ auto varSpecialMode =
+ ctx->bus->yield_method_call<std::variant<std::string>>(
+ ctx->yield, ec, specialModeService, specialModeBasePath,
+ dBusPropertyIntf, dBusPropertyGetMethod, specialModeIntf,
+ specialModeProperty);
if (ec)
{
phosphor::logging::log<phosphor::logging::level::ERR>(
@@ -2587,7 +2589,9 @@
}
else
{
- specialModeValue = std::get<uint8_t>(varSpecialMode);
+ specialModeValue = static_cast<uint8_t>(
+ securityNameSpace::SpecialMode::convertModesFromString(
+ std::get<std::string>(varSpecialMode)));
}
return ipmi::responseSuccess(restrictionModeValue, specialModeValue);
}