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:
parent
b8df0dfc02
commit
2df47d8999
@ -24,6 +24,11 @@ error as scripts most often do not have an actual terminal that control the
|
||||
process. This means that passwords and other commands can be passed to MaxAdmin
|
||||
without a controlling terminal.
|
||||
|
||||
### MaxCtrl password input
|
||||
|
||||
MaxCtrl can now query the password from the user. This allows passwords to be
|
||||
given without giving them as process arguments.
|
||||
|
||||
## Dropped Features
|
||||
|
||||
## New Features
|
||||
|
@ -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() {
|
||||
|
@ -31,7 +31,7 @@ program
|
||||
})
|
||||
.option('p', {
|
||||
alias: 'password',
|
||||
describe: 'Password for the user',
|
||||
describe: 'Password for the user. To input the password manually, give -p as the last argument or use --password=\'\'',
|
||||
default: 'mariadb',
|
||||
type: 'string'
|
||||
})
|
||||
|
@ -19,6 +19,7 @@
|
||||
"cli-table": "^0.3.1",
|
||||
"lodash": "^4.17.4",
|
||||
"lodash-getpath": "^0.2.4",
|
||||
"readline-sync": "^1.4.9",
|
||||
"request": "^2.81.0",
|
||||
"request-promise-native": "^1.0.3",
|
||||
"yargs": "^8.0.2"
|
||||
|
Loading…
x
Reference in New Issue
Block a user