diff --git a/.gitignore b/.gitignore index d238bd3..ff41219 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1 @@ -SOURCES/ipmitool-1.8.15.tar.bz2 +SOURCES/ipmitool-1.8.18.tar.bz2 diff --git a/.ipmitool.metadata b/.ipmitool.metadata index 7450e7c..ddc4b7c 100644 --- a/.ipmitool.metadata +++ b/.ipmitool.metadata @@ -1 +1 @@ -2c9c5d7c5a285586df508ad933577f275684353a SOURCES/ipmitool-1.8.15.tar.bz2 +ff4781bb78f264d44fa4bf1767f268d4079d87ba SOURCES/ipmitool-1.8.18.tar.bz2 diff --git a/SOURCES/0003-ipmitool-1.8.11-ipmieved-pidfile.patch.patch b/SOURCES/0003-ipmitool-1.8.11-ipmieved-pidfile.patch.patch deleted file mode 100644 index c141eb9..0000000 --- a/SOURCES/0003-ipmitool-1.8.11-ipmieved-pidfile.patch.patch +++ /dev/null @@ -1,39 +0,0 @@ -From 88634f0a667a2a69b232f33a6f973ce443d476cc Mon Sep 17 00:00:00 2001 -From: Boris Ranto -Date: Fri, 6 Nov 2015 12:15:36 +0100 -Subject: [PATCH 03/11] ipmitool-1.8.11-ipmieved-pidfile.patch - -596809: Initscript of the ipmievd service not LSB compliant - -Don't print pidfile name to output by default. -And if verbose output is enabled, print the final pidfile name, -not the initial value. - -Backported by: jsafrane ---- - src/ipmievd.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/src/ipmievd.c b/src/ipmievd.c -index f940579..218a4b6 100644 ---- a/src/ipmievd.c -+++ b/src/ipmievd.c -@@ -703,7 +703,6 @@ ipmievd_main(struct ipmi_event_intf * eintf, int argc, char ** argv) - - memset(pidfile, 0, 64); - sprintf(pidfile, "%s%d", DEFAULT_PIDFILE, eintf->intf->devnum); -- lprintf(LOG_NOTICE, "ipmievd: using pidfile %s", pidfile); - - for (i = 0; i < argc; i++) { - if (strncasecmp(argv[i], "help", 4) == 0) { -@@ -737,6 +736,7 @@ ipmievd_main(struct ipmi_event_intf * eintf, int argc, char ** argv) - __min(strlen((const char *)(argv[i]+8)), 63)); - } - } -+ lprintf(LOG_DEBUG, "ipmievd: using pidfile %s", pidfile); - - /* - * We need to open interface before forking daemon --- -2.1.0 - diff --git a/SOURCES/0004-ipmitool-1.8.11-set-kg-key.patch.patch b/SOURCES/0004-ipmitool-1.8.11-set-kg-key.patch.patch index 506a7ff..00a396e 100644 --- a/SOURCES/0004-ipmitool-1.8.11-set-kg-key.patch.patch +++ b/SOURCES/0004-ipmitool-1.8.11-set-kg-key.patch.patch @@ -1,43 +1,7 @@ -From 2e8c763e11b8b983e229f50dec9ddf98c07ff5bb Mon Sep 17 00:00:00 2001 -From: Boris Ranto -Date: Fri, 6 Nov 2015 12:32:45 +0100 -Subject: [PATCH 04/11] ipmitool-1.8.11-set-kg-key.patch - -503039 - [RHEL5] can't set k-g key in ipmitool - -Following patch implements "Set Channel Security Keys" command. It -allows users to set K_g key. Other variants of the command, like set K_r -keys or read both K_g and K_r keys, were not implemented (it won't be -difficult though). - -Usage: -* ipmitool channel setkg plain opensesame -* ipmitool channel setkg hex 00000000001 - -Tested on Dell PowerEdge 1950. - -As consequence, I moved ipmi_parse_hex() to lib/helper.c, now it's used -by more modules. - -Sent upstream as -http://sourceforge.net/mailarchive/message.php?msg_name=20090602140420.8553.84958.stgit%40dhcp-lab-214.englab.brq.redhat.com - -Backported by: jsafrane ---- - doc/ipmitool.1 | 14 ++++++ - include/ipmitool/helper.h | 4 ++ - include/ipmitool/ipmi_channel.h | 37 +++++++++++++++ - include/ipmitool/ipmi_intf.h | 1 - - lib/helper.c | 63 +++++++++++++++++++++++++ - lib/ipmi_channel.c | 100 ++++++++++++++++++++++++++++++++++++++++ - lib/ipmi_main.c | 63 ------------------------- - 7 files changed, 218 insertions(+), 64 deletions(-) - -diff --git a/doc/ipmitool.1 b/doc/ipmitool.1 -index 2c20821..4f9c877 100644 ---- a/doc/ipmitool.1 -+++ b/doc/ipmitool.1 -@@ -371,6 +371,20 @@ Configure user access information on the given channel for the given userid. +diff -urNp old/doc/ipmitool.1 new/doc/ipmitool.1 +--- old/doc/ipmitool.1 2017-02-06 10:20:02.254362909 +0100 ++++ new/doc/ipmitool.1 2017-02-06 10:33:41.729294474 +0100 +@@ -372,6 +372,20 @@ Configure user access information on the Displays the list of cipher suites supported for the given application (ipmi or sol) on the given channel. @@ -58,10 +22,9 @@ index 2c20821..4f9c877 100644 .RE .RE .TP -diff --git a/include/ipmitool/helper.h b/include/ipmitool/helper.h -index b6ee7fa..61723f1 100644 ---- a/include/ipmitool/helper.h -+++ b/include/ipmitool/helper.h +diff -urNp old/include/ipmitool/helper.h new/include/ipmitool/helper.h +--- old/include/ipmitool/helper.h 2017-02-06 10:20:02.254362909 +0100 ++++ new/include/ipmitool/helper.h 2017-02-06 10:40:07.336136844 +0100 @@ -58,6 +58,8 @@ # define IPMI_UID_MAX 63 #endif @@ -71,33 +34,23 @@ index b6ee7fa..61723f1 100644 struct ipmi_intf; struct valstr { -@@ -101,6 +103,8 @@ FILE * ipmi_open_file(const char * file, int rw); - void ipmi_start_daemon(struct ipmi_intf *intf); - uint16_t ipmi_get_oem_id(struct ipmi_intf *intf); - -+unsigned char *ipmi_parse_hex(const char *str); -+ - #define ipmi_open_file_read(file) ipmi_open_file(file, 0) - #define ipmi_open_file_write(file) ipmi_open_file(file, 1) - -diff --git a/include/ipmitool/ipmi_channel.h b/include/ipmitool/ipmi_channel.h -index 7cbb9ad..1485fa8 100644 ---- a/include/ipmitool/ipmi_channel.h -+++ b/include/ipmitool/ipmi_channel.h -@@ -48,7 +48,10 @@ +diff -urNp old/include/ipmitool/ipmi_channel.h new/include/ipmitool/ipmi_channel.h +--- old/include/ipmitool/ipmi_channel.h 2017-02-06 10:20:02.253316684 +0100 ++++ new/include/ipmitool/ipmi_channel.h 2017-02-06 10:58:15.291287621 +0100 +@@ -49,6 +49,10 @@ #define IPMI_GET_USER_NAME 0x46 #define IPMI_SET_USER_PASSWORD 0x47 #define IPMI_GET_CHANNEL_CIPHER_SUITES 0x54 +#define IPMI_SET_CHANNEL_SECURITY_KEYS 0x56 - ++ +#define IPMI_KG_KEY_ID 1 +#define IPMI_SET_CHANNEL_SECURITY_KEYS_OP_SET 1 - /* - * The Get Authentication Capabilities response structure -@@ -249,6 +252,40 @@ struct set_user_access_data { - #pragma pack(0) - #endif + /* These are for channel_info_t.session_support */ + #define IPMI_CHANNEL_SESSION_LESS 0x00 +@@ -137,6 +141,40 @@ int _ipmi_set_channel_access(struct ipmi + struct channel_access_t channel_access, uint8_t access_option, + uint8_t privilege_option); +struct set_channel_security_keys_req { +#if WORDS_BIGENDIAN @@ -136,134 +89,64 @@ index 7cbb9ad..1485fa8 100644 uint8_t ipmi_get_channel_medium(struct ipmi_intf * intf, uint8_t channel); uint8_t ipmi_current_channel_medium(struct ipmi_intf * intf); int ipmi_channel_main(struct ipmi_intf * intf, int argc, char ** argv); -diff --git a/include/ipmitool/ipmi_intf.h b/include/ipmitool/ipmi_intf.h -index f9f6592..0fb157e 100644 ---- a/include/ipmitool/ipmi_intf.h -+++ b/include/ipmitool/ipmi_intf.h +diff -urNp old/include/ipmitool/ipmi_intf.h new/include/ipmitool/ipmi_intf.h +--- old/include/ipmitool/ipmi_intf.h 2017-02-06 10:20:02.254362909 +0100 ++++ new/include/ipmitool/ipmi_intf.h 2017-02-06 10:40:40.264577602 +0100 @@ -60,7 +60,6 @@ enum LANPLUS_SESSION_STATE { #define IPMI_AUTHCODE_BUFFER_SIZE 20 - #define IPMI_SIK_BUFFER_SIZE 20 + #define IPMI_SIK_BUFFER_SIZE IPMI_MAX_MD_SIZE -#define IPMI_KG_BUFFER_SIZE 21 /* key plus null byte */ - struct ipmi_session { - char *hostname; /* Numeric IP adress or DNS name - see RFC 1034/RFC 1035 */ -diff --git a/lib/helper.c b/lib/helper.c -index 95d641e..d934fc0 100644 ---- a/lib/helper.c -+++ b/lib/helper.c -@@ -788,3 +788,66 @@ ipmi_get_oem_id(struct ipmi_intf *intf) - - return oem_id; - } -+ -+/* ipmi_parse_hex - convert hexadecimal numbers to ascii string -+ * Input string must be composed of two-characer hexadecimal numbers. -+ * There is no separator between the numbers. Each number results in one character -+ * of the converted string. -+ * -+ * Example: ipmi_parse_hex("50415353574F5244") returns 'PASSWORD' -+ * -+ * @param str: input string. It must contain only even number of '0'-'9','a'-'f' and 'A-F' characters. -+ * @returns converted ascii string -+ * @returns NULL on error -+ */ -+unsigned char * -+ipmi_parse_hex(const char *str) -+{ -+ const char * p; -+ unsigned char * out, *q; -+ unsigned char b = 0; -+ int shift = 4; -+ -+ if (strlen(str) == 0) -+ return NULL; -+ -+ if (strlen(str) % 2 != 0) { -+ lprintf(LOG_ERR, "Number of hex_kg characters is not even"); -+ return NULL; -+ } -+ -+ if (strlen(str) > (IPMI_KG_BUFFER_SIZE-1)*2) { -+ lprintf(LOG_ERR, "Kg key is too long"); -+ return NULL; -+ } -+ -+ out = calloc(IPMI_KG_BUFFER_SIZE, sizeof(unsigned char)); -+ if (out == NULL) { -+ lprintf(LOG_ERR, "malloc failure"); -+ return NULL; -+ } -+ -+ for (p = str, q = out; *p; p++) { -+ if (!isxdigit(*p)) { -+ lprintf(LOG_ERR, "Kg_hex is not hexadecimal number"); -+ free(out); -+ out = NULL; -+ return NULL; -+ } -+ -+ if (*p < 'A') /* it must be 0-9 */ -+ b = *p - '0'; -+ else /* it's A-F or a-f */ -+ b = (*p | 0x20) - 'a' + 10; /* convert to lowercase and to 10-15 */ -+ -+ *q = *q + b << shift; -+ if (shift) -+ shift = 0; -+ else { -+ shift = 4; -+ q++; -+ } -+ } -+ -+ return out; -+} -diff --git a/lib/ipmi_channel.c b/lib/ipmi_channel.c -index 43db338..634b4d1 100644 ---- a/lib/ipmi_channel.c -+++ b/lib/ipmi_channel.c -@@ -786,6 +786,90 @@ ipmi_current_channel_medium(struct ipmi_intf * intf) - return ipmi_get_channel_medium(intf, 0xE); + struct ipmi_session_params { + char * hostname; +diff -urNp old/lib/ipmi_channel.c new/lib/ipmi_channel.c +--- old/lib/ipmi_channel.c 2017-02-06 10:20:02.255409134 +0100 ++++ new/lib/ipmi_channel.c 2017-02-06 12:32:14.222282317 +0100 +@@ -821,6 +821,92 @@ ipmi_set_user_access(struct ipmi_intf *i + return 0; } +int -+ipmi_set_channel_security_keys (struct ipmi_intf *intf, uint8_t channel, -+ const char *method, const char *key) ++ipmi_set_channel_security_keys (struct ipmi_intf *intf, uint8_t channel, const char *method, const char *key) +{ -+ unsigned char* decoded_key = NULL; ++ uint8_t kgkey[IPMI_KG_BUFFER_SIZE]; + struct ipmi_rs *rsp; + struct ipmi_rq req; + struct set_channel_security_keys_req req_data; ++ int rc = -1; + + /* convert provided key to array of bytes */ + if (strcmp(method, "hex") == 0) { + if (strlen(key) > (IPMI_KG_BUFFER_SIZE-1)*2) { -+ lprintf(LOG_ERR, "Provided key is too long, max. length is 20 bytes"); ++ lprintf(LOG_ERR, "Provided key is too long, max. length is %d bytes", (IPMI_KG_BUFFER_SIZE-1)); + printf_channel_usage(); + return -1; + } -+ decoded_key = ipmi_parse_hex(key); -+ if (decoded_key == NULL) { -+ /* something went bad, ipmi_parse_hex already reported the error */ -+ return -1; ++ ++ rc = ipmi_parse_hex(key, kgkey, sizeof(kgkey)-1); ++ if (rc == -1) { ++ lprintf(LOG_ERR, "Number of Kg key characters is not even"); ++ return rc; ++ } else if (rc == -3) { ++ lprintf(LOG_ERR, "Kg key is not hexadecimal number"); ++ return rc; ++ } else if (rc > (IPMI_KG_BUFFER_SIZE-1)) { ++ lprintf(LOG_ERR, "Kg key is too long"); ++ return rc; + } ++ + } else if (strcmp(method, "plain") == 0) { + if (strlen(key) > IPMI_KG_BUFFER_SIZE-1) { -+ lprintf(LOG_ERR, "Provided key is too long, max. length is 20 bytes"); ++ lprintf(LOG_ERR, "Provided key is too long, max. length is %d bytes", (IPMI_KG_BUFFER_SIZE -1)); + printf_channel_usage(); -+ return -1; ++ return rc; + } + -+ decoded_key = calloc(IPMI_KG_BUFFER_SIZE, sizeof(unsigned char)); -+ if (decoded_key == NULL) { -+ lprintf(LOG_ERR, "Cannot allocate memory"); -+ return -1; -+ } -+ strncpy(decoded_key, key, IPMI_KG_BUFFER_SIZE-1); ++ strncpy(kgkey, key, IPMI_KG_BUFFER_SIZE-1); + } else { + printf_channel_usage(); -+ return -1; ++ return rc; + } + + /* assemble and send request to set kg key */ @@ -271,8 +154,7 @@ index 43db338..634b4d1 100644 + req_data.channel = channel; + req_data.operation = IPMI_SET_CHANNEL_SECURITY_KEYS_OP_SET; + req_data.key_id = IPMI_KG_KEY_ID; -+ memcpy(req_data.key_value, decoded_key, IPMI_KG_BUFFER_SIZE-1); -+ free(decoded_key); ++ memcpy(req_data.key_value, kgkey, IPMI_KG_BUFFER_SIZE-1); + + memset(&req, 0, sizeof(req)); + req.msg.netfn = IPMI_NETFN_APP; @@ -283,7 +165,7 @@ index 43db338..634b4d1 100644 + rsp = intf->sendrecv(intf, &req); + if (rsp == NULL) { + lprintf(LOG_ERR, "Set Channel Security Keys command failed"); -+ return -1; ++ return rc; + } + if (rsp->ccode > 0) { + const char *error = NULL; @@ -304,30 +186,21 @@ index 43db338..634b4d1 100644 + error = val2str(rsp->ccode, completion_code_vals); + } + lprintf(LOG_ERR, "Error setting security key: %X (%s)", rsp->ccode, error); -+ return -1; ++ return rc; + } + + lprintf(LOG_NOTICE, "Set Channel Security Keys command succeeded"); + return 0; +} + - void - printf_channel_usage() + int + ipmi_channel_main(struct ipmi_intf *intf, int argc, char **argv) { -@@ -795,6 +879,7 @@ printf_channel_usage() - " [callin=on|off] [ipmi=on|off] [link=on|off] [privilege=level]"); - lprintf(LOG_NOTICE, " info [channel number]"); - lprintf(LOG_NOTICE, " getciphers [channel]\n"); -+ lprintf(LOG_NOTICE, " setkg hex|plain [channel]\n"); - lprintf(LOG_NOTICE, "Possible privilege levels are:"); - lprintf(LOG_NOTICE, " 1 Callback level"); - lprintf(LOG_NOTICE, " 2 User level"); -@@ -892,6 +977,21 @@ ipmi_channel_main(struct ipmi_intf * intf, int argc, char ** argv) - ch); - } - } -+ else if (strcmp(argv[0], "setkg") == 0) -+ { +@@ -890,6 +976,19 @@ ipmi_channel_main(struct ipmi_intf *intf + retval = ipmi_get_channel_cipher_suites(intf, + argv[1], /* ipmi | sol */ + channel); ++ } else if (strncmp(argv[0], "setkg", 5) == 0) { + if (argc < 3 || argc > 4) + printf_channel_usage(); + else { @@ -340,84 +213,28 @@ index 43db338..634b4d1 100644 + + retval = ipmi_set_channel_security_keys(intf, ch, method, key); + } -+ } - else - { - printf("Invalid CHANNEL command: %s\n", argv[0]); -diff --git a/lib/ipmi_main.c b/lib/ipmi_main.c -index 2bbbe4b..b8c9e19 100644 ---- a/lib/ipmi_main.c -+++ b/lib/ipmi_main.c -@@ -275,69 +275,6 @@ void ipmi_catch_sigint() - exit(-1); - } + } else { + lprintf(LOG_ERR, "Invalid CHANNEL command: %s\n", argv[0]); + printf_channel_usage(); +@@ -916,6 +1015,10 @@ printf_channel_usage() + lprintf(LOG_NOTICE, + ""); + lprintf(LOG_NOTICE, ++" setkg hex|plain [channel]"); ++ lprintf(LOG_NOTICE, ++""); ++ lprintf(LOG_NOTICE, + "Possible privilege levels are:"); + lprintf(LOG_NOTICE, + " 1 Callback level"); +diff -urNp old/src/plugins/ipmi_intf.c new/src/plugins/ipmi_intf.c +--- old/src/plugins/ipmi_intf.c 2017-02-06 10:20:02.257501584 +0100 ++++ new/src/plugins/ipmi_intf.c 2017-02-06 10:42:12.585257810 +0100 +@@ -55,6 +55,7 @@ + #include + #include + #include ++#include + + #define IPMI_DEFAULT_PAYLOAD_SIZE 25 --/* ipmi_parse_hex - convert hexadecimal numbers to ascii string -- * Input string must be composed of two-characer hexadecimal numbers. -- * There is no separator between the numbers. Each number results in one character -- * of the converted string. -- * -- * Example: ipmi_parse_hex("50415353574F5244") returns 'PASSWORD' -- * -- * @param str: input string. It must contain only even number of '0'-'9','a'-'f' and 'A-F' characters. -- * @returns converted ascii string -- * @returns NULL on error -- */ --static unsigned char * --ipmi_parse_hex(const char *str) --{ -- const char * p; -- unsigned char * out, *q; -- unsigned char b = 0; -- int shift = 4; -- -- if (strlen(str) == 0) -- return NULL; -- -- if (strlen(str) % 2 != 0) { -- lprintf(LOG_ERR, "Number of hex_kg characters is not even"); -- return NULL; -- } -- -- if (strlen(str) > (IPMI_KG_BUFFER_SIZE-1)*2) { -- lprintf(LOG_ERR, "Kg key is too long"); -- return NULL; -- } -- -- out = calloc(IPMI_KG_BUFFER_SIZE, sizeof(unsigned char)); -- if (out == NULL) { -- lprintf(LOG_ERR, "malloc failure"); -- return NULL; -- } -- -- for (p = str, q = out; *p; p++) { -- if (!isxdigit(*p)) { -- lprintf(LOG_ERR, "Kg_hex is not hexadecimal number"); -- free(out); -- out = NULL; -- return NULL; -- } -- -- if (*p < 'A') /* it must be 0-9 */ -- b = *p - '0'; -- else /* it's A-F or a-f */ -- b = (*p | 0x20) - 'a' + 10; /* convert to lowercase and to 10-15 */ -- -- *q = *q + b << shift; -- if (shift) -- shift = 0; -- else { -- shift = 4; -- q++; -- } -- } -- -- return out; --} -- - /* ipmi_parse_options - helper function to handle parsing command line options - * - * @argc: count of options --- -2.1.0 - diff --git a/SOURCES/0005-ipmitool-1.8.11-set-kg-key2.patch.patch b/SOURCES/0005-ipmitool-1.8.11-set-kg-key2.patch.patch deleted file mode 100644 index 027781b..0000000 --- a/SOURCES/0005-ipmitool-1.8.11-set-kg-key2.patch.patch +++ /dev/null @@ -1,67 +0,0 @@ -From d17551b4a276a4af9228b80c383d1ac5fe083f08 Mon Sep 17 00:00:00 2001 -From: Boris Ranto -Date: Fri, 6 Nov 2015 12:54:06 +0100 -Subject: [PATCH 05/11] ipmitool-1.8.11-set-kg-key2.patch - -656841: ipmitool: '-k' option does not set correct Kg key - -The delloem patch broke kgkey setting, so let's fix it here. -ipmi_intf_session_set_kgkey() now expects that the kgkey has exactly 20 -bytes. - -Backported by: jsafrane branto ---- - lib/ipmi_main.c | 11 +++++++---- - 1 file changed, 7 insertions(+), 4 deletions(-) - -diff --git a/lib/ipmi_main.c b/lib/ipmi_main.c -index b8c9e19..47064be 100644 ---- a/lib/ipmi_main.c -+++ b/lib/ipmi_main.c -@@ -459,11 +459,12 @@ ipmi_main(int argc, char ** argv, - free(kgkey); - kgkey = NULL; - } -- kgkey = strdup(optarg); -+ kgkey = calloc(IPMI_KG_BUFFER_SIZE, 1); - if (kgkey == NULL) { - lprintf(LOG_ERR, "%s: malloc failure", progname); - goto out_free; - } -+ strncpy(kgkey, optarg, IPMI_KG_BUFFER_SIZE); - break; - case 'K': - if ((tmp_env = getenv("IPMI_KGKEY"))) { -@@ -471,11 +472,12 @@ ipmi_main(int argc, char ** argv, - free(kgkey); - kgkey = NULL; - } -- kgkey = strdup(tmp_env); -+ kgkey = calloc(IPMI_KG_BUFFER_SIZE, 1); - if (kgkey == NULL) { - lprintf(LOG_ERR, "%s: malloc failure", progname); - goto out_free; - } -+ strncpy(kgkey, tmp_env, IPMI_KG_BUFFER_SIZE); - } else { - lprintf(LOG_WARN, "Unable to read kgkey from environment"); - } -@@ -501,12 +503,13 @@ ipmi_main(int argc, char ** argv, - free(kgkey); - kgkey = NULL; - } -- kgkey = strdup(tmp_pass); -- tmp_pass = NULL; -+ kgkey = calloc(IPMI_KG_BUFFER_SIZE, 1); - if (kgkey == NULL) { - lprintf(LOG_ERR, "%s: malloc failure", progname); - goto out_free; - } -+ strncpy(kgkey, tmp_pass, IPMI_KG_BUFFER_SIZE); -+ tmp_pass = NULL; - } - break; - case 'U': --- -2.1.0 - diff --git a/SOURCES/0006-ipmitool-1.8.11-sol-leak.patch.patch b/SOURCES/0006-ipmitool-1.8.11-sol-leak.patch.patch deleted file mode 100644 index 56526e1..0000000 --- a/SOURCES/0006-ipmitool-1.8.11-sol-leak.patch.patch +++ /dev/null @@ -1,38 +0,0 @@ -From b38fc30dc4433050508802a9523fcf4f9487e03b Mon Sep 17 00:00:00 2001 -From: Boris Ranto -Date: Fri, 6 Nov 2015 12:56:17 +0100 -Subject: [PATCH 06/11] ipmitool-1.8.11-sol-leak.patch - -576004 - ipmitool lanplus SOL leaks memory on every SOL ack -731977 - memory leak: 25,830 bytes in 315 blocks are definitely lost - -Following command leaks memory with some SOL packets (simply generate -some activity on the console): - -ipmitool -I lanplus -H somehost -U root -P somepasswd sol activate - -The patch below plugs the leak. - -Sent upstream as -https://sourceforge.net/mailarchive/message.php?msg_name=20100329142345.19857.22196.stgit%40dhcp-30-141.brq.redhat.com - -Backported by: jsafrane ---- - src/plugins/lanplus/lanplus.c | 1 + - 1 file changed, 1 insertion(+) - -diff --git a/src/plugins/lanplus/lanplus.c b/src/plugins/lanplus/lanplus.c -index 0bff5b2..998c1f9 100644 ---- a/src/plugins/lanplus/lanplus.c -+++ b/src/plugins/lanplus/lanplus.c -@@ -2348,6 +2348,7 @@ ipmi_lanplus_send_payload( - case IPMI_PAYLOAD_TYPE_RMCP_OPEN_REQUEST: - case IPMI_PAYLOAD_TYPE_RAKP_1: - case IPMI_PAYLOAD_TYPE_RAKP_3: -+ case IPMI_PAYLOAD_TYPE_SOL: - free(msg_data); - msg_data = NULL; - break; --- -2.1.0 - diff --git a/SOURCES/0008-ipmitool-1.8.11-no-work-setaccess.patch.patch b/SOURCES/0008-ipmitool-1.8.11-no-work-setaccess.patch.patch deleted file mode 100644 index ee3a35f..0000000 --- a/SOURCES/0008-ipmitool-1.8.11-no-work-setaccess.patch.patch +++ /dev/null @@ -1,32 +0,0 @@ -From 3cdba40988549d38647e0650ceb18a18a05ca04f Mon Sep 17 00:00:00 2001 -From: Boris Ranto -Date: Fri, 6 Nov 2015 13:00:45 +0100 -Subject: [PATCH 08/11] ipmitool-1.8.11-no-work-setaccess.patch - -RESOLVES: #903251 - link=on and ipmi=on no longer work for setaccess - -Backported by: phracek ---- - lib/ipmi_channel.c | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -diff --git a/lib/ipmi_channel.c b/lib/ipmi_channel.c -index 634b4d1..fa68e35 100644 ---- a/lib/ipmi_channel.c -+++ b/lib/ipmi_channel.c -@@ -500,10 +500,10 @@ ipmi_set_user_access(struct ipmi_intf * intf, int argc, char ** argv) - set_access.callin_callback = !(strncmp (argv[i]+7, "off", 3)); - } - else if (strncmp(argv[i], "link=", 5) == 0) { -- set_access.link_auth = strncmp (argv[i]+5, "off", 3); -+ set_access.link_auth = (strncmp (argv[i]+5, "off", 3) != 0); - } - else if (strncmp(argv[i], "ipmi=", 5) == 0) { -- set_access.ipmi_messaging = strncmp (argv[i]+5, "off", 3); -+ set_access.ipmi_messaging = (strncmp (argv[i]+5, "off", 3) != 0); - } - else if (strncmp(argv[i], "privilege=", 10) == 0) { - if (str2uchar(argv[i]+10, &privilege_limit) != 0) { --- -2.1.0 - diff --git a/SOURCES/0009-ipmitool-1.8.11-bz1126333-slowswid.patch.patch b/SOURCES/0009-ipmitool-1.8.11-bz1126333-slowswid.patch.patch index fe99d9a..7b3d920 100644 --- a/SOURCES/0009-ipmitool-1.8.11-bz1126333-slowswid.patch.patch +++ b/SOURCES/0009-ipmitool-1.8.11-bz1126333-slowswid.patch.patch @@ -18,7 +18,7 @@ index fa7b082..9bc5ac2 100644 uint32_t save_addr; uint32_t save_channel; -+ if ((strncmp(intf->name, "ipmb", 4)) != 0) ++ if (target == (uint8_t) 0xb1) + return ipmi_sdr_get_sensor_reading(intf, sensor); if ( BRIDGE_TO_SENSOR(intf, target, channel) ) { lprintf(LOG_DEBUG, diff --git a/SOURCES/0011-ipmitool-1.8.13-bmc-snmp.patch.patch b/SOURCES/0011-ipmitool-1.8.13-bmc-snmp.patch.patch deleted file mode 100644 index 5bf4b50..0000000 --- a/SOURCES/0011-ipmitool-1.8.13-bmc-snmp.patch.patch +++ /dev/null @@ -1,362 +0,0 @@ -From 24522dfdfc97df38da50765c1131df80194b2050 Mon Sep 17 00:00:00 2001 -From: Boris Ranto -Date: Fri, 11 Dec 2015 16:27:31 +0100 -Subject: [PATCH 11/11] ipmitool-1.8.13-bmc-snmp.patch - -Incorporate upstream comments to #289, add whitespace, other -cleanup. - -Backported by: aledvink ---- - contrib/bmc-snmp-proxy | 130 +++++++++++++++++++++++++++++-------------------- - 1 file changed, 76 insertions(+), 54 deletions(-) - -diff --git a/contrib/bmc-snmp-proxy b/contrib/bmc-snmp-proxy -index 1704ef3..98479b9 100644 ---- a/contrib/bmc-snmp-proxy -+++ b/contrib/bmc-snmp-proxy -@@ -3,7 +3,7 @@ - # - # bmc-snmp-proxy: Set SNMP proxy to BMC (Baseboard Management Controller) - # --# version: 0.6 -+# version: 0.62 - # - # Authors: Charles Rose - # Jordan Hargrave -@@ -20,9 +20,9 @@ - SYSCONF_DIR="/etc/sysconfig" - CONFIG="${SYSCONF_DIR}/bmc-snmp-proxy" - --SNMPD_LOCAL_CONF_DIR="/etc/snmp/bmc" --SNMPD_LOCAL_CONF="${SNMPD_LOCAL_CONF_DIR}/snmpd.local.conf" --TRAPD_LOCAL_CONF="${SNMPD_LOCAL_CONF_DIR}/snmptrapd.local.conf" -+SNMPD_BMC_CONF_DIR="/etc/snmp/bmc" -+SNMPD_BMC_CONF="${SNMPD_BMC_CONF_DIR}/snmpd.local.conf" -+TRAPD_BMC_CONF="${SNMPD_BMC_CONF_DIR}/snmptrapd.local.conf" - - TRAPD_CONF="/etc/snmp/snmptrapd.conf" - -@@ -57,14 +57,16 @@ bmc_info_exists() - else - RETVAL=2 - fi -+ - return $RETVAL - } - - check_snmp() - { -- if [ ! -d /etc/snmp ] && [ ! -x /usr/sbin/snmpd ]; then -+ if [ ! -d /etc/snmp ] || [ ! -x /usr/sbin/snmpd ]; then - RETVAL=12 - fi -+ - return $RETVAL - } - -@@ -77,11 +79,12 @@ write_snmp_conf() - printf "###############################################\n" - printf "# Automatically created by %s #\n" "${SCRIPT_NAME}" - printf "###############################################\n" -- printf "view bmcview included %s 80\n" "${BMC_OID}" -- printf "com2sec -Cn bmc_ctx bmc_sec default bmc_cmty\n" -- printf "group bmc_grp v1 bmc_sec\n" -- printf "access bmc_grp bmc_ctx any noauth exact bmcview none none\n" -- printf "proxy -Cn bmc_ctx -v 1 %s\n" "${PROXY_TOKEN}" -+ printf "#view bmcview included %s 80\n" "${BMC_OID}" -+ printf "#com2sec -Cn bmc_ctx bmc_sec default bmc_cmty\n" -+ printf "#group bmc_grp v1 bmc_sec\n" -+ printf "#access bmc_grp bmc_ctx any noauth exact bmcview none none\n" -+ printf "#proxy -Cn bmc_ctx -v 1 %s\n" "${PROXY_TOKEN}" -+ printf "proxy -v 1 %s\n" "${PROXY_TOKEN}" - printf "###############################################\n" - } - -@@ -92,6 +95,7 @@ valid_ip() - - printf -- "%s" "${1}"| grep -Eq \ - "^${octet}\\.${octet}\\.${octet}\\.${octet}$" -+ - return $? - } - -@@ -112,37 +116,38 @@ set_snmp_proxy() - if check_vars; then - PROXY_TOKEN="-c ${BMC_COMMUNITY} ${BMC_IPv4} ${BMC_OID}" - -- if [ ! -d ${SNMPD_LOCAL_CONF_DIR} ] && \ -- mkdir ${SNMPD_LOCAL_CONF_DIR}; then -- write_snmp_conf > ${SNMPD_LOCAL_CONF} -- [ $? -ne 0 ] && RETVAL=4 -+ if [ -d ${SNMPD_BMC_CONF_DIR} ]; then -+ write_snmp_conf > ${SNMPD_BMC_CONF} || RETVAL=4 - fi - else - RETVAL=3 - fi - } - -- - set_snmpd_conf_path() - { -- for SYSCONF in ${SYSCONF_DIR}/snmp*d; -+ if [ ! -d ${SNMPD_BMC_CONF_DIR} ]; then -+ mkdir ${SNMPD_BMC_CONF_DIR} || RETVAL=7 -+ fi -+ -+ # We need SNMPCONFPATH set for both snmpd and snmptrapd -+ for sysconf in ${SYSCONF_DIR}/snmp*d; - do -- if grep -q "${SNMPD_LOCAL_CONF_DIR}" "${SYSCONF}" > \ -- /dev/null 2>&1; then -- continue -- else -- printf "SNMPCONFPATH=%s\n" "${SNMPD_LOCAL_CONF_DIR}" \ -- >> ${SYSCONF} || RETVAL=7 -+ if ! grep -q "^SNMPCONFPATH.*${SNMPD_BMC_CONF_DIR}" \ -+ "${sysconf}" > /dev/null 2>&1; then -+ printf "SNMPCONFPATH=/etc/snmp:%s\n" \ -+ "${SNMPD_BMC_CONF_DIR}" >> ${sysconf} || \ -+ RETVAL=7 - fi - done -+ - return $RETVAL - } - - disable_snmp_proxy() - { -- if [ -f ${SNMPD_LOCAL_CONF} ]; then -- rm -f ${SNMPD_LOCAL_CONF} -- [ $? -ne 0 ] && RETVAL=5 -+ if [ -f ${SNMPD_BMC_CONF} ]; then -+ rm -f ${SNMPD_BMC_CONF} || RETVAL=5 - fi - } - ############################################################################# -@@ -152,6 +157,7 @@ disable_snmp_proxy() - pick_alert_dest() - { - test_ip="$1" -+ # We have 4 IPv4 and 4 IPv6 alert dest. We will set IPv4 for now. - for ALERT_DEST in `seq 1 4` - do - temp_ip=$(${IPMITOOL} lan alert print ${CHANNEL} ${ALERT_DEST}\ -@@ -165,12 +171,12 @@ pick_alert_dest() - set_alert_dest_ip() - { - ${IPMITOOL} lan alert set ${CHANNEL} ${ALERT_DEST} ipaddr ${1} \ -- retry 4 type pet >/dev/null 2>&1 -- [ $? -ne 0 ] && RETVAL=8 -+ retry 4 type pet >/dev/null 2>&1 || RETVAL=8 - } - --bmc_alert_dest() -+config_bmc_alert_dest() - { -+ # call with enable|disable - # Pick the first active LAN channel - for CHANNEL in `seq 1 14` - do -@@ -180,12 +186,12 @@ bmc_alert_dest() - - # If TRAPD_IP is already set as an alert dest, - if pick_alert_dest "${TRAPD_IP}"; then -- # reset: reset it if we are called with reset -- [ "${1}" = "reset" ] && \ -+ # disable: reset it if we are called with disable -+ [ "${1}" = "disable" ] && \ - set_alert_dest_ip "0.0.0.0" - # else, find the next free alert dest, - elif pick_alert_dest "0.0.0.0"; then -- [ "${1}" = "reset" ] && \ -+ [ "${1}" = "disable" ] && \ - return $RETVAL - # set: the TRAPD_IP - set_alert_dest_ip "${TRAPD_IP}" -@@ -193,42 +199,54 @@ bmc_alert_dest() - # No free alert destinations - RETVAL=9 - fi -+ - return $RETVAL - } - --set_ipmi_alert() -+set_ipmi_pef() - { -- ${IPMITOOL} lan set ${CHANNEL} alert "${1}" >/dev/null 2>&1 -- [ $? -ne 0 ] && RETVAL=10 -+ # Needs ipmitool-1.8.13 + patches -+ ${IPMITOOL} pef setpolicy ${ALERT_DEST} "${1}" >/dev/null 2>&1 || \ -+ RETVAL=10 - } - - get_host_ip() - { -- # Get host's IP that the BMC can reach. -+ # Get host's IP that the BMC can reach. This is at best a hack. - IFACE=$(/usr/sbin/ip -o -f inet address |awk '!/: lo/ {print $2}') -+ - for dev in ${IFACE} - do -- ping -c 1 -I ${dev} ${BMC_IPv4} > /dev/null 2>&1 -+ temp_ping=$(ping -c 1 -I ${dev} ${BMC_IPv4}) -+ [ $? -ne 0 ] && continue -+ -+ printf -- "%s" "$temp_ping"| awk 'NR==1{print $5}' && break - done - } - - config_bmc_alert() - { -+ # Do two things -+ # Set/Reset TRAP IP in BMC -+ # Enable/Disable PEF alerting in BMC for TRAP -+ - # Get Host's IP that the BMC can send traps to - TRAPD_IP=$(get_host_ip) - - # Set Host's IP as the alert destination in the BMC -- valid_ip ${TRAPD_IP} && bmc_alert_dest "${ACTION}" -+ valid_ip ${TRAPD_IP} && config_bmc_alert_dest "${ACTION}" -+ -+ # Enable/Disable alerting on the LAN channel -+ [ $RETVAL -eq 0 ] && set_ipmi_pef "${ACTION}" - -- # Enable alerting on the LAN channel -- [ $RETVAL -eq 0 ] && set_ipmi_alert "${ACTION}" -+ return $RETVAL - } - - write_trapd_conf() - { - printf "###############################################\n" - printf "# Automatically created by %s #\n" "${SCRIPT_NAME}" -- printf "forward %s %s\n" "${BMC_OID}*" "${FORWARD_HOST}" -+ printf "forward default %s\n" "${FORWARD_HOST}" - printf "###############################################\n" - } - -@@ -236,10 +254,9 @@ config_trapd() - { - # Proceed only if snmptrapd is available on the system - if [ -f ${TRAPD_CONF} ]; then -- write_trapd_conf > ${TRAPD_LOCAL_CONF} -- [ $? -ne 0 ] && RETVAL=11 -+ write_trapd_conf > ${TRAPD_BMC_CONF} || RETVAL=11 - else -- return 1 -+ RETVAL=11 - fi - } - -@@ -249,6 +266,7 @@ trap_sink_exists() - # multiple - FORWARD_HOST=$(awk '/^trap.*sink/{print $2}; /^informsink/{print $2}' \ - /etc/snmp/snmpd*conf | head -1) -+ - if [ -z "${FORWARD_HOST}" ]; then - # there is no trapsink setup. - return 1 -@@ -261,19 +279,20 @@ trap_sink_exists() - trap_forward() - { - NO_TRAP=0 -- ACTION=${1} # set or reset -+ ACTION=${1} # enable or disable - -- if [ "${ACTION}" = "set" ]; then -+ if [ "${ACTION}" = "enable" ]; then - # Get trapd config, - if trap_sink_exists; then -- config_trapd && config_bmc_alert -+ config_bmc_alert && config_trapd - else - # exit silently if there is no sink - NO_TRAP=1 - fi - else -- if [ -f ${TRAPD_LOCAL_CONF} ]; then -- rm -f ${TRAPD_LOCAL_CONF} >/dev/null 2>&1 -+ if [ -f ${TRAPD_BMC_CONF} ]; then -+ rm -f ${TRAPD_BMC_CONF} >/dev/null 2>&1 -+ config_bmc_alert - else - NO_TRAP=1 - fi -@@ -288,7 +307,6 @@ service_reload() - service $1 reload - [ $? -ne 0 ] && RETVAL=6 - fi -- return - } - - ############################################################################# -@@ -296,11 +314,12 @@ start() - { - if bmc_info_exists && check_snmp; then - touch ${LOCKFILE} -+ - set_snmpd_conf_path && set_snmp_proxy - [ $RETVAL -eq 0 ] && service_reload snmpd - - if [ "${TRAP_FORWARD}" = "yes" ]; then -- trap_forward "set" -+ trap_forward "enable" - [ $RETVAL -eq 0 ] && [ $NO_TRAP -eq 0 ] && \ - service_reload snmptrapd - fi -@@ -316,10 +335,11 @@ stop() - [ $RETVAL -eq 0 ] && service_reload snmpd - - if [ "${TRAP_FORWARD}" = "yes" ]; then -- trap_forward "reset" -+ trap_forward "disable" - [ $RETVAL -eq 0 ] && [ $NO_TRAP -eq 0 ] && \ - service_reload snmptrapd - fi -+ - rm -f ${LOCKFILE} - fi - } -@@ -329,12 +349,13 @@ status() - { - eval_gettext "${SCRIPT_NAME}: snmp proxy to BMC is " - # Checking for lockfile is better. -- #if grep -q "^proxy" "${SNMPD_LOCAL_CONF}" > /dev/null 2>&1 ; then -+ #if grep -q "^proxy" "${SNMPD_BMC_CONF}" > /dev/null 2>&1 ; then - if [ -f ${LOCKFILE} ]; then - eval_gettext "set" - else - eval_gettext "not set" - fi -+ - echo - RETVAL=0 - } -@@ -360,10 +381,10 @@ case "$RETVAL" in - 0|1) ;; - 2) eval_gettext "${SCRIPT_NAME}: failed to read ${BMC_INFO} " 1>&2 ;; - 3) eval_gettext "${SCRIPT_NAME}: failed to get proxy config." 1>&2 ;; -- 4) eval_gettext "${SCRIPT_NAME}: failed to set ${SNMPD_LOCAL_CONF}." 1>&2 ;; -+ 4) eval_gettext "${SCRIPT_NAME}: failed to set ${SNMPD_BMC_CONF}." 1>&2 ;; - 5) eval_gettext "${SCRIPT_NAME}: failed to disable snmp proxy." 1>&2 ;; - 6) eval_gettext "${SCRIPT_NAME}: failed to reload snmpd." 1>&2 ;; -- 7) eval_gettext "${SCRIPT_NAME}: failed to update ${SYSCONF}." 1>&2 ;; -+ 7) eval_gettext "${SCRIPT_NAME}: failed to set snmpd config." 1>&2 ;; - 8) eval_gettext "${SCRIPT_NAME}: failed to set IPMI alert dest." 1>&2 ;; - 9) eval_gettext "${SCRIPT_NAME}: no free IPMI alert dest." 1>&2 ;; - 10) eval_gettext "${SCRIPT_NAME}: failed to set IPMI PEF." 1>&2 ;; -@@ -375,6 +396,7 @@ esac - if [ ${RETVAL} -gt 1 ]; then - eval_gettext " Return code: ${RETVAL}"; echo - fi -+ - exit ${RETVAL} - ############################################################################# - # end of file --- -2.1.0 - diff --git a/SOURCES/0012-Avoid-assert-on-mismatched-session-ID.patch b/SOURCES/0012-Avoid-assert-on-mismatched-session-ID.patch deleted file mode 100644 index f7b29f6..0000000 --- a/SOURCES/0012-Avoid-assert-on-mismatched-session-ID.patch +++ /dev/null @@ -1,64 +0,0 @@ -From 8460e0d8fa27ba073e6d85e0ab683586b2e3e007 Mon Sep 17 00:00:00 2001 -From: Boris Ranto -Date: Thu, 18 Feb 2016 16:10:42 +0100 -Subject: [PATCH] Avoid assert on mismatched session ID - -Move the logic that checks the session ID from read_session_data_v2x -function to the ipmi_lan_poll_single function in order to avoid calling -assert in this case. We can continue with the next packet if we detect -a session ID mismatch. - -Signed-off-by: Boris Ranto ---- - src/plugins/lanplus/lanplus.c | 28 +++++++++++++++------------- - 1 file changed, 15 insertions(+), 13 deletions(-) - -diff --git a/src/plugins/lanplus/lanplus.c b/src/plugins/lanplus/lanplus.c -index 998c1f9..7433337 100644 ---- a/src/plugins/lanplus/lanplus.c -+++ b/src/plugins/lanplus/lanplus.c -@@ -664,6 +664,21 @@ ipmi_lan_poll_recv(struct ipmi_intf * intf) - - read_session_data(rsp, &offset, intf->session); - -+ /* -+ * Skip packets that are not intended for this session -+ */ -+ if ((session->v2_data.session_state == LANPLUS_STATE_ACTIVE) && -+ (rsp->session.authtype == IPMI_SESSION_AUTHTYPE_RMCP_PLUS) && -+ (rsp->session.id != intf->session->v2_data.console_id)) -+ { -+ lprintf(LOG_INFO, "packet session id 0x%x does not " -+ "match active session 0x%0x", -+ rsp->session.id, intf->session->v2_data.console_id); -+ lprintf(LOG_ERR, "ERROR: Received an Unexpected message ID"); -+ /* read one more packet */ -+ continue; -+ } -+ - if (lanplus_has_valid_auth_code(rsp, intf->session) == 0) - { - lprintf(LOG_ERR, "ERROR: Received message with invalid authcode!"); -@@ -1172,19 +1187,6 @@ read_session_data_v2x( - #endif - - -- /* -- * Verify that the session ID is what we think it should be -- */ -- if ((s->v2_data.session_state == LANPLUS_STATE_ACTIVE) && -- (rsp->session.id != s->v2_data.console_id)) -- { -- lprintf(LOG_ERR, "packet session id 0x%x does not " -- "match active session 0x%0x", -- rsp->session.id, s->v2_data.console_id); -- assert(0); -- } -- -- - /* Ignored, so far */ - memcpy(&rsp->session.seq, rsp->data + *offset, 4); - *offset += 4; --- -2.5.0 - diff --git a/SOURCES/0013-ID-405-Use-meaningful-Generator-ID-for-ipmitool-sel-.patch b/SOURCES/0013-ID-405-Use-meaningful-Generator-ID-for-ipmitool-sel-.patch deleted file mode 100644 index 98eef9f..0000000 --- a/SOURCES/0013-ID-405-Use-meaningful-Generator-ID-for-ipmitool-sel-.patch +++ /dev/null @@ -1,50 +0,0 @@ -From ef47a601eac2d17705a67007c89e2701fe00e3ba Mon Sep 17 00:00:00 2001 -From: Martin Wilck -Date: Tue, 8 Dec 2015 11:47:04 +0100 -Subject: [PATCH] ID:405 - Use meaningful Generator ID for "ipmitool sel add" -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -"ipmitool sel add" always sets the Generator ID field of the generated SEL entry -to 0x0000. - -Looking at the IPMI spec v2, §13.2, this is questionable. The value 0 would be -read as a HW-generated event from IPMB with slave address 0, which is the -broadcast or ["general call"]http://www.i2c-bus.org/addressing/ address. - -The spec says that the Generator ID should be "Software ID if event was -generated from system software", and goes on to say that bit 0 should be set to -1 and bit 1-7 should be set to the Software ID for software-generated events. -SEL entries generated by ipmitool will usually be software-generated. - -Out of the SWIDs defined in §5.5 of the IPMI spec, "System management Software" -or "OEM" would match ipmitool's use best, thus it would make sense to set the -generator ID field to 0x0041 or 0x0061. I am using 0x0041 here. - -Signed-off-by: Martin Wilck ---- - lib/ipmi_sel.c | 7 ++++++- - 1 file changed, 6 insertions(+), 1 deletion(-) - -diff --git a/lib/ipmi_sel.c b/lib/ipmi_sel.c -index 67e12e3..affaed8 100644 ---- a/lib/ipmi_sel.c -+++ b/lib/ipmi_sel.c -@@ -412,7 +412,12 @@ ipmi_sel_add_entries_fromfile(struct ipmi_intf * intf, const char * filename) - memset(&sel_event, 0, sizeof(struct sel_event_record)); - sel_event.record_id = 0x0000; - sel_event.record_type = 0x02; -- sel_event.sel_type.standard_type.gen_id = 0x00; -+ /* -+ * IPMI spec §32.1 generator ID -+ * Bit 0 = 1 "Software defined" -+ * Bit 1-7: SWID (IPMI spec §5.5), using 2 = "System management software" -+ */ -+ sel_event.sel_type.standard_type.gen_id = 0x41; - sel_event.sel_type.standard_type.evm_rev = rqdata[0]; - sel_event.sel_type.standard_type.sensor_type = rqdata[1]; - sel_event.sel_type.standard_type.sensor_num = rqdata[2]; --- -2.5.0 - diff --git a/SOURCES/0014-ID-382-Fix-memcpy-params-in-HpmFwupgActionUploadFirm.patch b/SOURCES/0014-ID-382-Fix-memcpy-params-in-HpmFwupgActionUploadFirm.patch deleted file mode 100644 index f889297..0000000 --- a/SOURCES/0014-ID-382-Fix-memcpy-params-in-HpmFwupgActionUploadFirm.patch +++ /dev/null @@ -1,33 +0,0 @@ -From 7ebd9dc644b1c2980705e97775aabf6e1729dd59 Mon Sep 17 00:00:00 2001 -From: Zdenek Styblik -Date: Mon, 27 Jul 2015 06:37:37 +0200 -Subject: [PATCH 14/16] ID:382 - Fix memcpy() params in - HpmFwupgActionUploadFirmware() - -The 'bufLength' variable holds a constant chunk size. If the actual -data length is less than the 'bufLength', then it crashes IPMITool. The -code was already there to calculate the remaining data length, but was -not used in memcpy(). We changed it to use the 'count' variable which -holds the proper available data length. - -Commit for: Viswanathan Swaminathan ---- - lib/ipmi_hpmfwupg.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/lib/ipmi_hpmfwupg.c b/lib/ipmi_hpmfwupg.c -index fbb5a62..eccbae2 100644 ---- a/lib/ipmi_hpmfwupg.c -+++ b/lib/ipmi_hpmfwupg.c -@@ -1200,7 +1200,7 @@ HpmFwupgActionUploadFirmware(struct HpmfwupgComponentBitMask components, - } else { - count = (unsigned short)((pDataTemp+lengthOfBlock) - pData); - } -- memcpy(&uploadCmd.req->data, pData, bufLength); -+ memcpy(&uploadCmd.req->data, pData, count); - imageOffset = 0x00; - blockLength = 0x00; - numTxPkts++; --- -2.5.0 - diff --git a/SOURCES/0015-ID-390-Support-for-new-Communication-Interface-USB-M.patch b/SOURCES/0015-ID-390-Support-for-new-Communication-Interface-USB-M.patch index dafc75d..d3bfba5 100644 --- a/SOURCES/0015-ID-390-Support-for-new-Communication-Interface-USB-M.patch +++ b/SOURCES/0015-ID-390-Support-for-new-Communication-Interface-USB-M.patch @@ -1,785 +1,21 @@ -From ec8650bb6261927ac069f8cf645e7d02c3f2ba4e Mon Sep 17 00:00:00 2001 -From: Zdenek Styblik -Date: Fri, 11 Sep 2015 19:01:31 +0200 -Subject: [PATCH 15/16] ID:390 - Support for new Communication Interface (USB - Medium) - -This feature request is for adding support for USB Medium as an interface in -IPMITool. AMI BMC (OEM feature) provides Virtual USB devices in the host as -part of its feature list. IPMITool can use this 'Virtual USB device' as a -medium for Inband communication with BMC. - -Just like any other interface, use can just give 'ipmitool -I usb xxxx' to -communicate with the BMC via USB Interface. ---- - configure.ac | 19 ++ - src/plugins/Makefile.am | 4 +- - src/plugins/ipmi_intf.c | 6 + - src/plugins/usb/Makefile.am | 40 +++ - src/plugins/usb/usb.c | 617 ++++++++++++++++++++++++++++++++++++++++++++ - 5 files changed, 684 insertions(+), 2 deletions(-) - create mode 100644 src/plugins/usb/Makefile.am - create mode 100644 src/plugins/usb/usb.c - -diff --git a/configure.ac b/configure.ac -index 4c07d47..def7bf3 100644 ---- a/configure.ac -+++ b/configure.ac -@@ -60,6 +60,7 @@ dnl - xenable_intf_bmc=no - xenable_intf_imb=yes - xenable_intf_open=yes -+xenable_intf_usb=yes +diff -urNp old/configure.ac new/configure.ac +--- old/configure.ac 2017-02-02 14:20:33.230784269 +0100 ++++ new/configure.ac 2017-02-02 14:22:53.528510336 +0100 +@@ -63,7 +63,7 @@ xenable_intf_imb=yes xenable_intf_lipmi=yes + xenable_intf_open=yes #xenable_intf_serial=yes - xenable_intf_dummy=no -@@ -180,6 +181,22 @@ if test "x$xenable_intf_lan" = "xyes"; then - IPMITOOL_INTF_LIB="$IPMITOOL_INTF_LIB lan/libintf_lan.la" - fi +-xenable_intf_usb=no ++xenable_intf_usb=yes + xenable_ipmishell=yes -+dnl enable IPMI USB interface -+AC_ARG_ENABLE([intf-usb], -+ [AC_HELP_STRING([--enable-intf-usb], + dnl set some things so we build with GNU tools on Solaris +@@ -209,7 +209,7 @@ fi + dnl enable IPMI USB interface + AC_ARG_ENABLE([intf-usb], + [AC_HELP_STRING([--enable-intf-usb], +- [enable IPMI USB interface [default=auto]])], + [enable IPMI USB interface [default=yes]])], -+ [xenable_intf_usb=$enableval], -+ [xenable_intf_usb=yes]) -+if test "x$xenable_intf_usb" = "xstatic" || test "x$xenable_intf_usb" = "xplugin"; then -+ xenable_intf_usb=yes -+fi -+if test "x$xenable_intf_usb" = "xyes"; then -+ AC_DEFINE(IPMI_INTF_USB, [1], [Define to 1 to enable USB interface.]) -+ AC_SUBST(INTF_USB, [usb]) -+ AC_SUBST(INTF_USB_LIB, [libintf_usb.la]) -+ IPMITOOL_INTF_LIB="$IPMITOOL_INTF_LIB usb/libintf_usb.la" -+fi -+ - dnl enable IPMIv2.0 RMCP+ LAN interface - AC_ARG_ENABLE([intf-lanplus], - [AC_HELP_STRING([--enable-intf-lanplus], -@@ -621,6 +638,7 @@ AC_CONFIG_FILES([Makefile - src/plugins/free/Makefile - src/plugins/imb/Makefile - src/plugins/bmc/Makefile -+ src/plugins/usb/Makefile - src/plugins/lipmi/Makefile - src/plugins/serial/Makefile - src/plugins/dummy/Makefile]) -@@ -637,6 +655,7 @@ AC_MSG_RESULT([ open : $xenable_intf_open]) - AC_MSG_RESULT([ free : $xenable_intf_free]) - AC_MSG_RESULT([ imb : $xenable_intf_imb]) - AC_MSG_RESULT([ bmc : $xenable_intf_bmc]) -+AC_MSG_RESULT([ usb : $xenable_intf_usb]) - AC_MSG_RESULT([ lipmi : $xenable_intf_lipmi]) - AC_MSG_RESULT([ serial : $xenable_intf_serial]) - AC_MSG_RESULT([ dummy : $xenable_intf_dummy]) -diff --git a/src/plugins/Makefile.am b/src/plugins/Makefile.am -index 19b5f11..a2c48ff 100644 ---- a/src/plugins/Makefile.am -+++ b/src/plugins/Makefile.am -@@ -32,8 +32,8 @@ MAINTAINERCLEANFILES = Makefile.in - - INCLUDES = -I$(top_srcdir)/include - --SUBDIRS = @INTF_LAN@ @INTF_LANPLUS@ @INTF_OPEN@ @INTF_LIPMI@ @INTF_IMB@ @INTF_BMC@ @INTF_FREE@ @INTF_SERIAL@ @INTF_DUMMY@ --DIST_SUBDIRS = lan lanplus open lipmi imb bmc free serial dummy -+SUBDIRS = @INTF_LAN@ @INTF_LANPLUS@ @INTF_OPEN@ @INTF_LIPMI@ @INTF_IMB@ @INTF_BMC@ @INTF_FREE@ @INTF_SERIAL@ @INTF_DUMMY@ @INTF_USB@ -+DIST_SUBDIRS = lan lanplus open lipmi imb bmc free serial dummy usb - - noinst_LTLIBRARIES = libintf.la - libintf_la_SOURCES = ipmi_intf.c -diff --git a/src/plugins/ipmi_intf.c b/src/plugins/ipmi_intf.c -index a84237e..b0d938a 100644 ---- a/src/plugins/ipmi_intf.c -+++ b/src/plugins/ipmi_intf.c -@@ -83,6 +83,9 @@ extern struct ipmi_intf ipmi_serial_bm_intf; - #ifdef IPMI_INTF_DUMMY - extern struct ipmi_intf ipmi_dummy_intf; - #endif -+#ifdef IPMI_INTF_USB -+extern struct ipmi_intf ipmi_usb_intf; -+#endif - - struct ipmi_intf * ipmi_intf_table[] = { - #ifdef IPMI_INTF_OPEN -@@ -113,6 +116,9 @@ struct ipmi_intf * ipmi_intf_table[] = { - #ifdef IPMI_INTF_DUMMY - &ipmi_dummy_intf, - #endif -+#ifdef IPMI_INTF_USB -+ &ipmi_usb_intf, -+#endif - NULL - }; - -diff --git a/src/plugins/usb/Makefile.am b/src/plugins/usb/Makefile.am -new file mode 100644 -index 0000000..2a431f7 ---- /dev/null -+++ b/src/plugins/usb/Makefile.am -@@ -0,0 +1,40 @@ -+ # -+ # Copyright (c) 2015 American Megatrends, Inc. -+ # All rights reserved. -+ # -+ # Redistribution and use in source and binary forms, with or without -+ # modification,are permitted provided that the following conditions are met: -+ # -+ # 1. Redistributions of source code must retain the above copyright notice, -+ # this list of conditions and the following disclaimer. -+ # -+ # 2. Redistributions in binary form must reproduce the above copyright notice, -+ # this list of conditions and the following disclaimer in the documentation -+ # and/or other materials provided with the distribution. -+ # -+ # 3. Neither the name of the copyright holder nor the names of its contributors -+ # may be used to endorse or promote products derived from this software -+ # without specific prior written permission. -+ # -+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -+ # AND ANY EXPRESS OR IMPLIED WARRANTIES,INCLUDING, BUT NOT LIMITED TO, THE -+ # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -+ # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE -+ # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -+ # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -+ # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -+ # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -+ # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -+ # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -+ # POSSIBILITY OF SUCH DAMAGE. -+ # -+ -+MAINTAINERCLEANFILES = Makefile.in -+ -+INCLUDES = -I$(top_srcdir)/include -+ -+EXTRA_LTLIBRARIES = libintf_usb.la -+noinst_LTLIBRARIES = @INTF_USB_LIB@ -+libintf_usb_la_LIBADD = $(top_builddir)/lib/libipmitool.la -+libintf_usb_la_SOURCES = usb.c -+ -diff --git a/src/plugins/usb/usb.c b/src/plugins/usb/usb.c -new file mode 100644 -index 0000000..2d768de ---- /dev/null -+++ b/src/plugins/usb/usb.c -@@ -0,0 +1,617 @@ -+/* -+ * Copyright (c) 2015 American Megatrends, Inc. -+ * All rights reserved. -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright notice, -+ * this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright notice, -+ * this list of conditions and the following disclaimer in the documentation -+ * and/or other materials provided with the distribution. -+ * -+ * 3. Neither the name of the copyright holder nor the names of its -+ * contributors may be used to endorse or promote products derived from this -+ * software without specific prior written permission. -+ * -+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE -+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -+ * POSSIBILITY OF SUCH DAMAGE. -+ */ -+ -+#define _BSD_SOURCE -+ -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+ -+#define PACKED __attribute__ ((packed)) -+#define BEGIN_SIG "$G2-CONFIG-HOST$" -+#define BEGIN_SIG_LEN 16 -+#define MAX_REQUEST_SIZE 64 * 1024 -+#define CMD_RESERVED 0x0000 -+#define SCSI_AMICMD_CURI_WRITE 0xE2 -+#define SCSI_AMICMD_CURI_READ 0xE3 -+#define SCSI_AMIDEF_CMD_SECTOR 0x01 -+#define SCSI_AMIDEF_DATA_SECTOR 0x02 -+#define ERR_SUCCESS 0 /* Success */ -+#define ERR_BIG_DATA 1 /* Too Much Data */ -+#define ERR_NO_DATA 2 /* No/Less Data Available */ -+#define ERR_UNSUPPORTED 3 /* Unsupported Command */ -+#define IN_PROCESS 0x8000 /* Bit 15 of Status */ -+#define SCSI_AMICMD_ID 0xEE -+ -+/* SCSI Command Packets */ -+typedef struct { -+ unsigned char OpCode; -+ unsigned char Lun; -+ unsigned int Lba; -+ union { -+ struct { -+ unsigned char Reserved6; -+ unsigned short Length; -+ unsigned char Reserved9[3]; -+ } PACKED Cmd10; -+ struct Len32 { -+ unsigned int Length32; -+ unsigned char Reserved10[2]; -+ } PACKED Cmd12; -+ } PACKED CmdLen; -+} PACKED SCSI_COMMAND_PACKET; -+ -+typedef struct { -+ uint8_t byNetFnLUN; -+ uint8_t byCmd; -+ uint8_t byData[MAX_REQUEST_SIZE]; -+} PACKED IPMIUSBRequest_T; -+ -+typedef struct { -+ uint8_t BeginSig[BEGIN_SIG_LEN]; -+ uint16_t Command; -+ uint16_t Status; -+ uint32_t DataInLen; -+ uint32_t DataOutLen; -+ uint32_t InternalUseDataIn; -+ uint32_t InternalUseDataOut; -+} CONFIG_CMD; -+ -+static int ipmi_usb_setup(struct ipmi_intf *intf); -+static struct ipmi_rs *ipmi_usb_send_cmd(struct ipmi_intf *intf, -+ struct ipmi_rq *req); -+ -+struct ipmi_intf ipmi_usb_intf = { -+ .name = "usb", -+ .desc = "IPMI USB Interface(OEM Interface for AMI Devices)", -+ .setup = ipmi_usb_setup, -+ .sendrecv = ipmi_usb_send_cmd, -+}; -+ -+int -+scsiProbeNew(int *num_ami_devices, int *sg_nos) -+{ -+ int inplen = *num_ami_devices; -+ int numdevfound = 0; -+ char linebuf[81]; -+ char vendor[81]; -+ int lineno = 0; -+ FILE *fp; -+ -+ fp = fopen("/proc/scsi/sg/device_strs", "r"); -+ if (fp == NULL) { -+ /* Return 1 on error */ -+ return 1; -+ } -+ -+ while (1) { -+ /* Read line by line and search for "AMI" */ -+ if (fgets(linebuf, 80, fp) == NULL) { -+ if (fp != NULL) { -+ fclose(fp); -+ } -+ /* Return 1 on error */ -+ return 1; -+ } -+ -+ if (sscanf(linebuf, "%s", vendor) == 1) { -+ if (strncmp(vendor, "AMI", strlen("AMI")) == 0) { -+ numdevfound++; -+ sg_nos[numdevfound - 1] = lineno; -+ if (numdevfound == inplen) { -+ break; -+ } -+ } -+ lineno++; -+ } -+ } -+ -+ *num_ami_devices = numdevfound; -+ if (fp != NULL) { -+ fclose(fp); -+ } -+ -+ return 0; -+} -+ -+int -+OpenCD(struct ipmi_intf *intf, char *CDName) -+{ -+ intf->fd = open(CDName, O_RDWR); -+ if (intf->fd == (-1)) { -+ lprintf(LOG_ERR, "OpenCD:Unable to open device, %s", -+ strerror(errno)); -+ return 1; -+ } -+ return 0; -+} -+ -+int -+sendscsicmd_SGIO(int cd_desc, unsigned char *cdb_buf, unsigned char cdb_len, -+ void *data_buf, unsigned int *data_len, int direction, -+ void *sense_buf, unsigned char slen, unsigned int timeout) -+{ -+ sg_io_hdr_t io_hdr; -+ -+ /* Prepare command */ -+ memset(&io_hdr, 0, sizeof(sg_io_hdr_t)); -+ io_hdr.interface_id = 'S'; -+ io_hdr.cmd_len = cdb_len; -+ -+ /* Transfer direction and length */ -+ io_hdr.dxfer_direction = direction; -+ io_hdr.dxfer_len = *data_len; -+ -+ io_hdr.dxferp = data_buf; -+ -+ io_hdr.cmdp = cdb_buf; -+ -+ io_hdr.sbp = (unsigned char *)sense_buf; -+ io_hdr.mx_sb_len = slen; -+ -+ io_hdr.timeout = timeout; -+ -+ if (!timeout) { -+ io_hdr.timeout = 20000; -+ } -+ -+ if (ioctl(cd_desc, SG_IO, &io_hdr) < 0) { -+ lprintf(LOG_ERR, "sendscsicmd_SGIO: SG_IO ioctl error"); -+ return 1; -+ } else { -+ if (io_hdr.status != 0) { -+ return 1; -+ } -+ } -+ -+ if (!timeout) { -+ return 0; -+ } -+ -+ if ((io_hdr.info & SG_INFO_OK_MASK) != SG_INFO_OK) { -+ lprintf(LOG_DEBUG, "sendscsicmd_SGIO: SG_INFO_OK - Not OK"); -+ } else { -+ lprintf(LOG_DEBUG, "sendscsicmd_SGIO: SG_INFO_OK - OK"); -+ return 0; -+ } -+ -+ return 1; -+} -+ -+int -+AMI_SPT_CMD_Identify(int cd_desc, char *szSignature) -+{ -+ SCSI_COMMAND_PACKET IdPkt = {0}; -+ int ret; -+ unsigned int siglen = 10; -+ -+ IdPkt.OpCode = SCSI_AMICMD_ID; -+ ret = sendscsicmd_SGIO(cd_desc, (unsigned char *)&IdPkt, -+ 10, szSignature, &siglen, SG_DXFER_FROM_DEV, -+ NULL, 0, 5000); -+ -+ return ret; -+} -+ -+int -+IsG2Drive(int cd_desc) -+{ -+ char szSignature[15]; -+ int ret; -+ -+ memset(szSignature, 0, 15); -+ -+ flock(cd_desc, LOCK_EX); -+ ret = AMI_SPT_CMD_Identify(cd_desc, szSignature); -+ flock(cd_desc, LOCK_UN); -+ if (ret != 0) { -+ lprintf(LOG_DEBUG, -+ "IsG2Drive:Unable to send ID command to the device"); -+ return 1; -+ } -+ -+ if (strncmp(szSignature, "$$$AMI$$$", strlen("$$$AMI$$$")) != 0) { -+ lprintf(LOG_ERR, -+ "IsG2Drive:Signature mismatch when ID command sent"); -+ return 1; -+ } -+ -+ return 0; -+} -+ -+int -+FindG2CDROM(struct ipmi_intf *intf) -+{ -+ int err = 0; -+ char device[256]; -+ int devarray[8]; -+ int numdev = 8; -+ int iter; -+ err = scsiProbeNew(&numdev, devarray); -+ -+ if (err == 0 && numdev > 0) { -+ for (iter = 0; iter < numdev; iter++) { -+ sprintf(device, "/dev/sg%d", devarray[iter]); -+ -+ if (!OpenCD(intf, device)) { -+ if (!IsG2Drive(intf->fd)) { -+ lprintf(LOG_DEBUG, "USB Device found"); -+ return 1; -+ } -+ close(intf->fd); -+ } -+ } -+ } else { -+ lprintf(LOG_DEBUG, "Unable to find Virtual CDROM Device"); -+ } -+ -+ return 0; -+} -+ -+static int -+ipmi_usb_setup(struct ipmi_intf *intf) -+{ -+ if (FindG2CDROM(intf) == 0) { -+ lprintf(LOG_ERR, "Error in USB session setup \n"); -+ return (-1); -+ } -+ intf->opened = 1; -+ return 0; -+} -+ -+void -+InitCmdHeader(CONFIG_CMD *pG2CDCmdHeader) -+{ -+ memset(pG2CDCmdHeader, 0, sizeof(CONFIG_CMD)); -+ memcpy((char *)pG2CDCmdHeader->BeginSig, BEGIN_SIG, BEGIN_SIG_LEN); -+} -+ -+int -+AMI_SPT_CMD_SendCmd(int cd_desc, char *Buffer, char type, uint16_t buflen, -+ unsigned int timeout) -+{ -+ SCSI_COMMAND_PACKET Cmdpkt; -+ char sensebuff[32]; -+ int ret; -+ unsigned int pktLen; -+ int count = 3; -+ -+ memset(&Cmdpkt, 0, sizeof(SCSI_COMMAND_PACKET)); -+ -+ Cmdpkt.OpCode = SCSI_AMICMD_CURI_WRITE; -+ Cmdpkt.Lba = htonl(type); -+ Cmdpkt.CmdLen.Cmd10.Length = htons(1); -+ -+ pktLen = buflen; -+ while (count > 0) { -+ ret = sendscsicmd_SGIO(cd_desc, (unsigned char *)&Cmdpkt, -+ 10, Buffer, &pktLen, SG_DXFER_TO_DEV, -+ sensebuff, 32, timeout); -+ count--; -+ if (ret == 0) { -+ break; -+ } else { -+ ret = (-1); -+ } -+ } -+ -+ return ret; -+} -+ -+int -+AMI_SPT_CMD_RecvCmd(int cd_desc, char *Buffer, char type, uint16_t buflen) -+{ -+ SCSI_COMMAND_PACKET Cmdpkt; -+ char sensebuff[32]; -+ int ret; -+ unsigned int pktLen; -+ int count = 3; -+ -+ memset(&Cmdpkt, 0, sizeof(SCSI_COMMAND_PACKET)); -+ -+ Cmdpkt.OpCode = SCSI_AMICMD_CURI_READ; -+ Cmdpkt.Lba = htonl(type); -+ Cmdpkt.CmdLen.Cmd10.Length = htons(1); -+ -+ pktLen = buflen; -+ while (count > 0) { -+ ret = sendscsicmd_SGIO(cd_desc, (unsigned char *)&Cmdpkt, -+ 10, Buffer, &pktLen, SG_DXFER_FROM_DEV, -+ sensebuff, 32, 5000); -+ count--; -+ if (0 == ret) { -+ break; -+ } else { -+ ret = (-1); -+ } -+ } -+ -+ return ret; -+} -+ -+int -+ReadCD(int cd_desc, char CmdData, char *Buffer, uint32_t DataLen) -+{ -+ int ret; -+ -+ ret = AMI_SPT_CMD_RecvCmd(cd_desc, Buffer, CmdData, DataLen); -+ if (ret != 0) { -+ lprintf(LOG_ERR, "Error while reading CD-Drive"); -+ return (-1); -+ } -+ return 0; -+} -+ -+int -+WriteCD(int cd_desc, char CmdData, char *Buffer, unsigned int timeout, -+ uint32_t DataLen) -+{ -+ int ret; -+ -+ ret = AMI_SPT_CMD_SendCmd(cd_desc, Buffer, CmdData, DataLen, timeout); -+ if (ret != 0) { -+ lprintf(LOG_ERR, "Error while writing to CD-Drive"); -+ return (-1); -+ } -+ return 0; -+} -+ -+int -+WriteSplitData(struct ipmi_intf *intf, char *Buffer, char Sector, -+ uint32_t NumBytes, uint32_t timeout) -+{ -+ uint32_t BytesWritten = 0; -+ int retVal; -+ -+ if (NumBytes == 0) { -+ return 0; -+ } -+ -+ while (BytesWritten < NumBytes) { -+ if ((retVal = WriteCD(intf->fd, Sector, -+ (Buffer + BytesWritten), -+ timeout, NumBytes)) != 0) { -+ return retVal; -+ } -+ -+ BytesWritten += NumBytes; -+ } -+ -+ return 0; -+} -+ -+int -+ReadSplitData(struct ipmi_intf *intf, char *Buffer, char Sector, -+ uint32_t NumBytes) -+{ -+ uint32_t BytesRead = 0; -+ -+ if (NumBytes == 0) { -+ return 0; -+ } -+ -+ while (BytesRead < NumBytes) { -+ if (ReadCD(intf->fd, Sector, (Buffer + BytesRead), -+ NumBytes) == (-1)) { -+ return 1; -+ } -+ BytesRead += NumBytes; -+ } -+ -+ return 0; -+} -+ -+int -+WaitForCommandCompletion(struct ipmi_intf *intf, CONFIG_CMD *pG2CDCmdHeader, -+ uint32_t timeout, uint32_t DataLen) -+{ -+ uint32_t TimeCounter = 0; -+ -+ do { -+ if (ReadCD(intf->fd, SCSI_AMIDEF_CMD_SECTOR, -+ (char *)(pG2CDCmdHeader), DataLen) == (-1)) { -+ lprintf(LOG_ERR, "ReadCD returned ERROR"); -+ return 1; -+ } -+ -+ if (pG2CDCmdHeader->Status & IN_PROCESS) { -+ usleep(1000); -+ if (timeout > 0) { -+ TimeCounter++; -+ if (TimeCounter == (timeout + 1)) { -+ return 2; -+ } -+ } -+ } else { -+ lprintf(LOG_DEBUG, "Command completed"); -+ break; -+ } -+ } while (1); -+ -+ return 0; -+} -+ -+int -+SendDataToUSBDriver(struct ipmi_intf *intf, char *ReqBuffer, -+ unsigned int ReqBuffLen, unsigned char *ResBuffer, -+ int *ResBuffLen, unsigned int timeout) -+{ -+ char CmdHeaderBuffer[sizeof(CONFIG_CMD)]; -+ int retVal; -+ int waitretval = 0; -+ unsigned int to = 0; -+ uint32_t DataLen = 0; -+ -+ CONFIG_CMD *pG2CDCmdHeader = (CONFIG_CMD *)CmdHeaderBuffer; -+ -+ /* FillHeader */ -+ InitCmdHeader(pG2CDCmdHeader); -+ -+ /* Set command number */ -+ pG2CDCmdHeader->Command = CMD_RESERVED; -+ -+ /* Fill Lengths */ -+ pG2CDCmdHeader->DataOutLen = *ResBuffLen; -+ pG2CDCmdHeader->DataInLen = ReqBuffLen; -+ -+ if (!timeout) { -+ to = 3000; -+ } -+ -+ DataLen = sizeof(CONFIG_CMD); -+ -+ if (WriteCD(intf->fd, SCSI_AMIDEF_CMD_SECTOR, -+ (char *)(pG2CDCmdHeader), to, DataLen) == (-1)) { -+ lprintf(LOG_ERR, -+ "Error in Write CD of SCSI_AMIDEF_CMD_SECTOR"); -+ return (-1); -+ } -+ -+ /* Write the data to hard disk */ -+ if ((retVal = WriteSplitData(intf, ReqBuffer, -+ SCSI_AMIDEF_DATA_SECTOR, -+ ReqBuffLen, timeout)) != 0) { -+ lprintf(LOG_ERR, -+ "Error in WriteSplitData of SCSI_AMIDEF_DATA_SECTOR"); -+ return (-1); -+ } -+ -+ if (!timeout) { -+ return 0; -+ } -+ -+ /* Read Status now */ -+ waitretval = WaitForCommandCompletion(intf, pG2CDCmdHeader, timeout, -+ DataLen); -+ if (waitretval != 0) { -+ lprintf(LOG_ERR, "WaitForCommandComplete failed"); -+ return (0 - waitretval); -+ } else { -+ lprintf(LOG_DEBUG, "WaitForCommandCompletion SUCCESS"); -+ } -+ -+ switch (pG2CDCmdHeader->Status) { -+ case ERR_SUCCESS: -+ *ResBuffLen = pG2CDCmdHeader->DataOutLen; -+ lprintf(LOG_DEBUG, "Before ReadSplitData %x", *ResBuffLen); -+ if (ReadSplitData(intf, (char *)ResBuffer, -+ SCSI_AMIDEF_DATA_SECTOR, -+ pG2CDCmdHeader->DataOutLen) != 0) { -+ lprintf(LOG_ERR, -+ "Err ReadSplitData SCSI_AMIDEF_DATA_SCTR"); -+ return (-1); -+ } -+ /* Additional read to see verify there was not problem -+ * with the previous read -+ */ -+ DataLen = sizeof(CONFIG_CMD); -+ ReadCD(intf->fd, SCSI_AMIDEF_CMD_SECTOR, -+ (char *)(pG2CDCmdHeader), DataLen); -+ break; -+ case ERR_BIG_DATA: -+ lprintf(LOG_ERR, "Too much data"); -+ break; -+ case ERR_NO_DATA: -+ lprintf(LOG_ERR, "Too little data"); -+ break; -+ case ERR_UNSUPPORTED: -+ lprintf(LOG_ERR, "Unsupported command"); -+ break; -+ default: -+ lprintf(LOG_ERR, "Unknown status"); -+ } -+ -+ return pG2CDCmdHeader->Status; -+} -+ -+static struct ipmi_rs * -+ipmi_usb_send_cmd(struct ipmi_intf *intf, struct ipmi_rq *req) -+{ -+ static struct ipmi_rs rsp; -+ long timeout = 20000; -+ uint8_t byRet = 0; -+ char ReqBuff[MAX_REQUEST_SIZE] = {0}; -+ IPMIUSBRequest_T *pReqPkt = (IPMIUSBRequest_T *)ReqBuff; -+ int retries = 0; -+ /********** FORM IPMI PACKET *****************/ -+ pReqPkt->byNetFnLUN = req->msg.netfn << 2; -+ pReqPkt->byNetFnLUN += req->msg.lun; -+ pReqPkt->byCmd = req->msg.cmd; -+ if (req->msg.data_len) { -+ memcpy(pReqPkt->byData, req->msg.data, req->msg.data_len); -+ } -+ -+ /********** SEND DATA TO USB ******************/ -+ while (retries < 3) { -+ retries++; -+ byRet = SendDataToUSBDriver(intf, ReqBuff, -+ 2 + req->msg.data_len, rsp.data, -+ &rsp.data_len,timeout); -+ -+ if (byRet == 0) { -+ break; -+ } -+ } -+ -+ if (retries == 3) { -+ lprintf(LOG_ERR, -+ "Error while sending command using", -+ "SendDataToUSBDriver"); -+ rsp.ccode = byRet; -+ return &rsp; -+ } -+ -+ rsp.ccode = rsp.data[0]; -+ -+ /* Save response data for caller */ -+ if ((rsp.ccode == 0) && (rsp.data_len > 0)) { -+ memmove(rsp.data, rsp.data + 1, rsp.data_len - 1); -+ rsp.data[rsp.data_len] = 0; -+ rsp.data_len -= 1; -+ } -+ return &rsp; -+} --- -2.5.0 - + [xenable_intf_usb=$enableval], + [xenable_intf_usb=$xenable_intf_usb]) + if test "x$xenable_intf_usb" = "xstatic" || test "x$xenable_intf_usb" = "xplugin"; then diff --git a/SOURCES/0016-ID-394-plugins-usb-Fix-probe-for-SCSI-devices.patch b/SOURCES/0016-ID-394-plugins-usb-Fix-probe-for-SCSI-devices.patch deleted file mode 100644 index 3217aae..0000000 --- a/SOURCES/0016-ID-394-plugins-usb-Fix-probe-for-SCSI-devices.patch +++ /dev/null @@ -1,79 +0,0 @@ -From e5f711cf292ef0729b309278c7a1a9ba5a7952a0 Mon Sep 17 00:00:00 2001 -From: Jeremy Kerr -Date: Thu, 15 Oct 2015 17:40:34 +0800 -Subject: [PATCH 16/16] ID:394 - plugins/usb: Fix probe for SCSI devices - -The current USB plugin doesn't find my IPMI channel: - - # ipmitool -I usb mc info - Error in USB session setup - - Unable to setup interface usb - Error loading interface usb - -This is beacuse I have more than 8 scsi-generic devices that identify -as AMI: - - # grep -c ^AMI /proc/scsi/sg/device_strs - 13 - -So we end up hitting the max in FindG2CDROM, and abort without finding -the actual IPMI endpoint (on my system, this is /dev/sg11). - -This change bumps that maximum up to 16. - -However, that means we hit another bug in scsiProbeNew, where if -we hit the end of the file without completely filling the array, -we return with an error. This change handles the EOF condition -gracefully instead. - -Also, fp is never going to become NULL; we don't need to check for that -condition. - -Signed-off-by: Jeremy Kerr ---- - src/plugins/usb/usb.c | 14 ++++---------- - 1 file changed, 4 insertions(+), 10 deletions(-) - -diff --git a/src/plugins/usb/usb.c b/src/plugins/usb/usb.c -index 2d768de..888d81d 100644 ---- a/src/plugins/usb/usb.c -+++ b/src/plugins/usb/usb.c -@@ -131,11 +131,7 @@ scsiProbeNew(int *num_ami_devices, int *sg_nos) - while (1) { - /* Read line by line and search for "AMI" */ - if (fgets(linebuf, 80, fp) == NULL) { -- if (fp != NULL) { -- fclose(fp); -- } -- /* Return 1 on error */ -- return 1; -+ break; - } - - if (sscanf(linebuf, "%s", vendor) == 1) { -@@ -151,9 +147,7 @@ scsiProbeNew(int *num_ami_devices, int *sg_nos) - } - - *num_ami_devices = numdevfound; -- if (fp != NULL) { -- fclose(fp); -- } -+ fclose(fp); - - return 0; - } -@@ -268,8 +262,8 @@ FindG2CDROM(struct ipmi_intf *intf) - { - int err = 0; - char device[256]; -- int devarray[8]; -- int numdev = 8; -+ int devarray[16]; -+ int numdev = 16; - int iter; - err = scsiProbeNew(&numdev, devarray); - --- -2.5.0 - diff --git a/SOURCES/0017-Fix-missing-return-in-ipmi_kontronoem_main-CID-12613.patch b/SOURCES/0017-Fix-missing-return-in-ipmi_kontronoem_main-CID-12613.patch deleted file mode 100644 index 6204258..0000000 --- a/SOURCES/0017-Fix-missing-return-in-ipmi_kontronoem_main-CID-12613.patch +++ /dev/null @@ -1,25 +0,0 @@ -From f969515f85338298b530687a8b6851f208da7d03 Mon Sep 17 00:00:00 2001 -From: Zdenek Styblik -Date: Tue, 30 Dec 2014 17:20:49 +0100 -Subject: [PATCH] Fix missing return in ipmi_kontronoem_main() - CID#1261317 - ---- - lib/ipmi_kontronoem.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/lib/ipmi_kontronoem.c b/lib/ipmi_kontronoem.c -index 48dc684..6a24831 100644 ---- a/lib/ipmi_kontronoem.c -+++ b/lib/ipmi_kontronoem.c -@@ -105,7 +105,7 @@ ipmi_kontronoem_main(struct ipmi_intf *intf, int argc, char **argv) - if (argc < 2) { - lprintf(LOG_ERR, "Not enough parameters given."); - ipmi_kontron_nextboot_help(); -- rc = (-1); -+ return (-1); - } - rc = ipmi_kontron_nextboot_set(intf, (argc - 1), (argv + 1)); - if (rc == 0) { --- -2.5.0 - diff --git a/SOURCES/0018-ID-437-sel-Fix-sel-time-set-time.patch b/SOURCES/0018-ID-437-sel-Fix-sel-time-set-time.patch deleted file mode 100644 index 2374a7c..0000000 --- a/SOURCES/0018-ID-437-sel-Fix-sel-time-set-time.patch +++ /dev/null @@ -1,67 +0,0 @@ -From fdd19cb2f65413aacb32f1eca04c2997a892f62d Mon Sep 17 00:00:00 2001 -From: Vasant Hegde -Date: Wed, 30 Mar 2016 14:07:16 +0530 -Subject: [PATCH] ID:437 - sel: Fix "sel time set