Read MaxCtrl password from stdin when none provided
When the -p parameter is given without an argument, the password is read from the command line. This allows passwords to be given to MaxCtrl in a safer manner.
This commit is contained in:
@ -17,6 +17,7 @@ var Table = require('cli-table');
|
||||
var consoleLib = require('console')
|
||||
var os = require('os')
|
||||
var fs = require('fs')
|
||||
var readlineSync = require('readline-sync')
|
||||
|
||||
module.exports = function() {
|
||||
|
||||
@ -27,6 +28,13 @@ module.exports = function() {
|
||||
// servers.
|
||||
this.maxctrl = function(argv, cb) {
|
||||
|
||||
// No password given, ask it from the command line
|
||||
if (argv.p == '') {
|
||||
argv.p = readlineSync.question('Enter password: ', {
|
||||
hideEchoBack: true
|
||||
})
|
||||
}
|
||||
|
||||
// Split the hostnames, separated by commas
|
||||
argv.hosts = argv.hosts.split(',')
|
||||
|
||||
@ -209,7 +217,7 @@ module.exports = function() {
|
||||
base = 'https://'
|
||||
}
|
||||
|
||||
return base + argv.user + ':' + argv.password + '@' + host + '/v1/' + endpoint
|
||||
return base + argv.u + ':' + argv.p + '@' + host + '/v1/' + endpoint
|
||||
}
|
||||
|
||||
this.OK = function() {
|
||||
|
Reference in New Issue
Block a user