1
0
mirror of https://github.com/docker/docker-credential-helpers.git synced 2026-06-13 16:01:28 +05:30

Merge pull request #124 from eyJhb/master

pass: changed the way for checking if password-store is initalized
This commit is contained in:
Vincent Demeester
2018-09-25 10:51:22 +02:00
committed by GitHub
+3 -18
View File
@@ -46,25 +46,10 @@ func (p Pass) checkInitialized() error {
if passInitialized { if passInitialized {
return nil return nil
} }
// In principle, we could just run `pass init`. However, pass has a bug // We just run a `pass ls`, if it fails then pass is not initialized.
// where if gpg fails, it doesn't always exit 1. Additionally, pass _, err := p.runPassHelper("", "ls")
// uses gpg2, but gpg is the default, which may be confusing. So let's
// just explictily check that pass actually can store and retreive a
// password.
password := "pass is initialized"
name := path.Join(getPassDir(), "docker-pass-initialized-check")
_, err := p.runPassHelper(password, "insert", "-f", "-m", name)
if err != nil { if err != nil {
return fmt.Errorf("error initializing pass: %v", err) return fmt.Errorf("pass not initialized: %v", err)
}
stored, err := p.runPassHelper("", "show", name)
if err != nil {
return fmt.Errorf("error fetching password during initialization: %v", err)
}
if stored != password {
return fmt.Errorf("error round-tripping password during initialization: %q != %q", password, stored)
} }
passInitialized = true passInitialized = true
return nil return nil