Skip to content

Commit 123ba1b

Browse files
authored
Merge pull request #124 from eyJhb/master
pass: changed the way for checking if password-store is initalized
2 parents 73e5f5d + 9c18f03 commit 123ba1b

File tree

1 file changed

+3
-18
lines changed

1 file changed

+3
-18
lines changed

pass/pass_linux.go

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -46,25 +46,10 @@ func (p Pass) checkInitialized() error {
4646
if passInitialized {
4747
return nil
4848
}
49-
// In principle, we could just run `pass init`. However, pass has a bug
50-
// where if gpg fails, it doesn't always exit 1. Additionally, pass
51-
// uses gpg2, but gpg is the default, which may be confusing. So let's
52-
// just explictily check that pass actually can store and retreive a
53-
// password.
54-
password := "pass is initialized"
55-
name := path.Join(getPassDir(), "docker-pass-initialized-check")
56-
57-
_, err := p.runPassHelper(password, "insert", "-f", "-m", name)
49+
// We just run a `pass ls`, if it fails then pass is not initialized.
50+
_, err := p.runPassHelper("", "ls")
5851
if err != nil {
59-
return fmt.Errorf("error initializing pass: %v", err)
60-
}
61-
62-
stored, err := p.runPassHelper("", "show", name)
63-
if err != nil {
64-
return fmt.Errorf("error fetching password during initialization: %v", err)
65-
}
66-
if stored != password {
67-
return fmt.Errorf("error round-tripping password during initialization: %q != %q", password, stored)
52+
return fmt.Errorf("pass not initialized: %v", err)
6853
}
6954
passInitialized = true
7055
return nil

0 commit comments

Comments
 (0)