redfish: Only offset the IPMI user_id when using XCC

Both iDRAC and SuperMicro do the sensible thing.

Fixes https://github.com/fwupd/fwupd/issues/5129
This commit is contained in:
Richard Hughes 2023-02-20 14:19:14 +00:00
parent 4bd7b8a8f6
commit f358da7bda
3 changed files with 51 additions and 6 deletions

View File

@ -24,6 +24,9 @@ struct _FuRedfishBackend {
gchar *username; gchar *username;
gchar *password; gchar *password;
guint port; guint port;
gchar *vendor;
gchar *version;
gchar *uuid;
gchar *update_uri_path; gchar *update_uri_path;
gchar *push_uri_path; gchar *push_uri_path;
gboolean use_https; gboolean use_https;
@ -37,6 +40,24 @@ struct _FuRedfishBackend {
G_DEFINE_TYPE(FuRedfishBackend, fu_redfish_backend, FU_TYPE_BACKEND) G_DEFINE_TYPE(FuRedfishBackend, fu_redfish_backend, FU_TYPE_BACKEND)
const gchar *
fu_redfish_backend_get_vendor(FuRedfishBackend *self)
{
return self->vendor;
}
const gchar *
fu_redfish_backend_get_version(FuRedfishBackend *self)
{
return self->version;
}
const gchar *
fu_redfish_backend_get_uuid(FuRedfishBackend *self)
{
return self->uuid;
}
FuRedfishRequest * FuRedfishRequest *
fu_redfish_backend_request_new(FuRedfishBackend *self) fu_redfish_backend_request_new(FuRedfishBackend *self)
{ {
@ -334,7 +355,6 @@ fu_redfish_backend_setup(FuBackend *backend, FuProgress *progress, GError **erro
JsonObject *json_update_service = NULL; JsonObject *json_update_service = NULL;
const gchar *data_id; const gchar *data_id;
const gchar *version = NULL; const gchar *version = NULL;
const gchar *uuid = NULL;
g_autoptr(FuRedfishRequest) request = fu_redfish_backend_request_new(self); g_autoptr(FuRedfishRequest) request = fu_redfish_backend_request_new(self);
/* sanity check */ /* sanity check */
@ -359,10 +379,18 @@ fu_redfish_backend_setup(FuBackend *backend, FuProgress *progress, GError **erro
} else if (json_object_has_member(json_obj, "RedfishVersion")) { } else if (json_object_has_member(json_obj, "RedfishVersion")) {
version = json_object_get_string_member(json_obj, "RedfishVersion"); version = json_object_get_string_member(json_obj, "RedfishVersion");
} }
if (json_object_has_member(json_obj, "UUID")) if (version != NULL) {
uuid = json_object_get_string_member(json_obj, "UUID"); g_free(self->version);
g_debug("Version: %s", version); self->version = g_strdup(version);
g_debug("UUID: %s", uuid); }
if (json_object_has_member(json_obj, "UUID")) {
g_free(self->uuid);
self->uuid = g_strdup(json_object_get_string_member(json_obj, "UUID"));
}
if (json_object_has_member(json_obj, "Vendor")) {
g_free(self->vendor);
self->vendor = g_strdup(json_object_get_string_member(json_obj, "Vendor"));
}
if (json_object_has_member(json_obj, "UpdateService")) if (json_object_has_member(json_obj, "UpdateService"))
json_update_service = json_object_get_object_member(json_obj, "UpdateService"); json_update_service = json_object_get_object_member(json_obj, "UpdateService");
@ -477,6 +505,9 @@ fu_redfish_backend_finalize(GObject *object)
g_free(self->hostname); g_free(self->hostname);
g_free(self->username); g_free(self->username);
g_free(self->password); g_free(self->password);
g_free(self->vendor);
g_free(self->version);
g_free(self->uuid);
G_OBJECT_CLASS(fu_redfish_backend_parent_class)->finalize(object); G_OBJECT_CLASS(fu_redfish_backend_parent_class)->finalize(object);
} }

View File

@ -16,6 +16,12 @@ G_DECLARE_FINAL_TYPE(FuRedfishBackend, fu_redfish_backend, FU, REDFISH_BACKEND,
FuRedfishBackend * FuRedfishBackend *
fu_redfish_backend_new(FuContext *ctx); fu_redfish_backend_new(FuContext *ctx);
const gchar *
fu_redfish_backend_get_vendor(FuRedfishBackend *self);
const gchar *
fu_redfish_backend_get_version(FuRedfishBackend *self);
const gchar *
fu_redfish_backend_get_uuid(FuRedfishBackend *self);
void void
fu_redfish_backend_set_hostname(FuRedfishBackend *self, const gchar *hostname); fu_redfish_backend_set_hostname(FuRedfishBackend *self, const gchar *hostname);
void void

View File

@ -36,6 +36,9 @@ fu_redfish_plugin_to_string(FuPlugin *plugin, guint idt, GString *str)
g_autofree gchar *smbios = fu_firmware_to_string(FU_FIRMWARE(self->smbios)); g_autofree gchar *smbios = fu_firmware_to_string(FU_FIRMWARE(self->smbios));
fu_string_append(str, idt, "Smbios", smbios); fu_string_append(str, idt, "Smbios", smbios);
} }
fu_string_append(str, idt, "Vendor", fu_redfish_backend_get_vendor(self->backend));
fu_string_append(str, idt, "Version", fu_redfish_backend_get_version(self->backend));
fu_string_append(str, idt, "UUID", fu_redfish_backend_get_uuid(self->backend));
} }
static gchar * static gchar *
@ -345,9 +348,14 @@ fu_redfish_plugin_ipmi_create_user(FuPlugin *plugin, GError **error)
/* wait for Redfish to sync */ /* wait for Redfish to sync */
g_usleep(2 * G_USEC_PER_SEC); g_usleep(2 * G_USEC_PER_SEC);
/* XCC is the only BMC implementation that does not map the user_ids 1:1 */
if (fu_context_has_hwid_guid(fu_plugin_get_context(plugin),
"42f00735-c9ab-5374-bd63-a5deee5881e0"))
user_id -= 1;
/* now use Redfish to change the temporary password to the actual password */ /* now use Redfish to change the temporary password to the actual password */
request = fu_redfish_backend_request_new(self->backend); request = fu_redfish_backend_request_new(self->backend);
uri = g_strdup_printf("/redfish/v1/AccountService/Accounts/%u", (guint)user_id - 1); uri = g_strdup_printf("/redfish/v1/AccountService/Accounts/%u", (guint)user_id);
json_builder_begin_object(builder); json_builder_begin_object(builder);
json_builder_set_member_name(builder, "Password"); json_builder_set_member_name(builder, "Password");
json_builder_add_string_value(builder, password_new); json_builder_add_string_value(builder, password_new);