87 lines
2.1 KiB
Diff
87 lines
2.1 KiB
Diff
|
diff -up ./lib/ipmi_main.c.passarg ./lib/ipmi_main.c
|
||
|
--- ./lib/ipmi_main.c.passarg 2012-12-13 16:47:34.585182645 +0100
|
||
|
+++ ./lib/ipmi_main.c 2012-12-13 16:57:12.023739444 +0100
|
||
|
@@ -403,6 +403,7 @@ ipmi_main(int argc, char ** argv,
|
||
|
int argflag, i, found;
|
||
|
int rc = -1;
|
||
|
char sol_escape_char = SOL_ESCAPE_CHARACTER_DEFAULT;
|
||
|
+ int querrypass = 0;
|
||
|
|
||
|
/* save program name */
|
||
|
progname = strrchr(argv[0], '/');
|
||
|
@@ -501,6 +502,7 @@ ipmi_main(int argc, char ** argv,
|
||
|
}
|
||
|
break;
|
||
|
case 'f':
|
||
|
+ querrypass = 0;
|
||
|
if (password)
|
||
|
free(password);
|
||
|
password = ipmi_password_file_read(optarg);
|
||
|
@@ -509,22 +511,7 @@ ipmi_main(int argc, char ** argv,
|
||
|
"from file %s", optarg);
|
||
|
break;
|
||
|
case 'a':
|
||
|
- if (tmp)
|
||
|
- free(tmp);
|
||
|
-#ifdef HAVE_GETPASSPHRASE
|
||
|
- tmp = getpassphrase("Password: ");
|
||
|
-#else
|
||
|
- tmp = getpass("Password: ");
|
||
|
-#endif
|
||
|
- if (tmp != NULL) {
|
||
|
- if (password)
|
||
|
- free(password);
|
||
|
- password = strdup(tmp);
|
||
|
- if (password == NULL) {
|
||
|
- lprintf(LOG_ERR, "%s: malloc failure", progname);
|
||
|
- goto out_free;
|
||
|
- }
|
||
|
- }
|
||
|
+ querrypass = 1;
|
||
|
break;
|
||
|
case 'k':
|
||
|
if (kgkey)
|
||
|
@@ -623,6 +610,7 @@ ipmi_main(int argc, char ** argv,
|
||
|
oemtype = strdup("supermicro");
|
||
|
break;
|
||
|
case 'P':
|
||
|
+ querrypass = 0;
|
||
|
if (password)
|
||
|
free(password);
|
||
|
password = strdup(optarg);
|
||
|
@@ -636,6 +624,7 @@ ipmi_main(int argc, char ** argv,
|
||
|
memset(optarg, 'X', i);
|
||
|
break;
|
||
|
case 'E':
|
||
|
+ querrypass = 0;
|
||
|
if ((tmpe = getenv("IPMITOOL_PASSWORD"))) {
|
||
|
if (password)
|
||
|
free(password);
|
||
|
@@ -755,6 +744,26 @@ ipmi_main(int argc, char ** argv,
|
||
|
}
|
||
|
}
|
||
|
|
||
|
+ /* ask for password once and only if going to use it */
|
||
|
+ if (querrypass) {
|
||
|
+ if (tmp)
|
||
|
+ free(tmp);
|
||
|
+#ifdef HAVE_GETPASSPHRASE
|
||
|
+ tmp = getpassphrase("Password: ");
|
||
|
+#else
|
||
|
+ tmp = getpass("Password: ");
|
||
|
+#endif
|
||
|
+ if (tmp != NULL) {
|
||
|
+ if (password)
|
||
|
+ free(password);
|
||
|
+ password = strdup(tmp);
|
||
|
+ if (password == NULL) {
|
||
|
+ lprintf(LOG_ERR, "%s: malloc failure", progname);
|
||
|
+ goto out_free;
|
||
|
+ }
|
||
|
+ }
|
||
|
+ }
|
||
|
+
|
||
|
/* check for command before doing anything */
|
||
|
if (argc-optind > 0 &&
|
||
|
strncmp(argv[optind], "help", 4) == 0) {
|