[git] Pinentry - branch, master, updated. pinentry-0.9.7-31-g777650b

by Werner Koch cvs at cvs.gnupg.org
Tue Oct 4 09:40:23 CEST 2016


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  777650b9b021342ba887543396c67f9148218caf (commit)
      from  db3b2bf0c7ae4d3d0fbeecfe6a9a77ea4ed0f84e (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 777650b9b021342ba887543396c67f9148218caf
Author: Werner Koch <wk at gnupg.org>
Date:   Tue Oct 4 09:36:39 2016 +0200

    core: Add a way to print ERROR status lines.
    
    * pinentry/pinentry.h (struct pinentry): New fields SPECIFIC_ERR_LOC
    and SPECIFIC_ERR_INFO.
    * pinentry/pinentry.c (pinentry_reset): Free the new field.
    (write_status_error): New.
    (cmd_getpin): Use new fields.
    (cmd_confirm): Ditto.
    * gnome3/pinentry-gnome3.c (create_prompt): Set error for failed
    GCR_PROMPT.
    
    Signed-off-by: Werner Koch <wk at gnupg.org>

diff --git a/gnome3/pinentry-gnome3.c b/gnome3/pinentry-gnome3.c
index 8f91cb8..f8968c9 100644
--- a/gnome3/pinentry-gnome3.c
+++ b/gnome3/pinentry-gnome3.c
@@ -82,6 +82,9 @@ create_prompt (pinentry_t pe, int confirm)
     {
       g_warning ("couldn't create prompt for gnupg passphrase: %s",
 		 error->message);
+      pe->specific_err_loc = "gcr_prompt";
+      pe->specific_err_info = strdup (error->message);
+      pe->specific_err = gpg_error (GPG_ERR_CONFIGURATION);
       g_error_free (error);
       return NULL;
     }
diff --git a/pinentry/pinentry.c b/pinentry/pinentry.c
index 0c87271..e5cb806 100644
--- a/pinentry/pinentry.c
+++ b/pinentry/pinentry.c
@@ -132,6 +132,7 @@ pinentry_reset (int use_defaults)
   free (pinentry.quality_bar);
   free (pinentry.quality_bar_tt);
   free (pinentry.keyinfo);
+  free (pinentry.specific_err_info);
 
   /* Reset the pinentry structure.  */
   memset (&pinentry, 0, sizeof (pinentry));
@@ -947,6 +948,27 @@ strcpy_escaped (char *d, const char *s)
 }
 
 
+static void
+write_status_error (assuan_context_t ctx, pinentry_t pe)
+{
+  char buf[500];
+  const char *pgm;
+
+  pgm = strchr (this_pgmname, '-');
+  if (pgm && pgm[1])
+    pgm++;
+  else
+    pgm = this_pgmname;
+
+  snprintf (buf, sizeof buf, "%s.%s %d %s",
+            pgm,
+            pe->specific_err_loc? pe->specific_err_loc : "?",
+            pe->specific_err,
+            pe->specific_err_info? pe->specific_err_info : "");
+  assuan_write_status (ctx, "ERROR", buf);
+}
+
+
 static gpg_error_t
 cmd_setdesc (assuan_context_t ctx, char *line)
 {
@@ -1261,6 +1283,9 @@ cmd_getpin (assuan_context_t ctx, char *line)
     }
   pinentry.locale_err = 0;
   pinentry.specific_err = 0;
+  pinentry.specific_err_loc = NULL;
+  free (pinentry.specific_err_info);
+  pinentry.specific_err_info = NULL;
   pinentry.close_button = 0;
   pinentry.repeat_okay = 0;
   pinentry.one_button = 0;
@@ -1289,7 +1314,10 @@ cmd_getpin (assuan_context_t ctx, char *line)
     {
       pinentry_setbuffer_clear (&pinentry);
       if (pinentry.specific_err)
-        return pinentry.specific_err;
+        {
+          write_status_error (ctx, &pinentry);
+          return pinentry.specific_err;
+        }
       return (pinentry.locale_err
 	      ? gpg_error (GPG_ERR_LOCALE_PROBLEM)
 	      : gpg_error (GPG_ERR_CANCELED));
@@ -1337,6 +1365,9 @@ cmd_confirm (assuan_context_t ctx, char *line)
   pinentry.close_button = 0;
   pinentry.locale_err = 0;
   pinentry.specific_err = 0;
+  pinentry.specific_err_loc = NULL;
+  free (pinentry.specific_err_info);
+  pinentry.specific_err_info = NULL;
   pinentry.canceled = 0;
   pinentry_setbuffer_clear (&pinentry);
   result = (*pinentry_cmd_handler) (&pinentry);
@@ -1353,7 +1384,10 @@ cmd_confirm (assuan_context_t ctx, char *line)
     return 0;
 
   if (pinentry.specific_err)
-    return pinentry.specific_err;
+    {
+      write_status_error (ctx, &pinentry);
+      return pinentry.specific_err;
+    }
 
   if (pinentry.locale_err)
     return gpg_error (GPG_ERR_LOCALE_PROBLEM);
diff --git a/pinentry/pinentry.h b/pinentry/pinentry.h
index b203cfe..50d5f98 100644
--- a/pinentry/pinentry.h
+++ b/pinentry/pinentry.h
@@ -118,6 +118,13 @@ struct pinentry
      passphrase or a negative error code.  */
   int specific_err;
 
+  /* The frontend may store a string with the error location here.  */
+  const char *specific_err_loc;
+
+  /* The frontend may store a malloced string here to emit an ERROR
+   * status code with this extra info along with SPECIFIC_ERR.  */
+  char *specific_err_info;
+
   /* The frontend 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:
 gnome3/pinentry-gnome3.c |  3 +++
 pinentry/pinentry.c      | 38 ++++++++++++++++++++++++++++++++++++--
 pinentry/pinentry.h      |  7 +++++++
 3 files changed, 46 insertions(+), 2 deletions(-)


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




More information about the Gnupg-commits mailing list