chiark / gitweb /
Import gnupg2_2.1.18-8~deb9u1.debian.tar.bz2
[gnupg2.git] / patches / 0026-gpg-More-diagnostics-for-a-launched-pinentry.patch
1 From: Werner Koch <wk@gnupg.org>
2 Date: Fri, 3 Feb 2017 12:04:52 +0100
3 Subject: gpg: More diagnostics for a launched pinentry.
4
5 * agent/call-pinentry.c (start_pinentry): Call getinfo/ttyinfo.
6 * g10/server.c (gpg_proxy_pinentry_notify): Simplify the output so
7 that we do not change the code when adding new fields to
8 PINENTRY_LAUNCHED.
9 --
10
11 This patch changes the --verbose output of gpg to show
12 for example
13
14   gpg: pinentry launched (5228 gtk2 1.0.1-beta10 \
15   /dev/pts/4 xterm localhost:10.0)
16
17 the used tty, its type, and the value of DISPLAY in addiion to the
18 pid, flavor, and version.
19
20 Signed-off-by: Werner Koch <wk@gnupg.org>
21 (cherry picked from commit 7052a0d77cf8f3a445b252a809d29be445788625)
22 ---
23  agent/call-pinentry.c |  6 +++++-
24  g10/server.c          | 19 ++++++++-----------
25  2 files changed, 13 insertions(+), 12 deletions(-)
26
27 diff --git a/agent/call-pinentry.c b/agent/call-pinentry.c
28 index fa00bf921..2bebee205 100644
29 --- a/agent/call-pinentry.c
30 +++ b/agent/call-pinentry.c
31 @@ -541,7 +541,7 @@ start_pinentry (ctrl_t ctrl)
32      }
33  
34  
35 -  /* Ask the pinentry for its version and flavor and streo that as a
36 +  /* Ask the pinentry for its version and flavor and store that as a
37     * string in MB.  This information is useful for helping users to
38     * figure out Pinentry problems.  */
39    {
40 @@ -555,6 +555,10 @@ start_pinentry (ctrl_t ctrl)
41      if (assuan_transact (entry_ctx, "GETINFO version",
42                           put_membuf_cb, &mb, NULL, NULL, NULL, NULL))
43        put_membuf_str (&mb, "unknown");
44 +    put_membuf_str (&mb, " ");
45 +    if (assuan_transact (entry_ctx, "GETINFO ttyinfo",
46 +                         put_membuf_cb, &mb, NULL, NULL, NULL, NULL))
47 +      put_membuf_str (&mb, "? ? ?");
48      put_membuf (&mb, "", 1);
49      flavor_version = get_membuf (&mb, NULL);
50    }
51 diff --git a/g10/server.c b/g10/server.c
52 index b89f0be69..e3a3bad22 100644
53 --- a/g10/server.c
54 +++ b/g10/server.c
55 @@ -770,18 +770,15 @@ gpg_server (ctrl_t ctrl)
56  gpg_error_t
57  gpg_proxy_pinentry_notify (ctrl_t ctrl, const unsigned char *line)
58  {
59 -  if (opt.verbose)
60 -    {
61 -      char *linecopy = xtrystrdup (line);
62 -      char *fields[4];
63 -
64 -      if (linecopy
65 -          && split_fields (linecopy, fields, DIM (fields)) >= 4
66 -          && !strcmp (fields[0], "PINENTRY_LAUNCHED"))
67 -        log_info (_("pinentry launched (pid %s, flavor %s, version %s)\n"),
68 -                  fields[1], fields[2], fields[3]);
69 +  const char *s;
70  
71 -      xfree (linecopy);
72 +  if (opt.verbose
73 +      && !strncmp (line, "PINENTRY_LAUNCHED", 17)
74 +      && (line[17]==' '||!line[17]))
75 +    {
76 +      for (s = line + 17; *s && spacep (s); s++)
77 +        ;
78 +      log_info (_("pinentry launched (%s)\n"), s);
79      }
80  
81    if (!ctrl || !ctrl->server_local