Bug#851707: pinentry-gtk-2 frequently fails to grab the keyboard under awesome

2017-02-08 Thread Daniel Kahn Gillmor
On Mon 2017-02-06 04:49:44 -0500, Vincent Lefevre wrote:
> On 2017-02-02 19:29:19 +0100, Vincent Bernat wrote:
>> Index: pinentry-1.0.0/gtk+-2/pinentry-gtk-2.c
>> ===
>> --- pinentry-1.0.0.orig/gtk+-2/pinentry-gtk-2.c
>> +++ pinentry-1.0.0/gtk+-2/pinentry-gtk-2.c
> [...]
>> -  while (tries++ < max_tries && err == GDK_GRAB_NOT_VIEWABLE);
>> +  while (tries++ < max_tries && err == GDK_GRAB_NOT_VIEWABLE
>> + && (usleep(1000), TRUE));
> [...]
>>while (tries++ < max_tries && (err == GDK_GRAB_NOT_VIEWABLE
>> - || err == GDK_GRAB_ALREADY_GRABBED));
>> + || err == GDK_GRAB_ALREADY_GRABBED)
>> + && (usleep(1000), TRUE));
>
> I don't know how it has eventually been fixed, but FYI, usleep()
> is obsolete. The usleep(3) man page says:
>
>   CONFORMING TO
>   4.3BSD,  POSIX.1-2001.   POSIX.1-2001  declares this function
>   obsolete; use nanosleep(2) instead.  POSIX.1-2008 removes the
>   specification of usleep().

patches welcome to do the conversion if this matters to anyone. i'm not
going to lose any usleep over this deprecation right now, since i think
we'll have that function available for a long time in debian.

 --dkg


signature.asc
Description: PGP signature


Bug#851707: pinentry-gtk-2 frequently fails to grab the keyboard under awesome

2017-02-06 Thread Vincent Lefevre
On 2017-02-02 19:29:19 +0100, Vincent Bernat wrote:
> Index: pinentry-1.0.0/gtk+-2/pinentry-gtk-2.c
> ===
> --- pinentry-1.0.0.orig/gtk+-2/pinentry-gtk-2.c
> +++ pinentry-1.0.0/gtk+-2/pinentry-gtk-2.c
[...]
> -  while (tries++ < max_tries && err == GDK_GRAB_NOT_VIEWABLE);
> +  while (tries++ < max_tries && err == GDK_GRAB_NOT_VIEWABLE
> + && (usleep(1000), TRUE));
[...]
>while (tries++ < max_tries && (err == GDK_GRAB_NOT_VIEWABLE
> - || err == GDK_GRAB_ALREADY_GRABBED));
> + || err == GDK_GRAB_ALREADY_GRABBED)
> + && (usleep(1000), TRUE));

I don't know how it has eventually been fixed, but FYI, usleep()
is obsolete. The usleep(3) man page says:

  CONFORMING TO
  4.3BSD,  POSIX.1-2001.   POSIX.1-2001  declares this function
  obsolete; use nanosleep(2) instead.  POSIX.1-2008 removes the
  specification of usleep().

-- 
Vincent Lefèvre  - Web: 
100% accessible validated (X)HTML - Blog: 
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)



Bug#851707: [pkg-gnupg-maint] Bug#851707: pinentry-gtk-2 frequently fails to grab the keyboard under awesome

2017-02-03 Thread Vincent Bernat
 ❦  3 février 2017 12:14 +0100, Werner Koch  :

>> I am fixing with this patch. Only lightly tested.
>
> FWIW, I forgot to push a fix I had in my local repo.  Just did this, put
> also not tested.  This is basically the same as yours but w/o any
> delay.

I think your patch is about #850708. In #851707, I don't get the
"already grabbed" error, I get:

** (pinentry-gtk-2:21583): CRITICAL **: could not grab keyboard: not viewable 
(3)
** (pinentry-gtk-2:21583): WARNING **: it took 4097 tries to grab the keyboard
-- 
Keep it right when you make it faster.
- The Elements of Programming Style (Kernighan & Plauger)


signature.asc
Description: PGP signature


Bug#851707: [pkg-gnupg-maint] Bug#851707: pinentry-gtk-2 frequently fails to grab the keyboard under awesome

2017-02-03 Thread Werner Koch
On Thu,  2 Feb 2017 19:29, ber...@debian.org said:

> I am fixing with this patch. Only lightly tested.

FWIW, I forgot to push a fix I had in my local repo.  Just did this, put
also not tested.  This is basically the same as yours but w/o any delay.

Shalom-Salam,

   Werner


commit b0e0bdeac5d40ca645afc9017778b39a26303523
Author: Werner Koch 
Date:   Wed Jan 11 18:40:17 2017 +0100

gtk2: Fix a problem with fvwm

* gtk+-2/pinentry-gtk-2.c (grab_pointer): Take care of
GDK_GRAB_ALREADY_GRABBED.
--

Debian-bug-id: 850708
Co-authored-by: Vincent Lefevre 
Signed-off-by: Werner Koch 

Modified   gtk+-2/pinentry-gtk-2.c
diff --git a/gtk+-2/pinentry-gtk-2.c b/gtk+-2/pinentry-gtk-2.c
index 473c4aa..e37601f 100644
--- a/gtk+-2/pinentry-gtk-2.c
+++ b/gtk+-2/pinentry-gtk-2.c
@@ -203,7 +203,12 @@ grab_pointer (GtkWidget *win, GdkEvent *event, gpointer 
data)
   (void)data;
 
   /* Change the cursor for the duration of the grab to indicate that
- something is going on.  */
+   * something is going on.  The fvwm window manager grabs the pointer
+   * for a short time and thus we may end up with the already grabbed
+   * error code.  Actually this error code should be used to detect a
+   * malicious grabbing application but with fvwm this renders
+   * Pinentry only unusable.  Thus we try again several times also for
+   * that error code.  See Debian bug 850708 for details.  */
   /* XXX: It would be nice to have a key cursor, unfortunately there
  is none readily available.  */
   cursor = gdk_cursor_new_for_display (gtk_widget_get_display (win),
@@ -215,7 +220,8 @@ grab_pointer (GtkWidget *win, GdkEvent *event, gpointer 
data)
 NULL /* confine to */,
 cursor,
 gdk_event_get_time (event));
-  while (tries++ < max_tries && err == GDK_GRAB_NOT_VIEWABLE);
+  while (tries++ < max_tries && (err == GDK_GRAB_NOT_VIEWABLE
+ || err == GDK_GRAB_ALREADY_GRABBED));
 
   if (err)
 {


-- 
Die Gedanken sind frei.  Ausnahmen regelt ein Bundesgesetz.


pgpkegKbC5D6l.pgp
Description: PGP signature


Processed: Re: Bug#851707: pinentry-gtk-2 frequently fails to grab the keyboard under awesome

2017-02-02 Thread Debian Bug Tracking System
Processing control commands:

> tags -1 + patch
Bug #851707 [pinentry-gtk2] pinentry-gtk-2 frequently fails to grab the 
keyboard under awesome
Ignoring request to alter tags of bug #851707 to the same tags previously set

-- 
851707: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=851707
Debian Bug Tracking System
Contact ow...@bugs.debian.org with problems



Bug#851707: pinentry-gtk-2 frequently fails to grab the keyboard under awesome

2017-02-02 Thread Vincent Bernat
Control: tags -1 + patch

 ❦  2 février 2017 10:50 +0200, Lauri Niskanen  :

> I can reproduce this bug with awesomewm on Arch Linux. I get the same
> error message as Vincent Bernat.
>
> As a workaround I changed my pinentry program to pinentry-gnome3.

I am fixing with this patch. Only lightly tested.

Index: pinentry-1.0.0/gtk+-2/pinentry-gtk-2.c
===
--- pinentry-1.0.0.orig/gtk+-2/pinentry-gtk-2.c
+++ pinentry-1.0.0/gtk+-2/pinentry-gtk-2.c
@@ -166,7 +166,7 @@ static int
 grab_keyboard (GtkWidget *win, GdkEvent *event, gpointer data)
 {
   GdkGrabStatus err;
-  int tries = 0, max_tries = 4096;
+  int tries = 0, max_tries = 256;
   (void)data;
 
   if (! pinentry->grab)
@@ -175,7 +175,8 @@ grab_keyboard (GtkWidget *win, GdkEvent
   do
 err = gdk_keyboard_grab (gtk_widget_get_window (win),
  FALSE, gdk_event_get_time (event));
-  while (tries++ < max_tries && err == GDK_GRAB_NOT_VIEWABLE);
+  while (tries++ < max_tries && err == GDK_GRAB_NOT_VIEWABLE
+ && (usleep(1000), TRUE));
 
   if (err)
 {
@@ -199,7 +200,7 @@ grab_pointer (GtkWidget *win, GdkEvent *
 {
   GdkGrabStatus err;
   GdkCursor *cursor;
-  int tries = 0, max_tries = 4096;
+  int tries = 0, max_tries = 256;
   (void)data;
 
   /* Change the cursor for the duration of the grab to indicate that
@@ -221,7 +222,8 @@ grab_pointer (GtkWidget *win, GdkEvent *
 cursor,
 gdk_event_get_time (event));
   while (tries++ < max_tries && (err == GDK_GRAB_NOT_VIEWABLE
- || err == GDK_GRAB_ALREADY_GRABBED));
+ || err == GDK_GRAB_ALREADY_GRABBED)
+ && (usleep(1000), TRUE));
 
   if (err)
 {

-- 
Use uniform input formats.
- The Elements of Programming Style (Kernighan & Plauger)


signature.asc
Description: PGP signature


Bug#851707: pinentry-gtk-2 frequently fails to grab the keyboard under awesome

2017-02-02 Thread Lauri Niskanen
I can reproduce this bug with awesomewm on Arch Linux. I get the same 
error message as Vincent Bernat.


As a workaround I changed my pinentry program to pinentry-gnome3.

--
Lauri Niskanen