diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2009-12-23 12:47:53 +0200 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2009-12-23 12:47:53 +0200 |
commit | a0f39d8121a900672a29761a6366568892b99563 (patch) | |
tree | 3e453d8bfaac6b90557139e152e2797908b171e2 | |
parent | d44a5b0b3818601311c6cde02a5ffe65b1a47554 (diff) | |
download | wydawca-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.
-rw-r--r-- | doc/wydawca.texi | 6 | ||||
-rw-r--r-- | src/mail.c | 62 | ||||
-rw-r--r-- | src/null.c | 2 |
3 files changed, 57 insertions, 13 deletions
diff --git a/doc/wydawca.texi b/doc/wydawca.texi index 4161c2b..f26aef6 100644 --- a/doc/wydawca.texi +++ b/doc/wydawca.texi @@ -2201,13 +2201,13 @@ The argument is a list of statistics keywords as described in counters for at least one of the requested categories are not zero. For example, the following statement requires sending notifications only if there occurred any errors or access violation attempts, or any bad signature was uploaded: @smallexample -statistics (stat-msg, errors, access-violations, bad-signatures); +statistics (errors, access-violations, bad-signatures); @end smallexample @end deffn @deffn {Config: mail-statistics} gpg-sign key If this statement is present, the message will be signed using the supplied @acronym{GPG} @var{key}. The key is looked up in @@ -2770,13 +2770,13 @@ spool @var{tag:@i{string}} @{ # @r{Define file sweep time.} file-sweep-time @var{time:@i{interval}}; # @r{Define data dictionary.} # @r{See above}. - dictionary @var{ident:@i{string}}> @{ @dots{} @} + dictionary @var{ident:@i{string}} @{ @dots{} @} # @r{Set up archivation}. archive @var{type:@i{string}} @{ @dots{} @} # @r{Configure notification}. notify-event @{ @dots{} @} @@ -2929,13 +2929,13 @@ Print the program version and exit. Email bug reports to @email{bug-wydawca@@gnu.org.ua}. As the purpose of bug reporting is to improve software, please be sure to include a detailed information when reporting a bug. The minimum information needed is: -@itemize +@itemize @bullet @item Program version you use (see the output of @command{wydawca --version}. @item A description of the bug. @item Conditions under which the bug appears. @item It is often helpful to send the contents of @file{config.log} file along with your bug report. This file is created after running @command{./configure} in @command{wydawca} source root directory. @@ -69,18 +69,50 @@ mu_stream_data_read_cb (void *handle, void *buffer, size_t size) mhp->off += nread; return nread; } 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) { logmsg (LOG_ERR, _("GPGME: cannot create context: %s"), gpgme_strerror (err)); return 1; @@ -117,23 +149,31 @@ gpg_sign (gpgme_data_t *output, gpgme_data_t input, const char *sign_keys) /* FIXME: Passphrase */ gpgme_set_textmode (ctx, 1); gpgme_set_armor (ctx, 1); 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 sign_message (mu_message_t *pmsg, const char *key) { mu_message_t msg = *pmsg; @@ -185,13 +225,15 @@ sign_message (mu_message_t *pmsg, const char *key) logmsg (LOG_ERR, "gpgme_data_new_from_cbs: %s", gpgme_strerror (rc)); return 1; } 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)); return 1; } @@ -231,12 +273,14 @@ sign_message (mu_message_t *pmsg, const char *key) { mu_message_destroy (&msg, mu_message_get_owner (msg)); *pmsg = newmsg; } } + if (rc) + mu_message_destroy (&newmsg, mu_message_get_owner (msg)); gpgme_data_release (output); free (buf); return rc; } @@ -22,13 +22,13 @@ null_move_file (struct file_triplet *trp, const struct spool *spool, { const char *file_name = trp->file[file_id].name; if (debug_level) 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 1; } return 0; |