mirror of
https://git.proxmox.com/git/fwupd
synced 2025-05-29 20:32:50 +00:00
redfish: Do not hardcode the KCS user_id to be 0x4
This commit is contained in:
parent
a11ebbc03d
commit
0955e08a72
@ -205,11 +205,10 @@ fu_redfish_plugin_ipmi_create_user(FuPlugin *plugin, GError **error)
|
|||||||
{
|
{
|
||||||
FuPluginData *data = fu_plugin_get_data(plugin);
|
FuPluginData *data = fu_plugin_get_data(plugin);
|
||||||
const gchar *username_fwupd = "fwupd";
|
const gchar *username_fwupd = "fwupd";
|
||||||
guint8 user_id = 0x04;
|
guint8 user_id = G_MAXUINT8;
|
||||||
g_autofree gchar *password_new = fu_common_generate_password(15);
|
g_autofree gchar *password_new = fu_common_generate_password(15);
|
||||||
g_autofree gchar *password_tmp = fu_common_generate_password(15);
|
g_autofree gchar *password_tmp = fu_common_generate_password(15);
|
||||||
g_autofree gchar *uri = NULL;
|
g_autofree gchar *uri = NULL;
|
||||||
g_autofree gchar *username = NULL;
|
|
||||||
g_autoptr(FuDeviceLocker) locker = NULL;
|
g_autoptr(FuDeviceLocker) locker = NULL;
|
||||||
g_autoptr(FuIpmiDevice) device = fu_ipmi_device_new(fu_plugin_get_context(plugin));
|
g_autoptr(FuIpmiDevice) device = fu_ipmi_device_new(fu_plugin_get_context(plugin));
|
||||||
g_autoptr(FuRedfishRequest) request = NULL;
|
g_autoptr(FuRedfishRequest) request = NULL;
|
||||||
@ -221,14 +220,28 @@ fu_redfish_plugin_ipmi_create_user(FuPlugin *plugin, GError **error)
|
|||||||
if (locker == NULL)
|
if (locker == NULL)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
/* check the slot is clear */
|
/* check for existing user, and if not then remember the first spare slot */
|
||||||
username = fu_ipmi_device_get_user_password(device, 0x04, NULL);
|
for (guint8 i = 2; i < 0xFF; i++) {
|
||||||
if (username != NULL) {
|
g_autofree gchar *username = fu_ipmi_device_get_user_password(device, i, NULL);
|
||||||
g_set_error(error,
|
if (username == NULL && user_id == G_MAXUINT8) {
|
||||||
FWUPD_ERROR,
|
g_debug("KCS slot %u free", i);
|
||||||
FWUPD_ERROR_NOT_SUPPORTED,
|
user_id = i;
|
||||||
"cannot create fwupd user with account %s already existing",
|
continue;
|
||||||
username);
|
}
|
||||||
|
if (g_strcmp0(username, "fwupd") == 0) {
|
||||||
|
g_set_error(error,
|
||||||
|
FWUPD_ERROR,
|
||||||
|
FWUPD_ERROR_NOT_SUPPORTED,
|
||||||
|
"fwupd user already exists in KCS slot %u",
|
||||||
|
(guint)i);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (user_id == G_MAXUINT8) {
|
||||||
|
g_set_error_literal(error,
|
||||||
|
FWUPD_ERROR,
|
||||||
|
FWUPD_ERROR_NOT_SUPPORTED,
|
||||||
|
"all KCS slots full, cannot create user");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user