diff options
| author | Werner Koch <[email protected]> | 2015-08-25 11:22:43 +0000 | 
|---|---|---|
| committer | Werner Koch <[email protected]> | 2015-08-25 11:23:51 +0000 | 
| commit | 8ddc5801ade02297924447df5745c8877a96e5e3 (patch) | |
| tree | 0d26e47c4eef71c62c8e562d5b34a6e1d6019a0d /src/sign.c | |
| parent | tests: Build test programs in tests/ without wrappers. (diff) | |
| download | gpgme-8ddc5801ade02297924447df5745c8877a96e5e3.tar.gz gpgme-8ddc5801ade02297924447df5745c8877a96e5e3.zip | |
Improve error return by checking the FAILURE status.
* src/gpgme.h.in (GPGME_STATUS_FAILURE): New.
* src/status-table.c (FAILURE): New.
* src/op-support.c (_gpgme_parse_failure): New.
* src/passphrase.c (_gpgme_passphrase_status_handler): Forward FAILURE
status line to the status callback.
* src/decrypt.c (op_data_t): Add field failure_code.
(_gpgme_decrypt_status_handler): Parse that code and act upon it on EOF.
* src/encrypt.c (op_data_t): Add field failure_code.
(_gpgme_encrypt_status_handler): Parse that code and act upon it on EOF.
* src/genkey.c (op_data_t): Add field failure_code.
(genkey_status_handler): Parse that code and act upon it on EOF.
* src/passwd.c (op_data_t): Add field failure_code.
(passwd_status_handler): Parse that code and act upon it on EOF.
* src/sign.c (op_data_t): Add field failure_code.
(_gpgme_sign_status_handler): Parse that code and act upon it on EOF.
* src/verify.c (op_data_t): Add field failure_code.
(_gpgme_verify_status_handler): Parse that code and act upon it on EOF.
--
This requires GnuPG 2.1.8 to actually make a difference.
Signed-off-by: Werner Koch <[email protected]>
Diffstat (limited to 'src/sign.c')
| -rw-r--r-- | src/sign.c | 10 | 
1 files changed, 9 insertions, 1 deletions
| @@ -39,6 +39,9 @@ typedef struct  {    struct _gpgme_op_sign_result result; +  /* The error code from a FAILURE status line or 0.  */ +  gpg_error_t failure_code; +    /* A pointer to the next pointer of the last invalid signer in       the list.  This makes appending new invalid signers painless       while preserving the order.  */ @@ -327,6 +330,10 @@ _gpgme_sign_status_handler (void *priv, gpgme_status_code_t code, char *args)        opd->last_signer_p = &(*opd->last_signer_p)->next;        break; +    case GPGME_STATUS_FAILURE: +      opd->failure_code = _gpgme_parse_failure (args); +      break; +      case GPGME_STATUS_EOF:        /* The UI server does not send information about the created           signature.  This is irrelevant for this protocol and thus we @@ -335,7 +342,7 @@ _gpgme_sign_status_handler (void *priv, gpgme_status_code_t code, char *args)  	err = gpg_error (GPG_ERR_UNUSABLE_SECKEY);        else if (!opd->sig_created_seen                 && ctx->protocol != GPGME_PROTOCOL_UISERVER) -	err = gpg_error (GPG_ERR_GENERAL); +	err = opd->failure_code? opd->failure_code:gpg_error (GPG_ERR_GENERAL);        break;      case GPGME_STATUS_INQUIRE_MAXLEN: @@ -374,6 +381,7 @@ sign_init_result (gpgme_ctx_t ctx, int ignore_inv_recp)    opd = hook;    if (err)      return err; +  opd->failure_code = 0;    opd->last_signer_p = &opd->result.invalid_signers;    opd->last_sig_p = &opd->result.signatures;    opd->ignore_inv_recp = !!ignore_inv_recp; | 
