Index: common/src/ipmi-common.c =================================================================== RCS file: /sources/freeipmi/freeipmi/common/src/ipmi-common.c,v retrieving revision 1.13 diff -u -5 -p -r1.13 ipmi-common.c --- common/src/ipmi-common.c 13 Sep 2006 21:23:56 -0000 1.13 +++ common/src/ipmi-common.c 25 Apr 2007 23:03:01 -0000 @@ -36,10 +36,11 @@ Foundation, Inc., 675 Mass Ave, Cambridg #include #endif #include #include "ipmi-common.h" +#include "freeipmi/ipmi-messaging-support-cmds.h" #define IPMI_DPRINTF_MAX_BUF_LEN 65536 int ipmi_is_root () @@ -101,5 +102,91 @@ void *guaranteed_memset(void *s, int c, while (n--) *p++=c; return s; } + +/* a k_g key should be specified in hexadecimal, or given the prefix + * of s: which will cause it to be interpreted as ascii instead + */ +int +parse_kg(unsigned char *outbuf, unsigned char *inbuf) +{ + char *p; + int i, j; + unsigned char buf[3] = {0, 0, 0}; + + if (strncmp(inbuf, "s:", 2) == 0) + { + p = inbuf + 2; + if (strlen(p) > IPMI_MAX_K_G_LENGTH) + return -1; + guaranteed_memset(outbuf, 0, IPMI_MAX_K_G_LENGTH); + memcpy(outbuf, p, strlen(p)); + } + else + { + if (strlen(inbuf) > IPMI_MAX_K_G_LENGTH*2) + return -1; + guaranteed_memset(outbuf, 0, IPMI_MAX_K_G_LENGTH); + for (i = j = 0; i < strlen(inbuf)-1; i+=2, j++) + { + buf[0] = inbuf[i]; buf[1] = inbuf[i+1]; buf[2] = 0; + p = buf; + errno = 0; + outbuf[j] = strtoul(buf, &p, 16); + if (errno) + return -1; + } + } + + return 0; +} + +unsigned char * +format_kg(unsigned char *outbuf, unsigned char *k_g) +{ + int i; + int printable = 1; + int foundnull = 0; + unsigned char *p; + + /* Are there any characters that would prevent printing this as a + string on a single line? */ + for (i = 0; i < IPMI_MAX_K_G_LENGTH; i++) + { + if (k_g[i] == 0) + { + foundnull = 1; + continue; + } + if (!(isgraph(k_g[i]) || k_g[i] == ' ') || foundnull) + { + printable = 0; + break; + } + } + + if (printable) + { + p = outbuf; + p[0] = 's'; p[1] = ':'; + p+=2; + for (i = 0; i < IPMI_MAX_K_G_LENGTH; i++) + { + if (k_g[i] == 0) + break; + p[i] = k_g[i]; + } + p[i] = 0; + } + else + { + p = outbuf; + for (i = 0, p = outbuf; i < IPMI_MAX_K_G_LENGTH; i++, p+=2) + { + snprintf(p, 2, "%02x", k_g[i]); + } + } + + return outbuf; +} Index: common/src/ipmi-common.h =================================================================== RCS file: /sources/freeipmi/freeipmi/common/src/ipmi-common.h,v retrieving revision 1.9 diff -u -5 -p -r1.9 ipmi-common.h --- common/src/ipmi-common.h 21 Jul 2006 18:09:05 -0000 1.9 +++ common/src/ipmi-common.h 25 Apr 2007 23:03:01 -0000 @@ -68,6 +68,12 @@ int ipmi_is_root (); int ipmi_dprintf(int fd, char *fmt, ...); /* From David Wheeler's Secure Programming Guide */ void *guaranteed_memset(void *s, int c, size_t n); +/* Turn an input string into a 20-byte binary k_g key */ +int parse_kg(unsigned char *outbuf, unsigned char *inbuf); + +/* Turn a 20-byte binary k_g key into an output string */ +unsigned char *format_kg(unsigned char *outbuf, unsigned char *k_g); + #endif Index: ipmipower/src/Makefile.am =================================================================== RCS file: /sources/freeipmi/freeipmi/ipmipower/src/Makefile.am,v retrieving revision 1.12.2.2 diff -u -5 -p -r1.12.2.2 Makefile.am --- ipmipower/src/Makefile.am 7 Mar 2007 04:11:04 -0000 1.12.2.2 +++ ipmipower/src/Makefile.am 25 Apr 2007 23:03:01 -0000 @@ -21,10 +21,11 @@ ipmipower_SOURCES= \ wrappers.c ipmipower_LDADD = \ ../../common/src/libcbuf.la \ ../../common/src/libllnlcommon.la \ + ../../common/src/libipmicommon.la \ ../../libfreeipmi/src/libfreeipmi.la ipmipower_CPPFLAGS = \ -I$(srcdir)/../../common/src \ -I$(srcdir)/../../libfreeipmi/include \ @@ -56,9 +57,12 @@ noinst_HEADERS= \ $(MAKE) -C $(dir $@) $(notdir $@) ../../common/src/libllnlcommon.la: force-dependency-check $(MAKE) -C $(dir $@) $(notdir $@) +../../common/src/libipmicommon.la: force-dependency-check + $(MAKE) -C $(dir $@) $(notdir $@) + ../../libfreeipmi/src/libfreeipmi.la: force-dependency-check $(MAKE) -C $(dir $@) $(notdir $@) force-dependency-check: Index: ipmipower/src/ipmipower_config.c =================================================================== RCS file: /sources/freeipmi/freeipmi/ipmipower/src/ipmipower_config.c,v retrieving revision 1.44.2.3 diff -u -5 -p -r1.44.2.3 ipmipower_config.c --- ipmipower/src/ipmipower_config.c 28 Mar 2007 23:24:42 -0000 1.44.2.3 +++ ipmipower/src/ipmipower_config.c 25 Apr 2007 23:03:01 -0000 @@ -51,10 +51,11 @@ #include "ipmipower_privilege.h" #include "ipmipower_util.h" #include "ipmipower_wrappers.h" #include "secure.h" +#include "ipmi-common.h" extern struct ipmipower_config *conf; extern struct ipmipower_connection *ics; void @@ -87,11 +88,11 @@ ipmipower_config_setup(void) conf->hosts = NULL; conf->hosts_count = 0; memset(conf->username, '\0', IPMI_MAX_USER_NAME_LENGTH+1); memset(conf->password, '\0', IPMI_2_0_MAX_PASSWORD_LENGTH+1); - memset(conf->k_g, '\0', IPMI_MAX_K_G_LENGTH+1); + memset(conf->k_g, '\0', IPMI_MAX_K_G_LENGTH); conf->powercmd = POWER_CMD_NONE; memset(conf->configfile, '\0', MAXPATHLEN+1); conf->authentication_type = AUTHENTICATION_TYPE_AUTO; conf->privilege = PRIVILEGE_TYPE_AUTO; @@ -380,13 +381,12 @@ ipmipower_config_cmdline_parse(int argc, err_exit("password too long"); strcpy(conf->password, pw); conf->password_set = IPMIPOWER_TRUE; break; case 'k': /* --k-g */ - if (strlen(optarg) > IPMI_MAX_K_G_LENGTH) - err_exit("Command Line Error: K_g too long"); - strcpy(conf->k_g, optarg); + if (parse_kg(conf->k_g, optarg) != 0) + err_exit("Command Line Error: Invalid K_g"); conf->k_g_set = IPMIPOWER_TRUE; if (optarg) { int n; n = strlen(optarg); @@ -394,13 +394,12 @@ ipmipower_config_cmdline_parse(int argc, } break; case 'K': /* --k-g-prompt */ if (!(kg = getpass("K_g: "))) err_exit("getpass: %s", strerror(errno)); - if (strlen(kg) > IPMI_MAX_K_G_LENGTH) - err_exit("K_g too long"); - strcpy(conf->k_g, kg); + if (parse_kg(conf->k_g, optarg) != 0) + err_exit("K_g invalid"); conf->k_g_set = IPMIPOWER_TRUE; break; case 'n': /* --on */ conf->powercmd = POWER_CMD_POWER_ON; break; @@ -735,14 +734,13 @@ _cb_k_g(conffile_t cf, struct conffile_d int option_data, void *app_ptr, int app_data) { if (conf->k_g_set == IPMIPOWER_TRUE) return 0; - if (strlen(data->string) > IPMI_MAX_K_G_LENGTH) - err_exit("Config File Error: K_g too long"); + if (parse_kg(conf->k_g, data->string) != 0) + err_exit("Config File Error: K_g invalid"); - strcpy(conf->k_g, data->string); return 0; } void ipmipower_config_conffile_parse(char *configfile) @@ -874,11 +872,11 @@ ipmipower_config_check_values(void) err_exit("Error: password cannot be set for authentication type \"%s\"", ipmipower_authentication_type_string(conf->authentication_type)); if (conf->ipmi_version != IPMI_VERSION_AUTO && conf->ipmi_version != IPMI_VERSION_2_0 - && strlen(conf->k_g) > 0) + && conf->k_g_set == IPMIPOWER_TRUE) err_exit("Error: k_g is only used for IPMI 2.0"); if (conf->ipmi_version == IPMI_VERSION_1_5 && strlen(conf->password) >= IPMI_1_5_MAX_PASSWORD_LENGTH) err_exit("Error: password too long"); Index: ipmipower/src/ipmipower_prompt.c =================================================================== RCS file: /sources/freeipmi/freeipmi/ipmipower/src/ipmipower_prompt.c,v retrieving revision 1.38.2.1 diff -u -5 -p -r1.38.2.1 ipmipower_prompt.c --- ipmipower/src/ipmipower_prompt.c 15 Dec 2006 23:37:11 -0000 1.38.2.1 +++ ipmipower/src/ipmipower_prompt.c 25 Apr 2007 23:03:01 -0000 @@ -54,10 +54,12 @@ #include "ipmipower_powercmd.h" #include "ipmipower_output.h" #include "ipmipower_privilege.h" #include "ipmipower_wrappers.h" +#include "ipmi-common.h" + extern cbuf_t ttyout; extern cbuf_t ttyin; extern cbuf_t ttyerr; extern struct ipmipower_config *conf; extern struct ipmipower_connection *ics; @@ -342,32 +344,37 @@ _cmd_password(char **argv) } static void _cmd_k_g(char **argv) { + int rv = 0; + char buf[IPMI_MAX_K_G_LENGTH*2+1]; assert(argv != NULL); if (conf->ipmi_version != IPMI_VERSION_AUTO && conf->ipmi_version != IPMI_VERSION_2_0) cbuf_printf(ttyout, "k_g is only used for IPMI 2.0"); - else if (argv[1] == NULL - || (argv[1] && strlen(argv[1]) <= IPMI_MAX_K_G_LENGTH)) + else { - memset(conf->k_g, '\0', IPMI_MAX_K_G_LENGTH+1); + memset(conf->k_g, '\0', IPMI_MAX_K_G_LENGTH); if (argv[1]) - strcpy(conf->k_g, argv[1]); - + rv = parse_kg(conf->k_g, argv[1]); + + if (rv != 0) + cbuf_printf(ttyout, "k_g invalid length\n"); + else + { #ifdef NDEBUG - cbuf_printf(ttyout, "k_g changed\n"); + cbuf_printf(ttyout, "k_g changed\n"); #else /* !NDEBUG */ - cbuf_printf(ttyout, "k_g: %s\n", - (strlen(conf->k_g)) ? conf->k_g : "NULL"); + cbuf_printf(ttyout, "k_g: %s\n", + (conf->k_g_set == IPMIPOWER_TRUE) ? + format_kg(buf, conf->k_g) : "NULL"); #endif /* !NDEBUG */ + } } - else - cbuf_printf(ttyout, "k_g invalid length\n"); } static void _cmd_authentication_type(char **argv) { @@ -568,10 +575,12 @@ _cmd_logfile(char **argv) #endif /* NDEBUG */ static void _cmd_config(void) { + char buf[IPMI_MAX_K_G_LENGTH*2+1]; + if (conf->hosts != NULL) { int rv; char buffer[IPMIPOWER_HOSTLIST_BUFLEN]; #ifndef NDEBUG @@ -647,11 +656,12 @@ _cmd_config(void) #ifndef NDEBUG cbuf_printf(ttyout, "Password: %s\n", (strlen(conf->password)) ? conf->password : "NULL"); cbuf_printf(ttyout, "K_g: %s\n", - (strlen(conf->k_g)) ? conf->k_g : "NULL"); + (conf->k_g_set == IPMIPOWER_TRUE) ? + format_kg(buf, conf->k_g) : "NULL"); #else /* !NDEBUG */ cbuf_printf(ttyout, "Password: *****\n"); cbuf_printf(ttyout, "K_g: *****\n"); #endif /* !NDEBUG */ Index: common/src/ipmi-common.c =================================================================== RCS file: /sources/freeipmi/freeipmi/common/src/ipmi-common.c,v retrieving revision 1.13 diff -u -5 -p -r1.13 ipmi-common.c --- common/src/ipmi-common.c 13 Sep 2006 21:23:56 -0000 1.13 +++ common/src/ipmi-common.c 25 Apr 2007 23:04:10 -0000 @@ -36,10 +36,11 @@ Foundation, Inc., 675 Mass Ave, Cambridg #include #endif #include #include "ipmi-common.h" +#include "freeipmi/ipmi-messaging-support-cmds.h" #define IPMI_DPRINTF_MAX_BUF_LEN 65536 int ipmi_is_root () @@ -101,5 +102,91 @@ void *guaranteed_memset(void *s, int c, while (n--) *p++=c; return s; } + +/* a k_g key should be specified in hexadecimal, or given the prefix + * of s: which will cause it to be interpreted as ascii instead + */ +int +parse_kg(unsigned char *outbuf, unsigned char *inbuf) +{ + char *p; + int i, j; + unsigned char buf[3] = {0, 0, 0}; + + if (strncmp(inbuf, "s:", 2) == 0) + { + p = inbuf + 2; + if (strlen(p) > IPMI_MAX_K_G_LENGTH) + return -1; + guaranteed_memset(outbuf, 0, IPMI_MAX_K_G_LENGTH); + memcpy(outbuf, p, strlen(p)); + } + else + { + if (strlen(inbuf) > IPMI_MAX_K_G_LENGTH*2) + return -1; + guaranteed_memset(outbuf, 0, IPMI_MAX_K_G_LENGTH); + for (i = j = 0; i < strlen(inbuf)-1; i+=2, j++) + { + buf[0] = inbuf[i]; buf[1] = inbuf[i+1]; buf[2] = 0; + p = buf; + errno = 0; + outbuf[j] = strtoul(buf, &p, 16); + if (errno) + return -1; + } + } + + return 0; +} + +unsigned char * +format_kg(unsigned char *outbuf, unsigned char *k_g) +{ + int i; + int printable = 1; + int foundnull = 0; + unsigned char *p; + + /* Are there any characters that would prevent printing this as a + string on a single line? */ + for (i = 0; i < IPMI_MAX_K_G_LENGTH; i++) + { + if (k_g[i] == 0) + { + foundnull = 1; + continue; + } + if (!(isgraph(k_g[i]) || k_g[i] == ' ') || foundnull) + { + printable = 0; + break; + } + } + + if (printable) + { + p = outbuf; + p[0] = 's'; p[1] = ':'; + p+=2; + for (i = 0; i < IPMI_MAX_K_G_LENGTH; i++) + { + if (k_g[i] == 0) + break; + p[i] = k_g[i]; + } + p[i] = 0; + } + else + { + p = outbuf; + for (i = 0, p = outbuf; i < IPMI_MAX_K_G_LENGTH; i++, p+=2) + { + snprintf(p, 2, "%02x", k_g[i]); + } + } + + return outbuf; +} Index: common/src/ipmi-common.h =================================================================== RCS file: /sources/freeipmi/freeipmi/common/src/ipmi-common.h,v retrieving revision 1.9 diff -u -5 -p -r1.9 ipmi-common.h --- common/src/ipmi-common.h 21 Jul 2006 18:09:05 -0000 1.9 +++ common/src/ipmi-common.h 25 Apr 2007 23:04:10 -0000 @@ -68,6 +68,12 @@ int ipmi_is_root (); int ipmi_dprintf(int fd, char *fmt, ...); /* From David Wheeler's Secure Programming Guide */ void *guaranteed_memset(void *s, int c, size_t n); +/* Turn an input string into a 20-byte binary k_g key */ +int parse_kg(unsigned char *outbuf, unsigned char *inbuf); + +/* Turn a 20-byte binary k_g key into an output string */ +unsigned char *format_kg(unsigned char *outbuf, unsigned char *k_g); + #endif Index: ipmipower/src/Makefile.am =================================================================== RCS file: /sources/freeipmi/freeipmi/ipmipower/src/Makefile.am,v retrieving revision 1.12.2.2 diff -u -5 -p -r1.12.2.2 Makefile.am --- ipmipower/src/Makefile.am 7 Mar 2007 04:11:04 -0000 1.12.2.2 +++ ipmipower/src/Makefile.am 25 Apr 2007 23:04:10 -0000 @@ -21,10 +21,11 @@ ipmipower_SOURCES= \ wrappers.c ipmipower_LDADD = \ ../../common/src/libcbuf.la \ ../../common/src/libllnlcommon.la \ + ../../common/src/libipmicommon.la \ ../../libfreeipmi/src/libfreeipmi.la ipmipower_CPPFLAGS = \ -I$(srcdir)/../../common/src \ -I$(srcdir)/../../libfreeipmi/include \ @@ -56,9 +57,12 @@ noinst_HEADERS= \ $(MAKE) -C $(dir $@) $(notdir $@) ../../common/src/libllnlcommon.la: force-dependency-check $(MAKE) -C $(dir $@) $(notdir $@) +../../common/src/libipmicommon.la: force-dependency-check + $(MAKE) -C $(dir $@) $(notdir $@) + ../../libfreeipmi/src/libfreeipmi.la: force-dependency-check $(MAKE) -C $(dir $@) $(notdir $@) force-dependency-check: Index: ipmipower/src/ipmipower_config.c =================================================================== RCS file: /sources/freeipmi/freeipmi/ipmipower/src/ipmipower_config.c,v retrieving revision 1.44.2.3 diff -u -5 -p -r1.44.2.3 ipmipower_config.c --- ipmipower/src/ipmipower_config.c 28 Mar 2007 23:24:42 -0000 1.44.2.3 +++ ipmipower/src/ipmipower_config.c 25 Apr 2007 23:04:10 -0000 @@ -51,10 +51,11 @@ #include "ipmipower_privilege.h" #include "ipmipower_util.h" #include "ipmipower_wrappers.h" #include "secure.h" +#include "ipmi-common.h" extern struct ipmipower_config *conf; extern struct ipmipower_connection *ics; void @@ -87,11 +88,11 @@ ipmipower_config_setup(void) conf->hosts = NULL; conf->hosts_count = 0; memset(conf->username, '\0', IPMI_MAX_USER_NAME_LENGTH+1); memset(conf->password, '\0', IPMI_2_0_MAX_PASSWORD_LENGTH+1); - memset(conf->k_g, '\0', IPMI_MAX_K_G_LENGTH+1); + memset(conf->k_g, '\0', IPMI_MAX_K_G_LENGTH); conf->powercmd = POWER_CMD_NONE; memset(conf->configfile, '\0', MAXPATHLEN+1); conf->authentication_type = AUTHENTICATION_TYPE_AUTO; conf->privilege = PRIVILEGE_TYPE_AUTO; @@ -380,13 +381,12 @@ ipmipower_config_cmdline_parse(int argc, err_exit("password too long"); strcpy(conf->password, pw); conf->password_set = IPMIPOWER_TRUE; break; case 'k': /* --k-g */ - if (strlen(optarg) > IPMI_MAX_K_G_LENGTH) - err_exit("Command Line Error: K_g too long"); - strcpy(conf->k_g, optarg); + if (parse_kg(conf->k_g, optarg) != 0) + err_exit("Command Line Error: Invalid K_g"); conf->k_g_set = IPMIPOWER_TRUE; if (optarg) { int n; n = strlen(optarg); @@ -394,13 +394,12 @@ ipmipower_config_cmdline_parse(int argc, } break; case 'K': /* --k-g-prompt */ if (!(kg = getpass("K_g: "))) err_exit("getpass: %s", strerror(errno)); - if (strlen(kg) > IPMI_MAX_K_G_LENGTH) - err_exit("K_g too long"); - strcpy(conf->k_g, kg); + if (parse_kg(conf->k_g, optarg) != 0) + err_exit("K_g invalid"); conf->k_g_set = IPMIPOWER_TRUE; break; case 'n': /* --on */ conf->powercmd = POWER_CMD_POWER_ON; break; @@ -735,14 +734,13 @@ _cb_k_g(conffile_t cf, struct conffile_d int option_data, void *app_ptr, int app_data) { if (conf->k_g_set == IPMIPOWER_TRUE) return 0; - if (strlen(data->string) > IPMI_MAX_K_G_LENGTH) - err_exit("Config File Error: K_g too long"); + if (parse_kg(conf->k_g, data->string) != 0) + err_exit("Config File Error: K_g invalid"); - strcpy(conf->k_g, data->string); return 0; } void ipmipower_config_conffile_parse(char *configfile) @@ -874,11 +872,11 @@ ipmipower_config_check_values(void) err_exit("Error: password cannot be set for authentication type \"%s\"", ipmipower_authentication_type_string(conf->authentication_type)); if (conf->ipmi_version != IPMI_VERSION_AUTO && conf->ipmi_version != IPMI_VERSION_2_0 - && strlen(conf->k_g) > 0) + && conf->k_g_set == IPMIPOWER_TRUE) err_exit("Error: k_g is only used for IPMI 2.0"); if (conf->ipmi_version == IPMI_VERSION_1_5 && strlen(conf->password) >= IPMI_1_5_MAX_PASSWORD_LENGTH) err_exit("Error: password too long"); Index: ipmipower/src/ipmipower_prompt.c =================================================================== RCS file: /sources/freeipmi/freeipmi/ipmipower/src/ipmipower_prompt.c,v retrieving revision 1.38.2.1 diff -u -5 -p -r1.38.2.1 ipmipower_prompt.c --- ipmipower/src/ipmipower_prompt.c 15 Dec 2006 23:37:11 -0000 1.38.2.1 +++ ipmipower/src/ipmipower_prompt.c 25 Apr 2007 23:04:10 -0000 @@ -54,10 +54,12 @@ #include "ipmipower_powercmd.h" #include "ipmipower_output.h" #include "ipmipower_privilege.h" #include "ipmipower_wrappers.h" +#include "ipmi-common.h" + extern cbuf_t ttyout; extern cbuf_t ttyin; extern cbuf_t ttyerr; extern struct ipmipower_config *conf; extern struct ipmipower_connection *ics; @@ -342,32 +344,37 @@ _cmd_password(char **argv) } static void _cmd_k_g(char **argv) { + int rv = 0; + char buf[IPMI_MAX_K_G_LENGTH*2+1]; assert(argv != NULL); if (conf->ipmi_version != IPMI_VERSION_AUTO && conf->ipmi_version != IPMI_VERSION_2_0) cbuf_printf(ttyout, "k_g is only used for IPMI 2.0"); - else if (argv[1] == NULL - || (argv[1] && strlen(argv[1]) <= IPMI_MAX_K_G_LENGTH)) + else { - memset(conf->k_g, '\0', IPMI_MAX_K_G_LENGTH+1); + memset(conf->k_g, '\0', IPMI_MAX_K_G_LENGTH); if (argv[1]) - strcpy(conf->k_g, argv[1]); - + rv = parse_kg(conf->k_g, argv[1]); + + if (rv != 0) + cbuf_printf(ttyout, "k_g invalid\n"); + else + { #ifdef NDEBUG - cbuf_printf(ttyout, "k_g changed\n"); + cbuf_printf(ttyout, "k_g changed\n"); #else /* !NDEBUG */ - cbuf_printf(ttyout, "k_g: %s\n", - (strlen(conf->k_g)) ? conf->k_g : "NULL"); + cbuf_printf(ttyout, "k_g: %s\n", + (conf->k_g_set == IPMIPOWER_TRUE) ? + format_kg(buf, conf->k_g) : "NULL"); #endif /* !NDEBUG */ + } } - else - cbuf_printf(ttyout, "k_g invalid length\n"); } static void _cmd_authentication_type(char **argv) { @@ -568,10 +575,12 @@ _cmd_logfile(char **argv) #endif /* NDEBUG */ static void _cmd_config(void) { + char buf[IPMI_MAX_K_G_LENGTH*2+1]; + if (conf->hosts != NULL) { int rv; char buffer[IPMIPOWER_HOSTLIST_BUFLEN]; #ifndef NDEBUG @@ -647,11 +656,12 @@ _cmd_config(void) #ifndef NDEBUG cbuf_printf(ttyout, "Password: %s\n", (strlen(conf->password)) ? conf->password : "NULL"); cbuf_printf(ttyout, "K_g: %s\n", - (strlen(conf->k_g)) ? conf->k_g : "NULL"); + (conf->k_g_set == IPMIPOWER_TRUE) ? + format_kg(buf, conf->k_g) : "NULL"); #else /* !NDEBUG */ cbuf_printf(ttyout, "Password: *****\n"); cbuf_printf(ttyout, "K_g: *****\n"); #endif /* !NDEBUG */