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 | |||
@@ -2204,7 +2204,7 @@ notifications only if there occurred any errors or access violation | |||
2204 | attempts, or any bad signature was uploaded: | 2204 | attempts, or any bad signature was uploaded: |
2205 | 2205 | ||
2206 | @smallexample | 2206 | @smallexample |
2207 | statistics (stat-msg, errors, access-violations, bad-signatures); | 2207 | statistics (errors, access-violations, bad-signatures); |
2208 | @end smallexample | 2208 | @end smallexample |
2209 | @end deffn | 2209 | @end deffn |
2210 | 2210 | ||
@@ -2773,7 +2773,7 @@ spool @var{tag:@i{string}} @{ | |||
2773 | 2773 | ||
2774 | # @r{Define data dictionary.} | 2774 | # @r{Define data dictionary.} |
2775 | # @r{See above}. | 2775 | # @r{See above}. |
2776 | dictionary @var{ident:@i{string}}> @{ @dots{} @} | 2776 | dictionary @var{ident:@i{string}} @{ @dots{} @} |
2777 | 2777 | ||
2778 | # @r{Set up archivation}. | 2778 | # @r{Set up archivation}. |
2779 | archive @var{type:@i{string}} @{ @dots{} @} | 2779 | archive @var{type:@i{string}} @{ @dots{} @} |
@@ -2932,7 +2932,7 @@ Print the program version and exit. | |||
2932 | sure to include a detailed information when reporting a bug. The minimum | 2932 | sure to include a detailed information when reporting a bug. The minimum |
2933 | information needed is: | 2933 | information needed is: |
2934 | 2934 | ||
2935 | @itemize | 2935 | @itemize @bullet |
2936 | @item Program version you use (see the output of @command{wydawca --version}. | 2936 | @item Program version you use (see the output of @command{wydawca --version}. |
2937 | @item A description of the bug. | 2937 | @item A description of the bug. |
2938 | @item Conditions under which the bug appears. | 2938 | @item Conditions under which the bug appears. |
@@ -72,12 +72,44 @@ mu_stream_data_read_cb (void *handle, void *buffer, size_t size) | |||
72 | } | 72 | } |
73 | 73 | ||
74 | static int | 74 | static int |
75 | check_sign_result (gpgme_sign_result_t result, gpgme_sig_mode_t type) | ||
76 | { | ||
77 | gpgme_new_signature_t sign; | ||
78 | |||
79 | if (result->invalid_signers) | ||
80 | { | ||
81 | logmsg (LOG_ERR, _("GPGME: invalid signer found: %s"), | ||
82 | result->invalid_signers->fpr); | ||
83 | return 1; | ||
84 | } | ||
85 | |||
86 | if (!result->signatures) | ||
87 | { | ||
88 | logmsg (LOG_ERR, _("GPGME: no signatures created")); | ||
89 | return 1; | ||
90 | } | ||
91 | |||
92 | for (sign = result->signatures; sign; sign = sign->next) | ||
93 | { | ||
94 | if (sign->type != type) | ||
95 | { | ||
96 | logmsg (LOG_ERR, _("GPGME: wrong type of signature created")); | ||
97 | return 1; | ||
98 | } | ||
99 | } | ||
100 | /* FIXME: fingerprint? */ | ||
101 | return 0; | ||
102 | } | ||
103 | |||
104 | |||
105 | static int | ||
75 | gpg_sign (gpgme_data_t *output, gpgme_data_t input, const char *sign_keys) | 106 | gpg_sign (gpgme_data_t *output, gpgme_data_t input, const char *sign_keys) |
76 | { | 107 | { |
77 | gpgme_ctx_t ctx; | 108 | gpgme_ctx_t ctx; |
78 | gpgme_error_t err = 0; | 109 | gpgme_error_t err = 0; |
79 | gpgme_key_t key; | 110 | gpgme_key_t key; |
80 | 111 | int ret; | |
112 | |||
81 | err = gpgme_new (&ctx); | 113 | err = gpgme_new (&ctx); |
82 | if (err) | 114 | if (err) |
83 | { | 115 | { |
@@ -120,17 +152,25 @@ gpg_sign (gpgme_data_t *output, gpgme_data_t input, const char *sign_keys) | |||
120 | 152 | ||
121 | err = gpgme_op_sign (ctx, input, *output, GPGME_SIG_MODE_CLEAR); | 153 | err = gpgme_op_sign (ctx, input, *output, GPGME_SIG_MODE_CLEAR); |
122 | if (err) | 154 | if (err) |
123 | logmsg (LOG_ERR, _("%s: GPGME error: %s"), | 155 | { |
124 | "gpgme_op_sign", | 156 | logmsg (LOG_ERR, _("%s: GPGME error: %s"), |
125 | gpgme_strerror (err)); | 157 | "gpgme_op_sign", |
158 | gpgme_strerror (err)); | ||
159 | ret = 1; | ||
160 | } | ||
161 | else | ||
162 | { | ||
163 | ret = check_sign_result (gpgme_op_sign_result (ctx), | ||
164 | GPGME_SIG_MODE_CLEAR); | ||
126 | #if 0 | 165 | #if 0 |
127 | /* FIXME: */ | 166 | /* FIXME: */ |
128 | else if (debug_level > 1) | 167 | if (debug_level > 1) |
129 | gpgme_debug_info (ctx); | 168 | gpgme_debug_info (ctx); |
130 | #endif | 169 | #endif |
131 | 170 | } | |
171 | |||
132 | gpgme_release (ctx); | 172 | gpgme_release (ctx); |
133 | return err != 0; | 173 | return ret; |
134 | } | 174 | } |
135 | 175 | ||
136 | static int | 176 | static int |
@@ -188,7 +228,9 @@ sign_message (mu_message_t *pmsg, const char *key) | |||
188 | } | 228 | } |
189 | 229 | ||
190 | rc = gpg_sign (&output, input, key); | 230 | rc = gpg_sign (&output, input, key); |
191 | 231 | if (rc) | |
232 | return 1; | ||
233 | |||
192 | if (gpgme_data_seek (output, 0, SEEK_SET) == -1) | 234 | if (gpgme_data_seek (output, 0, SEEK_SET) == -1) |
193 | { | 235 | { |
194 | logmsg (LOG_ERR, "gpgme_data_seek: %s", strerror (errno)); | 236 | logmsg (LOG_ERR, "gpgme_data_seek: %s", strerror (errno)); |
@@ -234,6 +276,8 @@ sign_message (mu_message_t *pmsg, const char *key) | |||
234 | } | 276 | } |
235 | } | 277 | } |
236 | 278 | ||
279 | if (rc) | ||
280 | mu_message_destroy (&newmsg, mu_message_get_owner (msg)); | ||
237 | gpgme_data_release (output); | 281 | gpgme_data_release (output); |
238 | free (buf); | 282 | free (buf); |
239 | 283 | ||
@@ -25,7 +25,7 @@ null_move_file (struct file_triplet *trp, const struct spool *spool, | |||
25 | logmsg (LOG_DEBUG, _("spool %s: installing file `%s/%s'"), | 25 | logmsg (LOG_DEBUG, _("spool %s: installing file `%s/%s'"), |
26 | spool->tag, reldir, file_name); | 26 | spool->tag, reldir, file_name); |
27 | UPDATE_STATS (STAT_UPLOADS); | 27 | UPDATE_STATS (STAT_UPLOADS); |
28 | if (unlink (file_name)) | 28 | if (!dry_run_mode && unlink (file_name)) |
29 | { | 29 | { |
30 | logmsg (LOG_ERR, _("cannot unlink %s: %s"), | 30 | logmsg (LOG_ERR, _("cannot unlink %s: %s"), |
31 | file_name, strerror (errno)); | 31 | file_name, strerror (errno)); |