diff options
author | Johnathan Mantey <johnathanx.mantey@intel.com> | 2020-11-20 19:51:11 +0300 |
---|---|---|
committer | Ed Tanous <ed@tanous.net> | 2021-03-16 23:27:33 +0300 |
commit | 2db77d34ca673f32411621b7e34b039dec948bd3 (patch) | |
tree | 71fbb4110f9db5f73af186ffbe879dd753920d6c /redfish-core/lib/network_protocol.hpp | |
parent | 75710de2c0708a40a0caf6d513dba9ace033aad7 (diff) | |
download | bmcweb-2db77d34ca673f32411621b7e34b039dec948bd3.tar.xz |
Force HostName property to be read-only per the schema
The ManagerNetworkProtocol schema defines the HostName entry to be
read-only. Change the doPatch code to prevent updating the hostname
attribute.
The DMTF redfish/v1/Managers/bmc/NetworkProtocol is a read-only
location.
The DMTF approved location for changing the HostName is:
redfish/v1/Managers/bmc/EthernetInterfaces/<str>
This change does not impact phosphor-webui, as it uses D-Bus to
perform all of its work.
This change does not impact webui-vue, as it is using the DMTF
approved API.
This commit deprecates allowing Read/Write access to the Hostname in
the ManagersNetworkProtocol URI. To reduce the impact to Redfish
clients that rely upon Read/Write access a Meson compile time flag has
been added to allow Read/Write access to be restored. The Meson build
flag, redfish-allow-deprecated-hostname-patch, can be enabled to
restore Read/Write access. The Meson build flag is slated to be
removed in Q4 2021 enforcing the read-only state.
Tested:
Explicitly PATCH'd HostName to confirm it cannot be modified.
Enabled the HostName feature, and confirmed the HostName accepted a
PATCH command.
Ran Redfish_Service_Validator (deprecated, and re-enabled).
Change-Id: If7f2148d8bbb8a7b420c4abde086272c4320977a
Signed-off-by: Johnathan Mantey <johnathanx.mantey@intel.com>
Diffstat (limited to 'redfish-core/lib/network_protocol.hpp')
-rw-r--r-- | redfish-core/lib/network_protocol.hpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/redfish-core/lib/network_protocol.hpp b/redfish-core/lib/network_protocol.hpp index 65b90f7571..c8f63d1a8b 100644 --- a/redfish-core/lib/network_protocol.hpp +++ b/redfish-core/lib/network_protocol.hpp @@ -354,6 +354,7 @@ class NetworkProtocol : public Node "org.freedesktop.systemd1.Manager", "ListUnits"); } +#ifdef BMCWEB_ALLOW_DEPRECATED_HOSTNAME_PATCH void handleHostnamePatch(const std::string& hostName, const std::shared_ptr<AsyncResp>& asyncResp) { @@ -371,6 +372,7 @@ class NetworkProtocol : public Node "xyz.openbmc_project.Network.SystemConfiguration", "HostName", std::variant<std::string>(hostName)); } +#endif void handleNTPProtocolEnabled(const bool& ntpEnabled, const std::shared_ptr<AsyncResp>& asyncResp) @@ -484,7 +486,7 @@ class NetworkProtocol : public Node std::optional<nlohmann::json> ntp; std::optional<nlohmann::json> ipmi; - if (!json_util::readJson(req, res, "HostName", newHostName, "NTP", ntp, + if (!json_util::readJson(req, res, "NTP", ntp, "HostName", newHostName, "IPMI", ipmi)) { return; @@ -493,7 +495,11 @@ class NetworkProtocol : public Node res.result(boost::beast::http::status::no_content); if (newHostName) { +#ifdef BMCWEB_ALLOW_DEPRECATED_HOSTNAME_PATCH handleHostnamePatch(*newHostName, asyncResp); +#else + messages::propertyNotWritable(asyncResp->res, "HostName"); +#endif } if (ntp) |