From: Werner Koch Date: Mon, 5 Apr 2004 18:39:28 +0000 (+0000) Subject: * verify.c (parse_error): Compare only the last part of the where X-Git-Tag: gpgme-0-4-6~7 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=fe16ca5cc467899f94ab2c12510c83f98fe2455b;p=gpgme.git * verify.c (parse_error): Compare only the last part of the where token. (prepare_new_sig): New. (parse_new_sig): Use prepare_new_sig when required. (_gpgme_verify_status_handler): Handle STATUS_NEWSIG. * engine-gpgsm.c (gpgsm_keylist_ext): Send with-validation option. Fixed pattern construction. (status_handler): Add debugging output. --- diff --git a/gpgme/ChangeLog b/gpgme/ChangeLog index 5eb4766..d7fc125 100644 --- a/gpgme/ChangeLog +++ b/gpgme/ChangeLog @@ -1,10 +1,16 @@ 2004-04-05 Werner Koch + * gpgme.h: Add GPGME_STATUS_NEWSIG. + * verify.c (parse_error): Compare only the last part of the where token. + (prepare_new_sig): New. + (parse_new_sig): Use prepare_new_sig when required. + (_gpgme_verify_status_handler): Handle STATUS_NEWSIG. * engine-gpgsm.c (gpgsm_keylist_ext): Send with-validation option. Fixed pattern construction. + (status_handler): Add debugging output. 2004-03-23 Marcus Brinkmann diff --git a/gpgme/engine-gpgsm.c b/gpgme/engine-gpgsm.c index 79eb210..e08c03c 100644 --- a/gpgme/engine-gpgsm.c +++ b/gpgme/engine-gpgsm.c @@ -40,6 +40,7 @@ #include "assuan.h" #include "status-table.h" +#include "debug.h" #include "engine-backend.h" @@ -692,6 +693,8 @@ status_handler (void *opaque, int fd) /* Try our best to terminate the connection friendly. */ /* assuan_write_line (gpgsm->assuan_ctx, "BYE"); */ err = map_assuan_error (assuan_err); + DEBUG3 ("fd %d: error from assuan (%d) getting status line : %s \n", + fd, assuan_err, gpg_strerror (err)); } else if (linelen >= 3 && line[0] == 'E' && line[1] == 'R' && line[2] == 'R' @@ -701,6 +704,8 @@ status_handler (void *opaque, int fd) err = map_assuan_error (atoi (&line[4])); else err = gpg_error (GPG_ERR_GENERAL); + DEBUG2 ("fd %d: ERR line - mapped to: %s\n", + fd, err? gpg_strerror (err):"ok"); } else if (linelen >= 2 && line[0] == 'O' && line[1] == 'K' @@ -721,6 +726,8 @@ status_handler (void *opaque, int fd) err = gpgsm->colon.fnc (gpgsm->colon.fnc_value, NULL); } _gpgme_io_close (gpgsm->status_cb.fd); + DEBUG2 ("fd %d: OK line - final status: %s\n", + fd, err? gpg_strerror (err):"ok"); return err; } else if (linelen > 2 @@ -794,6 +801,8 @@ status_handler (void *opaque, int fd) dst++; } } + DEBUG2 ("fd %d: D line; final status: %s\n", + fd, err? gpg_strerror (err):"ok"); } else if (linelen > 2 && line[0] == 'S' && line[1] == ' ') @@ -816,6 +825,8 @@ status_handler (void *opaque, int fd) } else fprintf (stderr, "[UNKNOWN STATUS]%s %s", line + 2, rest); + DEBUG3 ("fd %d: S line (%s) - final status: %s\n", + fd, line+2, err? gpg_strerror (err):"ok"); } } while (!err && assuan_pending_line (gpgsm->assuan_ctx)); @@ -1424,8 +1435,8 @@ gpgsm_sign (void *engine, gpgme_data_t in, gpgme_data_t out, if (err) return err; - /* We must do a reset becuase we need to reset the list of signers. Note - that RESET does not reset OPTION commands. */ + /* We must send a reset because we need to reset the list of + signers. Note that RESET does not reset OPTION commands. */ err = gpgsm_assuan_simple_command (gpgsm->assuan_ctx, "RESET", NULL, NULL); if (err) return err; diff --git a/gpgme/verify.c b/gpgme/verify.c index 05ea520..18c24c9 100644 --- a/gpgme/verify.c +++ b/gpgme/verify.c @@ -24,6 +24,7 @@ #include #include #include +#include #include "gpgme.h" #include "util.h" @@ -36,6 +37,7 @@ typedef struct struct _gpgme_op_verify_result result; gpgme_signature_t current_sig; + int did_prepare_new_sig; } *op_data_t; @@ -145,6 +147,23 @@ calc_sig_summary (gpgme_signature_t sig) } +static gpgme_error_t +prepare_new_sig (op_data_t opd) +{ + gpgme_signature_t sig; + + sig = calloc (1, sizeof (*sig)); + if (!sig) + return gpg_error_from_errno (errno); + if (!opd->result.signatures) + opd->result.signatures = sig; + if (opd->current_sig) + opd->current_sig->next = sig; + opd->current_sig = sig; + opd->did_prepare_new_sig = 1; + return 0; +} + static gpgme_error_t parse_new_sig (op_data_t opd, gpgme_status_code_t code, char *args) { @@ -157,14 +176,19 @@ parse_new_sig (op_data_t opd, gpgme_status_code_t code, char *args) end++; } - sig = calloc (1, sizeof (*sig)); - if (!sig) - return gpg_error_from_errno (errno); - if (!opd->result.signatures) - opd->result.signatures = sig; - if (opd->current_sig) - opd->current_sig->next = sig; - opd->current_sig = sig; + if (!opd->did_prepare_new_sig) + { + gpg_error_t err; + + err = prepare_new_sig (opd); + if (err) + return err; + } + assert (opd->did_prepare_new_sig); + opd->did_prepare_new_sig = 0; + + assert (opd->current_sig); + sig = opd->current_sig; /* FIXME: We should set the source of the state. */ switch (code) @@ -481,12 +505,17 @@ _gpgme_verify_status_handler (void *priv, gpgme_status_code_t code, char *args) switch (code) { + case GPGME_STATUS_NEWSIG: + if (sig) + calc_sig_summary (sig); + break; + case GPGME_STATUS_GOODSIG: case GPGME_STATUS_EXPSIG: case GPGME_STATUS_EXPKEYSIG: case GPGME_STATUS_BADSIG: case GPGME_STATUS_ERRSIG: - if (sig) + if (sig && !opd->did_prepare_new_sig) calc_sig_summary (sig); return parse_new_sig (opd, code, args); @@ -524,7 +553,7 @@ _gpgme_verify_status_handler (void *priv, gpgme_status_code_t code, char *args) return sig ? parse_error (sig, args) : gpg_error (GPG_ERR_INV_ENGINE); case GPGME_STATUS_EOF: - if (sig) + if (sig && !opd->did_prepare_new_sig) calc_sig_summary (sig); break;