From 9c711e9022e4fd9c5f8ae7b34eb499696f4eeaf3 Mon Sep 17 00:00:00 2001 From: Greg Date: Wed, 4 Sep 2019 22:21:01 -0400 Subject: [PATCH] Add README.md. --- README.md | 24 ++++++++++++++++++++++++ cmd/gpass-gui/main.go | 10 +++++----- cmd/gpass/main.go | 7 +++---- impl_darwin.go | 3 ++- main.go | 6 ++---- 5 files changed, 36 insertions(+), 14 deletions(-) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..923cd0c --- /dev/null +++ b/README.md @@ -0,0 +1,24 @@ +# gpass + +This repository includes Go code to interact with pass, the Unix password +manager. Library code is provided to open a password store, list +saved passwords, and decrypt specified passwords. The library provides +a simple passphrase input function, or, if gpg-agent is running (on MacOS), +it will connect automatically to request your GPG passphrase. + +```go +store, err := gpass.GetStore() +if err != nil { ... } +passlist := store.List() +//storeDir := store.Dir +for _,x := range passlist { + if x.Pathname = "myPass" { + p, err := store.Decrypt(x.Pathname) + if err == nil { + gpass.Clip(p) // put on the clipboard + } else { + log.Fatal("Cannot decrypt ", x.Pathname) + } + } +} +``` diff --git a/cmd/gpass-gui/main.go b/cmd/gpass-gui/main.go index 16c049d..ac1fee3 100644 --- a/cmd/gpass-gui/main.go +++ b/cmd/gpass-gui/main.go @@ -27,12 +27,12 @@ import ( "golang.org/x/image/font/sfnt" - "git.wow.st/gmp/pass" + "git.wow.st/gmp/gpass" ) func main() { var err error - store,err = pass.GetStore() + store,err = gpass.GetStore() if err != nil { log(Fatal, err) } @@ -45,9 +45,9 @@ func main() { } var ( - l []pass.Pass + l []gpass.Pass mux sync.Mutex - store *pass.Store + store *gpass.Store updated chan struct{} ) @@ -224,7 +224,7 @@ func eventLoop() { //p,err := store.Decrypt(name, prompt) p,err := store.Decrypt(name) if err == nil { - pass.Clip(p) + gpass.Clip(p) } else { log(Info,"Can't decrypt ", name) log(Info,err) diff --git a/cmd/gpass/main.go b/cmd/gpass/main.go index 7f26711..7d08057 100644 --- a/cmd/gpass/main.go +++ b/cmd/gpass/main.go @@ -6,7 +6,7 @@ import ( "path" "strings" - "gitlab.wow.st/gmp/pass" + "git.wow.st/gmp/gpass" ) func usage() { @@ -35,7 +35,7 @@ func parse(args []string) ([]string,options) { } func main() { - store,err := pass.GetStore() + store,err := gpass.GetStore() if err != nil { fmt.Println(err) os.Exit(-1) @@ -64,13 +64,12 @@ func main() { os.Exit(-1) } if opts.clip { - pass.Clip(p) + gpass.Clip(p) } else { fmt.Print(p) } default: usage() } - pass.AskPass2() } diff --git a/impl_darwin.go b/impl_darwin.go index 81e8308..9fcf941 100644 --- a/impl_darwin.go +++ b/impl_darwin.go @@ -1,6 +1,6 @@ //+build !android !linux -package pass +package gpass import ( "fmt" @@ -70,6 +70,7 @@ func setAgentInfo() { s := fmt.Sprintf("%s:%d:1", filename, pid) fmt.Printf("GPG_AGENT_INFO = %s\n", s) os.Setenv("GPG_AGENT_INFO",s) + ask = GPGPrompt } func init() { diff --git a/main.go b/main.go index 83b7b69..841baa9 100644 --- a/main.go +++ b/main.go @@ -1,4 +1,4 @@ -package pass +package gpass import ( "bufio" @@ -22,6 +22,7 @@ import ( var ( basename *regexp.Regexp + ask openpgp.PromptFunction ) func init() { @@ -175,11 +176,8 @@ func GPGPrompt(keys []openpgp.Key, symmetric bool) ([]byte, error) { } func (s *Store) Decrypt(name string, prompts ...func() []byte) (string,error) { - var ask openpgp.PromptFunction if len(prompts) > 0 { ask = AskPass(prompts...) - } else { - ask = GPGPrompt } file := path.Join(s.Dir, strings.Join([]string{name,".gpg"},"")) if _, err := os.Stat(file); os.IsNotExist(err) {