Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix .gpg-id selection for subfolders #465

Merged
merged 1 commit into from
Nov 14, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions store/sub/recipients.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,10 @@ func (s *Store) OurKeyID(ctx context.Context) string {

// GetRecipients will load all Recipients from the .gpg-id file for the given
// secret path
func (s *Store) GetRecipients(ctx context.Context, file string) ([]string, error) {
idf := s.idFile(file)
func (s *Store) GetRecipients(ctx context.Context, name string) ([]string, error) {
idf := s.idFile(name)

out.Debug(ctx, "GetRecipients(%s) - idfile: %s", name, idf)
// open recipient list (store/.gpg-id)
f, err := os.Open(idf)
if err != nil {
Expand Down
8 changes: 4 additions & 4 deletions store/sub/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ func New(alias string, path string) *Store {
// idFile returns the path to the recipient list for this store
// it walks up from the given filename until it finds a directory containing
// a gpg id file or it leaves the scope of this store.
func (s *Store) idFile(fn string) string {
fn, err := filepath.Abs(filepath.Join(s.path, fn))
func (s *Store) idFile(name string) string {
fn, err := filepath.Abs(filepath.Join(s.path, name))
if err != nil {
panic(err)
}
Expand Down Expand Up @@ -96,8 +96,8 @@ func (s *Store) Exists(name string) bool {
return fsutil.IsFile(p)
}

func (s *Store) useableKeys(ctx context.Context, file string) ([]string, error) {
rs, err := s.GetRecipients(ctx, file)
func (s *Store) useableKeys(ctx context.Context, name string) ([]string, error) {
rs, err := s.GetRecipients(ctx, name)
if err != nil {
return nil, errors.Wrapf(err, "failed to get recipients")
}
Expand Down
2 changes: 1 addition & 1 deletion store/sub/write.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func (s *Store) Set(ctx context.Context, name string, sec *secret.Secret) error
return errors.Errorf("a folder named %s already exists", name)
}

recipients, err := s.useableKeys(ctx, p)
recipients, err := s.useableKeys(ctx, name)
if err != nil {
return errors.Wrapf(err, "failed to list useable keys for '%s'", p)
}
Expand Down