[git] GPGME - branch, master, updated. gpgme-1.5.5-19-g8ddc580

by Werner Koch cvs at cvs.gnupg.org
Tue Aug 25 15:31:59 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  8ddc5801ade02297924447df5745c8877a96e5e3 (commit)
       via  208f0297466ce68abfc432f4944f81eb8bf47cf8 (commit)
       via  491fcd91b84564232d5d061942baa50b99e166c0 (commit)
       via  ad46f4f655e653580343c15f1b0b365b7d307d1b (commit)
      from  a7dbab23ea4976d106d649aa515ffb2968a085ed (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 8ddc5801ade02297924447df5745c8877a96e5e3
Author: Werner Koch <wk at gnupg.org>
Date:   Tue Aug 25 13:22:43 2015 +0200

    Improve error return by checking the FAILURE status.
    
    * src/gpgme.h.in (GPGME_STATUS_FAILURE): New.
    * src/status-table.c (FAILURE): New.
    * src/op-support.c (_gpgme_parse_failure): New.
    * src/passphrase.c (_gpgme_passphrase_status_handler): Forward FAILURE
    status line to the status callback.
    
    * src/decrypt.c (op_data_t): Add field failure_code.
    (_gpgme_decrypt_status_handler): Parse that code and act upon it on EOF.
    * src/encrypt.c (op_data_t): Add field failure_code.
    (_gpgme_encrypt_status_handler): Parse that code and act upon it on EOF.
    * src/genkey.c (op_data_t): Add field failure_code.
    (genkey_status_handler): Parse that code and act upon it on EOF.
    * src/passwd.c (op_data_t): Add field failure_code.
    (passwd_status_handler): Parse that code and act upon it on EOF.
    * src/sign.c (op_data_t): Add field failure_code.
    (_gpgme_sign_status_handler): Parse that code and act upon it on EOF.
    * src/verify.c (op_data_t): Add field failure_code.
    (_gpgme_verify_status_handler): Parse that code and act upon it on EOF.
    
    --
    
    This requires GnuPG 2.1.8 to actually make a difference.
    
    Signed-off-by: Werner Koch <wk at gnupg.org>

diff --git a/src/decrypt.c b/src/decrypt.c
index 4fd92c6..4db68a1 100644
--- a/src/decrypt.c
+++ b/src/decrypt.c
@@ -38,6 +38,9 @@ typedef struct
 {
   struct _gpgme_op_decrypt_result result;
 
+  /* The error code from a FAILURE status line or 0.  */
+  gpg_error_t failure_code;
+
   int okay;
   int failed;
 
@@ -192,6 +195,10 @@ _gpgme_decrypt_status_handler (void *priv, gpgme_status_code_t code,
 
   switch (code)
     {
+    case GPGME_STATUS_FAILURE:
+      opd->failure_code = _gpgme_parse_failure (args);
+      break;
+
     case GPGME_STATUS_EOF:
       /* FIXME: These error values should probably be attributed to
 	 the underlying crypto engine (as error source).  */
@@ -199,6 +206,8 @@ _gpgme_decrypt_status_handler (void *priv, gpgme_status_code_t code,
 	return gpg_error (GPG_ERR_DECRYPT_FAILED);
       else if (!opd->okay)
 	return gpg_error (GPG_ERR_NO_DATA);
+      else if (opd->failure_code)
+        return opd->failure_code;
       break;
 
     case GPGME_STATUS_DECRYPTION_INFO:
diff --git a/src/encrypt.c b/src/encrypt.c
index 792c25c..9f5134d 100644
--- a/src/encrypt.c
+++ b/src/encrypt.c
@@ -36,6 +36,9 @@ typedef struct
 {
   struct _gpgme_op_encrypt_result result;
 
+  /* The error code from a FAILURE status line or 0.  */
+  gpg_error_t failure_code;
+
   /* A pointer to the next pointer of the last invalid recipient in
      the list.  This makes appending new invalid recipients painless
      while preserving the order.  */
@@ -114,9 +117,15 @@ _gpgme_encrypt_status_handler (void *priv, gpgme_status_code_t code,
 
   switch (code)
     {
+    case GPGME_STATUS_FAILURE:
+      opd->failure_code = _gpgme_parse_failure (args);
+      break;
+
     case GPGME_STATUS_EOF:
       if (opd->result.invalid_recipients)
 	return gpg_error (GPG_ERR_UNUSABLE_PUBKEY);
+      if (opd->failure_code)
+        return opd->failure_code;
       break;
 
     case GPGME_STATUS_INV_RECP:
diff --git a/src/genkey.c b/src/genkey.c
index 18765dd..3afd3b4 100644
--- a/src/genkey.c
+++ b/src/genkey.c
@@ -37,6 +37,9 @@ typedef struct
 {
   struct _gpgme_op_genkey_result result;
 
+  /* The error code from a FAILURE status line or 0.  */
+  gpg_error_t failure_code;
+
   /* The key parameters passed to the crypto engine.  */
   gpgme_data_t key_parameter;
 } *op_data_t;
@@ -118,10 +121,16 @@ genkey_status_handler (void *priv, gpgme_status_code_t code, char *args)
 	}
       break;
 
+    case GPGME_STATUS_FAILURE:
+      opd->failure_code = _gpgme_parse_failure (args);
+      break;
+
     case GPGME_STATUS_EOF:
       /* FIXME: Should return some more useful error value.  */
       if (!opd->result.primary && !opd->result.sub)
 	return gpg_error (GPG_ERR_GENERAL);
+      else if (opd->failure_code)
+        return opd->failure_code;
       break;
 
     case GPGME_STATUS_INQUIRE_MAXLEN:
diff --git a/src/gpgme.h.in b/src/gpgme.h.in
index 7605570..432d18a 100644
--- a/src/gpgme.h.in
+++ b/src/gpgme.h.in
@@ -548,7 +548,8 @@ typedef enum
     GPGME_STATUS_ATTRIBUTE = 89,
     GPGME_STATUS_BEGIN_SIGNING = 90,
     GPGME_STATUS_KEY_NOT_CREATED = 91,
-    GPGME_STATUS_INQUIRE_MAXLEN = 92
+    GPGME_STATUS_INQUIRE_MAXLEN = 92,
+    GPGME_STATUS_FAILURE = 93
   }
 gpgme_status_code_t;
 
diff --git a/src/op-support.c b/src/op-support.c
index 2bcb3a3..02940ef 100644
--- a/src/op-support.c
+++ b/src/op-support.c
@@ -337,3 +337,27 @@ _gpgme_parse_plaintext (char *args, char **filenamep)
     }
   return 0;
 }
+
+
+/* Parse a FAILURE status line and return the error code.  ARGS is
+   modified to contain the location part.  */
+gpgme_error_t
+_gpgme_parse_failure (char *args)
+{
+  char *where, *which;
+
+  where = strchr (args, ' ');
+  if (!where)
+    return trace_gpg_error (GPG_ERR_INV_ENGINE);
+
+  *where = '\0';
+  which = where + 1;
+
+  where = strchr (which, ' ');
+  if (where)
+    *where = '\0';
+
+  where = args;
+
+  return atoi (which);
+}
diff --git a/src/ops.h b/src/ops.h
index 782265e..3662d57 100644
--- a/src/ops.h
+++ b/src/ops.h
@@ -65,6 +65,10 @@ gpgme_error_t _gpgme_parse_inv_recp (char *args, gpgme_invalid_key_t *key);
    FILENAMEP.  */
 gpgme_error_t _gpgme_parse_plaintext (char *args, char **filenamep);
 
+/* Parse a FAILURE status line and return the error code.  ARGS is
+   modified to contain the location part.  */
+gpgme_error_t _gpgme_parse_failure (char *args);
+
 
 

 /* From verify.c.  */
diff --git a/src/passphrase.c b/src/passphrase.c
index 5d656b1..c88e57d 100644
--- a/src/passphrase.c
+++ b/src/passphrase.c
@@ -128,6 +128,19 @@ _gpgme_passphrase_status_handler (void *priv, gpgme_status_code_t code,
         }
       break;
 
+    case GPGME_STATUS_FAILURE:
+      /* We abuse this status handler to forward FAILURE status codes
+         to the caller.  This should better be done in a generic
+         handler, but for now this is sufficient.  */
+      if (ctx->status_cb)
+        {
+          err = ctx->status_cb (ctx->status_cb_value, "FAILURE", args);
+          if (err)
+            return err;
+        }
+      break;
+
+
     default:
       /* Ignore all other codes.  */
       break;
diff --git a/src/passwd.c b/src/passwd.c
index e832026..ff30df0 100644
--- a/src/passwd.c
+++ b/src/passwd.c
@@ -30,6 +30,9 @@
 
 typedef struct
 {
+  /* The error code from a FAILURE status line or 0.  */
+  gpg_error_t failure_code;
+
   int success_seen;
   int error_seen;
 } *op_data_t;
@@ -92,6 +95,10 @@ passwd_status_handler (void *priv, gpgme_status_code_t code, char *args)
       opd->success_seen = 1;
       break;
 
+    case GPGME_STATUS_FAILURE:
+      opd->failure_code = _gpgme_parse_failure (args);
+      break;
+
     case GPGME_STATUS_EOF:
       /* In case the OpenPGP engine does not properly implement the
          passwd command we won't get a success status back and thus we
@@ -102,6 +109,8 @@ passwd_status_handler (void *priv, gpgme_status_code_t code, char *args)
       if (ctx->protocol == GPGME_PROTOCOL_OpenPGP
           && !opd->error_seen && !opd->success_seen)
         err = gpg_error (GPG_ERR_NOT_SUPPORTED);
+      else if (opd->failure_code)
+        err = opd->failure_code;
       break;
 
     default:
diff --git a/src/sign.c b/src/sign.c
index 9e22fdb..6c9fc03 100644
--- a/src/sign.c
+++ b/src/sign.c
@@ -39,6 +39,9 @@ typedef struct
 {
   struct _gpgme_op_sign_result result;
 
+  /* The error code from a FAILURE status line or 0.  */
+  gpg_error_t failure_code;
+
   /* A pointer to the next pointer of the last invalid signer in
      the list.  This makes appending new invalid signers painless
      while preserving the order.  */
@@ -327,6 +330,10 @@ _gpgme_sign_status_handler (void *priv, gpgme_status_code_t code, char *args)
       opd->last_signer_p = &(*opd->last_signer_p)->next;
       break;
 
+    case GPGME_STATUS_FAILURE:
+      opd->failure_code = _gpgme_parse_failure (args);
+      break;
+
     case GPGME_STATUS_EOF:
       /* The UI server does not send information about the created
          signature.  This is irrelevant for this protocol and thus we
@@ -335,7 +342,7 @@ _gpgme_sign_status_handler (void *priv, gpgme_status_code_t code, char *args)
 	err = gpg_error (GPG_ERR_UNUSABLE_SECKEY);
       else if (!opd->sig_created_seen
                && ctx->protocol != GPGME_PROTOCOL_UISERVER)
-	err = gpg_error (GPG_ERR_GENERAL);
+	err = opd->failure_code? opd->failure_code:gpg_error (GPG_ERR_GENERAL);
       break;
 
     case GPGME_STATUS_INQUIRE_MAXLEN:
@@ -374,6 +381,7 @@ sign_init_result (gpgme_ctx_t ctx, int ignore_inv_recp)
   opd = hook;
   if (err)
     return err;
+  opd->failure_code = 0;
   opd->last_signer_p = &opd->result.invalid_signers;
   opd->last_sig_p = &opd->result.signatures;
   opd->ignore_inv_recp = !!ignore_inv_recp;
diff --git a/src/status-table.c b/src/status-table.c
index c85fa95..6d428d7 100644
--- a/src/status-table.c
+++ b/src/status-table.c
@@ -66,6 +66,7 @@ static struct status_table_s status_table[] =
   { "ERRSIG", GPGME_STATUS_ERRSIG },
   { "EXPKEYSIG", GPGME_STATUS_EXPKEYSIG },
   { "EXPSIG", GPGME_STATUS_EXPSIG },
+  { "FAILURE", GPGME_STATUS_FAILURE },
   { "FILE_DONE", GPGME_STATUS_FILE_DONE },
   { "FILE_ERROR", GPGME_STATUS_FILE_ERROR },
   { "FILE_START", GPGME_STATUS_FILE_START },
diff --git a/src/verify.c b/src/verify.c
index 84487ee..75914e2 100644
--- a/src/verify.c
+++ b/src/verify.c
@@ -38,6 +38,9 @@ typedef struct
 {
   struct _gpgme_op_verify_result result;
 
+  /* The error code from a FAILURE status line or 0.  */
+  gpg_error_t failure_code;
+
   gpgme_signature_t current_sig;
   int did_prepare_new_sig;
   int only_newsig_seen;
@@ -769,6 +772,10 @@ _gpgme_verify_status_handler (void *priv, gpgme_status_code_t code, char *args)
          error code if we are not ready to process this status.  */
       return parse_error (sig, args, !!sig );
 
+    case GPGME_STATUS_FAILURE:
+      opd->failure_code = _gpgme_parse_failure (args);
+      break;
+
     case GPGME_STATUS_EOF:
       if (sig && !opd->did_prepare_new_sig)
 	calc_sig_summary (sig);
@@ -795,6 +802,8 @@ _gpgme_verify_status_handler (void *priv, gpgme_status_code_t code, char *args)
           opd->current_sig = NULL;
         }
       opd->only_newsig_seen = 0;
+      if (opd->failure_code)
+        return opd->failure_code;
       break;
 
     case GPGME_STATUS_PLAINTEXT:

commit 208f0297466ce68abfc432f4944f81eb8bf47cf8
Author: Werner Koch <wk at gnupg.org>
Date:   Tue Aug 25 10:37:02 2015 +0200

    tests: Build test programs in tests/ without wrappers.
    
    --

diff --git a/tests/Makefile.am b/tests/Makefile.am
index 94eddac..89e52e8 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -26,6 +26,7 @@ TESTS = t-version t-data t-engine-info
 EXTRA_DIST = start-stop-agent t-data-1.txt t-data-2.txt ChangeLog-2011
 
 AM_CPPFLAGS = -I$(top_builddir)/src @GPG_ERROR_CFLAGS@
+AM_LDFLAGS = -no-install
 LDADD = ../src/libgpgme.la @GPG_ERROR_LIBS@
 
 noinst_HEADERS = run-support.h

commit 491fcd91b84564232d5d061942baa50b99e166c0
Author: Werner Koch <wk at gnupg.org>
Date:   Tue Aug 25 09:05:27 2015 +0200

    tests: Allow using run-sign to test loopback pinentry problems.
    
    * tests/run-sign.c: Add options --status and --loopback.

diff --git a/tests/run-sign.c b/tests/run-sign.c
index e1498ea..c59c356 100644
--- a/tests/run-sign.c
+++ b/tests/run-sign.c
@@ -36,6 +36,14 @@
 
 static int verbose;
 
+static gpg_error_t
+status_cb (void *opaque, const char *keyword, const char *value)
+{
+  (void)opaque;
+  printf ("status_cb: %s %s\n", keyword, value);
+  return 0;
+}
+
 
 static void
 print_result (gpgme_sign_result_t result, gpgme_sig_mode_t type)
@@ -67,9 +75,11 @@ show_usage (int ex)
   fputs ("usage: " PGM " [options] FILE\n\n"
          "Options:\n"
          "  --verbose        run in verbose mode\n"
+         "  --status         print status lines from the backend\n"
          "  --openpgp        use the OpenPGP protocol (default)\n"
          "  --cms            use the CMS protocol\n"
          "  --uiserver       use the UI server\n"
+         "  --loopback       use a loopback pinentry\n"
          "  --key NAME       use key NAME for signing\n"
          , stderr);
   exit (ex);
@@ -87,6 +97,8 @@ main (int argc, char **argv)
   gpgme_sig_mode_t sigmode = GPGME_SIG_MODE_NORMAL;
   gpgme_data_t in, out;
   gpgme_sign_result_t result;
+  int print_status = 0;
+  int use_loopback = 0;
 
   if (argc)
     { argc--; argv++; }
@@ -106,6 +118,11 @@ main (int argc, char **argv)
           verbose = 1;
           argc--; argv++;
         }
+      else if (!strcmp (*argv, "--status"))
+        {
+          print_status = 1;
+          argc--; argv++;
+        }
       else if (!strcmp (*argv, "--openpgp"))
         {
           protocol = GPGME_PROTOCOL_OpenPGP;
@@ -129,6 +146,11 @@ main (int argc, char **argv)
           key_string = *argv;
           argc--; argv++;
         }
+      else if (!strcmp (*argv, "--loopback"))
+        {
+          use_loopback = 1;
+          argc--; argv++;
+        }
       else if (!strncmp (*argv, "--", 2))
         show_usage (1);
 
@@ -149,6 +171,10 @@ main (int argc, char **argv)
   fail_if_err (err);
   gpgme_set_protocol (ctx, protocol);
   gpgme_set_armor (ctx, 1);
+  if (print_status)
+    gpgme_set_status_cb (ctx, status_cb, NULL);
+  if (use_loopback)
+    gpgme_set_pinentry_mode (ctx, GPGME_PINENTRY_MODE_LOOPBACK);
 
   if (key_string)
     {

commit ad46f4f655e653580343c15f1b0b365b7d307d1b
Author: Werner Koch <wk at gnupg.org>
Date:   Mon Aug 24 21:17:21 2015 +0200

    Call status_cb for an ERROR status seen in the passphrase handler.
    
    * src/passphrase.c (_gpgme_passphrase_status_handler): Call status_cb.
    --
    
    Frankly, we should have a more generic way of feeding the status_cb
    handler than our current ad-hoc method.
    
    Signed-off-by: Werner Koch <wk at gnupg.org>

diff --git a/src/passphrase.c b/src/passphrase.c
index 63ab31e..5d656b1 100644
--- a/src/passphrase.c
+++ b/src/passphrase.c
@@ -116,6 +116,18 @@ _gpgme_passphrase_status_handler (void *priv, gpgme_status_code_t code,
 	return gpg_error (GPG_ERR_BAD_PASSPHRASE);
       break;
 
+    case GPGME_STATUS_ERROR:
+      /* We abuse this status handler to forward ERROR status codes to
+         the caller.  This should better be done in a generic handler,
+         but for now this is sufficient.  */
+      if (ctx->status_cb)
+        {
+          err = ctx->status_cb (ctx->status_cb_value, "ERROR", args);
+          if (err)
+            return err;
+        }
+      break;
+
     default:
       /* Ignore all other codes.  */
       break;

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

Summary of changes:
 src/decrypt.c      |  9 +++++++++
 src/encrypt.c      |  9 +++++++++
 src/genkey.c       |  9 +++++++++
 src/gpgme.h.in     |  3 ++-
 src/op-support.c   | 24 ++++++++++++++++++++++++
 src/ops.h          |  4 ++++
 src/passphrase.c   | 25 +++++++++++++++++++++++++
 src/passwd.c       |  9 +++++++++
 src/sign.c         | 10 +++++++++-
 src/status-table.c |  1 +
 src/verify.c       |  9 +++++++++
 tests/Makefile.am  |  1 +
 tests/run-sign.c   | 26 ++++++++++++++++++++++++++
 13 files changed, 137 insertions(+), 2 deletions(-)


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




More information about the Gnupg-commits mailing list