Page MenuHome GnuPG

Pinentry shows on incorrect terminal
Closed, ResolvedPublic

Description

After starting agent, sometimes pinentry shows on terminal under which agent
was started.

  1. run xterm, rxvt or similar, notice that is for example /dev/pts/1
  2. run gpg-agent in it (*without* keep-tty option)
  3. run another xterm, notice that is, for example, /dev/pts/2
  4. try to use gpg with agent
  5. pinentry shows on first xterm

My suspect: in session-env.c
in function
static gpg_error_t
update_var (session_env_t se, const char *string, size_t namelen,

const char *explicit_value, int set_default)

we have
#v+
if (strlen (se->array[idx]->value) == valuelen)
#v-

shouldn't be something like:
#v+
if (!strncmp(se->array[idx]->value,explicit_value, valuelen))
#v-
here?

Details

Version
2.x

Event Timeline

Of course GPG_TTY is set properly in both xterm sessions

werner set Version to 2.x.
werner added a subscriber: werner.

You are right, that is faulty. The correct code is:

if (strlen (se->array[idx]->value) == valuelen)
  {
    /* The new value has the same length.  We can update it
       in-place.  */
    if (memcmp (se->array[idx]->value, value, valuelen))
      memcpy (se->array[idx]->value, value, valuelen);
    se->array[idx]->is_default = !!set_default;
    return 0;
  }

I fixed it in trunk and will backport it to 2.0.

It's fixed in 2.0.18 (as the T1203 was closed).

gniibe claimed this task.