[svn] pinentry - r193 - in trunk: . gtk+-2 pinentry

svn author wk cvs at cvs.gnupg.org
Thu Mar 19 10:48:11 CET 2009


Author: wk
Date: 2009-03-19 10:48:11 +0100 (Thu, 19 Mar 2009)
New Revision: 193

Modified:
   trunk/ChangeLog
   trunk/NEWS
   trunk/gtk+-2/pinentry-gtk-2.c
   trunk/pinentry/pinentry.c
   trunk/pinentry/pinentry.h
Log:
Return GPG_ERR_CANCELED if during a "CONFIRM" command the user
closed the window.
Only Gtk+-2 for now.


Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2009-02-20 15:41:11 UTC (rev 192)
+++ trunk/ChangeLog	2009-03-19 09:48:11 UTC (rev 193)
@@ -1,3 +1,12 @@
+2009-03-19  Werner Koch  <wk at g10code.com>
+
+	* pinentry/pinentry.h (struct pinentry): Add field user_closed.
+	* pinentry/pinentry.c (cmd_getpin, cmd_confirm, cmd_message):
+	Reset this field.
+	(cmd_confirm): Return cancel if the user closed the window.
+	* gtk+-2/pinentry-gtk-2.c (window_closed): New.
+	(gtk_cmd_handler, delete_event): Set it.
+
 2009-02-19  Marcus Brinkmann  <marcus at g10code.de>
 
 	* secmem/secmem++.h: New file.

Modified: trunk/NEWS
===================================================================
--- trunk/NEWS	2009-02-20 15:41:11 UTC (rev 192)
+++ trunk/NEWS	2009-03-19 09:48:11 UTC (rev 193)
@@ -7,7 +7,10 @@
 
  * Fix utf-8 problem in Qt pinentries.
 
+ * Return GPG_ERR_CANCELED if during a "CONFIRM" command the user
+   closed the window.
 
+
 Noteworthy changes in version 0.7.5 (2008-02-15)
 ------------------------------------------------
 

Modified: trunk/gtk+-2/pinentry-gtk-2.c
===================================================================
--- trunk/gtk+-2/pinentry-gtk-2.c	2009-02-20 15:41:11 UTC (rev 192)
+++ trunk/gtk+-2/pinentry-gtk-2.c	2009-03-19 09:48:11 UTC (rev 193)
@@ -54,6 +54,7 @@
 static pinentry_t pinentry;
 static int passphrase_ok;
 static int confirm_yes;
+static int window_closed;
 
 static GtkWidget *entry;
 static GtkWidget *qualitybar;
@@ -149,6 +150,7 @@
 static int
 delete_event (GtkWidget *widget, GdkEvent *event, gpointer data)
 {
+  window_closed = 1;
   gtk_main_quit ();
   return TRUE;
 }
@@ -489,6 +491,7 @@
 
   pinentry = pe;
   confirm_yes = 0;
+  window_closed = 0;
   passphrase_ok = 0;
   w = create_window (want_pass ? 0 : 1);
   gtk_main ();
@@ -496,6 +499,9 @@
   while (gtk_events_pending ())
     gtk_main_iteration ();
 
+  if (window_closed)
+    pe->user_closed = 1;
+
   pinentry = NULL;
   if (want_pass)
     {

Modified: trunk/pinentry/pinentry.c
===================================================================
--- trunk/pinentry/pinentry.c	2009-02-20 15:41:11 UTC (rev 192)
+++ trunk/pinentry/pinentry.c	2009-03-19 09:48:11 UTC (rev 193)
@@ -819,6 +819,7 @@
       set_prompt = 1;
     }
   pinentry.locale_err = 0;
+  pinentry.user_closed = 0;
   pinentry.one_button = 0;
   pinentry.ctx_assuan = ctx;
   result = (*pinentry_cmd_handler) (&pinentry);
@@ -875,6 +876,7 @@
   pinentry.one_button = !!strstr (line, "--one-button");
   pinentry.quality_bar = 0;
   pinentry.locale_err = 0;
+  pinentry.user_closed = 0;
   result = (*pinentry_cmd_handler) (&pinentry);
   if (pinentry.error)
     {
@@ -886,7 +888,9 @@
                 : (pinentry.locale_err? ASSUAN_Locale_Problem
                                       : (pinentry.one_button 
                                          ? 0
-                                         : ASSUAN_Not_Confirmed));
+                                         : (pinentry.user_closed
+                                            ? ASSUAN_Canceled
+                                            : ASSUAN_Not_Confirmed)));
 }
 
 
@@ -898,6 +902,7 @@
   pinentry.one_button = 1;
   pinentry.quality_bar = 0;
   pinentry.locale_err = 0;
+  pinentry.user_closed = 0;
   result = (*pinentry_cmd_handler) (&pinentry);
   if (pinentry.error)
     {

Modified: trunk/pinentry/pinentry.h
===================================================================
--- trunk/pinentry/pinentry.h	2009-02-20 15:41:11 UTC (rev 192)
+++ trunk/pinentry/pinentry.h	2009-03-19 09:48:11 UTC (rev 193)
@@ -84,6 +84,10 @@
      and to the length of the PIN stored in pin otherwise.  */
   int result;
 
+  /* The user should set this is the pinentry window was closed by the
+     user without using a button.  */
+  int user_closed;
+
   /* The user should set this to true if an error with the local
      conversion occured. */
   int locale_err;




More information about the Gnupg-commits mailing list