[PATCH himitsu v2] himitsud: query: improve prompter closing
Export this patch
Fix that the prompter was left open if used for unlock, decryption is
desired but there is no matches.
---
cmd/himitsud/cmd.ha | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/cmd/himitsud/cmd.ha b/cmd/himitsud/cmd.ha
index ce17c7d..3bc7e43 100644
--- a/cmd/himitsud/cmd.ha
+++ b/cmd/himitsud/cmd.ha
@@ -182,6 +182,9 @@ fn exec_query(serv: *server, client: *client, args: []str) (void | cmderror) = {
};
let prompter: (prompt::prompter | void) = void;
+ defer if (prompter is prompt::prompter) {
+ prompt::close(&(prompter: prompt::prompter))!;
+ };
if (serv.store.state == secstore::state::HARD_LOCKED) {
const new = prompt::newprompter(serv.conf.prompter[0],
serv.conf.prompter[1..])?;
@@ -190,9 +193,6 @@ fn exec_query(serv: *server, client: *client, args: []str) (void | cmderror) = {
writefmt(client, "error Failed to unlock");
return;
};
- if (!decrypt) {
- prompt::close(&new)?;
- };
prompter = new;
};
@@ -214,6 +214,8 @@ fn exec_query(serv: *server, client: *client, args: []str) (void | cmderror) = {
if (len(matches) > 0 && decrypt) {
const prompter = match (prompter) {
case let p: prompt::prompter =>
+ // Take the ownership since prompt::wait will also close it
+ prompter = void;
yield p;
case void =>
yield prompt::newprompter(serv.conf.prompter[0],
--
2.41.0
Thanks!
To https://git.sr.ht/~sircmpwn/himitsu
734a34b.. master -> master