[git] GPGME - branch, master, updated. gpgme-1.5.4-7-gddbd54e

by Werner Koch cvs at cvs.gnupg.org
Mon Jun 8 12:56:49 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 "GnuPG Made Easy".

The branch, master has been updated
       via  ddbd54ef881bd2c3481d62b89bef7241667b64ee (commit)
       via  7addffc0826e7f36afcc7f66268e9ee2a37e2042 (commit)
      from  8b9f84828cd04a7dab37e219123edc1905da8e6b (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 ddbd54ef881bd2c3481d62b89bef7241667b64ee
Author: Werner Koch <wk at gnupg.org>
Date:   Mon Jun 8 12:34:49 2015 +0200

    Fix regression with gpgsm 2.0 due to "OPTION with-secret".
    
    * src/engine-gpgsm.c (gpgsm_assuan_simple_command): Do not terminate
    on a status lines.
    --
    
    This bug has been with us since the support for gpgsm: If there is no
    status line handler but a status line is received anyway the command
    handling loop terminates and thus the command/answer order gets out of
    sync.  In the case of the bug report this is triggered by sending an
    option which starts the agent and that starting emits a "PROGRESS"
    status line.
    
    The solution is not to stop reading after a status line but record a
    possible error code and return that only after OK or ERR.
    
    GnuPG-bug-id: 1795
    Signed-off-by: Werner Koch <wk at gnupg.org>

diff --git a/src/engine-gpgsm.c b/src/engine-gpgsm.c
index 3a83757..ac6c5fc 100644
--- a/src/engine-gpgsm.c
+++ b/src/engine-gpgsm.c
@@ -564,7 +564,7 @@ gpgsm_assuan_simple_command (assuan_context_t ctx, char *cmd,
 			     engine_status_handler_t status_fnc,
 			     void *status_fnc_value)
 {
-  gpg_error_t err;
+  gpg_error_t err, cb_err;
   char *line;
   size_t linelen;
 
@@ -572,6 +572,7 @@ gpgsm_assuan_simple_command (assuan_context_t ctx, char *cmd,
   if (err)
     return err;
 
+  cb_err = 0;
   do
     {
       err = assuan_read_line (ctx, &line, &linelen);
@@ -584,32 +585,45 @@ gpgsm_assuan_simple_command (assuan_context_t ctx, char *cmd,
       if (linelen >= 2
 	  && line[0] == 'O' && line[1] == 'K'
 	  && (line[2] == '\0' || line[2] == ' '))
-	return 0;
+	return cb_err;
       else if (linelen >= 4
 	  && line[0] == 'E' && line[1] == 'R' && line[2] == 'R'
 	  && line[3] == ' ')
-	err = atoi (&line[4]);
+        {
+          /* We prefer a callback generated error because that one is
+             more related to gpgme and thus probably more important
+             than the error returned by the engine.  */
+          err = cb_err? cb_err : atoi (&line[4]);
+        }
       else if (linelen >= 2
 	       && line[0] == 'S' && line[1] == ' ')
 	{
-	  char *rest;
-	  gpgme_status_code_t r;
+          /* After an error from a status callback we skip all further
+             status lines.  */
+          if (!cb_err)
+            {
+              char *rest;
+              gpgme_status_code_t r;
 
-	  rest = strchr (line + 2, ' ');
-	  if (!rest)
-	    rest = line + linelen; /* set to an empty string */
-	  else
-	    *(rest++) = 0;
+              rest = strchr (line + 2, ' ');
+              if (!rest)
+                rest = line + linelen; /* set to an empty string */
+              else
+                *(rest++) = 0;
 
-	  r = _gpgme_parse_status (line + 2);
+              r = _gpgme_parse_status (line + 2);
 
-	  if (r >= 0 && status_fnc)
-	    err = status_fnc (status_fnc_value, r, rest);
-	  else
-	    err = gpg_error (GPG_ERR_GENERAL);
+              if (r >= 0 && status_fnc)
+                cb_err = status_fnc (status_fnc_value, r, rest);
+            }
 	}
       else
-	err = gpg_error (GPG_ERR_GENERAL);
+        {
+          /* Invalid line or INQUIRY.  We can't do anything else than
+             to stop.  As with ERR we prefer a status callback
+             generated error code, though.  */
+          err = cb_err ? cb_err : gpg_error (GPG_ERR_GENERAL);
+        }
     }
   while (!err);
 

commit 7addffc0826e7f36afcc7f66268e9ee2a37e2042
Author: Werner Koch <wk at gnupg.org>
Date:   Mon Jun 8 12:30:11 2015 +0200

    tests: Add option --secret to run-keylist.
    
    Signed-off-by: Werner Koch <wk at gnupg.org>

diff --git a/tests/run-keylist.c b/tests/run-keylist.c
index c0c7202..07c6fa1 100644
--- a/tests/run-keylist.c
+++ b/tests/run-keylist.c
@@ -45,6 +45,7 @@ show_usage (int ex)
          "  --verbose        run in verbose mode\n"
          "  --openpgp        use the OpenPGP protocol (default)\n"
          "  --cms            use the CMS protocol\n"
+         "  --secret         list only secret keys\n"
          "  --local          use GPGME_KEYLIST_MODE_LOCAL\n"
          "  --extern         use GPGME_KEYLIST_MODE_EXTERN\n"
          "  --sigs           use GPGME_KEYLIST_MODE_SIGS\n"
@@ -70,6 +71,7 @@ main (int argc, char **argv)
   gpgme_key_t keyarray[100];
   int keyidx = 0;
   gpgme_protocol_t protocol = GPGME_PROTOCOL_OpenPGP;
+  int only_secret = 0;
 
   if (argc)
     { argc--; argv++; }
@@ -99,6 +101,11 @@ main (int argc, char **argv)
           protocol = GPGME_PROTOCOL_CMS;
           argc--; argv++;
         }
+      else if (!strcmp (*argv, "--secret"))
+        {
+          only_secret = 1;
+          argc--; argv++;
+        }
       else if (!strcmp (*argv, "--local"))
         {
           mode |= GPGME_KEYLIST_MODE_LOCAL;
@@ -150,7 +157,7 @@ main (int argc, char **argv)
 
   gpgme_set_keylist_mode (ctx, mode);
 
-  err = gpgme_op_keylist_start (ctx, argc? argv[0]:NULL, 0);
+  err = gpgme_op_keylist_start (ctx, argc? argv[0]:NULL, only_secret);
   fail_if_err (err);
 
   while (!(err = gpgme_op_keylist_next (ctx, &key)))

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

Summary of changes:
 src/engine-gpgsm.c  | 46 ++++++++++++++++++++++++++++++----------------
 tests/run-keylist.c |  9 ++++++++-
 2 files changed, 38 insertions(+), 17 deletions(-)


hooks/post-receive
-- 
GnuPG Made Easy
http://git.gnupg.org




More information about the Gnupg-commits mailing list