aboutsummaryrefslogtreecommitdiff
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
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.
-rw-r--r--doc/wydawca.texi6
-rw-r--r--src/mail.c62
-rw-r--r--src/null.c2
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
2204attempts, or any bad signature was uploaded: 2204attempts, or any bad signature was uploaded:
2205 2205
2206@smallexample 2206@smallexample
2207statistics (stat-msg, errors, access-violations, bad-signatures); 2207statistics (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.
2932sure to include a detailed information when reporting a bug. The minimum 2932sure to include a detailed information when reporting a bug. The minimum
2933information needed is: 2933information 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.
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)
72} 72}
73 73
74static int 74static int
75check_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
105static int
75gpg_sign (gpgme_data_t *output, gpgme_data_t input, const char *sign_keys) 106gpg_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
136static int 176static 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
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,
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));

Return to:

Send suggestions and report system problems to the System administrator.