389 Commits

Author SHA1 Message Date
Alexander Amelkin
4b791f8bf6 lan: channel: Fix set alert on/off
From IPMI Spec, Chapter 22.22 Set Channel Access Command
Table 22, Set Channel Access Command

Byte#2, Bit#5 is "PEF Alerting Enable/Disable"
And the bit value:
    0b = enable PEF Alerting
    1b = disable PEF Alerting on this channel

In current code, alert "on" set Bit#5 to 1 and alert "off" set Bit#5 to
0, it's straightforward but just opposite of IPMI spec bit definition.

Resolves ipmitool/ipmitool#247

Reported-by: Ryan Fang <Ryan.Fang@quantatw.com>
Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
2023-01-12 13:47:25 +03:00
Vincent Fazio
26b088193a Do not require the IANA PEN registry file
Previously, ipmitool would fail to run if the local copy of the IANA PEN
registry could not be parsed.

When the registry is not available the manufacturer will be "Unknown" but
ipmitool will otherwise function so should not be considered fatal.

Also, fix an issue with improperly handling the `oem_info_list_load`
return value. Previously, in `ipmi_oem_info_init`, if `oem_info_list_load`
returned a negative value due to the registry file not existing, an
improper count would cause `oem_info_init_from_list` to aallocate a list
that didn't encompass the full header/tail list.

  IANA PEN registry open failed: No such file or directory
    Allocating      3 entries
    [     1] 16777214 | A Debug Assisting Company, Ltd.
    [     0]  1048575 | Unspecified

Now, use a signed int and ensure a valid count of loaded OEMs is used.

Signed-off-by: Vincent Fazio <vfazio@gmail.com>
2023-01-11 19:17:49 +03:00
SliderLu
206dba615d delloem: Fix the unalign bug in arm64
For computers using the arm64 of the Apple chip, the link requires strict
alignment of pointers in 32-bit form. Replace the struct vFlashstr to valstr.
Replace the Function get_vFlash_compcode_str to val2str.

Resolves ipmitool/ipmitool#332
Signed-off-by: SliderLu <314238828@qq.com>
2023-01-09 12:01:28 +03:00
Alexander Amelkin
63d59a50a6 fru print: Add area checksum verification
Before this change, `ipmitool` would not detect any checksum errors
in FRU areas when using 'fru print'. Now it will print whether the
area checksum is OK or INVALID for Chassis, Board, and Product areas.

Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
2022-12-21 15:15:55 +03:00
Alexander Amelkin
f033b5549e fru: Add decoder for multirec system mgmt records
* Add a decoder for System Management records in
  the Multirecord area
* Refactor GUID/UUID decoding: Use the same code for `mc guid`
  and for `fru print` to decode the GUID and System Unique ID
  in System Management records in the Multirecord Area.
* Fix some type errors in calls to printf/sprintf in GUID decoder

Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
2022-12-06 02:48:52 +03:00
Andy Clegg
a1dc78c456 sel: Fix the deasserted thresholds inequality
The choice of > or < when printing the threshold inequality currently
only depends on whether it is an upper or lower threshold. This is
correct when the event is asserted, but when the event is deasserted the
inequality is reversed and therefore the current code can give confusing
results, e.g.:

```
Temperature ps1_inlet_temp |
Upper Non-critical going high |
Deasserted |
Reading 43.94 > Threshold 44.88 degrees C
```

This commit fixes that.

See ipmitool/ipmitool#349

Signed-off-by: Andy Clegg <andyc@graphcore.ai>
2022-08-05 18:57:19 +03:00
Alexander Amelkin
65ba015f5c chassis restart_cause: Add new causes
Add 'soft reset' and 'power-up by RTC wakeup' causes
from IPMI 2.0 spec.

Resolves ipmitool/ipmitool#329

Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
2022-03-09 17:39:45 +03:00
Bing-Hua Wang
4d4f29f0b6 sel: Remove redundant "Reserve SEL"
There is no need to reserve SEL when doing "sel list" and "sel get"
since we don't do partial get in both commands, and we didn't even use
the reservation ID returned by "Reserve SEL".

Signed-off-by: Bing-Hua Wang <binghuawang@ami.com>
2022-02-07 14:35:28 +03:00
jason63716
86ef8fb091 sdr: Fix modifier unit
Previously instead of the modifier unit, the base unit was printed.
2021-11-03 16:04:41 +03:00
Josef Möllers
11c7605c0d helper: Fix stderr file descriptor
The third file descriptor is STDERR_FILENO, not STDOUT_FILENO
2021-06-22 23:55:49 +03:00
Thomas Renninger
cdac4e07f7 Use /run instead of /var/run
In FHS 3.0, /var/run is replaced by /run:

https://refspecs.linuxfoundation.org/FHS_3.0/fhs/ch05s13.html
2021-06-22 23:45:59 +03:00
Alexander Amelkin
cd57365fc4
oem: Update product IDs for YADRO
Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
2021-06-18 17:45:28 +03:00
Alexander Amelkin
351dad24a2 lan: Add processing of get/set specific CCs
Both 'Set/Get LAN Configuration Parameter' commands may return
command-specific codes that weren't properly parsed and were
reported as 'Unknown' before. This is fixed now.

Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
2021-06-15 21:12:49 +03:00
Alexander Amelkin
fb47ae8d7c lan: Refactor pointer style
Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
2021-06-15 21:12:49 +03:00
Alexander Amelkin
9a1c0e68ba
ekanalyzer: Fix internal use area off-by-one bug
The length of internal use area printed by ekanalyzer
didn't take in account the version byte.
The data printed was also 1 byte longer than needed.

Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
2021-05-21 02:39:16 +03:00
Alexander Amelkin
1f429f1ed7 ekanalyzer frushow: Fix internal area size calc
When there was no chassis and board areas, the internal use
are size was calculated incorrectly.

Additionally, it is possible that the internal area is actually
located after all other areas or that areas are arranged in
a different order than their offsets in the header. All those
cases weren't properly handled.

Now that is fixed.

Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
2021-05-21 01:16:16 +03:00
Bing-Hua Wang
682fec09ef Remove unneeded execution bits from C source files and a header file
Signed-off-by: Bing-Hua Wang <binghuawang@ami.com>
2021-04-08 11:29:25 +03:00
Shitalkumar Gandhi
d674bfdc9a Fixed compiler warning.
This patch has been added to fix "error: comparison between signed
and unsigned integer expressions [-Werror=sign-compare]"

Signed-off-by: Shitalkumar Gandhi <shitalkumar.gandhi@seagate.com>
2021-02-24 14:10:42 +03:00
Alexander Amelkin
7108884793 hpmfwupg: Clean up / refactor
- Drop a useless `extern` definition
- Remove static variable `errorCount` from header, move it to
  the c file where it is actually used if needed

Related to ipmitool/ipmitool#220

Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
2020-10-01 20:27:31 +03:00
Alexander Amelkin
1245aaa387 fru: Fix crashes on 6-bit ASCII strings
Fix calculation of the buffer size for decoded 6-bit ASCII
strings. Previously the program could allocate too a short buffer
that caused buffer overflows and segmentation fault crashes on
certain FRU contents.

Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
2020-09-16 13:26:53 +03:00
Alexander Amelkin
50d8c36edf Refix 6e037d6bfbbb93b349c8ca331ebde03a837f76bf
Restore using strncmp() for "options=" and similar
substrings.

Resolves ipmitool/ipmitool#223

Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
2020-08-07 10:53:06 +03:00
Alexander Amelkin
aee377bead
oem: Add product ID for YADRO VEGMAN
Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
2020-07-23 13:41:11 +03:00
Alexander Amelkin
16f937a117 Add version info to debug output
- Initialize the log at the start of ipmi_main() to allow for proper
  logging at the start;
- Remove the unused log_level_get() function;
- Update log_level_set() to take verbosity instead of log level
  (default verbosity is 0, which is LOG_NOTICE log level),
  use the function to update log level as `-v` is encountered
  in command line;
- Move IANA PEN list debugging to verbosity 6. The list is too long
  to see it in each debug output of verbosity 5 that is used for
  debugging lan/lanplus packets;
- For verbosity >= 2 (that is `-vv`) add the ipmitool version
  information at the start.

Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
2020-07-17 15:57:06 +03:00
Alexander Amelkin
1f92c9ee23
dist: Fix dependencies and cleanup
The `make distcheck` was failing because of some files deleted twice
and some intermediate files not deleted at all.

Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
2020-06-30 16:19:35 +03:00
Alexander Amelkin
956ae2b372 Finalize refactoring of string comparisons
Unify the comparison idioms use.
Always use `if(!strcmp())` for "if string equals"
and `if(strcmp())` for "if string is not equal".
Never use `== 0` and `!= 0` with `strcmp()`.

Minor reformatting of the code immediately surrounding the
refactored lines.

Resolves ipmitool/ipmitool#104

Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
2020-06-10 13:46:57 +03:00
Alexander Amelkin
e3fc775d26 channel: Refactor set_user_access option processing
Reduce code duplication by extracting option names, types,
and value ranges into a separate structure, and rewriting
the option parsing code without mixing it with the data.

Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
2020-06-10 13:46:57 +03:00
Jiang Junyu
6e037d6bfb Refactor string comparisons
Clean up use of strcmp/strncmp/strncasecmp for command line arguments.
Never use anything but `strcmp()` unless absolutely neccessary.

Partialy resolves ipmitool/ipmitool#104
2020-06-10 13:46:57 +03:00
John Levon
dfe17311d6
sdr: harden against bad records
Harden ipmi_sdr_get_record() against bad records

Signed-off-by: John Levon <john.levon@joyent.com>
2020-05-26 18:03:39 +03:00
Vaclav Dolezal
b97a110721 fru: fix memory leak in ipmi_spd_print_fru
Fixed by using centralised exiting.

Signed-off-by: Václav Doležal <vdolezal@redhat.com>
2020-05-25 18:50:16 +03:00
Pavel Kiryukhin
284adfe2e2 ipmi_sel_set_time: fix strptime() return check
The current behavior:
- correct date format is not accepted by "sel time set".
- incorrect date format that looks correct is accepted, but time is not
  set correctly.
- commands like
    ipmitool sel time set "11/22/2013 trash"
  are accepted.
2020-05-22 19:47:10 +03:00
John Levon
2a17967159
hpm: use portable __max() in hpmfwupg
Instead of non-portable MAX() use __max() in hpmfwupg
2020-05-18 09:04:24 +03:00
Vaclav Dolezal
c3939dac2c hpmfwupg: move variable definition to .c file
Signed-off-by: Vaclav Dolezal <vdolezal@redhat.com>
2020-02-13 13:02:48 +03:00
Pavel Kiryukhin
f80effb1fc sel: time: fix null pointer dereference in set
This is a refix of commit f0d5c17e
2020-02-12 16:37:02 +03:00
Chrostoper Ertl
7ccea283dd
fru, sdr: Fix id_string buffer overflows
Final part of the fixes for CVE-2020-5208, see
https://github.com/ipmitool/ipmitool/security/advisories/GHSA-g659-9qxw-p7cp

9 variants of stack buffer overflow when parsing `id_string` field of
SDR records returned from `CMD_GET_SDR` command.

SDR record structs have an `id_code` field, and an `id_string` `char`
array.

The length of `id_string` is calculated as `(id_code & 0x1f) + 1`,
which can be larger than expected 16 characters (if `id_code = 0xff`,
then length will be `(0xff & 0x1f) + 1 = 32`).

In numerous places, this can cause stack buffer overflow when copying
into fixed buffer of size `17` bytes from this calculated length.
2020-02-04 15:00:14 +03:00
Chrostoper Ertl
d45572d71e
lanp: Fix buffer overflows in get_lan_param_select
Partial fix for CVE-2020-5208, see
https://github.com/ipmitool/ipmitool/security/advisories/GHSA-g659-9qxw-p7cp

The `get_lan_param_select` function is missing a validation check on the
response’s `data_len`, which it then returns to caller functions, where
stack buffer overflow can occur.
2020-02-04 14:59:55 +03:00
Chrostoper Ertl
9452be8718
channel: Fix buffer overflow
Partial fix for CVE-2020-5208, see
https://github.com/ipmitool/ipmitool/security/advisories/GHSA-g659-9qxw-p7cp

The `ipmi_get_channel_cipher_suites` function does not properly check
the final response’s `data_len`, which can lead to stack buffer overflow
on the final copy.
2020-02-04 14:59:52 +03:00
Chrostoper Ertl
41d7026946
session: Fix buffer overflow in ipmi_get_session_info
Partial fix for CVE-2020-5208, see
https://github.com/ipmitool/ipmitool/security/advisories/GHSA-g659-9qxw-p7cp

The `ipmi_get_session_info` function does not properly check the
response `data_len`, which is used as a copy size, allowing stack buffer
overflow.
2020-02-04 14:59:49 +03:00
Chrostoper Ertl
840fb1cbb4
fru: Fix buffer overflow in ipmi_spd_print_fru
Partial fix for CVE-2020-5208, see
https://github.com/ipmitool/ipmitool/security/advisories/GHSA-g659-9qxw-p7cp

The `ipmi_spd_print_fru` function has a similar issue as the one fixed
by the previous commit in `read_fru_area_section`. An initial request is
made to get the `fru.size`, which is used as the size for the allocation
of `spd_data`. Inside a loop, further requests are performed to get the
copy sizes which are not checked before being used as the size for a
copy into the buffer.
2020-02-04 14:59:43 +03:00
Chrostoper Ertl
e824c23316
fru: Fix buffer overflow vulnerabilities
Partial fix for CVE-2020-5208, see
https://github.com/ipmitool/ipmitool/security/advisories/GHSA-g659-9qxw-p7cp

The `read_fru_area_section` function only performs size validation of
requested read size, and falsely assumes that the IPMI message will not
respond with more than the requested amount of data; it uses the
unvalidated response size to copy into `frubuf`. If the response is
larger than the request, this can result in overflowing the buffer.

The same issue affects the `read_fru_area` function.
2020-02-04 14:58:06 +03:00
Ivan Mikhaylov
7a66d8725d
chassis: bootmbox: Refix 62a04390
Fix ipmitool not writing the last block of boot mailbox data if the
block is shorter than 3 bytes.

Signed-off-by: Ivan Mikhaylov <fr0st61te@gmail.com>
Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
2020-01-23 18:06:47 +03:00
Pavel Kiryukhin
d9adbf12f1 ipmi_dcmi: fix typo in nm_policy_options initialization.
This re-enables "nm policy add" functionality.
2019-11-27 13:47:41 +03:00
Alexander Amelkin
42a023ff07 chassis: Refactor to get rid of strncmp()
For parameter checking replace calls to strncmp() with calls
to strcmp() in order to improve readability and get rid of literal
string lengths.

Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
2019-11-12 17:55:21 +03:00
Alexander Amelkin
58c9263a28 chassis: Refactor main for centralized exiting
In ipmi_chassis_main:

* Default to error return code (-1).

* Use centralized exit.

Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
2019-11-12 17:55:21 +03:00
Alexander Amelkin
0663814eec chassis: bootdev: Refactor more
* Get rid of magic '8' in bootdev options processing.

* Optimize the code of bootdev arguments processing, remove the
  special crafting of flags for 'clear-cmos' argument, make it use
  the same code as other options.

Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
2019-11-12 17:55:21 +03:00
Alexander Amelkin
aa72d9c426 chassis: bootdev: Refactor to reduce nesting
Move bootdev options parsing to a separate helper function

Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
2019-11-12 17:55:21 +03:00
Alexander Amelkin
0854344db5 chassis: bootdev: Fix help message and its formatting
There was a wrong help message regarding the console redirection,
and also the help formatting was a bit off. Straightened this all up.

Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
2019-11-12 17:55:21 +03:00
Alexander Amelkin
4b89f1b42d chassis: bootparam/bootdev: Refactor for less magic
Refactor the boot flags decoder:

* Add macros for boot flag bits, replace magic numbers in
  the `chassis bootparam get 5` and in `chassis bootdev`
  handlers.

  The macros are prefixed with BFx_ where x stands for the
  boot flags data byte as per IPMI 2.0 specification Table 28-14;

* Add decoding of remote/redirected media boot flags;

* Remove erroneous decoding of boot flags byte 3 bit 1 as
  Sleep button lockout whereas the bit is a part of console
  redirection setting;

* Fix console redirection settings reported under the 'BIOS verbosity'
  header and vice versa;

* Fix resetting of all other boot flags in the data byte when
  setting any of the bits in the same byte. This fixes inability
  to set both 'efiboot' and 'persistent' bits at the same time,
  and other similar cases.

Resolves ipmitool/ipmitool#163
Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
2019-11-12 17:55:21 +03:00
Alexander Amelkin
0e3e436eb6
oem: supermicro: Add product codes from IPMICFG
ftp://ftp.supermicro.com/utility/IPMICFG/IPMICFG_1.30.0_build.190710.zip
contains MBType.dat file that lists all known Supermicro product IDs
with their respective names.

Import that knowledge into ipmitool.

Resolves ipmitool/ipmitool#151
Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
2019-11-06 18:50:08 +03:00
Alexander Amelkin
eed9d5950e
lan: Refix 6e2b688e. Fix vlan range checking.
Commit 6e2b688e introduced a bug due to which VLAN id range checking
was negated and resulted in error messages printed for correct VLAN ids.

Resolves ipmitool/ipmitool#55

Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
2019-09-05 15:10:02 +03:00
Alexander Amelkin
6940a6717a user: Cleanup/refactor ipmi_user_password()
Get rid of magic numbers, fix some formatting, drop unneeded checks.

Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
2019-09-03 23:40:48 +03:00