Skip to content

Commit

Permalink
Merge pull request #105 from williammartin/master
Browse files Browse the repository at this point in the history
Fix suspected race condition in prompt handling
  • Loading branch information
mikkeloscar authored Mar 15, 2024
2 parents b0e756d + 70fd443 commit 987647a
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions secret_service/secret_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,12 +186,7 @@ func (s *SecretService) CreateItem(collection dbus.BusObject, label string, attr
// the prompt to the user.
func (s *SecretService) handlePrompt(prompt dbus.ObjectPath) (bool, dbus.Variant, error) {
if prompt != dbus.ObjectPath("/") {
err := s.Object(serviceName, prompt).Call(promptInterface+".Prompt", 0, "").Err
if err != nil {
return false, dbus.MakeVariant(""), err
}

err = s.AddMatchSignal(dbus.WithMatchObjectPath(prompt),
err := s.AddMatchSignal(dbus.WithMatchObjectPath(prompt),
dbus.WithMatchInterface(promptInterface),
)
if err != nil {
Expand All @@ -205,6 +200,11 @@ func (s *SecretService) handlePrompt(prompt dbus.ObjectPath) (bool, dbus.Variant
promptSignal := make(chan *dbus.Signal, 1)
s.Signal(promptSignal)

err = s.Object(serviceName, prompt).Call(promptInterface+".Prompt", 0, "").Err
if err != nil {
return false, dbus.MakeVariant(""), err
}

signal := <-promptSignal
switch signal.Name {
case promptInterface + ".Completed":
Expand Down

0 comments on commit 987647a

Please sign in to comment.