[git] Pinentry - branch, master, updated. pinentry-0.9.1-25-gbf71ac5

by Werner Koch cvs at cvs.gnupg.org
Mon May 11 13:13:26 CEST 2015


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  bf71ac5a685afacb98f6c4c6a86c9d27d5414beb (commit)
       via  726c00514be4a0c2831dd775e306f7d5243bab8b (commit)
      from  d7f2081fdd605b0d0789bcb6984decfea3777f23 (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 bf71ac5a685afacb98f6c4c6a86c9d27d5414beb
Author: Werner Koch <wk at gnupg.org>
Date:   Mon May 11 13:12:17 2015 +0200

    gtk: Silence compiler warning at another place.
    
    --
    
    This extends
    commit 3d02645d757e573e4628a1caf2e36bb92d523e77

diff --git a/gtk+-2/gtksecentry.c b/gtk+-2/gtksecentry.c
index 824d45a..10f41c3 100644
--- a/gtk+-2/gtksecentry.c
+++ b/gtk+-2/gtksecentry.c
@@ -37,7 +37,14 @@
 #include <stdlib.h>
 #include <string.h>
 #include <gdk/gdkkeysyms.h>
+#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7 )
+# pragma GCC diagnostic push
+# pragma GCC diagnostic ignored "-Wstrict-prototypes"
+#endif
 #include <gtk/gtk.h>
+#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7 )
+# pragma GCC diagnostic pop
+#endif
 
 #include "gtksecentry.h"
 #include "memory.h"

commit 726c00514be4a0c2831dd775e306f7d5243bab8b
Author: Werner Koch <wk at gnupg.org>
Date:   Mon May 11 13:10:14 2015 +0200

    Return better error codes.
    
    * assuan/assuan.h (ASSUAN_Too_Short): New
    (ASSUAN_ENOENT, ASSUAN_ENOTTY): New.
    * pinentry/pinentry-curses.c: Include assuan.h.
    (dialog_create, dialog_run): Set specific error codes.
    * pinentry/pinentry.h (struct pinentry): Add field specific_err.
    * pinentry/pinentry.c (cmd_getpin): Return specific_err.
    (cmd_confirm, cmd_message): Ditto.
    --
    
    GnuPG-bug-id: 1463

diff --git a/assuan/assuan.h b/assuan/assuan.h
index ada5d64..7087d7b 100644
--- a/assuan/assuan.h
+++ b/assuan/assuan.h
@@ -25,7 +25,7 @@
 #include <sys/types.h>
 
 #ifdef __cplusplus
-extern "C" { 
+extern "C" {
 #if 0
  }
 #endif
@@ -64,6 +64,9 @@ typedef enum {
   ASSUAN_Invalid_Option = ASSUAN_ERROR (174), /* GPG_ERR_UNKNOWN_OPTION */
   ASSUAN_Locale_Problem = ASSUAN_ERROR (166),
   ASSUAN_Not_Confirmed = ASSUAN_ERROR (114),
+  ASSUAN_Too_Short = ASSUAN_ERROR (66),
+  ASSUAN_ENOENT    = ASSUAN_ERROR (81 | (1 << 15)),
+  ASSUAN_ENOTTY    = ASSUAN_ERROR (102 | (1 << 15)),
 
 } assuan_error_t;
 
@@ -91,7 +94,7 @@ typedef enum {
 #define ASSUAN_LINELENGTH 1002 /* 1000 + [CR,]LF */
 
 struct assuan_context_s;
-typedef struct assuan_context_s *assuan_context_t; 
+typedef struct assuan_context_s *assuan_context_t;
 typedef struct assuan_context_s *ASSUAN_CONTEXT; /* Deprecated.  */
 
 /*-- assuan-handler.c --*/
@@ -153,7 +156,7 @@ void assuan_disconnect (ASSUAN_CONTEXT ctx);
 pid_t assuan_get_pid (ASSUAN_CONTEXT ctx);
 
 /*-- assuan-client.c --*/
-AssuanError 
+AssuanError
 assuan_transact (ASSUAN_CONTEXT ctx,
                  const char *command,
                  AssuanError (*data_cb)(void *, const void *, size_t),
diff --git a/pinentry/pinentry-curses.c b/pinentry/pinentry-curses.c
index 8d3f9a5..60fd9da 100644
--- a/pinentry/pinentry-curses.c
+++ b/pinentry/pinentry-curses.c
@@ -47,6 +47,7 @@
 #endif /*HAVE_WCHAR_H*/
 
 #include "pinentry.h"
+#include "assuan.h"
 
 /* FIXME: We should allow configuration of these button labels and in
    any case use the default_ok, default_cancel values if available.
@@ -242,6 +243,7 @@ dialog_create (pinentry_t pinentry, dialog_t dialog)
         if (!what)							\
 	  {								\
 	    err = 1;							\
+            pinentry->specific_err = ASSUAN_Locale_Problem;             \
 	    goto out;							\
 	  }								\
       }									\
@@ -262,6 +264,7 @@ dialog_create (pinentry_t pinentry, dialog_t dialog)
 	  if (!new)							\
 	    {								\
 	      err = 1;							\
+              pinentry->specific_err = ASSUAN_Out_Of_Core;              \
 	      goto out;							\
 	    }								\
 	  new[0] = '<';							\
@@ -274,6 +277,7 @@ dialog_create (pinentry_t pinentry, dialog_t dialog)
       if (!dialog->which)						\
         {								\
 	  err = 1;							\
+          pinentry->specific_err = ASSUAN_Locale_Problem;               \
 	  goto out;							\
 	}								\
     }									\
@@ -339,6 +343,7 @@ dialog_create (pinentry_t pinentry, dialog_t dialog)
   if (y > size_y)
     {
       err = 1;
+      pinentry->specific_err = ASSUAN_Too_Short;
       goto out;
     }
 
@@ -393,6 +398,7 @@ dialog_create (pinentry_t pinentry, dialog_t dialog)
   if (x > size_x)
     {
       err = 1;
+      pinentry->specific_err = ASSUAN_Too_Short;
       goto out;
     }
 
@@ -738,13 +744,17 @@ dialog_run (pinentry_t pinentry, const char *tty_name, const char *tty_type)
     {
       ttyfi = fopen (tty_name, "r");
       if (!ttyfi)
-	return -1;
+        {
+          pinentry->specific_err = ASSUAN_ENOENT;
+          return -1;
+        }
       ttyfo = fopen (tty_name, "w");
       if (!ttyfo)
 	{
 	  int err = errno;
 	  fclose (ttyfi);
 	  errno = err;
+          pinentry->specific_err = ASSUAN_ENOENT;
 	  return -1;
 	}
       screen = newterm (tty_type, ttyfo, ttyfi);
@@ -757,6 +767,7 @@ dialog_run (pinentry_t pinentry, const char *tty_name, const char *tty_type)
           if (!(isatty(fileno(stdin)) && isatty(fileno(stdout))))
             {
               errno = ENOTTY;
+              pinentry->specific_err = ASSUAN_ENOTTY;
               return -1;
             }
 	  init_screen = 1;
@@ -799,6 +810,7 @@ dialog_run (pinentry_t pinentry, const char *tty_name, const char *tty_type)
   /* Create the dialog.  */
   if (dialog_create (pinentry, &diag))
     {
+      /* Note: pinentry->specific_err has already been set.  */
       endwin ();
       if (screen)
         delscreen (screen);
diff --git a/pinentry/pinentry.c b/pinentry/pinentry.c
index 16e634c..51c873c 100644
--- a/pinentry/pinentry.c
+++ b/pinentry/pinentry.c
@@ -86,6 +86,7 @@ struct pinentry pinentry =
     0,		/* Canceled.  */
     0,		/* Close button flag.  */
     0,          /* Locale error flag. */
+    0,          /* Specific error flag. */
     0,          /* One-button flag.  */
     NULL,       /* Repeat passphrase flag.  */
     NULL,       /* Repeat error string.  */
@@ -1037,6 +1038,7 @@ cmd_getpin (ASSUAN_CONTEXT ctx, char *line)
       set_prompt = 1;
     }
   pinentry.locale_err = 0;
+  pinentry.specific_err = 0;
   pinentry.close_button = 0;
   pinentry.repeat_okay = 0;
   pinentry.one_button = 0;
@@ -1068,6 +1070,8 @@ cmd_getpin (ASSUAN_CONTEXT ctx, char *line)
 	  secmem_free (pinentry.pin);
 	  pinentry.pin = NULL;
 	}
+      if (pinentry.specific_err)
+        return pinentry.specific_err;
       return pinentry.locale_err? ASSUAN_Locale_Problem: ASSUAN_Canceled;
     }
 
@@ -1116,6 +1120,7 @@ cmd_confirm (ASSUAN_CONTEXT ctx, char *line)
   pinentry.quality_bar = 0;
   pinentry.close_button = 0;
   pinentry.locale_err = 0;
+  pinentry.specific_err = 0;
   pinentry.canceled = 0;
   result = (*pinentry_cmd_handler) (&pinentry);
   if (pinentry.error)
@@ -1128,7 +1133,8 @@ cmd_confirm (ASSUAN_CONTEXT ctx, char *line)
     assuan_write_status (ctx, "BUTTON_INFO", "close");
 
   return result ? 0
-                : (pinentry.locale_err? ASSUAN_Locale_Problem
+                : (pinentry.specific_err? pinentry.specific_err :
+                   pinentry.locale_err? ASSUAN_Locale_Problem
                                       : (pinentry.one_button
                                          ? 0
                                          : (pinentry.canceled
@@ -1146,6 +1152,7 @@ cmd_message (ASSUAN_CONTEXT ctx, char *line)
   pinentry.quality_bar = 0;
   pinentry.close_button = 0;
   pinentry.locale_err = 0;
+  pinentry.specific_err = 0;
   result = (*pinentry_cmd_handler) (&pinentry);
   if (pinentry.error)
     {
@@ -1157,7 +1164,8 @@ cmd_message (ASSUAN_CONTEXT ctx, char *line)
     assuan_write_status (ctx, "BUTTON_INFO", "close");
 
   return result ? 0
-                : (pinentry.locale_err? ASSUAN_Locale_Problem
+                : (pinentry.specific_err? pinentry.specific_err :
+                   pinentry.locale_err? ASSUAN_Locale_Problem
                                       : 0);
 }
 
diff --git a/pinentry/pinentry.h b/pinentry/pinentry.h
index 2b5ad27..2fd267e 100644
--- a/pinentry/pinentry.h
+++ b/pinentry/pinentry.h
@@ -104,6 +104,12 @@ struct pinentry
      conversion occured. */
   int locale_err;
 
+  /* The user should set this to an gpg-error so that commands are
+     abale to return specific error codes.  This is an ugly hack due
+     to the fact that pinentry_cmd_handler_t return the length of the
+     passphrase or an negative error code.  */
+  int specific_err;
+
   /* The user should set this to true if the window close button has
      been used.  This flag is used in addition to a regular return
      value.  */

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

Summary of changes:
 assuan/assuan.h            |  9 ++++++---
 gtk+-2/gtksecentry.c       |  7 +++++++
 pinentry/pinentry-curses.c | 14 +++++++++++++-
 pinentry/pinentry.c        | 12 ++++++++++--
 pinentry/pinentry.h        |  6 ++++++
 5 files changed, 42 insertions(+), 6 deletions(-)


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




More information about the Gnupg-commits mailing list