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:
@ -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
|
process. This means that passwords and other commands can be passed to MaxAdmin
|
||||||
without a controlling terminal.
|
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
|
## Dropped Features
|
||||||
|
|
||||||
## New Features
|
## New Features
|
||||||
|
@ -17,6 +17,7 @@ var Table = require('cli-table');
|
|||||||
var consoleLib = require('console')
|
var consoleLib = require('console')
|
||||||
var os = require('os')
|
var os = require('os')
|
||||||
var fs = require('fs')
|
var fs = require('fs')
|
||||||
|
var readlineSync = require('readline-sync')
|
||||||
|
|
||||||
module.exports = function() {
|
module.exports = function() {
|
||||||
|
|
||||||
@ -27,6 +28,13 @@ module.exports = function() {
|
|||||||
// servers.
|
// servers.
|
||||||
this.maxctrl = function(argv, cb) {
|
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
|
// Split the hostnames, separated by commas
|
||||||
argv.hosts = argv.hosts.split(',')
|
argv.hosts = argv.hosts.split(',')
|
||||||
|
|
||||||
@ -209,7 +217,7 @@ module.exports = function() {
|
|||||||
base = 'https://'
|
base = 'https://'
|
||||||
}
|
}
|
||||||
|
|
||||||
return base + argv.user + ':' + argv.password + '@' + host + '/v1/' + endpoint
|
return base + argv.u + ':' + argv.p + '@' + host + '/v1/' + endpoint
|
||||||
}
|
}
|
||||||
|
|
||||||
this.OK = function() {
|
this.OK = function() {
|
||||||
|
@ -31,7 +31,7 @@ program
|
|||||||
})
|
})
|
||||||
.option('p', {
|
.option('p', {
|
||||||
alias: 'password',
|
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',
|
default: 'mariadb',
|
||||||
type: 'string'
|
type: 'string'
|
||||||
})
|
})
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
"cli-table": "^0.3.1",
|
"cli-table": "^0.3.1",
|
||||||
"lodash": "^4.17.4",
|
"lodash": "^4.17.4",
|
||||||
"lodash-getpath": "^0.2.4",
|
"lodash-getpath": "^0.2.4",
|
||||||
|
"readline-sync": "^1.4.9",
|
||||||
"request": "^2.81.0",
|
"request": "^2.81.0",
|
||||||
"request-promise-native": "^1.0.3",
|
"request-promise-native": "^1.0.3",
|
||||||
"yargs": "^8.0.2"
|
"yargs": "^8.0.2"
|
||||||
|
Reference in New Issue
Block a user