diff options
-rw-r--r-- | meson.build | 10 | ||||
-rw-r--r-- | meson_options.txt | 1 | ||||
-rw-r--r-- | redfish-core/lib/network_protocol.hpp | 8 |
3 files changed, 18 insertions, 1 deletions
diff --git a/meson.build b/meson.build index 1bb76361f2..66a066b4f0 100644 --- a/meson.build +++ b/meson.build @@ -206,6 +206,16 @@ if (cxx.get_id() == 'gcc' and cxx.version().version_compare('>8.0')) },section : 'Enabled Features') endif + if( get_option('redfish-allow-deprecated-hostname-patch').enabled()) + add_project_arguments([ + '-DBMCWEB_ALLOW_DEPRECATED_HOSTNAME_PATCH' + ], + language : 'cpp') + + summary({'hostname-patch' :'-DBMCWEB_ALLOW_DEPRECATED_HOSTNAME_PATCH' + },section : 'Enabled Features') + endif + endif endif diff --git a/meson_options.txt b/meson_options.txt index 5e5f7b503d..9611631e85 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -29,6 +29,7 @@ option('cookie-auth', type : 'feature', value : 'enabled', description : '''Enab option('mutual-tls-auth', type : 'feature', value : 'enabled', description : '''Enables authenticating users through TLS client certificates. The insecure-disable-ssl must be disabled for this option to take effect.''') option('ibm-management-console', type : 'feature', value : 'disabled', description : 'Enable the IBM management console specific functionality. Paths are under \'/ibm/v1/\'') option('http-body-limit', type: 'integer', min : 0, max : 512, value : 30, description : 'Specifies the http request body length limit') +option('redfish-allow-deprecated-hostname-patch', type : 'feature', value : 'disabled', description : 'Enable/disable Managers/bmc/NetworkProtocol HostName PATCH commands. The default condition is to prevent HostName changes from this URI, following the Redfish schema. Enabling this switch permits the HostName to be PATCHed at this URI. In Q4 2021 this feature will be removed, and the Redfish schema enforced, making the HostName read-only.') # Insecure options. Every option that starts with a `insecure` flag should # not be enabled by default for any platform, unless the author fully comprehends 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) |