1988 Commits

Author SHA1 Message Date
Patrick Venture
be3d57c013 fru: replace magic return codes with macros
Use the return code macros instead of magic numbers.

Signed-off-by: Patrick Venture <venture@google.com>
2019-02-13 21:28:14 +03:00
Patrick Venture
f64044a3de fru header: add return error codes specific to fru
Add two special return codes specific to the IPMI
FRU commands.

Signed-off-by: Patrick Venture <venture@google.com>
2019-02-13 21:28:14 +03:00
Patrick Venture
3737b035e8 fru: fix ipmi_fru_picmg_ext_edit as bool
Fix ipmi_fru_picmg_ext_edit to use bools instead
of an int treated as a boolean.

Signed-off-by: Patrick Venture <venture@google.com>
2019-02-13 21:28:14 +03:00
Patrick Venture
6b003c3852 fru: use bool with ipmi_fru_oemkontron_edit
Convert ipmi_fru_oemkontron_edit to return a bool
type instead of an int used as a bool.

Signed-off-by: Patrick Venture <venture@google.com>
2019-02-13 21:28:14 +03:00
Patrick Venture
8991f5a9a0 fru: change ipmi_fru_query_new_value to return bool
Change ipmi_fru_query_new_value to return the bool type
instead of an int that's being used as a boolean value.

Signed-off-by: Patrick Venture <venture@google.com>
2019-02-13 21:28:14 +03:00
Patrick Venture
49384e47be fru: mark ipmi_fru_query_new_value as static
Mark ipmi_fru_query_new_value as static as it's only
used internally in this object.

Signed-off-by: Patrick Venture <venture@google.com>
2019-02-13 21:28:14 +03:00
Patrick Venture
6dcb168442 fru: add fru_cc_rq2big helper method for code checks
Add fru_cc_rq2big helper method to reduce duplicate
code checking for specific size-based IPMI response
codes.

Signed-off-by: Patrick Venture <venture@google.com>
2019-02-13 21:28:14 +03:00
Patrick Venture
1c4a00d26b fru: cleanup ipmi_fru_upg_ekeying
Cleanup ipmi_fru_upg_ekeying such that it exits from
one place that handles cleanup.

Signed-off-by: Patrick Venture <venture@google.com>
2019-02-13 21:28:14 +03:00
Patrick Venture
aef8a1ccb4 fru: use ipmi_cc defined maros for return codes
Use the macros defined in ipmi_cc for IPMI return
codes instead of magic numbers.

Signed-off-by: Patrick Venture <venture@google.com>
2019-02-13 21:28:14 +03:00
Patrick Venture
81761e6f60 fru: drop extraneous parentheses on negative returns
Drop extraneous parentheses when returning a
negative value.

Signed-off-by: Patrick Venture <venture@google.com>
2019-02-13 21:28:14 +03:00
Patrick Venture
715c7b8a1f fru: delete unused variable matchInstance
Delete unused variable matchInstance.  The variable is repeatedly
assigned, but nothing reads it.

Signed-off-by: Patrick Venture <venture@google.com>
2019-02-13 21:28:14 +03:00
Patrick Venture
92ee477cde fru: cleanup ipmi_fru_oemkontron_get
Cleanup style in method ipmi_fru_oemkontron_get as well as add inverted
logic checks to reduce indentation.

Signed-off-by: Patrick Venture <venture@google.com>
2019-02-13 21:28:14 +03:00
Patrick Venture
6d515dd06b fru: fixup array bounds checking
Fixup the following array bounds checking bugs:
[lib/ipmi_fru.c:1003]: (style) Array index 'i' is
used before limits check.
[lib/ipmi_fru.c:1127]: (style) Array index 'i' is
used before limits check.
[lib/ipmi_fru.c:1262]: (style) Array index 'i' is
used before limits check.

Signed-off-by: Patrick Venture <venture@google.com>
2019-02-13 21:28:14 +03:00
Josef Moellers
7941806a9b hpm: Adhere to centralized exiting
Replace `return`s with `goto`s to appropriate labels
(with or without closing the file).
2019-01-24 15:22:21 +03:00
Josef Moellers
4631d3f942 hpm: Minor refactoring
Remove an `if()` with a condition that is always true.
Merge two calls to time() into one.
2019-01-24 15:22:21 +03:00
Josef Moellers
272d9d0d9b hpm: Fix resource leak
fclose(pImageFile) was missing before returning from
HpmfwupgGetBufferFromFile()
2019-01-24 15:22:21 +03:00
Alexander Amelkin
0ca9c66b84
sol: Make interface timeout obey the -N option
For `sol activate` the timeout on lanplus interface was hard-coded
to 1 second, overriding the value set with the `-N` option.

Resolves ipmitool/ipmitool#87

Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
2018-12-28 16:33:18 +03:00
Patrick Venture
8b6d127bb1 helper: add free_n method to handle clearing pointers
free_n() will free the memory and clear the pointer, which will reduce
the probability a developer will forget to clear the pointer after
freeing.

Resolves: #79

Signed-off-by: Patrick Venture <venture@google.com>
2018-12-24 19:17:48 +03:00
Jörg Krause
34fc86bd75
cygwin: imb: Fix build error (wchar_t)
For Win32/Cygwin, the imb plugin was failing to build with
the following message:

imbapi.h:140:9: error: unknown type name 'wchar_t'
 typedef wchar_t      WCHAR;

Signed-off-by: Jörg Krause <joerg.krause@embedded.rocks>
2018-12-07 18:46:55 +03:00
pjdhpe
9ec2232321 lanplus: Fix segfault for truncated dcmi response
On occasion a dcmi power reading will return error C6, and a
truncated response payload. As the decrypted payload is shorter
than the expected length, lanplus_decrypt_aes_cbc_128() adjusts
the payload_size downward by one byte. In ipmi_lan_poll_single()
the calculation to determine if the payload size has increased
erroniously sets extra_data_length to -1, with a subsequent
segv when calling a memmove to shift response data.
The fix is to check for a positive value in the extra_data_length.

Resolves ipmitool/ipmitool#72
2018-12-06 12:41:22 +03:00
Alexander Amelkin
64727f59c4
lanplus: Cleanup. Refix 6dec83ff, fix be2c0c4b
This is a cleanup commit.

Commit 6dec83ff removed assignment of `rsp` pointer
in SOL-processing block of ipmi_lan_poll_single(),
but left the check for the pointer validity in place.
Although that has effectively fixed the bug of potentially
accessing the null `rsp` pointer in the `else` block introduced
with be2c0c4b, the resulting if/else looked suspicious and left
and impression that a NULL pointer could still be accessed.

This commit removes the check for `rsp` from the `if`
as it is checked at the start of the function where `rsp`
is initialized (and that is the only place where it is ever changed).

Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
2018-11-29 13:19:29 +03:00
Alexander Amelkin
5183b2c288 Move led color static array to source file
Move led color static array from header to ipmi_picmg module
and introduce `picmg_led_color_str()` function for use in
ipmi_vita module.

Partially resolves ipmitool/ipmitool#13

Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
2018-11-23 16:41:06 +03:00
Patrick Venture
83fee27624 drop unused static arrays
Originally marked unused, now dropped.

Partially resolves ipmitool/ipmitool#13

Signed-off-by: Patrick Venture <venture@google.com>
2018-11-23 16:41:06 +03:00
Patrick Venture
3e0ecc5edc move static objects to source file
Move static objects declared in headers to the source files where
they're used.

Partially resolves ipmitool/ipmitool#13

Signed-off-by: Patrick Venture <venture@google.com>
2018-11-23 16:41:06 +03:00
Patrick Venture
8ea6094118 cleanup all unused-parameter warnings
Cleanup all unused-parameter warnings.  Each warning was examined to
verify it wasn't simply a case of a build macro difference.

Partially resolves ipmitool/ipmitool#13

Signed-off-by: Patrick Venture <venture@google.com>
2018-11-23 16:41:06 +03:00
Patrick Venture
d6d9c85139 use __UNUSED__ macro instead of gcc specific attribute
Use __UNUSED__ macro defined in helper.h instead of the gcc-specific
attribute unused macro.

Partially resolves ipmitool/ipmitool#13

Signed-off-by: Patrick Venture <venture@google.com>
2018-11-23 16:41:06 +03:00
Patrick Venture
9a55136bfb implement __UNUSED__ macro for marking unused
Implement __UNUSED__ macro for marking symbols unused safely.

Partially resolves ipmitool/ipmitool#13

Signed-off-by: Patrick Venture <venture@google.com>
2018-11-23 16:41:06 +03:00
Patrick Venture
4ac93853a6 Add .dirstamp to .gitignore
Add the .dirstamp path to .gitignore.  .dirstamp is automatically
generated by some build systems.

Signed-off-by: Patrick Venture <venture@google.com>
2018-11-23 16:41:06 +03:00
Alexander Amelkin
a4c1040420
fru: Fix processing of unspecified board mfg. date
FRU board mfg. date uses a different value for 'unspecified'
timestamp than the general IPMI specification.

This commit makes ekanalyzer and fru commands process unspecified
FRU dates properly, displaying 'Unspecified' instead of
'Mon Jan  1 03:00:00 1996'.

Resolves ipmitool/ipmitool#57

Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
2018-11-16 22:25:27 +03:00
Vernon Mauery
576d4855d9 [compiler-warnings-fixes] use correct fall through comment
In some of the SDR calculating code, there were switch statements that
had cases that would fall through deliberately into the next case. But
the compiler didn't like the comment and would complain about the fall
through anyway. This changes to a comment that the compiler recognizes.

Partially resolves ipmitool/ipmitool#13

Signed-off-by: Vernon Mauery <vernon.mauery@intel.com>
2018-11-11 14:55:43 +03:00
Vernon Mauery
f2780c5d86 [compiler-warnings-fixes] ipmi_start_daemon: check return values
Some return values were being ignored in ipmi_start_daemon. This adds
checks to the values and changes some hard-coded numbers into named
values.

Partially resolves ipmitool/ipmitool#13

Signed-off-by: Vernon Mauery <vernon.mauery@intel.com>
2018-11-11 14:55:43 +03:00
Vernon Mauery
dc9b4ebfc9 [compiler-warnings-fixes] ipmi_sdr.c: remove unused function parameters
Several functions were passed a struct ipmi_intf* even though it was
unused. This removes the unused parameters and changes calls and
signatures.

Partially resolves ipmitool/ipmitool#13

Signed-off-by: Vernon Mauery <vernon.mauery@intel.com>
2018-11-11 14:55:43 +03:00
Alexander Amelkin
6e2b688e24
lan: Fix processing disabled VLAN
Before this fix `ipmitool` would complain that VLAN ID
is out of range when trying to disable an already disabled VLAN
on a lan channel. With this fix it will properly report that
VLAN is already disabled.

Resolves ipmitool/ipmitool#55

Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
2018-11-11 11:57:12 +03:00
Alexander Amelkin
6c3d4b56c9
Make ipmitool respect system locale settings
Dates, times and floating point numbers from now on
will be displayed using system locale settings.

Resolves ipmitoo/ipmitool#23

Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
2018-11-08 21:26:32 +03:00
Alexander Amelkin
4f05b95f6c
Fix strftime() non-literal argument warning
There is a bug in gcc since 4.3.2 and still not fixed in 8.1.0.
Even if __attribute__((format(strftime... is specified for a
wrapper function around strftime, gcc still complains about strftime
being called from the wrapper with a "non-literal" format argument.

See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=39438

This commit adds 'ugly hacks' from that discussion to call strftime()
from strftime-formatted wrappers and silence the warnings.

Partially resolves ipmitool/ipmitool#23

Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
2018-11-07 18:50:10 +03:00
Alexander Amelkin
f0d5c17ea7
Refactor timestamp handling
Handle all date/time stamps uniformly, taking in account the host
endianness. Respect the local time zone and the '-Z' option for
all ipmitool commands. Unify the date and time formatting.
Add correct handling of IPMI timestamps 'since system startup'
and for 'unspecified' timestamps.

Partially resolves ipmitool/ipmitool#23

Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
2018-11-07 18:11:58 +03:00
Alexander Amelkin
a4ac8ce4ab
doc: Update manpage with new contact info 2018-11-01 19:32:11 +03:00
Alexander Amelkin
65a2c548d8 lanplus: Refactoring
Some minor formatting corrections.
Also introduced a new helper function to reduce nesting level.

Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
2018-11-01 19:29:45 +03:00
Alexander Amelkin
1283382e82 lanplus: Fix -C option processing
Cipher suite ID is a byte as per IPMI spec.
Use the appropriate function and consider target endianness
(so write to a temporary variable).

Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
2018-11-01 19:29:45 +03:00
Vernon Mauery
7772254b62 lanplus: Auto-select 'best' cipher suite available
Based on current crypto alogrithms, one could rank cipher suites along
these lines:

17 > 3 >> all the rest

17 and 3 are the only cipher suites that implement any sort of
confidentiality alogorithm that is secure. In addition, any hmac-md5 or
md5 integrity algorithm used in integrity is weak at best and dangerous
for authentication.

This could possibly be enabled in a simpler mechanism by simply checking
for 17 and then choosing it before falling back to 3, but the way this
is implemented, it makes it easy to change the list of acceptable
algorithms from two to three or more items.

Resolves ipmitool/ipmitool#29

Signed-off-by: Vernon Mauery <vernon.mauery@intel.com>
2018-11-01 19:29:45 +03:00
Rosen Penev
a8862d7508 lanplus: Fix compile with deprecated APIs disabled.
From the man page:

EVP_CIPHER_CTX was made opaque in OpenSSL 1.1.0. As a result,
EVP_CIPHER_CTX_reset() appeared and EVP_CIPHER_CTX_cleanup() disappeared.
EVP_CIPHER_CTX_init() remains as an alias for EVP_CIPHER_CTX_reset().

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2018-10-31 16:29:19 +03:00
Alexander Amelkin
081bde8e1b
doc: Update home page links 2018-10-01 18:55:00 +03:00
Alexander Amelkin
9e05c0b120
doc: Update formatting of ipmitool man page 2018-10-01 18:54:43 +03:00
eyjhbb@gmail.com
6f336d04f1 sensor: Refactor ipmi_sensor_print_fc_threshold()
Break the function into smaller pieces to reduce
complexity.
2018-09-25 14:32:46 +03:00
eyjhbb@gmail.com
9d49a6edfe sensor: Add support for csv output 2018-09-25 14:32:46 +03:00
BenjaminFair
c70665c3d1 plugins: open: Properly enable event receiver (#35)
The ioctl to enable the event receiver in the OpenIPMI interface is
called with an argument of 0, which tells OpenIPMI to disable it. Set
the argument to 1 instead so that it will be enabled.

Signed-off-by: Benjamin Fair <benjaminfair@google.com>
2018-09-09 14:48:58 +03:00
Alexander Amelkin
2ed677c388
lan: Refactoring: Remove unused function
Function ipmi_lan_build_rsp() is never used anywhere.
Remove it.

Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
2018-08-21 18:32:35 +03:00
Alexander Amelkin
03d2b53c97
strings: Refix 329ebdff: Enlarge data type
Make val in valstr 32-bit to accomodate the values added
by commit 329ebdff.

Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
2018-08-21 18:18:07 +03:00
Alexander Amelkin
4c155320be
general: Get rid of some unused parameter warnings
Silence the unused parameter warnings in helper.c
introduced earlier.

Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
2018-08-21 18:10:28 +03:00
Alexander Amelkin
40d52b5fa1
mc: guid: Implement encoding autodetection
With this commit the GUID encoding is now by default detected
automatically based on the validity of the version field,
and the timestamp (for time-based version 1 GUIDs).

The version is considered valid if it is 1 through 5.
The timestamp is considered valid if the year is past UNIX Epoch
and before the current year.

Resolves ipmitool/ipmitool#25

Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
2018-08-21 18:10:28 +03:00