diff options
author | Werner Koch <wk@gnupg.org> | 2015-08-25 09:03:31 +0200 |
---|---|---|
committer | Werner Koch <wk@gnupg.org> | 2015-08-25 15:26:33 +0200 |
commit | 9cdff09743c473a12359bfdb914578ede0e4e3e2 (patch) | |
tree | ecad07063ec0abab01e9e29eca601d7ee33ef5ee /g10/cpr.c | |
parent | agent: Raise the maximum password length. Don't hard code it. (diff) | |
download | gnupg2-9cdff09743c473a12359bfdb914578ede0e4e3e2.tar.xz gnupg2-9cdff09743c473a12359bfdb914578ede0e4e3e2.zip |
gpg: Print a new FAILURE status after most commands.
* common/status.h (STATUS_FAILURE): New.
* g10/cpr.c (write_status_failure): New.
* g10/gpg.c (main): Call write_status_failure for all commands which
print an error message here.
* g10/call-agent.c (start_agent): Print an STATUS_ERROR if we can't
set the pinentry mode.
--
This status line can be used similar to the error code returned by
commands send over the Assuan interface in gpgsm. We don't emit them
in gpgsm because there we already have that Assuan interface to return
proper error code. This change helps GPGME to return better error
codes.
Signed-off-by: Werner Koch <wk@gnupg.org>
Diffstat (limited to 'g10/cpr.c')
-rw-r--r-- | g10/cpr.c | 16 |
1 files changed, 15 insertions, 1 deletions
@@ -183,7 +183,7 @@ write_status_text (int no, const char *text) write_status_strings (no, text, NULL); } -/* Wrte an ERROR status line using a full gpg-error error value. */ +/* Write an ERROR status line using a full gpg-error error value. */ void write_status_error (const char *where, gpg_error_t err) { @@ -211,6 +211,20 @@ write_status_errcode (const char *where, int errcode) } +/* Write a FAILURE status line. */ +void +write_status_failure (const char *where, gpg_error_t err) +{ + if (!statusfp || !status_currently_allowed (STATUS_FAILURE)) + return; /* Not enabled or allowed. */ + + es_fprintf (statusfp, "[GNUPG:] %s %s %u\n", + get_status_string (STATUS_FAILURE), where, err); + if (es_fflush (statusfp) && opt.exit_on_status_write_error) + g10_exit (0); +} + + /* * Write a status line with a buffer using %XX escapes. If WRAP is > * 0 wrap the line after this length. If STRING is not NULL it will |