Add README.md.

This commit is contained in:
Greg 2019-09-04 22:21:01 -04:00
parent e8a4ad031b
commit 9c711e9022
5 changed files with 36 additions and 14 deletions

24
README.md Normal file
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"
"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)

View File

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

View File

@ -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() {

View File

@ -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) {