Package: pinentry / 1.0.0-2

0002-Fix-linkage-problem-in-tty-and-emacs-pinentries.patch Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
From: Werner Koch <wk@gnupg.org>
Date: Thu, 1 Dec 2016 09:10:08 +0100
Subject: Fix linkage problem in tty and emacs pinentries.

* emacs/pinentry-emacs.c (curses_cmd_handler): Remove var.
* tty/pinentry-tty.c (curses_cmd_handler): Remove var.
* pinentry/pinentry.c (flavor_flag): New local var.
(pinentry_set_flavor_flag): New function.
(cmd_getinfo): Use FLAVOR_FLAG for the "flavor" sub-command.
* gnome3/pinentry-gnome3.c (main): Call pinentry_set_flavor_flag.
* gtk+-2/pinentry-gtk-2.c (main): Ditto.
* pinentry/pinentry-emacs.c (initial_emacs_cmd_handler): Ditto.
* qt/main.cpp (main): Ditto.
--

Fixes-commit: e4e3a9cc88704dcffac660d0b92fd1ed8abecc11
Fixes-commit: d126036671e7dd631babc118cb4113f723f15748
Signed-off-by: Werner Koch <wk@gnupg.org>
(cherry picked from commit c5c7bee68730c9f66a27f9bb0d023480623a2bfb)
---
 emacs/pinentry-emacs.c    |  4 ----
 gnome3/pinentry-gnome3.c  |  3 +++
 gtk+-2/pinentry-gtk-2.c   | 10 ++++++++--
 pinentry/pinentry-emacs.c |  5 ++++-
 pinentry/pinentry.c       | 34 ++++++++++++++++++----------------
 pinentry/pinentry.h       |  4 ++++
 qt/main.cpp               |  1 +
 tty/pinentry-tty.c        |  3 ---
 8 files changed, 38 insertions(+), 26 deletions(-)

diff --git a/emacs/pinentry-emacs.c b/emacs/pinentry-emacs.c
index b6b3eb8..3c39a96 100644
--- a/emacs/pinentry-emacs.c
+++ b/emacs/pinentry-emacs.c
@@ -29,10 +29,6 @@
 
 pinentry_cmd_handler_t pinentry_cmd_handler = emacs_cmd_handler;
 
-/* needed to link cleanly; should never be used except for comparison
- * in pinentry/pinentry.c's cmd_getinfo(): */
-pinentry_cmd_handler_t curses_cmd_handler = NULL;
-
 
 
 int
diff --git a/gnome3/pinentry-gnome3.c b/gnome3/pinentry-gnome3.c
index a040f9b..d5a49d6 100644
--- a/gnome3/pinentry-gnome3.c
+++ b/gnome3/pinentry-gnome3.c
@@ -517,18 +517,21 @@ main (int argc, char *argv[])
       fprintf (stderr, "No $DBUS_SESSION_BUS_ADDRESS found,"
                " falling back to curses\n");
       pinentry_cmd_handler = curses_cmd_handler;
+      pinentry_set_flavor_flag ("curses");
     }
   else if (!pe_gcr_system_prompt_available ())
     {
       fprintf (stderr, "No Gcr System Prompter available,"
                " falling back to curses\n");
       pinentry_cmd_handler = curses_cmd_handler;
+      pinentry_set_flavor_flag ("curses");
     }
   else if (pe_gnome_screen_locked ())
     {
       fprintf (stderr, "GNOME screensaver is locked,"
                " falling back to curses\n");
       pinentry_cmd_handler = curses_cmd_handler;
+      pinentry_set_flavor_flag ("curses");
     }
 #endif
 
diff --git a/gtk+-2/pinentry-gtk-2.c b/gtk+-2/pinentry-gtk-2.c
index 6037533..473c4aa 100644
--- a/gtk+-2/pinentry-gtk-2.c
+++ b/gtk+-2/pinentry-gtk-2.c
@@ -938,10 +938,16 @@ main (int argc, char *argv[])
   if (pinentry_have_display (argc, argv))
     {
       if (! gtk_init_check (&argc, &argv))
-	pinentry_cmd_handler = curses_cmd_handler;
+        {
+          pinentry_cmd_handler = curses_cmd_handler;
+          pinentry_set_flavor_flag ("curses");
+        }
     }
   else
-    pinentry_cmd_handler = curses_cmd_handler;
+    {
+      pinentry_cmd_handler = curses_cmd_handler;
+      pinentry_set_flavor_flag ("curses");
+    }
 #else
   gtk_init (&argc, &argv);
 #endif
diff --git a/pinentry/pinentry-emacs.c b/pinentry/pinentry-emacs.c
index df12f1b..50ba406 100644
--- a/pinentry/pinentry-emacs.c
+++ b/pinentry/pinentry-emacs.c
@@ -644,7 +644,10 @@ initial_emacs_cmd_handler (pinentry_t pe)
   if (emacs_socket < 0)
     pinentry_cmd_handler = fallback_cmd_handler;
   else
-    pinentry_cmd_handler = emacs_cmd_handler;
+    {
+      pinentry_cmd_handler = emacs_cmd_handler;
+      pinentry_set_flavor_flag ("emacs");
+    }
 
   return (* pinentry_cmd_handler) (pe);
 }
diff --git a/pinentry/pinentry.c b/pinentry/pinentry.c
index 322a651..a198fb3 100644
--- a/pinentry/pinentry.c
+++ b/pinentry/pinentry.c
@@ -67,6 +67,10 @@ static char this_pgmname[50];
 
 struct pinentry pinentry;
 
+
+static const char *flavor_flag;
+
+
 static void
 pinentry_reset (int use_defaults)
 {
@@ -793,6 +797,16 @@ pinentry_parse_opts (int argc, char *argv[])
     }
 }
 
+
+/* Set the optional flag used with getinfo. */
+void
+pinentry_set_flavor_flag (const char *string)
+{
+  flavor_flag = string;
+}
+
+
+
 
 static gpg_error_t
 option_handler (assuan_context_t ctx, const char *key, const char *value)
@@ -1444,27 +1458,15 @@ cmd_getinfo (assuan_context_t ctx, char *line)
     }
   else if (!strcmp (line, "flavor"))
     {
-      const char *flags;
-
       if (!strncmp (this_pgmname, "pinentry-", 9) && this_pgmname[9])
         s = this_pgmname + 9;
       else
         s = this_pgmname;
 
-      if (0)
-        ;
-#ifdef INSIDE_EMACS
-      else if (pinentry_cmd_handler == emacs_cmd_handler)
-        flags = ":emacs";
-#endif
-#ifdef FALLBACK_CURSES
-      else if (pinentry_cmd_handler == curses_cmd_handler)
-        flags = ":curses";
-#endif
-      else
-        flags = "";
-
-      snprintf (buffer, sizeof buffer, "%s%s", s, flags);
+      snprintf (buffer, sizeof buffer, "%s%s%s",
+                s,
+                flavor_flag? ":":"",
+                flavor_flag? flavor_flag : "");
       buffer[sizeof buffer -1] = 0;
       rc = assuan_send_data (ctx, buffer, strlen (buffer));
     }
diff --git a/pinentry/pinentry.h b/pinentry/pinentry.h
index 01fb373..45d35ad 100644
--- a/pinentry/pinentry.h
+++ b/pinentry/pinentry.h
@@ -275,6 +275,10 @@ int pinentry_have_display (int argc, char **argv);
    or version output is requested.  */
 void pinentry_parse_opts (int argc, char *argv[]);
 
+/* Set the optional flag used with getinfo. */
+void pinentry_set_flavor_flag (const char *string);
+
+
 
 /* The caller must define this variable to process assuan commands.  */
 extern pinentry_cmd_handler_t pinentry_cmd_handler;
diff --git a/qt/main.cpp b/qt/main.cpp
index 8284960..225c06b 100644
--- a/qt/main.cpp
+++ b/qt/main.cpp
@@ -308,6 +308,7 @@ main(int argc, char *argv[])
 #ifdef FALLBACK_CURSES
     if (!pinentry_have_display(argc, argv)) {
         pinentry_cmd_handler = curses_cmd_handler;
+        pinentry_set_flavor_flag ("curses");
     } else
 #endif
     {
diff --git a/tty/pinentry-tty.c b/tty/pinentry-tty.c
index 3d6cd5a..a509d79 100644
--- a/tty/pinentry-tty.c
+++ b/tty/pinentry-tty.c
@@ -556,9 +556,6 @@ tty_cmd_handler(pinentry_t pinentry)
 
 pinentry_cmd_handler_t pinentry_cmd_handler = tty_cmd_handler;
 
-/* needed to link cleanly; should never be used except for comparison
- * in pinentry/pinentry.c's cmd_getinfo(): */
-pinentry_cmd_handler_t curses_cmd_handler = NULL;
 
 
 int