Add new '-Y' option to prompt for kg_key. It's similar to '-a' option, which prompts user to enter password.
The patch is based on https://sourceforge.net/tracker/index.php?func=detail&aid=1694175&group_id=95200&atid=610553 written by Jose Plans. Ipmitool used the '-K' option for another purpose, so I used '-Y'. Signed-off-by: Jan Safranek <jsafr...@redhat.com> Signed-off-by: Jose Plans <j...@redhat.com> --- doc/ipmitool.1 | 8 +++++++- lib/ipmi_main.c | 19 ++++++++++++++++++- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/doc/ipmitool.1 b/doc/ipmitool.1 index 78c7fd6..da68d58 100644 --- a/doc/ipmitool.1 +++ b/doc/ipmitool.1 @@ -26,7 +26,7 @@ ipmitool [\fB\-c\fR|\fB\-h\fR|\fB\-v\fR|\fB\-V\fR] [\fB\-o\fR <\fIoemtype\fP>] [\fB\-O\fR <\fIsel oem\fP>] [\fB\-C\fR <\fIciphersuite\fP>] - [\fB\-K\fR|\fB\-k\fR <\fIkg_key\fP>] + [\fB\-Y\fR|[\fB\-K\fR|\fB\-k\fR <\fIkg_key\fP>] [\fB\-y\fR <\fIhex_kg_key\fP>] [\fB\-e\fR <\fIesc_char\fP>] <\fIcommand\fP> @@ -62,6 +62,9 @@ This is not available with all commands. Use supplied character for SOL session escape character. The default is to use \fI~\fP but this can conflict with ssh sessions. .TP +\fB\-K\fR +Read Kg key from IPMI_KGKEY environment variable. +.TP \fB\-k\fR <\fIkey\fP> Use supplied Kg key for IPMIv2 authentication. The default is not to use any Kg key. @@ -72,6 +75,9 @@ hexadecimal format and can be used to specify keys with non-printable characters. E.g. '-k PASSWORD' and '-y 50415353574F5244' are equivalent. The default is not to use any Kg key. +.TP +\fB\-Y\fR +Prompt for the Kg key for IPMIv2 authentication. .TP \fB\-C\fR <\fIciphersuite\fP> The remote server authentication, integrity, and encryption algorithms diff --git a/lib/ipmi_main.c b/lib/ipmi_main.c index f4a4a4f..44dc815 100644 --- a/lib/ipmi_main.c +++ b/lib/ipmi_main.c @@ -73,7 +73,7 @@ #endif #ifdef ENABLE_ALL_OPTIONS -# define OPTION_STRING "I:hVvcgsEKao:H:d:P:f:U:p:C:L:A:t:T:m:S:l:b:B:e:k:y:O:" +# define OPTION_STRING "I:hVvcgsEKYao:H:d:P:f:U:p:C:L:A:t:T:m:S:l:b:B:e:k:y:O:" #else # define OPTION_STRING "I:hVvcH:f:U:p:d:S:" #endif @@ -227,6 +227,7 @@ ipmi_option_usage(const char * progname, struct ipmi_cmd * cmdlist, struct ipmi_ lprintf(LOG_NOTICE, " -S sdr Use local file for remote SDR cache"); #ifdef ENABLE_ALL_OPTIONS lprintf(LOG_NOTICE, " -a Prompt for remote password"); + lprintf(LOG_NOTICE, " -Y Prompt for the Kg key for IPMIv2 authentication"); lprintf(LOG_NOTICE, " -e char Set SOL escape character"); lprintf(LOG_NOTICE, " -C ciphersuite Cipher suite to be used by lanplus interface"); lprintf(LOG_NOTICE, " -k key Use Kg key for IPMIv2 authentication"); @@ -470,6 +471,22 @@ ipmi_main(int argc, char ** argv, goto out_free; } break; + case 'Y': +#ifdef HAVE_GETPASSPHRASE + tmp = getpassphrase("Key: "); +#else + tmp = getpass("Key: "); +#endif + if (tmp != NULL) { + if (kgkey) + free(kgkey); + kgkey = strdup(tmp); + if (kgkey == NULL) { + lprintf(LOG_ERR, "%s: malloc failure", progname); + goto out_free; + } + } + break; case 'U': username = strdup(optarg); if (username == NULL) { ------------------------------------------------------------------------------ Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA -OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise -Strategies to boost innovation and cut costs with open source participation -Receive a $600 discount off the registration fee with the source code: SFAD http://p.sf.net/sfu/XcvMzF8H _______________________________________________ Ipmitool-devel mailing list Ipmitool-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/ipmitool-devel