* 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.
This commit is contained in:
Werner Koch 2004-04-05 18:39:28 +00:00
parent 761cd12e1e
commit fe16ca5cc4
3 changed files with 58 additions and 12 deletions

View File

@ -1,10 +1,16 @@
2004-04-05 Werner Koch <wk@gnupg.org> 2004-04-05 Werner Koch <wk@gnupg.org>
* gpgme.h: Add GPGME_STATUS_NEWSIG.
* verify.c (parse_error): Compare only the last part of the where * verify.c (parse_error): Compare only the last part of the where
token. 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 * engine-gpgsm.c (gpgsm_keylist_ext): Send with-validation
option. Fixed pattern construction. option. Fixed pattern construction.
(status_handler): Add debugging output.
2004-03-23 Marcus Brinkmann <marcus@g10code.de> 2004-03-23 Marcus Brinkmann <marcus@g10code.de>

View File

@ -40,6 +40,7 @@
#include "assuan.h" #include "assuan.h"
#include "status-table.h" #include "status-table.h"
#include "debug.h"
#include "engine-backend.h" #include "engine-backend.h"
@ -692,6 +693,8 @@ status_handler (void *opaque, int fd)
/* Try our best to terminate the connection friendly. */ /* Try our best to terminate the connection friendly. */
/* assuan_write_line (gpgsm->assuan_ctx, "BYE"); */ /* assuan_write_line (gpgsm->assuan_ctx, "BYE"); */
err = map_assuan_error (assuan_err); 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 else if (linelen >= 3
&& line[0] == 'E' && line[1] == 'R' && line[2] == 'R' && 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])); err = map_assuan_error (atoi (&line[4]));
else else
err = gpg_error (GPG_ERR_GENERAL); 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 else if (linelen >= 2
&& line[0] == 'O' && line[1] == 'K' && 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); err = gpgsm->colon.fnc (gpgsm->colon.fnc_value, NULL);
} }
_gpgme_io_close (gpgsm->status_cb.fd); _gpgme_io_close (gpgsm->status_cb.fd);
DEBUG2 ("fd %d: OK line - final status: %s\n",
fd, err? gpg_strerror (err):"ok");
return err; return err;
} }
else if (linelen > 2 else if (linelen > 2
@ -794,6 +801,8 @@ status_handler (void *opaque, int fd)
dst++; dst++;
} }
} }
DEBUG2 ("fd %d: D line; final status: %s\n",
fd, err? gpg_strerror (err):"ok");
} }
else if (linelen > 2 else if (linelen > 2
&& line[0] == 'S' && line[1] == ' ') && line[0] == 'S' && line[1] == ' ')
@ -816,6 +825,8 @@ status_handler (void *opaque, int fd)
} }
else else
fprintf (stderr, "[UNKNOWN STATUS]%s %s", line + 2, rest); 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)); 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) if (err)
return err; return err;
/* We must do a reset becuase we need to reset the list of signers. Note /* We must send a reset because we need to reset the list of
that RESET does not reset OPTION commands. */ signers. Note that RESET does not reset OPTION commands. */
err = gpgsm_assuan_simple_command (gpgsm->assuan_ctx, "RESET", NULL, NULL); err = gpgsm_assuan_simple_command (gpgsm->assuan_ctx, "RESET", NULL, NULL);
if (err) if (err)
return err; return err;

View File

@ -24,6 +24,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <errno.h> #include <errno.h>
#include <assert.h>
#include "gpgme.h" #include "gpgme.h"
#include "util.h" #include "util.h"
@ -36,6 +37,7 @@ typedef struct
struct _gpgme_op_verify_result result; struct _gpgme_op_verify_result result;
gpgme_signature_t current_sig; gpgme_signature_t current_sig;
int did_prepare_new_sig;
} *op_data_t; } *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 static gpgme_error_t
parse_new_sig (op_data_t opd, gpgme_status_code_t code, char *args) 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++; end++;
} }
sig = calloc (1, sizeof (*sig)); if (!opd->did_prepare_new_sig)
if (!sig) {
return gpg_error_from_errno (errno); gpg_error_t err;
if (!opd->result.signatures)
opd->result.signatures = sig; err = prepare_new_sig (opd);
if (opd->current_sig) if (err)
opd->current_sig->next = sig; return err;
opd->current_sig = sig; }
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. */ /* FIXME: We should set the source of the state. */
switch (code) switch (code)
@ -481,12 +505,17 @@ _gpgme_verify_status_handler (void *priv, gpgme_status_code_t code, char *args)
switch (code) switch (code)
{ {
case GPGME_STATUS_NEWSIG:
if (sig)
calc_sig_summary (sig);
break;
case GPGME_STATUS_GOODSIG: case GPGME_STATUS_GOODSIG:
case GPGME_STATUS_EXPSIG: case GPGME_STATUS_EXPSIG:
case GPGME_STATUS_EXPKEYSIG: case GPGME_STATUS_EXPKEYSIG:
case GPGME_STATUS_BADSIG: case GPGME_STATUS_BADSIG:
case GPGME_STATUS_ERRSIG: case GPGME_STATUS_ERRSIG:
if (sig) if (sig && !opd->did_prepare_new_sig)
calc_sig_summary (sig); calc_sig_summary (sig);
return parse_new_sig (opd, code, args); 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); return sig ? parse_error (sig, args) : gpg_error (GPG_ERR_INV_ENGINE);
case GPGME_STATUS_EOF: case GPGME_STATUS_EOF:
if (sig) if (sig && !opd->did_prepare_new_sig)
calc_sig_summary (sig); calc_sig_summary (sig);
break; break;