Skip to content

Commit

Permalink
Use shorter SSH control path
Browse files Browse the repository at this point in the history
Fixes #1896

RELEASE_NOTES=[BUGFIX] Fix SSH control path

Signed-off-by: Dominik Schulz <dominik.schulz@gauner.org>
  • Loading branch information
dominikschulz committed Apr 5, 2021
1 parent 274c552 commit 3377916
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
8 changes: 7 additions & 1 deletion internal/backend/storage/fs/fsck.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/gopasspw/gopass/pkg/ctxutil"
"github.com/gopasspw/gopass/pkg/debug"
"github.com/gopasspw/gopass/pkg/fsutil"
"github.com/gopasspw/gopass/pkg/termio"
)

// Fsck checks the storage integrity
Expand Down Expand Up @@ -47,7 +48,12 @@ func (s *Store) Fsck(ctx context.Context) error {
}

debug.Log("checking root dir %q", s.path)
return s.fsckCheckDir(ctx, s.path)
if err := s.fsckCheckDir(ctx, s.path); err != nil {
return err
}

debug.Log("checking git config")
return s.InitConfig(ctx, termio.DetectName(ctx, nil), termio.DetectEmail(ctx, nil))
}

func (s *Store) fsckCheckFile(ctx context.Context, filename string) error {
Expand Down
5 changes: 4 additions & 1 deletion internal/backend/storage/gitfs/ssh_others.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ import "os"
//
// Note: Setting GIT_SSH_COMMAND, possibly to an empty string, will take
// precedence over this setting.
//
// %C is a hash of %l%h%p%r and should avoid "path too long for unix domain socket"
// errors.
func gitSSHCommand() string {
return "ssh -oControlMaster=auto -oControlPersist=600 -oControlPath=" + os.TempDir() + "/.gopass-ssh-${USER}-%r@%h:%p"
return "ssh -oControlMaster=auto -oControlPersist=600 -oControlPath=" + os.TempDir() + "/.ssh-%C"
}
3 changes: 3 additions & 0 deletions internal/store/leaf/fsck.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ func (s *Store) fsckCheckEntry(ctx context.Context, name string) error {
}

// check itemRecps matches storeRecps
// TODO we need to noramlize both slices before we can compare them,
// otherwise one might contain a short key id or a name while the other has
// the full key id
missing, extra := compareStringSlices(perItemStoreRecps, itemRecps)
if len(missing) > 0 {
out.Errorf(ctx, "Missing recipients on %s: %+v\nRun fsck with the --decrypt flag to re-encrypt it automatically, or edit this secret yourself.", name, missing)
Expand Down

0 comments on commit 3377916

Please sign in to comment.