Report MACAddress is read-only for a D-Bus Not Allowed response
The BMC Manager MACAddress ethernet property is a Read/Write property
in the Redfish spec. There are OpenBMC users that configure the
property to be Read Only. The phosphor-network build includes a
'persist-mac' configuration switch which controls MAC address
assignment. An attempt to set a R/O MACAddress causes D-Bus to return
an error. The exact error is available in a sdbus message.
The EthernetInterface XML indicates this is acceptable behavior:
"If an assignable MAC address is not supported, this value is a
read-only alias of the PermanentMACAddress."
As this condition is considered proper behavior it is incorrect to
return an internalError(). It is better behavior to return a
"Read-only" error message.
Tested:
Performed a Redfish PATCH for the MACAddress property.
The PATCH command returns a 403 error code, and a message body
indicating that the MACAddress is not writable.
Change-Id: Ice97affe694f4bee15436293c9e5944bcae7f4cc
Signed-off-by: Johnathan Mantey <johnathanx.mantey@intel.com>
diff --git a/redfish-core/lib/ethernet.hpp b/redfish-core/lib/ethernet.hpp
index 5ccc25f..0469f74 100644
--- a/redfish-core/lib/ethernet.hpp
+++ b/redfish-core/lib/ethernet.hpp
@@ -1123,10 +1123,25 @@
const std::string& macAddress,
const std::shared_ptr<bmcweb::AsyncResp>& asyncResp)
{
+ static constexpr std::string_view dbusNotAllowedError =
+ "xyz.openbmc_project.Common.Error.NotAllowed";
+
crow::connections::systemBus->async_method_call(
- [asyncResp, macAddress](const boost::system::error_code ec) {
+ [asyncResp, macAddress](const boost::system::error_code ec,
+ const sdbusplus::message::message& msg) {
if (ec)
{
+ const sd_bus_error* err = msg.get_error();
+ if (err == nullptr)
+ {
+ messages::internalError(asyncResp->res);
+ return;
+ }
+ if (err->name == dbusNotAllowedError)
+ {
+ messages::propertyNotWritable(asyncResp->res, "MACAddress");
+ return;
+ }
messages::internalError(asyncResp->res);
return;
}