mirror of
https://github.com/docker/docker-credential-helpers.git
synced 2026-06-13 16:01: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:
+2
-17
@@ -46,26 +46,11 @@ 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("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
|
passInitialized = true
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user