fix: change ControlPath to .vuls of SSH option (#618)

This commit is contained in:
Kota Kanbe
2018-03-14 16:39:17 +09:00
committed by GitHub
parent 9afbf1255f
commit 0c919da4b1
6 changed files with 55 additions and 2 deletions

View File

@@ -45,6 +45,7 @@ type ConfigtestCmd struct {
deep bool
debug bool
vvv bool
}
// Name return subcommand name
@@ -68,6 +69,7 @@ func (*ConfigtestCmd) Usage() string {
[-containers-only]
[-http-proxy=http://192.168.0.1:8080]
[-debug]
[-vvv]
[SERVER]...
`
@@ -125,6 +127,8 @@ func (p *ConfigtestCmd) SetFlags(f *flag.FlagSet) {
"containers-only",
false,
"Test containers only. Default: Test both of hosts and containers")
f.BoolVar(&p.vvv, "vvv", false, "ssh -vvv")
}
// Execute execute
@@ -134,6 +138,11 @@ func (p *ConfigtestCmd) Execute(_ context.Context, f *flag.FlagSet, _ ...interfa
c.Conf.LogDir = p.logDir
util.Log = util.NewCustomLogger(c.ServerInfo{})
if err := mkdirDotVuls(); err != nil {
util.Log.Errorf("Failed to create .vuls: %s", err)
return subcommands.ExitUsageError
}
var keyPass string
var err error
if p.askKeyPassword {
@@ -161,6 +170,7 @@ func (p *ConfigtestCmd) Execute(_ context.Context, f *flag.FlagSet, _ ...interfa
if !(c.Conf.Fast || c.Conf.Offline || c.Conf.Deep) {
c.Conf.Fast = true
}
c.Conf.Vvv = p.vvv
var servernames []string
if 0 < len(f.Args()) {

View File

@@ -188,6 +188,11 @@ func (p *ScanCmd) Execute(_ context.Context, f *flag.FlagSet, _ ...interface{})
c.Conf.LogDir = p.logDir
util.Log = util.NewCustomLogger(c.ServerInfo{})
if err := mkdirDotVuls(); err != nil {
util.Log.Errorf("Failed to create .vuls: %s", err)
return subcommands.ExitUsageError
}
var keyPass string
var err error
if p.askKeyPassword {

View File

@@ -19,8 +19,11 @@ package commands
import (
"fmt"
"os"
"path/filepath"
"github.com/howeyc/gopass"
homedir "github.com/mitchellh/go-homedir"
)
func getPasswd(prompt string) (string, error) {
@@ -36,3 +39,17 @@ func getPasswd(prompt string) (string, error) {
}
}
func mkdirDotVuls() error {
home, err := homedir.Dir()
if err != nil {
return err
}
dotVuls := filepath.Join(home, ".vuls")
if _, err := os.Stat(dotVuls); os.IsNotExist(err) {
if err := os.Mkdir(dotVuls, 0700); err != nil {
return err
}
}
return nil
}