Skip to content

Commit 53473b6

Browse files
authored
fix: gnoNativeService: In RotatePassword, call Lock() after getSigner (#190)
In gnoNativeService, `RotatePassword` calls `Lock` at the beginning of the function, then [calls `getSigner`](https://github.com/gnolang/gnonative/blob/cdd7bcbfc3b932396e3c469f65859b772d35d44a/service/api.go#L285) . But `getSigner` [calls `RLock`](https://github.com/gnolang/gnonative/blob/cdd7bcbfc3b932396e3c469f65859b772d35d44a/service/service.go#L193) which blocks, and `RotatePassword` never returns. (The effect is that Gnokey Mobile hangs during "Change Master Password".) This PR changes `RotatePassword` to call `Lock` after the loop which calls `getSigner`. This was tested by doing `make npm.pack` and installing it locally in Gnokey Mobile. Signed-off-by: Jeff Thompson <[email protected]>
1 parent cdd7bcb commit 53473b6

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

service/api.go

+2-3
Original file line numberDiff line numberDiff line change
@@ -275,9 +275,6 @@ func (s *gnoNativeService) SetPassword(ctx context.Context, req *connect.Request
275275
}
276276

277277
func (s *gnoNativeService) RotatePassword(ctx context.Context, req *connect.Request[api_gen.RotatePasswordRequest]) (*connect.Response[api_gen.RotatePasswordResponse], error) {
278-
s.lock.Lock()
279-
defer s.lock.Unlock()
280-
281278
// Get all the signers, before trying to update the password.
282279
var signers = make([]*gnoclient.SignerFromKeybase, len(req.Msg.Addresses))
283280
for i := range len(req.Msg.Addresses) {
@@ -287,6 +284,8 @@ func (s *gnoNativeService) RotatePassword(ctx context.Context, req *connect.Requ
287284
}
288285
}
289286

287+
s.lock.Lock()
288+
defer s.lock.Unlock()
290289
getNewPassword := func() (string, error) { return req.Msg.NewPassword, nil }
291290
for i := range len(req.Msg.Addresses) {
292291
if err := s.keybase.Rotate(signers[i].Account, signers[i].Password, getNewPassword); err != nil {

0 commit comments

Comments
 (0)