aboutsummaryrefslogtreecommitdiffstats
path: root/tests/run-decrypt.c
diff options
context:
space:
mode:
authorAndre Heinecke <[email protected]>2018-07-04 13:39:01 +0000
committerAndre Heinecke <[email protected]>2018-07-05 09:29:36 +0000
commita2458806f8bf04b66795e1dde765b42fe1ef6797 (patch)
tree0eebff2f24f9f8bfdce1871b4041bccd293773d9 /tests/run-decrypt.c
parentcpp: Fix memory of DecryptionResult::symkeyAlgo (diff)
downloadgpgme-a2458806f8bf04b66795e1dde765b42fe1ef6797.tar.gz
gpgme-a2458806f8bf04b66795e1dde765b42fe1ef6797.zip
core: Add gpg auditlog to get diagnostics
* src/engine-gpg.c (engine_gpg): Add diagnostics member. (gpg_release): Release diagnostics data. (gpg_new): Set up logger-fd and diagnostics. (gpg_getauditlog): New. Copy diagnostics to a user data. (engine_ops): Add getauditlog. * src/engine-gpgsm.c (gpgsm_getauditlog): Return not implemented for GPGME_AUDITLOG_DIAG. * src/getauditlog.c (getauditlog_start): Don't reset engine for diagnostics. * src/gpgme.h.in (GPGME_AUDITLOG_DIAG): New. (GPGME_AUDITLOG_DEFAULT): New alias to 0. * tests/run-decrypt.c (show_usage, main): Add --diagnostics. * doc/gpgme.texi(Additional Logs): Document getauditlog. -- This enables users of GPGME to get more verbose information from gpg which can assist users in figuring out a problem that was before hidden behind a generalized error like "Decryption Failed". For GPGSM it is not yet available as it is problematic to get it properly in server mode and GPGSM already had the original audit log mechanism in place. GPGME_AUDITLOG_DEFAULT was added for a more explicit documentation.
Diffstat (limited to 'tests/run-decrypt.c')
-rw-r--r--tests/run-decrypt.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/run-decrypt.c b/tests/run-decrypt.c
index 99a15c7e..c9d9e72d 100644
--- a/tests/run-decrypt.c
+++ b/tests/run-decrypt.c
@@ -88,6 +88,7 @@ show_usage (int ex)
" --no-symkey-cache disable the use of that cache\n"
" --ignore-mdc-error allow decryption of legacy data\n"
" --unwrap remove only the encryption layer\n"
+ " --diagnostics print diagnostics\n"
, stderr);
exit (ex);
}
@@ -112,6 +113,7 @@ main (int argc, char **argv)
int no_symkey_cache = 0;
int ignore_mdc_error = 0;
int raw_output = 0;
+ int diagnostics = 0;
if (argc)
{ argc--; argv++; }
@@ -177,6 +179,11 @@ main (int argc, char **argv)
ignore_mdc_error = 1;
argc--; argv++;
}
+ else if (!strcmp (*argv, "--diagnostics"))
+ {
+ diagnostics = 1;
+ argc--; argv++;
+ }
else if (!strcmp (*argv, "--unwrap"))
{
flags |= GPGME_DECRYPT_UNWRAP;
@@ -283,6 +290,28 @@ main (int argc, char **argv)
err = gpgme_op_decrypt_ext (ctx, flags, in, out);
result = gpgme_op_decrypt_result (ctx);
+
+ if (diagnostics)
+ {
+ gpgme_data_t diag;
+ gpgme_error_t diag_err;
+
+ gpgme_data_new (&diag);
+ diag_err = gpgme_op_getauditlog (ctx, diag, GPGME_AUDITLOG_DIAG);
+ if (diag_err)
+ {
+ fprintf (stderr, PGM ": getting diagnostics failed: %s\n",
+ gpgme_strerror (diag_err));
+ }
+ else
+ {
+ fputs ("Begin Diagnostics:\n", stdout);
+ print_data (diag);
+ fputs ("End Diagnostics.\n", stdout);
+ }
+ gpgme_data_release (diag);
+ }
+
if (err)
{
fprintf (stderr, PGM ": decrypt failed: %s\n", gpgme_strerror (err));