aboutsummaryrefslogtreecommitdiffstats
path: root/agent/agent.h
diff options
context:
space:
mode:
authorNIIBE Yutaka <[email protected]>2017-10-27 00:54:48 +0000
committerWerner Koch <[email protected]>2017-10-27 12:15:58 +0000
commit3924e1442c6625a2b57573a1a634a5ec56b09a29 (patch)
treeeaea4b4a9e471d5585851ae70b8d937362127b01 /agent/agent.h
parentagent: Allow recursive use of pinentry. (diff)
downloadgnupg-3924e1442c6625a2b57573a1a634a5ec56b09a29.tar.gz
gnupg-3924e1442c6625a2b57573a1a634a5ec56b09a29.zip
agent: Clean up pinentry access locking.
* agent/agent.h (struct server_control_s): Rename PINENTRY_ACTIVE. * agent/call-pinentry.c (entry_owner): Remove. (agent_reset_query): Use thread private object of PINENTRY_ACTIVE. (unlock_pinentry): Add CTRL to arguments to access thread private. Check and decrement PINENTRY_ACTIVE for recursive use. (start_pinentry): Check and increment PINENTRY_ACTIVE for recursion. (agent_askpin): Follow the change of unlock_pinentry API. (agent_get_passphrase, agent_get_confirmation): Likewise. (agent_show_message, agent_popup_message_start): Likewise. (agent_popup_message_stop, agent_clear_passphrase): Likewise. -- We use the member PINENTRY_ACTIVE as a thread private object. It's only valid for a single thread at a time. It would be possible to have a thread shared object of PINENTRY_ACTIVE, keeping ENTRY_OWNER for distinguishing its owner (which is also a thread shared object). But, in this case, access to ENTRY_OWNER is tricky (only comparison to accessing thread would be OK with no lock), or we need to introduce another lock for accessing ENTRY_OWNER, which complicates the code too much. So, simply have a thread private object for recursive pinentry access. GnuPG-bug-id: 3190 Signed-off-by: NIIBE Yutaka <[email protected]> (cherry picked from commit fb7828676cc2c01047498898378711e049f73fee)
Diffstat (limited to 'agent/agent.h')
-rw-r--r--agent/agent.h5
1 files changed, 3 insertions, 2 deletions
diff --git a/agent/agent.h b/agent/agent.h
index cde38fe4a..7bb46faa1 100644
--- a/agent/agent.h
+++ b/agent/agent.h
@@ -255,8 +255,9 @@ struct server_control_s
count. */
unsigned long s2k_count;
- /* Recursion level of pinentry. */
- int pinentry_level;
+ /* If pinentry is active for this thread. It can be more than 1,
+ when pinentry is called recursively. */
+ int pinentry_active;
};