aboutsummaryrefslogtreecommitdiffstats
path: root/g10
diff options
context:
space:
mode:
Diffstat (limited to 'g10')
-rw-r--r--g10/ChangeLog6
-rw-r--r--g10/mainproc.c2
-rw-r--r--g10/options.h5
-rw-r--r--g10/server.c3
4 files changed, 16 insertions, 0 deletions
diff --git a/g10/ChangeLog b/g10/ChangeLog
index 11e13fb0c..dfe54e770 100644
--- a/g10/ChangeLog
+++ b/g10/ChangeLog
@@ -1,3 +1,9 @@
+2009-10-19 Werner Koch <[email protected]>
+
+ * options.h (glo_ctrl): Add field LASTERR.
+ * mainproc.c (proc_encrypted): Set LASTERR.
+ * server.c (cmd_decrypt): Check LASTERR.
+
2009-10-02 Werner Koch <[email protected]>
* server.c (cmd_encrypt, cmd_decrypt): Implement.
diff --git a/g10/mainproc.c b/g10/mainproc.c
index 4a8df6f57..c3d082c56 100644
--- a/g10/mainproc.c
+++ b/g10/mainproc.c
@@ -581,6 +581,7 @@ proc_encrypted( CTX c, PACKET *pkt )
}
}
else if( result == G10ERR_BAD_SIGN ) {
+ glo_ctrl.lasterr = result;
log_error(_("WARNING: encrypted message has been manipulated!\n"));
write_status( STATUS_BADMDC );
write_status( STATUS_DECRYPTION_FAILED );
@@ -593,6 +594,7 @@ proc_encrypted( CTX c, PACKET *pkt )
c->dek->s2k_cacheid);
passphrase_clear_cache (NULL, c->dek->s2k_cacheid, 0);
}
+ glo_ctrl.lasterr = result;
write_status( STATUS_DECRYPTION_FAILED );
log_error(_("decryption failed: %s\n"), g10_errstr(result));
/* Hmmm: does this work when we have encrypted using multiple
diff --git a/g10/options.h b/g10/options.h
index 3a2a68e61..b6e7e55b8 100644
--- a/g10/options.h
+++ b/g10/options.h
@@ -257,6 +257,11 @@ EXTERN_UNLESS_MAIN_MODULE
struct {
int in_auto_key_retrieve; /* True if we are doing an
auto_key_retrieve. */
+ /* Hack to store the last error. We currently need it because the
+ proc_packet machinery is not able to reliabale return error
+ codes. Thus for the --server purposes we store some of the error
+ codes here. FIXME! */
+ gpg_error_t lasterr;
} glo_ctrl;
#define DBG_PACKET_VALUE 1 /* debug packet reading/writing */
diff --git a/g10/server.c b/g10/server.c
index 478c0ec28..657091b0e 100644
--- a/g10/server.c
+++ b/g10/server.c
@@ -362,7 +362,10 @@ cmd_decrypt (assuan_context_t ctx, char *line)
if (out_fd == -1)
return set_error (GPG_ERR_ASS_NO_OUTPUT, NULL);
+ glo_ctrl.lasterr = 0;
err = decrypt_message_fd (inp_fd, out_fd);
+ if (!err)
+ err = glo_ctrl.lasterr;
/* Close and reset the fds. */
close_message_fd (ctrl);