Home GnuPG
Diffusion GnuPG 3b66a256e376

agent: Allow recursive use of pinentry.

Description

agent: Allow recursive use of pinentry.

* agent/agent.h (struct server_control_s): Add pinentry_level.
* agent/call-pinentry.c (agent_popup_message_stop): Not clear
ENTRY_CTX here.
(unlock_pinentry): Handle recursion.  Clear ENTRY_CTX here.
(start_pinentry): Allow recursive use.
  • GnuPG-bug-id: T3190
  • Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>

Details

Provenance
gniibeAuthored on Oct 26 2017, 7:40 AM
Parents
rGbf26c08b9538: agent, tests: Support --disable-scdaemon build case.
Branches
Unknown
Tags
Unknown
Tasks
T3190: Recursive call of pinentry

Event Timeline

werner added inline comments.
/agent/call-pinentry.c
180

The comment describing ENTRY_OWNER says that this variable shall ne ver be referenced. I am not 100% sure why I requested that constraint,

Would't it be easier to have a file global variable entry_level instead of ctrl->pinentry_level? Afaics, pinentry_level is only used while we are holding the mutex.

298

We should add a comment that we hold the mutex when arriving here.

I'm going to change the code a bit.

I'd imagine the comment for ENTRY_OWNER.
ENTRY_OWNER and ENTRY_CTX are shared objects among threads.
The principle (for mutual exclusion) is: Those objects should be accessed only after it gets ENTRY_LOCK.
But, it is OK to just compare the address to the one of accessing thread.

The reason why I put pinentry_level member to CTRL structure is to make it clear that it's a private object only for a thread, not shared by among threads.
But, it's waste of memory.

The code can be changed like:

  • ENTRY_LOCK for mutual exclusion for ENTRY_CTX and pinentry communication
  • Add ENTRY_OWNER_LOCK for mutual exclusion for accessing ENTRY_OWNER and ENTRY_LEVEL.

But, it complicates the code.
I'd like simpler waste of memory approach of adding private member to CTRL.