2129 Commits

Author SHA1 Message Date
Alexander Amelkin
239ef6a4ef
doc: Fix a small typo in INSTALL
Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
2020-07-06 12:55:00 +03:00
Gilles Buloz
c6a0baee84 RPM support: updated spec file changelog
Updated specfile changelog according to the Changelog file

Signed-off-by: Gilles Buloz <gilles.buloz@kontron.com>
2020-07-04 01:48:50 +03:00
Gilles Buloz
bc13db6304 RPM support: simplified build process
Simplified target "rpm" of Makefile, and removed rpmrc and rpmmacros to use
default settings and those from the spec file such as Distribution that has
been changed to "GitHub Build" instead of "Sourceforge Build".

Signed-off-by: Gilles Buloz <gilles.buloz@kontron.com>
2020-07-04 01:48:50 +03:00
Gilles Buloz
8838e4b0e2 RPM support: fixed broken RPM build
The command "make rpm" was failing for the following reasons :
- setting the build directory to ./rpmbuild/ instead of default
  ~/rpmbuild/ was ignored.
- errors in the spec file : wrong dates and characters in the
  changelog, and unpackaged files under misc/*
- debug package built even if unneeded but failing to build because
  of missing requisites.
Using "rpmbuild -tb ipmitool-*.tar.gz" instead of 'make rpm" builds
under ~/rpmbuild/ but also fails because of the last two reasons.

Signed-off-by: Gilles Buloz <gilles.buloz@kontron.com>
2020-07-04 01:48:50 +03:00
Alexander Amelkin
055719b7b9 doc: Update INSTALL with Windows info
The documentation now contains instructions on how to build on
Windows. The instructions have been verified and added to
a continous integration workflow with the previous commit,
so Windows buildability will from now on be automatically verified.

Resolves: ipmitool/ipmitool#148 (ipmitool for win with FreeIPMI)
          ipmitool/ipmitool#200 (windows build error)
          ipmitool/ipmitool#201 (windows build error)
          ipmitool/ipmitool#203 (no lanplus on windows)

Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
2020-07-04 00:26:38 +03:00
Alexander Amelkin
38b120eb5a ci: Add Windows/cygwin config
Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
2020-07-04 00:26:38 +03:00
Alexander Amelkin
01b53a013b doc: Update INSTALL for new CI
Update according to the new GitHub CI build configuration.
Add information regarding prerequisites for macOS X 10.15.

Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
2020-07-04 00:26:38 +03:00
Alexander Amelkin
0cd847579f ci: Add github workflow, drop travis
Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
2020-07-04 00:26:38 +03:00
Alexander Amelkin
2158e6ea49 Fix compatibility with OpenBSD and macOS
Neither of these systems have the `-t` option for `install`.
For Linux the option is not necessary and is only needed
if the target directory is specified before the source file(s).

Also, macOS produces strange files with -e suffix for man
pages when they are processed with sed using AC_CONFIG_FILES().
Move prefix expansion to another point in code to avoid these
unneeded intermediate files produced by configure.

Resolves: ipmitool/ipmitool#206
Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
2020-07-04 00:26:38 +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
b18619e14e
dist: Add missing ipmi_time.h header to packaging
Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
2020-06-30 15:51:31 +03:00
Alexander Amelkin
84469a9c54 configure: Fix compatibility with non-bash systems
Remove a bashims from configure to make build compatible
with systems without bash.

Resolves ipmitool/ipmitool#205

Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
2020-06-16 12:37:49 +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
Alexander Amelkin
9d5ea21df7
sel: Fix OEM record definition example
The example contained nested double quotes. Changed them to
single quotes.

Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
2020-06-05 21:12:40 +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
Alexander Amelkin
63dd71c39c configure: Drop requirement for curses et. al libs
Libraries ncurses, curses, tinfo and termcap are not actually
needed as the tgetent() function listed as required is not actually
used anywhere in the code.

Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
2019-12-05 13:45:57 +03:00
Alexander Amelkin
e60eac12cc configure: remove some duplicate code
Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
2019-12-05 13:45:57 +03:00
Alexander Amelkin
dec04e79fd
doc: Update INSTALL to fix installation errors
The `sudo` was missing from `make install` which prevented installation
if build is performed, as it should be, by an unpriviliged user.

Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
2019-11-29 14:34:20 +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
John L. Villalovos
5647cd16d2 Docs: Add info on packages to install on Ubuntu 16.04
Add some documenation on packages to install on Ubuntu 16.04 and
Fedora 31 before building the software.

This will make it easier for people who are building ipmitool as they
won't need to figure out all the package dependencies on their own.
2019-11-15 14:25:08 +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
G Dutton
4dc962b614 doc: Update man page regarding user set password
Document password length argument to "set password", as per usage info.

Since we don't check whether we're using IPMI1.5/2.0 when setting the
password, ipmitool can't reject 20-char passwords being sent to
16-char interfaces, so the behaviour is somewhat undefined.
For 20-chars, it's now clearer and long passwords will be rejected.

Man page changed to reflect the above.
2019-09-03 23:40:48 +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
G Dutton
51a2ab8180 user: Improve password length handling
No longer truncate passwords (16 < p <= 20) silently, instead attempt
to set a 20-char password when such a password is given.
Fail if an explicit length is exceeded, and any time the upper limit
is exceeded.
2019-09-03 23:40:48 +03:00
G Dutton
af062a9a5e user: Alter "set password" usage information
This changes the usage string to match reality and note that [<16|20>]
is an optional argument to set password.
2019-09-03 23:40:48 +03:00
Alexander Amelkin
1724b031b3
intf: Add missing function declarations
ipmi_intf.h was missing a couple of declarations for the functions
used by fru, sdr and hpmfwupg modules. Add those declarations
to ipmi_intf.h and remove local declarations.

This fixes a couple of compilation warnings.

Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
2019-08-29 12:26:40 +03:00
Selivanov Pavel
9006f2b26d doc: fix URL in README 2019-08-29 11:54:18 +03:00
Alexander Amelkin
b7db637984 event: Clean up event sending from a file
The ipmi_event_fromfile() function was massively repeating the code of
ipmi_send_platform_event() and ipmi_event_msg_print().

This commit cleans up ipmi_event_fromfile() to simply call
ipmi_send_platform_event() with all the prepared data read from the
file. That function in its turn calls ipmi_event_msg_print().

This commit also replaces the dummy generator ID 2 that was printed to
the user with a more relevant generator ID that will actually be sent
by ipmi_send_platform_event().

Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
2019-07-02 13:50:12 +03:00
Alexander Amelkin
82d6629a66 event: Clean up the event sending code
Get rid of magic numbers, reduce code duplication

Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
2019-07-02 13:50:12 +03:00