From: Werner Koch Date: Fri, 23 Nov 2007 13:07:04 +0000 (+0000) Subject: Make getauditlog work. For now only when configured with --enable-fd-passing. X-Git-Tag: gpgme-1.1.6~6 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=c07011580a3e642baccb0e6d208a309d60aa5a62;p=gpgme.git Make getauditlog work. For now only when configured with --enable-fd-passing. --- diff --git a/gpgme/ChangeLog b/gpgme/ChangeLog index 03f72a9..b75d9c1 100644 --- a/gpgme/ChangeLog +++ b/gpgme/ChangeLog @@ -1,3 +1,8 @@ +2007-11-23 Werner Koch + + * op-support.c (_gpgme_op_reset): Implement a no-reset flag. + * getauditlog.c (getauditlog_start): Use that flag. + 2007-11-22 Werner Koch * gpgme.h (gpgme_op_getauditlog_start, gpgme_op_getauditlog): New. diff --git a/gpgme/getauditlog.c b/gpgme/getauditlog.c index e48637b..9f02b09 100644 --- a/gpgme/getauditlog.c +++ b/gpgme/getauditlog.c @@ -42,7 +42,7 @@ getauditlog_start (gpgme_ctx_t ctx, int synchronous, if (!output) return gpg_error (GPG_ERR_INV_VALUE); - err = _gpgme_op_reset (ctx, synchronous); + err = _gpgme_op_reset (ctx, ((synchronous&255) | 256) ); if (err) return err; diff --git a/gpgme/op-support.c b/gpgme/op-support.c index 6e11804..20c0738 100644 --- a/gpgme/op-support.c +++ b/gpgme/op-support.c @@ -62,16 +62,24 @@ _gpgme_op_data_lookup (gpgme_ctx_t ctx, ctx_op_data_id_t type, void **hook, /* type is: 0: asynchronous operation (use global or user event loop). 1: synchronous operation (always use private event loop). 2: asynchronous private operation (use private or user - event loop). */ + event loop). + 256: Modification flag to suppress the engine reset. +*/ gpgme_error_t _gpgme_op_reset (gpgme_ctx_t ctx, int type) { gpgme_error_t err = 0; struct gpgme_io_cbs io_cbs; + int no_reset = (type & 256); + int reuse_engine = 0; + + type &= 255; _gpgme_release_result (ctx); - if (ctx->engine) + if (ctx->engine && no_reset) + reuse_engine = 1; + else if (ctx->engine) { /* Attempt to reset an existing engine. */ @@ -99,18 +107,20 @@ _gpgme_op_reset (gpgme_ctx_t ctx, int type) return err; } - err = _gpgme_engine_set_locale (ctx->engine, LC_CTYPE, ctx->lc_ctype); + if (!reuse_engine) + { + err = _gpgme_engine_set_locale (ctx->engine, LC_CTYPE, ctx->lc_ctype); #ifdef LC_MESSAGES - if (!err) - err = _gpgme_engine_set_locale (ctx->engine, - LC_MESSAGES, ctx->lc_messages); + if (!err) + err = _gpgme_engine_set_locale (ctx->engine, + LC_MESSAGES, ctx->lc_messages); #endif - - if (err) - { - _gpgme_engine_release (ctx->engine); - ctx->engine = NULL; - return err; + if (err) + { + _gpgme_engine_release (ctx->engine); + ctx->engine = NULL; + return err; + } } if (type == 1 || (type == 2 && !ctx->io_cbs.add)) diff --git a/tests/ChangeLog b/tests/ChangeLog index f57a447..259f560 100644 --- a/tests/ChangeLog +++ b/tests/ChangeLog @@ -1,3 +1,10 @@ +2007-11-23 Werner Koch + + * gpgsm/t-verify.c (check_result): Don't exit on error but set a flag. + (main): Cosnult flag for return value. + (show_auditlog): New. + (main): Use it. + 2007-09-27 Marcus Brinkmann * t-engine-info.c (check_engine_info): Fix debug output. diff --git a/tests/gpgsm/t-verify.c b/tests/gpgsm/t-verify.c index 88d5f37..c6c5d90 100644 --- a/tests/gpgsm/t-verify.c +++ b/tests/gpgsm/t-verify.c @@ -34,6 +34,8 @@ #include "t-support.h" +static int got_errors; + static const char test_text1[] = "Hallo Leute!\n"; static const char test_text1f[]= "Hallo Leute?\n"; static const char test_sig1[] = @@ -60,50 +62,50 @@ check_result (gpgme_verify_result_t result, int summary, char *fpr, { fprintf (stderr, "%s:%i: Unexpected number of signatures\n", __FILE__, __LINE__); - exit (1); + got_errors = 1; } if (sig->summary != summary) { fprintf (stderr, "%s:%i: Unexpected signature summary: " "want=0x%x have=0x%x\n", __FILE__, __LINE__, summary, sig->summary); - exit (1); + got_errors = 1; } if (strcmp (sig->fpr, fpr)) { fprintf (stderr, "%s:%i: Unexpected fingerprint: %s\n", __FILE__, __LINE__, sig->fpr); - exit (1); + got_errors = 1; } if (gpg_err_code (sig->status) != status) { fprintf (stderr, "%s:%i: Unexpected signature status: %s\n", __FILE__, __LINE__, gpgme_strerror (sig->status)); - exit (1); + got_errors = 1; } if (sig->notations) { fprintf (stderr, "%s:%i: Unexpected notation data\n", __FILE__, __LINE__); - exit (1); + got_errors = 1; } if (sig->wrong_key_usage) { fprintf (stderr, "%s:%i: Unexpectedly wrong key usage\n", __FILE__, __LINE__); - exit (1); + got_errors = 1; } if (sig->validity != validity) { fprintf (stderr, "%s:%i: Unexpected validity: %i\n", __FILE__, __LINE__, sig->validity); - exit (1); + got_errors = 1; } if (gpg_err_code (sig->validity_reason) != GPG_ERR_NO_ERROR) { fprintf (stderr, "%s:%i: Unexpected validity reason: %s\n", __FILE__, __LINE__, gpgme_strerror (sig->validity_reason)); - exit (1); + got_errors = 1; } } @@ -117,7 +119,13 @@ show_auditlog (gpgme_ctx_t ctx) err = gpgme_data_new (&data); fail_if_err (err); err = gpgme_op_getauditlog (ctx, data, 0); - fail_if_err (err); + if (err) + { + fprintf (stderr, "%s:%i: Can't get audit log: %s\n", + __FILE__, __LINE__, gpgme_strerror (err)); + got_errors = 1; + } + print_data (data); gpgme_data_release (data); } @@ -164,8 +172,10 @@ main (int argc, char **argv) "3CF405464F66ED4A7DF45BBDD1E4282E33BDB76E", GPG_ERR_BAD_SIGNATURE, GPGME_VALIDITY_UNKNOWN); + show_auditlog (ctx); + gpgme_data_release (text); gpgme_data_release (sig); gpgme_release (ctx); - return 0; + return got_errors? 1 : 0; }