static config_err_t _set_alert_policy_table (struct pef_config_state_data *state_data, const char *section_name, struct alert_policy_table *apt) { fiid_obj_t obj_cmd_rs = NULL; config_err_t rv = CONFIG_ERR_FATAL_ERROR; uint8_t alert_policy_entry_number; assert(state_data); assert(section_name); assert(apt); alert_policy_entry_number = atoi (section_name + strlen ("Alert_Policy_")); _FIID_OBJ_CREATE(obj_cmd_rs, tmpl_cmd_set_pef_configuration_parameters_rs); if (ipmi_cmd_set_pef_configuration_parameters_alert_policy_table (state_data->ipmi_ctx, alert_policy_entry_number, apt->policy_type, apt->policy_enabled, apt->policy_number, apt->destination_selector, apt->channel_number, apt->alert_string_set_selector, apt->event_specific_alert_string, obj_cmd_rs) < 0) { if (state_data->prog_data->args->config_args.common.debug) pstdout_fprintf(state_data->pstate, stderr, "ipmi_cmd_set_pef_configuration_parameters_alert_policy_table: %s\n", ipmi_ctx_strerror(ipmi_ctx_errnum(state_data->ipmi_ctx))); /* IPMI Workaround * * Fujitsu RX 100 S5 * * All fields have to be applied simultaneously, the motherboard * does not appear to like configuration of one field of a time, * always leading to invalid input errors. */ if (ipmi_ctx_errnum (state_data->ipmi_ctx) == IPMI_ERR_BAD_COMPLETION_CODE_REQUEST_DATA_INVALID && (ipmi_check_completion_code (obj_cmd_rs, IPMI_COMP_CODE_REQUEST_INVALID_DATA_FIELD) == 1)) { struct config_section *section = NULL; struct config_keyvalue *kv; unsigned int i; for (i = 0; i < state_data->alert_policy_sections_len; i++) { if (!strcasecmp (section_name, state_data->alert_policy_sections[i]->section_name)) { section = state_data->alert_policy_sections[i]; break; } } /* shouldn't be possible */ if (!section) goto cleanup; if ((kv = config_find_keyvalue (state_data->pstate, section, "Policy_Type"))) apt->policy_type = policy_type_number (kv->value_input); if ((kv = config_find_keyvalue (state_data->pstate, section, "Policy_Enabled"))) apt->policy_enabled = same (kv->value_input, "yes"); if ((kv = config_find_keyvalue (state_data->pstate, section, "Policy_Number"))) apt->policy_number = atoi (kv->value_input); if ((kv = config_find_keyvalue (state_data->pstate, section, "Destination_Selector"))) apt->destination_selector = atoi (kv->value_input); if ((kv = config_find_keyvalue (state_data->pstate, section, "Channel_Number"))) apt->channel_number = atoi (kv->value_input); if ((kv = config_find_keyvalue (state_data->pstate, section, "Alert_String_Set_Selector"))) apt->alert_string_set_selector = atoi (kv->value_input); if ((kv = config_find_keyvalue (state_data->pstate, section, "Event_Specific_Alert_String"))) apt->event_specific_alert_string = same (kv->value_input, "yes"); if (state_data->prog_data->args->config_args.common.debug) pstdout_fprintf (state_data->pstate, stderr, "ipmi_cmd_set_pef_configuration_parameters_alert_policy_table: attempting workaround\n"); if (ipmi_cmd_set_pef_configuration_parameters_alert_policy_table (state_data->ipmi_ctx, alert_policy_entry_number, apt->policy_type, apt->policy_enabled, apt->policy_number, apt->destination_selector, apt->channel_number, apt->alert_string_set_selector, apt->event_specific_alert_string, obj_cmd_rs) < 0) { if (state_data->prog_data->args->config_args.common.debug) pstdout_fprintf (state_data->pstate, stderr, "ipmi_cmd_set_pef_configuration_parameters_alert_policy_table: %s\n", ipmi_ctx_strerror(ipmi_ctx_errnum(state_data->ipmi_ctx))); if (!IPMI_CTX_ERRNUM_IS_FATAL_ERROR(state_data->ipmi_ctx)) rv = CONFIG_ERR_NON_FATAL_ERROR; goto cleanup; } /* success */ goto out; } else if (!IPMI_CTX_ERRNUM_IS_FATAL_ERROR(state_data->ipmi_ctx)) rv = CONFIG_ERR_NON_FATAL_ERROR; goto cleanup; } out: rv = CONFIG_ERR_SUCCESS; cleanup: _FIID_OBJ_DESTROY(obj_cmd_rs); return (rv); }
static config_err_t _set_alert_policy_table (struct ipmi_pef_config_state_data *state_data, const char *section_name, struct alert_policy_table *apt) { fiid_obj_t obj_cmd_rs = NULL; config_err_t rv = CONFIG_ERR_FATAL_ERROR; uint8_t alert_policy_entry_number; assert (state_data); assert (section_name); assert (apt); alert_policy_entry_number = atoi (section_name + strlen ("Alert_Policy_")); if (!(obj_cmd_rs = fiid_obj_create (tmpl_cmd_set_pef_configuration_parameters_rs))) { pstdout_fprintf (state_data->pstate, stderr, "fiid_obj_create: %s\n", strerror (errno)); goto cleanup; } if (ipmi_cmd_set_pef_configuration_parameters_alert_policy_table (state_data->ipmi_ctx, alert_policy_entry_number, apt->policy_type, apt->policy_enabled, apt->policy_number, apt->destination_selector, apt->channel_number, apt->alert_string_set_selector, apt->event_specific_alert_string, obj_cmd_rs) < 0) { config_err_t ret; if (state_data->prog_data->args->config_args.common_args.debug) pstdout_fprintf (state_data->pstate, stderr, "ipmi_cmd_set_pef_configuration_parameters_alert_policy_table: %s\n", ipmi_ctx_errormsg (state_data->ipmi_ctx)); /* IPMI Workaround * * Fujitsu RX 100 S5 * * Inventec 5441/Dell Xanadu II * * All fields have to be applied simultaneously, the motherboard * does not appear to like configuration of one field of a time, * always leading to invalid input errors. This isn't a * compliance issue, but makes it tough to make a portable/good * interface. */ if (ipmi_ctx_errnum (state_data->ipmi_ctx) == IPMI_ERR_BAD_COMPLETION_CODE && (ipmi_check_completion_code (obj_cmd_rs, IPMI_COMP_CODE_INVALID_DATA_FIELD_IN_REQUEST) == 1)) { struct config_section *section; struct config_keyvalue *kv; section = state_data->sections; while (section) { if (!strcasecmp (section_name, section->section_name)) break; section = section->next; } /* shouldn't be possible */ if (!section) goto cleanup; if ((kv = config_find_keyvalue (section, "Policy_Type"))) apt->policy_type = policy_type_number (kv->value_input); if ((kv = config_find_keyvalue (section, "Policy_Enabled"))) apt->policy_enabled = same (kv->value_input, "yes"); if ((kv = config_find_keyvalue (section, "Policy_Number"))) apt->policy_number = atoi (kv->value_input); if ((kv = config_find_keyvalue (section, "Destination_Selector"))) apt->destination_selector = atoi (kv->value_input); if ((kv = config_find_keyvalue (section, "Channel_Number"))) apt->channel_number = atoi (kv->value_input); if ((kv = config_find_keyvalue (section, "Alert_String_Set_Selector"))) apt->alert_string_set_selector = atoi (kv->value_input); if ((kv = config_find_keyvalue (section, "Event_Specific_Alert_String"))) apt->event_specific_alert_string = same (kv->value_input, "yes"); if (state_data->prog_data->args->config_args.common_args.debug) pstdout_fprintf (state_data->pstate, stderr, "ipmi_cmd_set_pef_configuration_parameters_alert_policy_table: attempting workaround\n"); if (ipmi_cmd_set_pef_configuration_parameters_alert_policy_table (state_data->ipmi_ctx, alert_policy_entry_number, apt->policy_type, apt->policy_enabled, apt->policy_number, apt->destination_selector, apt->channel_number, apt->alert_string_set_selector, apt->event_specific_alert_string, obj_cmd_rs) < 0) { if (state_data->prog_data->args->config_args.common_args.debug) pstdout_fprintf (state_data->pstate, stderr, "ipmi_cmd_set_pef_configuration_parameters_alert_policy_table: %s\n", ipmi_ctx_errormsg (state_data->ipmi_ctx)); if (config_is_config_param_non_fatal_error (state_data->ipmi_ctx, obj_cmd_rs, &ret)) rv = ret; goto cleanup; } /* success */ goto out; } else if (config_is_config_param_non_fatal_error (state_data->ipmi_ctx, obj_cmd_rs, &ret)) rv = ret; goto cleanup; } out: rv = CONFIG_ERR_SUCCESS; cleanup: fiid_obj_destroy (obj_cmd_rs); return (rv); }
static config_err_t id_commit (const char *section_name, const struct config_keyvalue *kv, void *arg, int id) { bmc_config_state_data_t *state_data; fiid_obj_t obj_cmd_rs = NULL; config_err_t rv = CONFIG_ERR_FATAL_ERROR; config_err_t ret; uint8_t channel_number; uint8_t privs[CIPHER_SUITE_LEN]; uint8_t privilege; unsigned int i; assert (section_name); assert (kv); assert (arg); state_data = (bmc_config_state_data_t *)arg; if ((ret = _rmcpplus_cipher_suite_id_privilege_setup (state_data, section_name)) != CONFIG_ERR_SUCCESS) return (ret); if (!(obj_cmd_rs = fiid_obj_create (tmpl_cmd_set_lan_configuration_parameters_rs))) { pstdout_fprintf (state_data->pstate, stderr, "fiid_obj_create: %s\n", strerror (errno)); goto cleanup; } if ((ret = get_lan_channel_number (state_data, section_name, &channel_number)) != CONFIG_ERR_SUCCESS) { rv = ret; goto cleanup; } privilege = rmcpplus_priv_number (kv->value_input); memset (privs, '\0', CIPHER_SUITE_LEN); memcpy (privs, state_data->cipher_suite_priv, CIPHER_SUITE_LEN); /* achu: NOT A BUG. * * IPMI spec is_supported does not map to privileges array, you want to index at [id] not a searched [i] */ privs[id] = privilege; /* IPMI Workaround (achu) * * HP DL145 * * See comments above in _rmcpplus_cipher_suite_id_privilege_setup * surrounding HP DL145 workaround. * * B/c of the issue above, there may be illegal privilege levels * sitting in the cipher_suite_priv[] array, we need to fill them in * with the values configured by users. * * If the users didn't configure all the entries, they're out of * luck, we need to return an error. */ for (i = 0; i < CIPHER_SUITE_LEN; i++) { if (privs[i] == BMC_CONFIG_PRIVILEGE_LEVEL_SUPPORTED_BUT_NOT_READABLE) { struct config_section *section; if ((section = config_find_section (state_data->sections, section_name))) { char keynametmp[CONFIG_MAX_KEY_NAME_LEN + 1]; struct config_keyvalue *kvtmp; memset (keynametmp, '\0', CONFIG_MAX_KEY_NAME_LEN + 1); snprintf (keynametmp, CONFIG_MAX_KEY_NAME_LEN, "Maximum_Privilege_Cipher_Suite_Id_%u", i); if ((kvtmp = config_find_keyvalue (section, keynametmp))) { uint8_t privilege_tmp; privilege_tmp = rmcpplus_priv_number (kvtmp->value_input); privs[i] = privilege_tmp; } else { pstdout_fprintf (state_data->pstate, stderr, "ERROR: '%s:%s' Field Required\n", section_name, keynametmp); rv = CONFIG_ERR_NON_FATAL_ERROR; goto cleanup; } } else { /* This is a fatal error, we're already in this section, * it should be findable */ if (state_data->prog_data->args->config_args.common_args.debug) pstdout_fprintf (state_data->pstate, stderr, "Cannot find section '%s'\n", section_name); goto cleanup; } } } if (ipmi_cmd_set_lan_configuration_parameters_rmcpplus_messaging_cipher_suite_privilege_levels (state_data->ipmi_ctx, channel_number, privs[0], privs[1], privs[2], privs[3], privs[4], privs[5], privs[6], privs[7], privs[8], privs[9], privs[10], privs[11], privs[12], privs[13], privs[14], privs[15], obj_cmd_rs) < 0) { if (state_data->prog_data->args->config_args.common_args.debug) pstdout_fprintf (state_data->pstate, stderr, "ipmi_cmd_set_lan_configuration_parameters_rmcpplus_messaging_cipher_suite_privilege_levels: %s\n", ipmi_ctx_errormsg (state_data->ipmi_ctx)); if (config_is_config_param_non_fatal_error (state_data->ipmi_ctx, obj_cmd_rs, &ret)) rv = ret; goto cleanup; } /* achu: NOT A BUG. * * IPMI spec is_supported does not map to privileges array, you want to index at [id] not [i] */ state_data->cipher_suite_priv[id] = privilege; rv = CONFIG_ERR_SUCCESS; cleanup: fiid_obj_destroy (obj_cmd_rs); return (rv); }
config_err_t config_parse (pstdout_state_t pstate, struct config_section *sections, struct config_arguments *cmd_args, FILE *fp) { char buf[CONFIG_PARSE_BUFLEN]; int line_num = 0; struct config_section *section = NULL; struct config_key *key; char *str, *tok; config_err_t rv = CONFIG_ERR_FATAL_ERROR; while (fgets (buf, CONFIG_PARSE_BUFLEN, fp)) { line_num++; buf[CONFIG_PARSE_BUFLEN-1] = '\0'; str = strtok (buf, " \t\n"); if (!str) { if (cmd_args->common_args.debug) pstdout_fprintf (pstate, stderr, "%d: empty line\n", line_num); continue; } if (str[0] == '#') { if (cmd_args->common_args.debug) pstdout_fprintf (pstate, stderr, "Comment on line %d\n", line_num); continue; } if (same (str, "Section")) { if (!(tok = strtok (NULL, " \t\n"))) { pstdout_fprintf (pstate, stderr, "FATAL: Error parsing line number %d\n", line_num); goto cleanup; } if (!(section = config_find_section (sections, tok))) { pstdout_fprintf (pstate, stderr, "Unknown section `%s'\n", tok); goto cleanup; } if (cmd_args->common_args.debug) pstdout_fprintf (pstate, stderr, "Entering section `%s'\n", section->section_name); continue; } /* same (str, "Section") */ if (same (str, "EndSection")) { if (!section) { pstdout_fprintf (pstate, stderr, "FATAL: encountered `%s' without a matching Section\n", str); goto cleanup; } if (cmd_args->common_args.debug) pstdout_fprintf (pstate, stderr, "Leaving section `%s'\n", section->section_name); section = NULL; continue; } /* same (str, "EndSection") */ if (!section) { pstdout_fprintf (pstate, stderr, "FATAL: Key `%s' not inside a valid Section\n", str); goto cleanup; } if (!(key = config_find_key (section, str))) { pstdout_fprintf (pstate, stderr, "Unknown key `%s' in section `%s'\n", str, section->section_name); goto cleanup; } tok = strtok (NULL, " \t\n"); if (!tok) tok = ""; if (cmd_args->common_args.debug) pstdout_fprintf (pstate, stderr, "Parsed `%s:%s=%s'\n", section->section_name, key->key_name, tok); if (config_find_keyvalue (section, key->key_name)) { pstdout_fprintf (pstate, stderr, "Key '%s' specified twice in section '%s'\n", key->key_name, section->section_name); goto cleanup; } if (config_section_add_keyvalue (pstate, section, key, tok, NULL) < 0) goto cleanup; } rv = CONFIG_ERR_SUCCESS; cleanup: return (rv); }
static config_err_t _set_authentication_type_enables (bmc_config_state_data_t *state_data, const char *section_name, struct bmc_authentication_level *al) { fiid_obj_t obj_cmd_rs = NULL; config_err_t rv = CONFIG_ERR_FATAL_ERROR; config_err_t ret; uint8_t channel_number; assert (state_data); assert (section_name); assert (al); if (!(obj_cmd_rs = fiid_obj_create (tmpl_cmd_set_lan_configuration_parameters_rs))) { pstdout_fprintf (state_data->pstate, stderr, "fiid_obj_create: %s\n", strerror (errno)); goto cleanup; } if ((ret = get_lan_channel_number (state_data, section_name, &channel_number)) != CONFIG_ERR_SUCCESS) { rv = ret; goto cleanup; } if (ipmi_cmd_set_lan_configuration_parameters_authentication_type_enables (state_data->ipmi_ctx, channel_number, al->callback_level_none, al->callback_level_md2, al->callback_level_md5, al->callback_level_straight_password, al->callback_level_oem_proprietary, al->user_level_none, al->user_level_md2, al->user_level_md5, al->user_level_straight_password, al->user_level_oem_proprietary, al->operator_level_none, al->operator_level_md2, al->operator_level_md5, al->operator_level_straight_password, al->operator_level_oem_proprietary, al->admin_level_none, al->admin_level_md2, al->admin_level_md5, al->admin_level_straight_password, al->admin_level_oem_proprietary, al->oem_level_none, al->oem_level_md2, al->oem_level_md5, al->oem_level_straight_password, al->oem_level_oem_proprietary, obj_cmd_rs) < 0) { if (state_data->prog_data->args->config_args.common_args.debug) pstdout_fprintf (state_data->pstate, stderr, "ipmi_cmd_set_lan_configuration_parameters_authentication_type_enables: %s\n", ipmi_ctx_errormsg (state_data->ipmi_ctx)); /* * IPMI Workaround * * Dell Poweredge R610 * * Nodes come default w/ OEM authentication enables turned * on, but you cannot configure them on. So this always * leads to invalid data errors (0xCC) b/c we are * configuring one field at a time. So we will "absorb" the * OEM configuration of later fields and try again, hoping * that the user has tried to "right" the badness already * sitting on the motherboard. */ if (ipmi_ctx_errnum (state_data->ipmi_ctx) == IPMI_ERR_COMMAND_INVALID_OR_UNSUPPORTED && (ipmi_check_completion_code (obj_cmd_rs, IPMI_COMP_CODE_INVALID_DATA_FIELD_IN_REQUEST) == 1)) { struct config_section *section; struct config_keyvalue *kv; section = state_data->sections; while (section) { if (!strcasecmp (section->section_name, "Lan_Conf_Auth")) break; section = section->next; } /* shouldn't be possible */ if (!section) goto cleanup; if ((kv = config_find_keyvalue (section, "Callback_Enable_Auth_Type_OEM_Proprietary"))) al->callback_level_oem_proprietary = same (kv->value_input, "yes"); if ((kv = config_find_keyvalue (section, "User_Enable_Auth_Type_OEM_Proprietary"))) al->user_level_oem_proprietary = same (kv->value_input, "yes"); if ((kv = config_find_keyvalue (section, "Operator_Enable_Auth_Type_OEM_Proprietary"))) al->operator_level_oem_proprietary = same (kv->value_input, "yes"); if ((kv = config_find_keyvalue (section, "Admin_Enable_Auth_Type_OEM_Proprietary"))) al->admin_level_oem_proprietary = same (kv->value_input, "yes"); if ((kv = config_find_keyvalue (section, "OEM_Enable_Auth_Type_None"))) al->oem_level_none = same (kv->value_input, "yes"); if ((kv = config_find_keyvalue (section, "OEM_Enable_Auth_Type_MD2"))) al->oem_level_md2 = same (kv->value_input, "yes"); if ((kv = config_find_keyvalue (section, "OEM_Enable_Auth_Type_MD5"))) al->oem_level_md5 = same (kv->value_input, "yes"); if ((kv = config_find_keyvalue (section, "OEM_Enable_Auth_Type_Straight_Password"))) al->oem_level_straight_password = same (kv->value_input, "yes"); if ((kv = config_find_keyvalue (section, "OEM_Enable_Auth_Type_OEM_Proprietary"))) al->oem_level_oem_proprietary = same (kv->value_input, "yes"); if (ipmi_cmd_set_lan_configuration_parameters_authentication_type_enables (state_data->ipmi_ctx, channel_number, al->callback_level_none, al->callback_level_md2, al->callback_level_md5, al->callback_level_straight_password, al->callback_level_oem_proprietary, al->user_level_none, al->user_level_md2, al->user_level_md5, al->user_level_straight_password, al->user_level_oem_proprietary, al->operator_level_none, al->operator_level_md2, al->operator_level_md5, al->operator_level_straight_password, al->operator_level_oem_proprietary, al->admin_level_none, al->admin_level_md2, al->admin_level_md5, al->admin_level_straight_password, al->admin_level_oem_proprietary, al->oem_level_none, al->oem_level_md2, al->oem_level_md5, al->oem_level_straight_password, al->oem_level_oem_proprietary, obj_cmd_rs) < 0) { if (state_data->prog_data->args->config_args.common_args.debug) pstdout_fprintf (state_data->pstate, stderr, "ipmi_cmd_set_lan_configuration_parameters_authentication_type_enables: %s\n", ipmi_ctx_errormsg (state_data->ipmi_ctx)); if (config_is_config_param_non_fatal_error (state_data->ipmi_ctx, obj_cmd_rs, &ret)) rv = ret; goto cleanup; } /* success!! */ goto out; } else if (config_is_config_param_non_fatal_error (state_data->ipmi_ctx, obj_cmd_rs, &ret)) rv = ret; goto cleanup; } out: rv = CONFIG_ERR_SUCCESS; cleanup: fiid_obj_destroy (obj_cmd_rs); return (rv); }