mirror of
https://github.com/octoleo/restic.git
synced 2024-11-09 14:50:56 +00:00
Merge pull request #1227 from restic/fix-1204-2
Handle invalid key file
This commit is contained in:
commit
1a08a8219f
@ -319,7 +319,7 @@ func OpenRepository(opts GlobalOptions) (*repository.Repository, error) {
|
|||||||
|
|
||||||
err = s.SearchKey(context.TODO(), opts.password, maxKeys)
|
err = s.SearchKey(context.TODO(), opts.password, maxKeys)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Fatalf("unable to open repo: %v", err)
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return s, nil
|
return s, nil
|
||||||
|
@ -19,10 +19,10 @@ import (
|
|||||||
|
|
||||||
var (
|
var (
|
||||||
// ErrNoKeyFound is returned when no key for the repository could be decrypted.
|
// ErrNoKeyFound is returned when no key for the repository could be decrypted.
|
||||||
ErrNoKeyFound = errors.New("wrong password or no key found")
|
ErrNoKeyFound = errors.Fatal("wrong password or no key found")
|
||||||
|
|
||||||
// ErrMaxKeysReached is returned when the maximum number of keys was checked and no key could be found.
|
// ErrMaxKeysReached is returned when the maximum number of keys was checked and no key could be found.
|
||||||
ErrMaxKeysReached = errors.New("maximum number of keys reached")
|
ErrMaxKeysReached = errors.Fatal("maximum number of keys reached")
|
||||||
)
|
)
|
||||||
|
|
||||||
// Key represents an encrypted master key for a repository.
|
// Key represents an encrypted master key for a repository.
|
||||||
@ -133,7 +133,10 @@ func SearchKey(ctx context.Context, s *Repository, password string, maxKeys int)
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil, err
|
if err != nil {
|
||||||
|
debug.Log("unable to open key %v: %v\n", err)
|
||||||
|
continue
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
debug.Log("successfully opened key %v", name[:12])
|
debug.Log("successfully opened key %v", name[:12])
|
||||||
|
@ -68,7 +68,7 @@ func ParallelWorkFuncParseID(f ParallelIDWorkFunc) ParallelWorkFunc {
|
|||||||
id, err := restic.ParseID(s)
|
id, err := restic.ParseID(s)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
debug.Log("invalid ID %q: %v", id, err)
|
debug.Log("invalid ID %q: %v", id, err)
|
||||||
return err
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
return f(ctx, id)
|
return f(ctx, id)
|
||||||
|
Loading…
Reference in New Issue
Block a user