pass manager options and logging

This commit is contained in:
Pavel Vorobyov
2019-09-25 13:32:13 +03:00
parent e659ccb06f
commit f126f5bbc2
5 changed files with 62 additions and 39 deletions

View File

@@ -122,7 +122,7 @@ func New(cfg *config.XCConfig, backend store.Backend) (*Cli, error) {
if cfg.PasswordManagerPath != "" {
term.Warnf("Loading password manager from %s\n", cfg.PasswordManagerPath)
err = passmgr.Load(cfg.PasswordManagerPath)
err = passmgr.Load(cfg.PasswordManagerPath, cfg.PasswordManagerOptions)
if err != nil {
term.Errorf("Error initializing password manager: %s\n", err)
} else {
@@ -482,6 +482,5 @@ func (c *Cli) setDistributeType(dtr string) {
term.Errorf("Unknown distribute type: %s\n", dtr)
return
}
term.Successf("distribute_type set to %s\n", dtr)
remote.SetDistributeType(c.distributeType)
}

View File

@@ -159,6 +159,7 @@ func (c *Cli) doDistributeType(name string, argsLine string, args ...string) {
return
}
c.setDistributeType(args[0])
term.Successf("distribute_type set to %s\n", args[0])
}
func (c *Cli) doPasswd(name string, argsLine string, args ...string) {

View File

@@ -164,8 +164,15 @@ Rcfile is just a number of xc commands in a text file.`,
"passmgr": &helpItem{
isTopic: true,
help: `Password manager is a golang plugin which must have two exported functions:
func Init() error, which is called on xc start
func GetPass(host string) (password string), which is kinda self-explanatory
func Init(options map[string]string, debugf func(string, ...interface{})) error
func GetPass(host string) string
Init function is called on xc start passing all the options found in [passmgr] config section
as a map[string]string, and a debugf function which logs to xc shared log if it's enabled.
GetPass function is called to acquire proper password for a host. Xc passes a hostname as the
only argument and expects function to return a password.
For more info on how to write golang plugins, please refer to golang documentation or this article:
https://medium.com/learning-the-go-programming-language/writing-modular-go-programs-with-plugins-ec46381ee1a9`,