From 36e2c1a9d1376057fb2b3c4ce016c2707ee49ca7 Mon Sep 17 00:00:00 2001 From: Marcus Brinkmann Date: Tue, 27 Oct 2009 19:23:56 +0000 Subject: [PATCH] 2009-10-27 Marcus Brinkmann * edit.c (gpgme_op_edit_start, gpgme_op_edit) (gpgme_op_card_edit_start, gpgme_op_card_edit): Add debug output. * encrypt-sign.c (gpgme_op_encrypt_sign_start) (gpgme_op_encrypt_sign): Likewise. * encrypt.c (gpgme_op_encrypt_start, gpgme_op_encrypt) (gpgme_op_encrypt_result): Likewise. * export.c (gpgme_op_export_start, gpgme_op_export) (gpgme_op_export_ext_start, gpgme_op_export_ext) (gpgme_op_export_keys_start, gpgme_op_export_keys): Likewise. * genkey.c (gpgme_op_genkey_start, gpgme_op_genkey) (gpgme_op_genkey_result): Likewise. * getauditlog.c (gpgme_op_getauditlog_start) (gpgme_op_getauditlog): Likewise. * import.c (gpgme_op_import_result, gpgme_op_import_start) (gpgme_op_import): Likewise. * keylist.c (gpgme_op_keylist_result, keylist_colon_handler) (gpgme_op_keylist_start, gpgme_op_keylist_ext_start) (gpgme_op_keylist_next, gpgme_op_keylist_end, gpgme_get_key): Likewise. * opassuan.c (gpgme_op_assuan_transact_start) (gpgme_op_assuan_transact_ext, gpgme_op_assuan_result) (gpgme_op_assuan_transact): Likewise. * signers.c (gpgme_signers_add, gpgme_signers_clear): Likewise. * trustlist.c (gpgme_op_trustlist_start) (gpgme_op_trustlist_next, gpgme_op_trustlist_end): Likewise. * verify.c (gpgme_op_verify_start, gpgme_op_verify) (gpgme_op_verify_result): Likewise. --- src/ChangeLog | 29 +++++++++++++++ src/debug.h | 23 ++++++++++++ src/decrypt.c | 2 +- src/edit.c | 35 ++++++++++++++---- src/encrypt-sign.c | 41 +++++++++++++++++++-- src/encrypt.c | 64 ++++++++++++++++++++++++++++++--- src/export.c | 86 ++++++++++++++++++++++++++++++++++++++++---- src/genkey.c | 22 ++++++++++-- src/getauditlog.c | 14 ++++++-- src/import.c | 90 ++++++++++++++++++++++++++++++++++++++++++---- src/keylist.c | 76 +++++++++++++++++++++++++++------------ src/opassuan.c | 66 ++++++++++++++++++++++++++++------ src/signers.c | 14 ++++++-- src/trustlist.c | 50 ++++++++++++++++++++------ src/verify.c | 51 ++++++++++++++++++++++++-- src/wait-private.c | 9 ++--- 16 files changed, 583 insertions(+), 89 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index f1ac7b4..e50d811 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,32 @@ +2009-10-27 Marcus Brinkmann + + * edit.c (gpgme_op_edit_start, gpgme_op_edit) + (gpgme_op_card_edit_start, gpgme_op_card_edit): Add debug output. + * encrypt-sign.c (gpgme_op_encrypt_sign_start) + (gpgme_op_encrypt_sign): Likewise. + * encrypt.c (gpgme_op_encrypt_start, gpgme_op_encrypt) + (gpgme_op_encrypt_result): Likewise. + * export.c (gpgme_op_export_start, gpgme_op_export) + (gpgme_op_export_ext_start, gpgme_op_export_ext) + (gpgme_op_export_keys_start, gpgme_op_export_keys): Likewise. + * genkey.c (gpgme_op_genkey_start, gpgme_op_genkey) + (gpgme_op_genkey_result): Likewise. + * getauditlog.c (gpgme_op_getauditlog_start) + (gpgme_op_getauditlog): Likewise. + * import.c (gpgme_op_import_result, gpgme_op_import_start) + (gpgme_op_import): Likewise. + * keylist.c (gpgme_op_keylist_result, keylist_colon_handler) + (gpgme_op_keylist_start, gpgme_op_keylist_ext_start) + (gpgme_op_keylist_next, gpgme_op_keylist_end, gpgme_get_key): Likewise. + * opassuan.c (gpgme_op_assuan_transact_start) + (gpgme_op_assuan_transact_ext, gpgme_op_assuan_result) + (gpgme_op_assuan_transact): Likewise. + * signers.c (gpgme_signers_add, gpgme_signers_clear): Likewise. + * trustlist.c (gpgme_op_trustlist_start) + (gpgme_op_trustlist_next, gpgme_op_trustlist_end): Likewise. + * verify.c (gpgme_op_verify_start, gpgme_op_verify) + (gpgme_op_verify_result): Likewise. + 2009-10-26 Marcus Brinkmann * gpgme.h.in (struct gpgme_io_event_done_data) diff --git a/src/debug.h b/src/debug.h index d46c34d..c4455b2 100644 --- a/src/debug.h +++ b/src/debug.h @@ -117,6 +117,25 @@ void _gpgme_debug_buffer (int lvl, const char *const fmt, _gpgme_debug (_gpgme_trace_level, "%s (%s=%p): enter: " fmt "\n", \ _gpgme_trace_func, _gpgme_trace_tagname, \ _gpgme_trace_tag, arg1, arg2, arg3, arg4), 0 +#define TRACE_BEG5(lvl, name, tag, fmt, arg1, arg2, arg3, arg4, arg5) \ + _TRACE (lvl, name, tag); \ + _gpgme_debug (_gpgme_trace_level, "%s (%s=%p): enter: " fmt "\n", \ + _gpgme_trace_func, _gpgme_trace_tagname, \ + _gpgme_trace_tag, arg1, arg2, arg3, arg4, arg5), 0 +#define TRACE_BEG7(lvl, name, tag, fmt, arg1, arg2, arg3, arg4, \ + arg5, arg6, arg7) \ + _TRACE (lvl, name, tag); \ + _gpgme_debug (_gpgme_trace_level, "%s (%s=%p): enter: " fmt "\n", \ + _gpgme_trace_func, _gpgme_trace_tagname, \ + _gpgme_trace_tag, arg1, arg2, arg3, arg4, arg5, \ + arg6, arg7), 0 +#define TRACE_BEG8(lvl, name, tag, fmt, arg1, arg2, arg3, arg4, \ + arg5, arg6, arg7, arg8) \ + _TRACE (lvl, name, tag); \ + _gpgme_debug (_gpgme_trace_level, "%s (%s=%p): enter: " fmt "\n", \ + _gpgme_trace_func, _gpgme_trace_tagname, \ + _gpgme_trace_tag, arg1, arg2, arg3, arg4, arg5, \ + arg6, arg7, arg8), 0 #define TRACE(lvl, name, tag) \ _gpgme_debug (lvl, "%s (%s=%p): call\n", \ @@ -199,6 +218,10 @@ void _gpgme_debug_buffer (int lvl, const char *const fmt, _gpgme_debug (_gpgme_trace_level, "%s (%s=%p): check: " fmt "\n", \ _gpgme_trace_func, _gpgme_trace_tagname, \ _gpgme_trace_tag, arg1, arg2, arg3, arg4), 0 +#define TRACE_LOG5(fmt, arg1, arg2, arg3, arg4, arg5) \ + _gpgme_debug (_gpgme_trace_level, "%s (%s=%p): check: " fmt "\n", \ + _gpgme_trace_func, _gpgme_trace_tagname, \ + _gpgme_trace_tag, arg1, arg2, arg3, arg4, arg5), 0 #define TRACE_LOG6(fmt, arg1, arg2, arg3, arg4, arg5, arg6) \ _gpgme_debug (_gpgme_trace_level, "%s (%s=%p): check: " fmt "\n", \ _gpgme_trace_func, _gpgme_trace_tagname, \ diff --git a/src/decrypt.c b/src/decrypt.c index c48e1a9..5e76156 100644 --- a/src/decrypt.c +++ b/src/decrypt.c @@ -379,7 +379,7 @@ gpgme_op_decrypt (gpgme_ctx_t ctx, gpgme_data_t cipher, gpgme_data_t plain) { gpgme_error_t err; - TRACE_BEG2 (DEBUG_CTX, "gpgme_op_decrypt_start", ctx, + TRACE_BEG2 (DEBUG_CTX, "gpgme_op_decrypt", ctx, "cipher=%p, plain=%p", cipher, plain); err = decrypt_start (ctx, 1, cipher, plain); if (!err) diff --git a/src/edit.c b/src/edit.c index 186d4f9..edf2089 100644 --- a/src/edit.c +++ b/src/edit.c @@ -24,6 +24,7 @@ #include #include "gpgme.h" +#include "debug.h" #include "context.h" #include "ops.h" @@ -138,7 +139,11 @@ gpgme_error_t gpgme_op_edit_start (gpgme_ctx_t ctx, gpgme_key_t key, gpgme_edit_cb_t fnc, void *fnc_value, gpgme_data_t out) { - return edit_start (ctx, 0, 0, key, fnc, fnc_value, out); + TRACE_BEG5 (DEBUG_CTX, "gpgme_op_edit_start", ctx, + "key=%p (%s), fnc=%p fnc_value=%p, out=%p", key, + (key->subkeys && !key->subkeys->fpr) ? + key->subkeys->fpr : "invalid", fnc, fnc_value, out); + return TRACE_ERR (edit_start (ctx, 0, 0, key, fnc, fnc_value, out)); } @@ -148,10 +153,18 @@ gpgme_error_t gpgme_op_edit (gpgme_ctx_t ctx, gpgme_key_t key, gpgme_edit_cb_t fnc, void *fnc_value, gpgme_data_t out) { - gpgme_error_t err = edit_start (ctx, 1, 0, key, fnc, fnc_value, out); + gpgme_error_t err; + + TRACE_BEG5 (DEBUG_CTX, "gpgme_op_edit", ctx, + "key=%p (%s), fnc=%p fnc_value=%p, out=%p", key, + (key->subkeys && !key->subkeys->fpr) ? + key->subkeys->fpr : "invalid", fnc, fnc_value, out); + + err = edit_start (ctx, 1, 0, key, fnc, fnc_value, out); + if (!err) err = _gpgme_wait_one (ctx); - return err; + return TRACE_ERR (err); } @@ -160,7 +173,11 @@ gpgme_op_card_edit_start (gpgme_ctx_t ctx, gpgme_key_t key, gpgme_edit_cb_t fnc, void *fnc_value, gpgme_data_t out) { - return edit_start (ctx, 0, 1, key, fnc, fnc_value, out); + TRACE_BEG5 (DEBUG_CTX, "gpgme_op_card_edit_start", ctx, + "key=%p (%s), fnc=%p fnc_value=%p, out=%p", key, + (key->subkeys && !key->subkeys->fpr) ? + key->subkeys->fpr : "invalid", fnc, fnc_value, out); + return TRACE_ERR (edit_start (ctx, 0, 1, key, fnc, fnc_value, out)); } @@ -170,8 +187,14 @@ gpgme_error_t gpgme_op_card_edit (gpgme_ctx_t ctx, gpgme_key_t key, gpgme_edit_cb_t fnc, void *fnc_value, gpgme_data_t out) { - gpgme_error_t err = edit_start (ctx, 1, 1, key, fnc, fnc_value, out); + gpgme_error_t err; + + TRACE_BEG5 (DEBUG_CTX, "gpgme_op_card_edit", ctx, + "key=%p (%s), fnc=%p fnc_value=%p, out=%p", key, + (key->subkeys && !key->subkeys->fpr) ? + key->subkeys->fpr : "invalid", fnc, fnc_value, out); + err = edit_start (ctx, 1, 1, key, fnc, fnc_value, out); if (!err) err = _gpgme_wait_one (ctx); - return err; + return TRACE_ERR (err); } diff --git a/src/encrypt-sign.c b/src/encrypt-sign.c index 7e3d2ed..c80cb2a 100644 --- a/src/encrypt-sign.c +++ b/src/encrypt-sign.c @@ -24,6 +24,7 @@ #endif #include "gpgme.h" +#include "debug.h" #include "context.h" #include "ops.h" @@ -91,7 +92,23 @@ gpgme_op_encrypt_sign_start (gpgme_ctx_t ctx, gpgme_key_t recp[], gpgme_encrypt_flags_t flags, gpgme_data_t plain, gpgme_data_t cipher) { - return encrypt_sign_start (ctx, 0, recp, flags, plain, cipher); + TRACE_BEG3 (DEBUG_CTX, "gpgme_op_encrypt_sign_start", ctx, + "flags=0x%x, plain=%p, cipher=%p", flags, plain, cipher); + + if (_gpgme_debug_trace () && recp) + { + int i = 0; + + while (recp[i]) + { + TRACE_LOG3 ("recipient[%i] = %p (%s)", i,recp[i], + (recp[i]->subkeys && !recp[i]->subkeys->fpr) ? + recp[i]->subkeys->fpr : "invalid"); + i++; + } + } + + return TRACE_ERR (encrypt_sign_start (ctx, 0, recp, flags, plain, cipher)); } @@ -103,8 +120,26 @@ gpgme_op_encrypt_sign (gpgme_ctx_t ctx, gpgme_key_t recp[], gpgme_encrypt_flags_t flags, gpgme_data_t plain, gpgme_data_t cipher) { - gpgme_error_t err = encrypt_sign_start (ctx, 1, recp, flags, plain, cipher); + gpgme_error_t err; + + TRACE_BEG3 (DEBUG_CTX, "gpgme_op_encrypt_sign", ctx, + "flags=0x%x, plain=%p, cipher=%p", flags, plain, cipher); + + if (_gpgme_debug_trace () && recp) + { + int i = 0; + + while (recp[i]) + { + TRACE_LOG3 ("recipient[%i] = %p (%s)", i,recp[i], + (recp[i]->subkeys && !recp[i]->subkeys->fpr) ? + recp[i]->subkeys->fpr : "invalid"); + i++; + } + } + + err = encrypt_sign_start (ctx, 1, recp, flags, plain, cipher); if (!err) err = _gpgme_wait_one (ctx); - return err; + return TRACE_ERR (err); } diff --git a/src/encrypt.c b/src/encrypt.c index 4744090..c59292f 100644 --- a/src/encrypt.c +++ b/src/encrypt.c @@ -27,6 +27,7 @@ #include #include "gpgme.h" +#include "debug.h" #include "context.h" #include "ops.h" @@ -66,12 +67,33 @@ gpgme_op_encrypt_result (gpgme_ctx_t ctx) op_data_t opd; gpgme_error_t err; + TRACE_BEG (DEBUG_CTX, "gpgme_op_encrypt_result", ctx); + err = _gpgme_op_data_lookup (ctx, OPDATA_ENCRYPT, &hook, -1, NULL); opd = hook; if (err || !opd) - return NULL; + { + TRACE_SUC0 ("result=(null)"); + return NULL; + } + if (_gpgme_debug_trace ()) + { + gpgme_invalid_key_t invkeys = opd->result.invalid_recipients; + int i = 0; + + while (invkeys) + { + TRACE_LOG3 ("invalid_recipients[%i] = %s (%s)", + i, invkeys->fpr ? invkeys->fpr : "(null)", + gpg_strerror (invkeys->reason)); + invkeys = invkeys->next; + i++; + } + } + + TRACE_SUC1 ("result=%p", &opd->result); return &opd->result; } @@ -205,7 +227,23 @@ gpgme_op_encrypt_start (gpgme_ctx_t ctx, gpgme_key_t recp[], gpgme_encrypt_flags_t flags, gpgme_data_t plain, gpgme_data_t cipher) { - return encrypt_start (ctx, 0, recp, flags, plain, cipher); + TRACE_BEG3 (DEBUG_CTX, "gpgme_op_encrypt_start", ctx, + "flags=0x%x, plain=%p, cipher=%p", flags, plain, cipher); + + if (_gpgme_debug_trace () && recp) + { + int i = 0; + + while (recp[i]) + { + TRACE_LOG3 ("recipient[%i] = %p (%s)", i,recp[i], + (recp[i]->subkeys && !recp[i]->subkeys->fpr) ? + recp[i]->subkeys->fpr : "invalid"); + i++; + } + } + + return TRACE_ERR (encrypt_start (ctx, 0, recp, flags, plain, cipher)); } @@ -216,8 +254,26 @@ gpgme_op_encrypt (gpgme_ctx_t ctx, gpgme_key_t recp[], gpgme_encrypt_flags_t flags, gpgme_data_t plain, gpgme_data_t cipher) { - gpgme_error_t err = encrypt_start (ctx, 1, recp, flags, plain, cipher); + gpgme_error_t err; + + TRACE_BEG3 (DEBUG_CTX, "gpgme_op_encrypt", ctx, + "flags=0x%x, plain=%p, cipher=%p", flags, plain, cipher); + + if (_gpgme_debug_trace () && recp) + { + int i = 0; + + while (recp[i]) + { + TRACE_LOG3 ("recipient[%i] = %p (%s)", i, recp[i], + (recp[i]->subkeys && !recp[i]->subkeys->fpr) ? + recp[i]->subkeys->fpr : "invalid"); + i++; + } + } + + err = encrypt_start (ctx, 1, recp, flags, plain, cipher); if (!err) err = _gpgme_wait_one (ctx); - return err; + return TRACE_ERR (err); } diff --git a/src/export.c b/src/export.c index 1e29439..70f9728 100644 --- a/src/export.c +++ b/src/export.c @@ -26,6 +26,7 @@ #include #include "gpgme.h" +#include "debug.h" #include "context.h" #include "ops.h" @@ -74,7 +75,9 @@ gpgme_error_t gpgme_op_export_start (gpgme_ctx_t ctx, const char *pattern, gpgme_export_mode_t mode, gpgme_data_t keydata) { - return export_start (ctx, 0, pattern, mode, keydata); + TRACE_BEG3 (DEBUG_CTX, "gpgme_op_export_start", ctx, + "pattern=%s, mode=0x%x, keydata=%p", pattern, mode, keydata); + return TRACE_ERR (export_start (ctx, 0, pattern, mode, keydata)); } @@ -83,7 +86,12 @@ gpgme_error_t gpgme_op_export (gpgme_ctx_t ctx, const char *pattern, gpgme_export_mode_t mode, gpgme_data_t keydata) { - gpgme_error_t err = export_start (ctx, 1, pattern, mode, keydata); + gpgme_error_t err; + + TRACE_BEG3 (DEBUG_CTX, "gpgme_op_export", ctx, + "pattern=%s, mode=0x%x, keydata=%p", pattern, mode, keydata); + + err = export_start (ctx, 1, pattern, mode, keydata); if (!err) err = _gpgme_wait_one (ctx); return err; @@ -126,7 +134,21 @@ gpgme_error_t gpgme_op_export_ext_start (gpgme_ctx_t ctx, const char *pattern[], gpgme_export_mode_t mode, gpgme_data_t keydata) { - return export_ext_start (ctx, 0, pattern, mode, keydata); + TRACE_BEG2 (DEBUG_CTX, "gpgme_op_export_ext_start", ctx, + "mode=0x%x, keydata=%p", mode, keydata); + + if (_gpgme_debug_trace () && pattern) + { + int i = 0; + + while (pattern[i]) + { + TRACE_LOG2 ("pattern[%i] = %s", i, pattern[i]); + i++; + } + } + + return TRACE_ERR (export_ext_start (ctx, 0, pattern, mode, keydata)); } @@ -135,10 +157,26 @@ gpgme_error_t gpgme_op_export_ext (gpgme_ctx_t ctx, const char *pattern[], gpgme_export_mode_t mode, gpgme_data_t keydata) { - gpgme_error_t err = export_ext_start (ctx, 1, pattern, mode, keydata); + gpgme_error_t err; + + TRACE_BEG2 (DEBUG_CTX, "gpgme_op_export_ext_start", ctx, + "mode=0x%x, keydata=%p", mode, keydata); + + if (_gpgme_debug_trace () && pattern) + { + int i = 0; + + while (pattern[i]) + { + TRACE_LOG2 ("pattern[%i] = %s", i, pattern[i]); + i++; + } + } + + err = export_ext_start (ctx, 1, pattern, mode, keydata); if (!err) err = _gpgme_wait_one (ctx); - return err; + return TRACE_ERR (err); } @@ -206,7 +244,23 @@ gpgme_op_export_keys_start (gpgme_ctx_t ctx, gpgme_export_mode_t mode, gpgme_data_t keydata) { - return export_keys_start (ctx, 0, keys, mode, keydata); + TRACE_BEG2 (DEBUG_CTX, "gpgme_op_export_keys_start", ctx, + "mode=0x%x, keydata=%p", mode, keydata); + + if (_gpgme_debug_trace () && keys) + { + int i = 0; + + while (keys[i]) + { + TRACE_LOG3 ("keys[%i] = %p (%s)", i,keys[i], + (keys[i]->subkeys && !keys[i]->subkeys->fpr) ? + keys[i]->subkeys->fpr : "invalid"); + i++; + } + } + + return TRACE_ERR (export_keys_start (ctx, 0, keys, mode, keydata)); } gpgme_error_t @@ -215,7 +269,25 @@ gpgme_op_export_keys (gpgme_ctx_t ctx, gpgme_export_mode_t mode, gpgme_data_t keydata) { - gpgme_error_t err = export_keys_start (ctx, 1, keys, mode, keydata); + gpgme_error_t err; + + TRACE_BEG2 (DEBUG_CTX, "gpgme_op_export_keys", ctx, + "mode=0x%x, keydata=%p", mode, keydata); + + if (_gpgme_debug_trace () && keys) + { + int i = 0; + + while (keys[i]) + { + TRACE_LOG3 ("keys[%i] = %p (%s)", i,keys[i], + (keys[i]->subkeys && !keys[i]->subkeys->fpr) ? + keys[i]->subkeys->fpr : "invalid"); + i++; + } + } + + err = export_keys_start (ctx, 1, keys, mode, keydata); if (!err) err = _gpgme_wait_one (ctx); return err; diff --git a/src/genkey.c b/src/genkey.c index afebb7c..32c6f36 100644 --- a/src/genkey.c +++ b/src/genkey.c @@ -27,6 +27,7 @@ #include #include "gpgme.h" +#include "debug.h" #include "context.h" #include "ops.h" @@ -59,11 +60,21 @@ gpgme_op_genkey_result (gpgme_ctx_t ctx) op_data_t opd; gpgme_error_t err; + TRACE_BEG (DEBUG_CTX, "gpgme_op_genkey_result", ctx); + err = _gpgme_op_data_lookup (ctx, OPDATA_GENKEY, &hook, -1, NULL); opd = hook; if (err || !opd) - return NULL; + { + TRACE_SUC0 ("result=(null)"); + return NULL; + } + TRACE_LOG3 ("fpr = %s, %s, %s", opd->result.fpr, + opd->result.primary ? "primary" : "no primary", + opd->result.sub ? "sub" : "no sub"); + + TRACE_SUC1 ("result=%p", &opd->result); return &opd->result; } @@ -186,7 +197,10 @@ gpgme_error_t gpgme_op_genkey_start (gpgme_ctx_t ctx, const char *parms, gpgme_data_t pubkey, gpgme_data_t seckey) { - return genkey_start (ctx, 0, parms, pubkey, seckey); + TRACE_BEG2 (DEBUG_CTX, "gpgme_op_genkey_start", ctx, + "pubkey=%p, seckey=%p", pubkey, seckey); + TRACE_LOGBUF (parms, strlen (parms)); + return TRACE_ERR (genkey_start (ctx, 0, parms, pubkey, seckey)); } @@ -199,6 +213,10 @@ gpgme_op_genkey (gpgme_ctx_t ctx, const char *parms, gpgme_data_t pubkey, { gpgme_error_t err; + TRACE_BEG2 (DEBUG_CTX, "gpgme_op_genkey", ctx, + "pubkey=%p, seckey=%p", pubkey, seckey); + TRACE_LOGBUF (parms, strlen (parms)); + err = genkey_start (ctx, 1, parms, pubkey, seckey); if (!err) err = _gpgme_wait_one (ctx); diff --git a/src/getauditlog.c b/src/getauditlog.c index 9f02b09..a16c51f 100644 --- a/src/getauditlog.c +++ b/src/getauditlog.c @@ -22,6 +22,7 @@ #endif #include "gpgme.h" +#include "debug.h" #include "context.h" #include "ops.h" @@ -62,7 +63,9 @@ gpgme_error_t gpgme_op_getauditlog_start (gpgme_ctx_t ctx, gpgme_data_t output, unsigned int flags) { - return getauditlog_start (ctx, 0, output, flags); + TRACE_BEG2 (DEBUG_CTX, "gpgme_op_getauditlog_start", ctx, + "output=%p, flags=0x%x", output, flags); + return TRACE_ERR (getauditlog_start (ctx, 0, output, flags)); } @@ -73,9 +76,14 @@ gpgme_op_getauditlog_start (gpgme_ctx_t ctx, gpgme_error_t gpgme_op_getauditlog (gpgme_ctx_t ctx, gpgme_data_t output, unsigned int flags) { - gpgme_error_t err = getauditlog_start (ctx, 1, output, flags); + gpgme_error_t err; + + TRACE_BEG2 (DEBUG_CTX, "gpgme_op_getauditlog", ctx, + "output=%p, flags=0x%x", output, flags); + + err = getauditlog_start (ctx, 1, output, flags); if (!err) err = _gpgme_wait_one (ctx); - return err; + return TRACE_ERR (err); } diff --git a/src/import.c b/src/import.c index 8212a25..1f6ece1 100644 --- a/src/import.c +++ b/src/import.c @@ -27,6 +27,7 @@ #include #include "gpgme.h" +#include "debug.h" #include "context.h" #include "ops.h" @@ -65,11 +66,48 @@ gpgme_op_import_result (gpgme_ctx_t ctx) op_data_t opd; gpgme_error_t err; + TRACE_BEG (DEBUG_CTX, "gpgme_op_import_result", ctx); + err = _gpgme_op_data_lookup (ctx, OPDATA_IMPORT, &hook, -1, NULL); opd = hook; if (err || !opd) - return NULL; + { + TRACE_SUC0 ("result=(null)"); + return NULL; + } + + + if (_gpgme_debug_trace ()) + { + gpgme_import_status_t impstat; + int i; + + TRACE_LOG5 ("%i considered, %i no UID, %i imported, %i imported RSA, " + "%i unchanged", opd->result.considered, + opd->result.no_user_id, opd->result.imported, + opd->result.imported_rsa, opd->result.unchanged); + TRACE_LOG4 ("%i new UIDs, %i new sub keys, %i new signatures, " + "%i new revocations", opd->result.new_user_ids, + opd->result.new_sub_keys, opd->result.new_signatures, + opd->result.new_revocations); + TRACE_LOG3 ("%i secret keys, %i imported, %i unchanged", + opd->result.secret_read, opd->result.secret_imported, + opd->result.secret_unchanged); + TRACE_LOG2 ("%i skipped new keys, %i not imported", + opd->result.skipped_new_keys, opd->result.not_imported); + + impstat = opd->result.imports; + i = 0; + while (impstat) + { + TRACE_LOG4 ("import[%i] for %s = 0x%x (%s)", + i, impstat->fpr, impstat->status, impstat->result); + impstat = impstat->next; + i++; + } + } + TRACE_SUC1 ("result=%p", &opd->result); return &opd->result; } @@ -245,7 +283,10 @@ _gpgme_op_import_start (gpgme_ctx_t ctx, int synchronous, gpgme_data_t keydata) gpgme_error_t gpgme_op_import_start (gpgme_ctx_t ctx, gpgme_data_t keydata) { - return _gpgme_op_import_start (ctx, 0, keydata); + TRACE_BEG1 (DEBUG_CTX, "gpgme_op_import_start", ctx, + "keydata=%p", keydata); + + return TRACE_ERR (_gpgme_op_import_start (ctx, 0, keydata)); } @@ -253,10 +294,15 @@ gpgme_op_import_start (gpgme_ctx_t ctx, gpgme_data_t keydata) gpgme_error_t gpgme_op_import (gpgme_ctx_t ctx, gpgme_data_t keydata) { - gpgme_error_t err = _gpgme_op_import_start (ctx, 1, keydata); + gpgme_error_t err; + + TRACE_BEG1 (DEBUG_CTX, "gpgme_op_import", ctx, + "keydata=%p", keydata); + + err = _gpgme_op_import_start (ctx, 1, keydata); if (!err) err = _gpgme_wait_one (ctx); - return err; + return TRACE_ERR (err); } @@ -312,7 +358,21 @@ _gpgme_op_import_keys_start (gpgme_ctx_t ctx, int synchronous, gpgme_error_t gpgme_op_import_keys_start (gpgme_ctx_t ctx, gpgme_key_t *keys) { - return _gpgme_op_import_keys_start (ctx, 0, keys); + TRACE_BEG (DEBUG_CTX, "gpgme_op_import_keys_start", ctx); + if (_gpgme_debug_trace () && keys) + { + int i = 0; + + while (keys[i]) + { + TRACE_LOG3 ("keys[%i] = %p (%s)", i, keys[i], + (keys[i]->subkeys && !keys[i]->subkeys->fpr) ? + keys[i]->subkeys->fpr : "invalid"); + i++; + } + } + + return TRACE_ERR (_gpgme_op_import_keys_start (ctx, 0, keys)); } @@ -330,10 +390,26 @@ gpgme_op_import_keys_start (gpgme_ctx_t ctx, gpgme_key_t *keys) gpgme_error_t gpgme_op_import_keys (gpgme_ctx_t ctx, gpgme_key_t *keys) { - gpgme_error_t err = _gpgme_op_import_keys_start (ctx, 1, keys); + gpgme_error_t err; + + TRACE_BEG (DEBUG_CTX, "gpgme_op_import_keys", ctx); + if (_gpgme_debug_trace () && keys) + { + int i = 0; + + while (keys[i]) + { + TRACE_LOG3 ("keys[%i] = %p (%s)", i, keys[i], + (keys[i]->subkeys && !keys[i]->subkeys->fpr) ? + keys[i]->subkeys->fpr : "invalid"); + i++; + } + } + + err = _gpgme_op_import_keys_start (ctx, 1, keys); if (!err) err = _gpgme_wait_one (ctx); - return err; + return TRACE_ERR (err); } diff --git a/src/keylist.c b/src/keylist.c index 926b762..e344b31 100644 --- a/src/keylist.c +++ b/src/keylist.c @@ -94,11 +94,19 @@ gpgme_op_keylist_result (gpgme_ctx_t ctx) op_data_t opd; gpgme_error_t err; + TRACE_BEG (DEBUG_CTX, "gpgme_op_keylist_result", ctx); + err = _gpgme_op_data_lookup (ctx, OPDATA_KEYLIST, &hook, -1, NULL); opd = hook; if (err || !opd) - return NULL; + { + TRACE_SUC0 ("result=(null)"); + return NULL; + } + + TRACE_LOG1 ("truncated = %i", opd->result.truncated); + TRACE_SUC1 ("result=%p", &opd->result); return &opd->result; } @@ -850,25 +858,29 @@ gpgme_op_keylist_start (gpgme_ctx_t ctx, const char *pattern, int secret_only) void *hook; op_data_t opd; + TRACE_BEG2 (DEBUG_CTX, "gpgme_op_keylist_start", ctx, + "pattern=%s, secret_only=%i", pattern, secret_only); + err = _gpgme_op_reset (ctx, 2); if (err) - return err; + return TRACE_ERR (err); err = _gpgme_op_data_lookup (ctx, OPDATA_KEYLIST, &hook, sizeof (*opd), release_op_data); opd = hook; if (err) - return err; + return TRACE_ERR (err); _gpgme_engine_set_status_handler (ctx->engine, keylist_status_handler, ctx); err = _gpgme_engine_set_colon_line_handler (ctx->engine, keylist_colon_handler, ctx); if (err) - return err; + return TRACE_ERR (err); - return _gpgme_engine_op_keylist (ctx->engine, pattern, secret_only, - ctx->keylist_mode); + err = _gpgme_engine_op_keylist (ctx->engine, pattern, secret_only, + ctx->keylist_mode); + return TRACE_ERR (err); } @@ -883,24 +895,28 @@ gpgme_op_keylist_ext_start (gpgme_ctx_t ctx, const char *pattern[], void *hook; op_data_t opd; + TRACE_BEG2 (DEBUG_CTX, "gpgme_op_keylist_ext_start", ctx, + "secret_only=%i, reserved=0x%x", secret_only, reserved); + err = _gpgme_op_reset (ctx, 2); if (err) - return err; + return TRACE_ERR (err); err = _gpgme_op_data_lookup (ctx, OPDATA_KEYLIST, &hook, sizeof (*opd), release_op_data); opd = hook; if (err) - return err; + return TRACE_ERR (err); _gpgme_engine_set_status_handler (ctx->engine, keylist_status_handler, ctx); err = _gpgme_engine_set_colon_line_handler (ctx->engine, keylist_colon_handler, ctx); if (err) - return err; + return TRACE_ERR (err); - return _gpgme_engine_op_keylist_ext (ctx->engine, pattern, secret_only, - reserved, ctx->keylist_mode); + err = _gpgme_engine_op_keylist_ext (ctx->engine, pattern, secret_only, + reserved, ctx->keylist_mode); + return TRACE_ERR (err); } @@ -913,27 +929,29 @@ gpgme_op_keylist_next (gpgme_ctx_t ctx, gpgme_key_t *r_key) void *hook; op_data_t opd; + TRACE_BEG (DEBUG_CTX, "gpgme_op_keylist_next", ctx); + if (!ctx || !r_key) - return gpg_error (GPG_ERR_INV_VALUE); + return TRACE_ERR (gpg_error (GPG_ERR_INV_VALUE)); *r_key = NULL; if (!ctx) - return gpg_error (GPG_ERR_INV_VALUE); + return TRACE_ERR (gpg_error (GPG_ERR_INV_VALUE)); err = _gpgme_op_data_lookup (ctx, OPDATA_KEYLIST, &hook, -1, NULL); opd = hook; if (err) - return err; + return TRACE_ERR (err); if (opd == NULL) - return gpg_error (GPG_ERR_INV_VALUE); + return TRACE_ERR (gpg_error (GPG_ERR_INV_VALUE)); if (!opd->key_queue) { err = _gpgme_wait_on_condition (ctx, &opd->key_cond, NULL); if (err) - return err; + return TRACE_ERR (err); if (!opd->key_cond) - return gpg_error (GPG_ERR_EOF); + return TRACE_ERR (gpg_error (GPG_ERR_EOF)); opd->key_cond = 0; assert (opd->key_queue); @@ -945,7 +963,10 @@ gpgme_op_keylist_next (gpgme_ctx_t ctx, gpgme_key_t *r_key) *r_key = queue_item->key; free (queue_item); - return 0; + + return TRACE_SUC2 ("key=%p (%s)", *r_key, + ((*r_key)->subkeys && !(*r_key)->subkeys->fpr) ? + (*r_key)->subkeys->fpr : "invalid"); } @@ -953,6 +974,8 @@ gpgme_op_keylist_next (gpgme_ctx_t ctx, gpgme_key_t *r_key) gpgme_error_t gpgme_op_keylist_end (gpgme_ctx_t ctx) { + TRACE (DEBUG_CTX, "gpgme_op_keylist_end", ctx); + if (!ctx) return gpg_error (GPG_ERR_INV_VALUE); @@ -970,17 +993,20 @@ gpgme_get_key (gpgme_ctx_t ctx, const char *fpr, gpgme_key_t *r_key, gpgme_error_t err; gpgme_key_t key; + TRACE_BEG2 (DEBUG_CTX, "gpgme_get_key", ctx, + "fpr=%s, secret=%i", fpr, secret); + if (!ctx || !r_key || !fpr) - return gpg_error (GPG_ERR_INV_VALUE); + return TRACE_ERR (gpg_error (GPG_ERR_INV_VALUE)); if (strlen (fpr) < 8) /* We have at least a key ID. */ - return gpg_error (GPG_ERR_INV_VALUE); + return TRACE_ERR (gpg_error (GPG_ERR_INV_VALUE)); /* FIXME: We use our own context because we have to avoid the user's I/O callback handlers. */ err = gpgme_new (&listctx); if (err) - return err; + return TRACE_ERR (err); { gpgme_protocol_t proto; gpgme_engine_info_t info; @@ -1031,5 +1057,11 @@ gpgme_get_key (gpgme_ctx_t ctx, const char *fpr, gpgme_key_t *r_key, } } gpgme_release (listctx); - return err; + if (! err) + { + TRACE_LOG2 ("key=%p (%s)", *r_key, + ((*r_key)->subkeys && !(*r_key)->subkeys->fpr) ? + (*r_key)->subkeys->fpr : "invalid"); + } + return TRACE_ERR (err); } diff --git a/src/opassuan.c b/src/opassuan.c index 2db9f6c..d17bfea 100644 --- a/src/opassuan.c +++ b/src/opassuan.c @@ -21,10 +21,13 @@ #include #endif +/* Suppress warning for accessing deprecated member "err". */ +#define _GPGME_IN_GPGME 1 #include "gpgme.h" #include "context.h" #include "ops.h" #include "util.h" +#include "debug.h" static gpgme_error_t opassuan_start (gpgme_ctx_t ctx, int synchronous, @@ -66,10 +69,15 @@ gpgme_op_assuan_transact_start (gpgme_ctx_t ctx, gpgme_assuan_status_cb_t status_cb, void *status_cb_value) { - return opassuan_start (ctx, 0, command, - data_cb, data_cb_value, - inq_cb, inq_cb_value, - status_cb, status_cb_value); + TRACE_BEG7 (DEBUG_CTX, "gpgme_op_assuan_transact_start", ctx, + "command=%s, data_cb=%p/%p, inq_cb=%p/%p, status_cb=%p/%p", + command, data_cb, data_cb_value, inq_cb, inq_cb_value, + status_cb, status_cb_value); + + return TRACE_ERR (opassuan_start (ctx, 0, command, + data_cb, data_cb_value, + inq_cb, inq_cb_value, + status_cb, status_cb_value)); } @@ -83,17 +91,37 @@ gpgme_op_assuan_transact_ext (gpgme_ctx_t ctx, void *inq_cb_value, gpgme_assuan_status_cb_t status_cb, void *status_cb_value, - gpgme_error_t *op_err) + gpgme_error_t *op_err_p) { gpgme_error_t err; + gpgme_error_t op_err; + + TRACE_BEG8 (DEBUG_CTX, "gpgme_op_assuan_transact", ctx, + "command=%s, data_cb=%p/%p, inq_cb=%p/%p, status_cb=%p/%p, " + "op_err=%p", + command, data_cb, data_cb_value, inq_cb, inq_cb_value, + status_cb, status_cb_value, op_err_p); err = opassuan_start (ctx, 1, command, data_cb, data_cb_value, inq_cb, inq_cb_value, status_cb, status_cb_value); if (!err) - err = _gpgme_wait_one_ext (ctx, op_err); - return err; + err = _gpgme_wait_one_ext (ctx, &op_err); + + if (op_err) + { + TRACE_LOG2 ("op_err = %s <%s>", gpgme_strerror (op_err), + gpgme_strsource (op_err)); + if (! op_err_p) + { + TRACE_LOG ("warning: operational error ignored by user"); + } + } + if (op_err_p) + *op_err_p = op_err; + + return TRACE_ERR (err); } @@ -123,17 +151,32 @@ gpgme_op_assuan_result (gpgme_ctx_t ctx) void *hook; op_data_t opd; + TRACE_BEG (DEBUG_CTX, "gpgme_op_assuan_result", ctx); + err = _gpgme_op_data_lookup (ctx, OPDATA_ASSUAN, &hook, -1, NULL); opd = hook; /* Check in case this function is used without having run a command before. */ if (err || !opd) - return NULL; + { + TRACE_SUC0 ("result=(null)"); + return NULL; + } /* All of this is a hack for the old style interface. The new style interface returns op errors directly. */ opd->result.err = _gpgme_engine_assuan_last_op_err (ctx->engine->engine); - + if (opd->result.err) + { + TRACE_LOG1 ("err = %s", gpg_strerror (0)); + } + else + { + TRACE_LOG2 ("err = %s <%s>", gpg_strerror (opd->result.err), + gpg_strsource (opd->result.err)); + } + + TRACE_SUC1 ("result=%p", &opd->result); return &opd->result; } @@ -148,14 +191,15 @@ gpgme_op_assuan_transact (gpgme_ctx_t ctx, gpgme_assuan_status_cb_t status_cb, void *status_cb_value) { - gpgme_error_t op_err; gpgme_error_t err; + TRACE (DEBUG_CTX, "gpgme_op_assuan_transact", ctx); + /* Users of the old-style session based interfaces need to look at the result structure. */ gpgme_op_assuan_transact_ext (ctx, command, data_cb, data_cb_value, inq_cb, inq_cb_value, - status_cb, status_cb_value, &op_err); + status_cb, status_cb_value, NULL); return err; } diff --git a/src/signers.c b/src/signers.c index f1ce58f..da7d319 100644 --- a/src/signers.c +++ b/src/signers.c @@ -28,8 +28,10 @@ #include #include +#include "gpgme.h" #include "util.h" #include "context.h" +#include "debug.h" /* Delete all signers from CTX. */ @@ -38,6 +40,8 @@ gpgme_signers_clear (gpgme_ctx_t ctx) { unsigned int i; + TRACE (DEBUG_CTX, "gpgme_signers_clear", ctx); + if (!ctx || !ctx->signers) return; @@ -54,8 +58,12 @@ gpgme_signers_clear (gpgme_ctx_t ctx) gpgme_error_t gpgme_signers_add (gpgme_ctx_t ctx, const gpgme_key_t key) { + TRACE_BEG2 (DEBUG_CTX, "gpgme_signers_add", ctx, + "key=%p (%s)", key, (key->subkeys && !key->subkeys->fpr) ? + key->subkeys->fpr : "invalid"); + if (!ctx || !key) - return gpg_error (GPG_ERR_INV_VALUE); + return TRACE_ERR (gpg_error (GPG_ERR_INV_VALUE)); if (ctx->signers_len == ctx->signers_size) { @@ -65,7 +73,7 @@ gpgme_signers_add (gpgme_ctx_t ctx, const gpgme_key_t key) newarr = realloc (ctx->signers, n * sizeof (*newarr)); if (!newarr) - return gpg_error_from_errno (errno); + return TRACE_ERR (gpg_error_from_errno (errno)); for (j = ctx->signers_size; j < n; j++) newarr[j] = NULL; ctx->signers = newarr; @@ -74,7 +82,7 @@ gpgme_signers_add (gpgme_ctx_t ctx, const gpgme_key_t key) gpgme_key_ref (key); ctx->signers[ctx->signers_len++] = key; - return 0; + return TRACE_SUC (); } diff --git a/src/trustlist.c b/src/trustlist.c index 23da08c..67c724f 100644 --- a/src/trustlist.c +++ b/src/trustlist.c @@ -28,6 +28,7 @@ #include #include "gpgme.h" +#include "debug.h" #include "util.h" #include "context.h" #include "ops.h" @@ -173,27 +174,31 @@ gpgme_op_trustlist_start (gpgme_ctx_t ctx, const char *pattern, int max_level) void *hook; op_data_t opd; + TRACE_BEG2 (DEBUG_CTX, "gpgme_op_trustlist_start", ctx, + "pattern=%s, max_level=%i", pattern, max_level); + if (!pattern || !*pattern) - return gpg_error (GPG_ERR_INV_VALUE); + return TRACE_ERR (gpg_error (GPG_ERR_INV_VALUE)); err = _gpgme_op_reset (ctx, 2); if (err) - return err; + return TRACE_ERR (err); err = _gpgme_op_data_lookup (ctx, OPDATA_TRUSTLIST, &hook, sizeof (*opd), NULL); opd = hook; if (err) - return err; + return TRACE_ERR (err); _gpgme_engine_set_status_handler (ctx->engine, trustlist_status_handler, ctx); err = _gpgme_engine_set_colon_line_handler (ctx->engine, trustlist_colon_handler, ctx); if (err) - return err; + return TRACE_ERR (err); - return _gpgme_engine_op_trustlist (ctx->engine, pattern); + err = _gpgme_engine_op_trustlist (ctx->engine, pattern); + return TRACE_ERR (err); } @@ -205,26 +210,28 @@ gpgme_op_trustlist_next (gpgme_ctx_t ctx, gpgme_trust_item_t *r_item) op_data_t opd; struct trust_queue_item_s *q; + TRACE_BEG (DEBUG_CTX, "gpgme_op_trustlist_next", ctx); + if (!r_item) - return gpg_error (GPG_ERR_INV_VALUE); + return TRACE_ERR (gpg_error (GPG_ERR_INV_VALUE)); *r_item = NULL; if (!ctx) - return gpg_error (GPG_ERR_INV_VALUE); + return TRACE_ERR (gpg_error (GPG_ERR_INV_VALUE)); err = _gpgme_op_data_lookup (ctx, OPDATA_TRUSTLIST, &hook, -1, NULL); opd = hook; if (err) - return err; + return TRACE_ERR (err); if (opd == NULL) - return gpg_error (GPG_ERR_INV_VALUE); + return TRACE_ERR (gpg_error (GPG_ERR_INV_VALUE)); if (!opd->trust_queue) { err = _gpgme_wait_on_condition (ctx, &opd->trust_cond, NULL); if (err) - return err; + return TRACE_ERR (err); if (!opd->trust_cond) - return gpg_error (GPG_ERR_EOF); + return TRACE_ERR (gpg_error (GPG_ERR_EOF)); opd->trust_cond = 0; assert (opd->trust_queue); } @@ -233,6 +240,25 @@ gpgme_op_trustlist_next (gpgme_ctx_t ctx, gpgme_trust_item_t *r_item) *r_item = q->item; free (q); + if ((*r_item)->type == 1) + { + TRACE_SUC5 ("trust_item=%p: %s: owner trust %s with level %i " + "and validity 0x%x", *r_item, (*r_item)->keyid, + (*r_item)->owner_trust, (*r_item)->level, + (*r_item)->validity); + } + else if ((*r_item)->type == 2) + { + TRACE_SUC5 ("trust_item=%p: %s: UID %s with level %i " + "and validity 0x%x", *r_item, (*r_item)->keyid, + (*r_item)->name, (*r_item)->level, (*r_item)->validity); + } + else + { + TRACE_SUC5 ("trust_item=%p: %s: unknown type %i with level %i " + "and validity 0x%x", *r_item, (*r_item)->keyid, + (*r_item)->type, (*r_item)->level, (*r_item)->validity); + } return 0; } @@ -241,6 +267,8 @@ gpgme_op_trustlist_next (gpgme_ctx_t ctx, gpgme_trust_item_t *r_item) gpgme_error_t gpgme_op_trustlist_end (gpgme_ctx_t ctx) { + TRACE (DEBUG_CTX, "gpgme_op_trustlist_end", ctx); + if (!ctx) return gpg_error (GPG_ERR_INV_VALUE); diff --git a/src/verify.c b/src/verify.c index bf73a8c..e930f7b 100644 --- a/src/verify.c +++ b/src/verify.c @@ -28,6 +28,7 @@ #include #include "gpgme.h" +#include "debug.h" #include "util.h" #include "context.h" #include "ops.h" @@ -83,11 +84,48 @@ gpgme_op_verify_result (gpgme_ctx_t ctx) op_data_t opd; gpgme_error_t err; + TRACE_BEG (DEBUG_CTX, "gpgme_op_verify_result", ctx); err = _gpgme_op_data_lookup (ctx, OPDATA_VERIFY, &hook, -1, NULL); opd = hook; if (err || !opd) - return NULL; + { + TRACE_SUC0 ("result=(null)"); + return NULL; + } + + if (_gpgme_debug_trace ()) + { + gpgme_signature_t sig = opd->result.signatures; + int i = 0; + + while (sig) + { + TRACE_LOG4 ("sig[%i] = fpr %s, summary 0x%x, status %s", + i, sig->fpr, sig->summary, gpg_strerror (sig->status)); + TRACE_LOG6 ("sig[%i] = timestamps 0x%x/0x%x flags:%s%s%s", + i, sig->timestamp, sig->exp_timestamp, + sig->wrong_key_usage ? "wrong key usage" : "", + sig->pka_trust == 1 ? "pka bad" + : (sig->pka_trust == 2 ? "pka_okay" : "pka RFU"), + sig->chain_model ? "chain model" : ""); + TRACE_LOG5 ("sig[%i] = validity 0x%x (%s), algos %s/%s", + i, sig->validity, gpg_strerror (sig->validity_reason), + gpgme_pubkey_algo_name (sig->pubkey_algo), + gpgme_hash_algo_name (sig->hash_algo)); + if (sig->pka_address) + { + TRACE_LOG2 ("sig[%i] = PKA address %s", i, sig->pka_address); + } + if (sig->notations) + { + TRACE_LOG1 ("sig[%i] = has notations (not shown)", i); + } + sig = sig->next; + i++; + } + } + TRACE_SUC1 ("result=%p", &opd->result); return &opd->result; } @@ -794,7 +832,10 @@ gpgme_error_t gpgme_op_verify_start (gpgme_ctx_t ctx, gpgme_data_t sig, gpgme_data_t signed_text, gpgme_data_t plaintext) { - return verify_start (ctx, 0, sig, signed_text, plaintext); + TRACE_BEG3 (DEBUG_CTX, "gpgme_op_verify_start", ctx, + "sig=%p, signed_text=%p, plaintext=%p", + sig, signed_text, plaintext); + return TRACE_ERR (verify_start (ctx, 0, sig, signed_text, plaintext)); } @@ -806,10 +847,14 @@ gpgme_op_verify (gpgme_ctx_t ctx, gpgme_data_t sig, gpgme_data_t signed_text, { gpgme_error_t err; + TRACE_BEG3 (DEBUG_CTX, "gpgme_op_verify", ctx, + "sig=%p, signed_text=%p, plaintext=%p", + sig, signed_text, plaintext); + err = verify_start (ctx, 1, sig, signed_text, plaintext); if (!err) err = _gpgme_wait_one (ctx); - return err; + return TRACE_ERR (err); } diff --git a/src/wait-private.c b/src/wait-private.c index 5d3f267..c5cbd3c 100644 --- a/src/wait-private.c +++ b/src/wait-private.c @@ -78,6 +78,9 @@ _gpgme_wait_on_condition (gpgme_ctx_t ctx, volatile int *cond, gpgme_error_t err = 0; int hang = 1; + if (op_err_p) + *op_err_p = 0; + do { int nr = _gpgme_io_select (ctx->fdt.fds, ctx->fdt.size, 0); @@ -90,8 +93,6 @@ _gpgme_wait_on_condition (gpgme_ctx_t ctx, volatile int *cond, err = gpg_error_from_errno (errno); _gpgme_cancel_with_err (ctx, err, 0); - if (op_err_p) - *op_err_p = 0; return err; } @@ -118,8 +119,6 @@ _gpgme_wait_on_condition (gpgme_ctx_t ctx, volatile int *cond, and signal it. */ _gpgme_cancel_with_err (ctx, err, 0); - if (op_err_p) - *op_err_p = 0; return err; } else if (op_err) @@ -157,8 +156,6 @@ _gpgme_wait_on_condition (gpgme_ctx_t ctx, volatile int *cond, } while (hang); - if (op_err_p) - *op_err_p = 0; return 0; } -- 2.26.2