aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2009-12-23 12:47:53 +0200
committerSergey Poznyakoff <gray@gnu.org.ua>2009-12-23 12:47:53 +0200
commita0f39d8121a900672a29761a6366568892b99563 (patch)
tree3e453d8bfaac6b90557139e152e2797908b171e2 /src
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')
-rw-r--r--src/mail.c48
-rw-r--r--src/null.c2
2 files changed, 47 insertions, 3 deletions
diff --git a/src/mail.c b/src/mail.c
index 756490a..e424017 100644
--- a/src/mail.c
+++ b/src/mail.c
@@ -72,11 +72,43 @@ 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));
+ ret = 1;
+ }
+ else
+ {
+ ret = check_sign_result (gpgme_op_sign_result (ctx),
+ GPGME_SIG_MODE_CLEAR);
#if 0
/* FIXME: */
- else if (debug_level > 1)
+ if (debug_level > 1)
gpgme_debug_info (ctx);
#endif
+ }
gpgme_release (ctx);
- return err != 0;
+ return ret;
}
static int
@@ -188,6 +228,8 @@ 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)
{
@@ -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);
diff --git a/src/null.c b/src/null.c
index 6a1b0a7..26ccdbf 100644
--- a/src/null.c
+++ b/src/null.c
@@ -25,7 +25,7 @@ null_move_file (struct file_triplet *trp, const struct spool *spool,
logmsg (LOG_DEBUG, _("spool %s: installing file `%s/%s'"),
spool->tag, reldir, file_name);
UPDATE_STATS (STAT_UPLOADS);
- if (unlink (file_name))
+ if (!dry_run_mode && unlink (file_name))
{
logmsg (LOG_ERR, _("cannot unlink %s: %s"),
file_name, strerror (errno));

Return to:

Send suggestions and report system problems to the System administrator.