Add README.md.

This commit is contained in:
Greg 2019-09-04 22:32:19 -04:00
parent 114530a2fa
commit 58d80a181b
5 changed files with 36 additions and 14 deletions

View File

@ -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)
}
}
}
```

View File

@ -27,12 +27,12 @@ import (
"golang.org/x/image/font/sfnt" "golang.org/x/image/font/sfnt"
"git.wow.st/gmp/pass" "git.wow.st/gmp/gpass"
) )
func main() { func main() {
var err error var err error
store,err = pass.GetStore() store,err = gpass.GetStore()
if err != nil { if err != nil {
log(Fatal, err) log(Fatal, err)
} }
@ -45,9 +45,9 @@ func main() {
} }
var ( var (
l []pass.Pass l []gpass.Pass
mux sync.Mutex mux sync.Mutex
store *pass.Store store *gpass.Store
updated chan struct{} updated chan struct{}
) )
@ -224,7 +224,7 @@ func eventLoop() {
//p,err := store.Decrypt(name, prompt) //p,err := store.Decrypt(name, prompt)
p,err := store.Decrypt(name) p,err := store.Decrypt(name)
if err == nil { if err == nil {
pass.Clip(p) gpass.Clip(p)
} else { } else {
log(Info,"Can't decrypt ", name) log(Info,"Can't decrypt ", name)
log(Info,err) log(Info,err)

View File

@ -6,7 +6,7 @@ import (
"path" "path"
"strings" "strings"
"gitlab.wow.st/gmp/pass" "git.wow.st/gmp/gpass"
) )
func usage() { func usage() {
@ -35,7 +35,7 @@ func parse(args []string) ([]string,options) {
} }
func main() { func main() {
store,err := pass.GetStore() store,err := gpass.GetStore()
if err != nil { if err != nil {
fmt.Println(err) fmt.Println(err)
os.Exit(-1) os.Exit(-1)
@ -64,13 +64,12 @@ func main() {
os.Exit(-1) os.Exit(-1)
} }
if opts.clip { if opts.clip {
pass.Clip(p) gpass.Clip(p)
} else { } else {
fmt.Print(p) fmt.Print(p)
} }
default: default:
usage() usage()
} }
pass.AskPass2()
} }

View File

@ -1,6 +1,6 @@
//+build !android !linux //+build !android !linux
package pass package gpass
import ( import (
"fmt" "fmt"
@ -70,6 +70,7 @@ func setAgentInfo() {
s := fmt.Sprintf("%s:%d:1", filename, pid) s := fmt.Sprintf("%s:%d:1", filename, pid)
fmt.Printf("GPG_AGENT_INFO = %s\n", s) fmt.Printf("GPG_AGENT_INFO = %s\n", s)
os.Setenv("GPG_AGENT_INFO",s) os.Setenv("GPG_AGENT_INFO",s)
ask = GPGPrompt
} }
func init() { func init() {

View File

@ -1,4 +1,4 @@
package pass package gpass
import ( import (
"bufio" "bufio"
@ -22,6 +22,7 @@ import (
var ( var (
basename *regexp.Regexp basename *regexp.Regexp
ask openpgp.PromptFunction
) )
func init() { 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) { func (s *Store) Decrypt(name string, prompts ...func() []byte) (string,error) {
var ask openpgp.PromptFunction
if len(prompts) > 0 { if len(prompts) > 0 {
ask = AskPass(prompts...) ask = AskPass(prompts...)
} else {
ask = GPGPrompt
} }
file := path.Join(s.Dir, strings.Join([]string{name,".gpg"},"")) file := path.Join(s.Dir, strings.Join([]string{name,".gpg"},""))
if _, err := os.Stat(file); os.IsNotExist(err) { if _, err := os.Stat(file); os.IsNotExist(err) {