[git] Pinentry - branch, master, updated. pinentry-0.8.2-5-g31467f7

by Ben Kibbey cvs at cvs.gnupg.org
Thu Feb 14 03:44:17 CET 2013


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "The standard pinentry collection".

The branch, master has been updated
       via  31467f7c2cd748d6f822ccf627a2ce8870fb09c6 (commit)
       via  8ce6e0c9cecd91d7b1dfe8bcc9942803c13c7afb (commit)
       via  e3bed4f087304ac126e247053fc82a593bec31b6 (commit)
      from  d33537aef0358313cbcf1d010b227d93f3430900 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 31467f7c2cd748d6f822ccf627a2ce8870fb09c6
Author: Ben Kibbey <bjk at luxsci.net>
Date:   Wed Feb 13 21:31:24 2013 -0500

    Document the --timeout and SETTIMEOUT feature.

diff --git a/doc/pinentry.texi b/doc/pinentry.texi
index 967b933..a65298d 100644
--- a/doc/pinentry.texi
+++ b/doc/pinentry.texi
@@ -182,6 +182,13 @@ means to connect to the machine to kill the @pinentry{}).
 Use window ID @var{n} as the parent window for positioning the window.
 Note, that this is not fully supported by all flavors of @pinentry{}.
 
+ at item --timeout @var{seconds}
+ at opindex timeout
+Give up waiting for input from the user after the specified number of
+seconds and return an error. The error returned is the same as if the
+Cancel button was selected. To disable the timeout and wait indefinately
+then set to 0, the default.
+
 @item --display @var{string}
 @itemx --ttyname @var{string}
 @itemx --ttytype @var{string}
@@ -230,6 +237,12 @@ Here is the list of supported commands:
 
 @table @gnupgtabopt
 
+ at item Set the timeout before returning an error
+ at example
+  C: SETTIMEOUT 30
+  S: OK
+ at end example
+
 @item Set the descriptive text to be displayed
 @example
   C: SETDESC Enter PIN for Richard Nixon <nobody@@trickydicky.gov>

commit 8ce6e0c9cecd91d7b1dfe8bcc9942803c13c7afb
Author: Ben Kibbey <bjk at luxsci.net>
Date:   Wed Feb 13 21:14:23 2013 -0500

    Add timeout support to the Gtk+2 pinentry.
    
    * gtk+-2/pinentry-gtk-2.c (create_window): Add timer.
    (timeout_cb): New.

diff --git a/gtk+-2/pinentry-gtk-2.c b/gtk+-2/pinentry-gtk-2.c
index da4dc77..421bc02 100644
--- a/gtk+-2/pinentry-gtk-2.c
+++ b/gtk+-2/pinentry-gtk-2.c
@@ -64,6 +64,7 @@ static GtkWidget *insure;
 static GtkWidget *time_out;
 #endif
 static GtkTooltips *tooltips;
+static gboolean got_input;
 
 /* Gnome hig small and large space in pixels.  */
 #define HIG_SMALL      6
@@ -249,6 +250,8 @@ changed_text_handler (GtkWidget *widget)
   int percent;
   GdkColor color = { 0, 0, 0, 0};
 
+  got_input = TRUE;
+
   if (!qualitybar || !pinentry->quality_bar)
     return;
 
@@ -280,6 +283,15 @@ changed_text_handler (GtkWidget *widget)
 }
 
 
+static gboolean
+timeout_cb (gpointer data)
+{
+  (void)data;
+  if (!got_input)
+    gtk_main_quit ();
+  return FALSE;
+}
+
 
 static GtkWidget *
 create_window (int confirm_mode)
@@ -541,6 +553,9 @@ create_window (int confirm_mode)
   gtk_widget_show_all (win);
   gtk_window_present (GTK_WINDOW (win));  /* Make sure it has the focus.  */
 
+  if (pinentry->timeout > 0)
+    g_timeout_add (pinentry->timeout*1000, timeout_cb, NULL);
+
   return win;
 }
 
@@ -551,6 +566,7 @@ gtk_cmd_handler (pinentry_t pe)
   GtkWidget *w;
   int want_pass = !!pe->pin;
 
+  got_input = FALSE;
   pinentry = pe;
   confirm_value = CONFIRM_CANCEL;
   passphrase_ok = 0;

commit e3bed4f087304ac126e247053fc82a593bec31b6
Author: Ben Kibbey <bjk at luxsci.net>
Date:   Wed Feb 13 19:45:24 2013 -0500

    Add timeout support to the curses pinentry.
    
    * pinentry/pinentry-curses.c (dialog_run): Set the window input to
    non-blocking.
    (catchsig): New.
    (main): Catch SIGALRM and set the timeout.

diff --git a/pinentry/pinentry-curses.c b/pinentry/pinentry-curses.c
index 585059f..2957aa2 100644
--- a/pinentry/pinentry-curses.c
+++ b/pinentry/pinentry-curses.c
@@ -60,6 +60,7 @@ static short pinentry_color[] = { -1, -1, COLOR_BLACK, COLOR_RED,
 				  COLOR_GREEN, COLOR_YELLOW, COLOR_BLUE,
 				  COLOR_MAGENTA, COLOR_CYAN, COLOR_WHITE };
 static int init_screen;
+static int timed_out;
 
 typedef enum
   {
@@ -712,6 +713,7 @@ dialog_run (pinentry_t pinentry, const char *tty_name, const char *tty_type)
   FILE *ttyfo = NULL;
   SCREEN *screen = 0;
   int done = 0;
+  int no_input = 1;
   char *pin_utf8;
 #ifdef HAVE_NCURSESW
   char *old_ctype = NULL;
@@ -786,14 +788,24 @@ dialog_run (pinentry_t pinentry, const char *tty_name, const char *tty_type)
     return -2;
   dialog_switch_pos (&diag, diag.pin ? DIALOG_POS_PIN : DIALOG_POS_OK);
 
+  wtimeout (stdscr, 70);
+
   do
     {
       int c;
 
-      c = getch ();     /* Refresh, accept single keystroke of input.  */
+      c = wgetch (stdscr);     /* Refresh, accept single keystroke of input.  */
+
+      if (timed_out && no_input)
+	{
+	  done = -2;
+	  break;
+	}
 
       switch (c)
 	{
+	case ERR:
+	  continue;
 	case KEY_LEFT:
 	case KEY_UP:
 	  switch (diag.pos)
@@ -889,6 +901,8 @@ dialog_run (pinentry_t pinentry, const char *tty_name, const char *tty_type)
 	  if (diag.pos == DIALOG_POS_PIN)
 	    dialog_input (&diag, c);
 	}
+
+      no_input = 0;
     }
   while (!done);
 
@@ -960,12 +974,30 @@ do_touch_file (pinentry_t pinentry)
 #endif /*HAVE_UTIME_H*/
 }
 
+static void
+catchsig (int sig)
+{
+  if (sig == SIGALRM)
+    timed_out = 1;
+}
 
 int
 curses_cmd_handler (pinentry_t pinentry)
 {
   int rc;
 
+  timed_out = 0;
+
+  if (pinentry->timeout)
+    {
+      struct sigaction sa;
+
+      memset (&sa, 0, sizeof(sa));
+      sa.sa_handler = catchsig;
+      sigaction (SIGALRM, &sa, NULL);
+      alarm (pinentry->timeout);
+    }
+
   rc = dialog_run (pinentry, pinentry->ttyname, pinentry->ttytype);
   do_touch_file (pinentry);
   return rc;

-----------------------------------------------------------------------

Summary of changes:
 doc/pinentry.texi          |   13 +++++++++++++
 gtk+-2/pinentry-gtk-2.c    |   16 ++++++++++++++++
 pinentry/pinentry-curses.c |   34 +++++++++++++++++++++++++++++++++-
 3 files changed, 62 insertions(+), 1 deletions(-)


hooks/post-receive
-- 
The standard pinentry collection
http://git.gnupg.org




More information about the Gnupg-commits mailing list