summaryrefslogtreecommitdiffabout
path: root/src/mail.c
authorSergey Poznyakoff <gray@gnu.org.ua>2009-12-23 10:47:53 (GMT)
committer Sergey Poznyakoff <gray@gnu.org.ua>2009-12-23 10:47:53 (GMT)
commita0f39d8121a900672a29761a6366568892b99563 (patch) (side-by-side diff)
tree3e453d8bfaac6b90557139e152e2797908b171e2 /src/mail.c
parentd44a5b0b3818601311c6cde02a5ffe65b1a47554 (diff)
downloadwydawca-a0f39d8121a900672a29761a6366568892b99563.tar.gz
wydawca-a0f39d8121a900672a29761a6366568892b99563.tar.bz2
Minor bug fixes.
* src/mail.c (gpg_sign): Verify sign result. (sign_message): Likewise. Free temporary message on errors. * src/null.c (null_move_file): Do not remove file in dry-run mode. * doc/wydawca.texi: Update.
Diffstat (limited to 'src/mail.c') (more/less context) (ignore whitespace changes)
-rw-r--r--src/mail.c62
1 files changed, 53 insertions, 9 deletions
diff --git a/src/mail.c b/src/mail.c
index 756490a..e424017 100644
--- a/src/mail.c
+++ b/src/mail.c
@@ -72,12 +72,44 @@ mu_stream_data_read_cb (void *handle, void *buffer, size_t size)
}
static int
+check_sign_result (gpgme_sign_result_t result, gpgme_sig_mode_t type)
+{
+ gpgme_new_signature_t sign;
+
+ if (result->invalid_signers)
+ {
+ logmsg (LOG_ERR, _("GPGME: invalid signer found: %s"),
+ result->invalid_signers->fpr);
+ return 1;
+ }
+
+ if (!result->signatures)
+ {
+ logmsg (LOG_ERR, _("GPGME: no signatures created"));
+ return 1;
+ }
+
+ for (sign = result->signatures; sign; sign = sign->next)
+ {
+ if (sign->type != type)
+ {
+ logmsg (LOG_ERR, _("GPGME: wrong type of signature created"));
+ return 1;
+ }
+ }
+ /* FIXME: fingerprint? */
+ return 0;
+}
+
+
+static int
gpg_sign (gpgme_data_t *output, gpgme_data_t input, const char *sign_keys)
{
gpgme_ctx_t ctx;
gpgme_error_t err = 0;
gpgme_key_t key;
-
+ int ret;
+
err = gpgme_new (&ctx);
if (err)
{
@@ -120,17 +152,25 @@ gpg_sign (gpgme_data_t *output, gpgme_data_t input, const char *sign_keys)
err = gpgme_op_sign (ctx, input, *output, GPGME_SIG_MODE_CLEAR);
if (err)
- logmsg (LOG_ERR, _("%s: GPGME error: %s"),
- "gpgme_op_sign",
- gpgme_strerror (err));
+ {
+ logmsg (LOG_ERR, _("%s: GPGME error: %s"),
+ "gpgme_op_sign",
+ gpgme_strerror (err));
+ ret = 1;
+ }
+ else
+ {
+ ret = check_sign_result (gpgme_op_sign_result (ctx),
+ GPGME_SIG_MODE_CLEAR);
#if 0
/* FIXME: */
- else if (debug_level > 1)
- gpgme_debug_info (ctx);
+ if (debug_level > 1)
+ gpgme_debug_info (ctx);
#endif
-
+ }
+
gpgme_release (ctx);
- return err != 0;
+ return ret;
}
static int
@@ -188,7 +228,9 @@ sign_message (mu_message_t *pmsg, const char *key)
}
rc = gpg_sign (&output, input, key);
-
+ if (rc)
+ return 1;
+
if (gpgme_data_seek (output, 0, SEEK_SET) == -1)
{
logmsg (LOG_ERR, "gpgme_data_seek: %s", strerror (errno));
@@ -234,6 +276,8 @@ sign_message (mu_message_t *pmsg, const char *key)
}
}
+ if (rc)
+ mu_message_destroy (&newmsg, mu_message_get_owner (msg));
gpgme_data_release (output);
free (buf);

Return to:

Send suggestions and report system problems to the System administrator.