1
0
mirror of https://github.com/docker/docker-credential-helpers.git synced 2026-06-14 00:11:28 +05:30

pass: changed the way for checking if password-store is initalized

Signed-off-by: eyjhbb@gmail.com <eyjhbb@gmail.com>
This commit is contained in:
eyjhbb@gmail.com
2018-09-22 12:43:08 +02:00
parent 73e5f5dbfe
commit d6c1f136e4
+2 -17
View File
@@ -46,26 +46,11 @@ func (p Pass) checkInitialized() error {
if passInitialized {
return nil
}
// In principle, we could just run `pass init`. However, pass has a bug
// where if gpg fails, it doesn't always exit 1. Additionally, pass
// 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)
// We just run a `pass ls`, if it fails then pass is not initialized.
_, err := p.runPassHelper("", "ls")
if err != nil {
return fmt.Errorf("error initializing pass: %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
return nil
}