aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/config.c9
-rw-r--r--src/gpg.c9
-rw-r--r--src/mail.c244
-rw-r--r--src/wydawca.c1
-rw-r--r--src/wydawca.h4
5 files changed, 240 insertions, 27 deletions
diff --git a/src/config.c b/src/config.c
index 559f766..f0a7042 100644
--- a/src/config.c
+++ b/src/config.c
@@ -860,12 +860,15 @@ cb_archive (enum grecs_callback_command cmd,
860static struct grecs_keyword mail_statistics_kw[] = { 860static struct grecs_keyword mail_statistics_kw[] = {
861 { "message", N_("text"), N_("Message text"), 861 { "message", N_("text"), N_("Message text"),
862 grecs_type_string, &admin_stat_message }, 862 grecs_type_string, &admin_stat_message },
863 { "statistics", 863 { "statistics",
864 N_("items"), N_("Send mail if one or more of these items are set"), 864 N_("items"), N_("Send mail if one or more of these items are set"),
865 grecs_type_string, &mail_admin_mask, 0, cb_statistics }, 865 grecs_type_string, &mail_admin_mask, 0, cb_statistics },
866 { "gpg-sign",
867 N_("key"), N_("Sign message with this key"),
868 grecs_type_string, &admin_stat_sign_key },
866 { NULL } 869 { NULL }
867}; 870};
868 871
869 872
870 873
871static int 874static int
@@ -904,12 +907,15 @@ static struct grecs_keyword notify_event_kw[] = {
904 { "recipient", N_("who"), N_("Notify this recipient"), 907 { "recipient", N_("who"), N_("Notify this recipient"),
905 grecs_type_string, NULL, offsetof(struct notification, tgt), 908 grecs_type_string, NULL, offsetof(struct notification, tgt),
906 cb_recipient }, 909 cb_recipient },
907 { "message", N_("text-or-id"), 910 { "message", N_("text-or-id"),
908 N_("Text of the notification or identifier of a defined message template"), 911 N_("Text of the notification or identifier of a defined message template"),
909 grecs_type_string, NULL, offsetof(struct notification, msg) }, 912 grecs_type_string, NULL, offsetof(struct notification, msg) },
913 { "gpg-sign", N_("key"),
914 N_("Sign message with this key"),
915 grecs_type_string, NULL, offsetof(struct notification, sign_keys) },
910 { NULL } 916 { NULL }
911}; 917};
912 918
913static int 919static int
914cb_notify_event (enum grecs_callback_command cmd, 920cb_notify_event (enum grecs_callback_command cmd,
915 grecs_locus_t *locus, 921 grecs_locus_t *locus,
@@ -1453,12 +1459,15 @@ static struct grecs_keyword wydawca_kw[] = {
1453 { "spool", N_("tag: string"), N_("Define distribution spool"), 1459 { "spool", N_("tag: string"), N_("Define distribution spool"),
1454 grecs_type_section, NULL, 0, 1460 grecs_type_section, NULL, 0,
1455 cb_spool, NULL, spool_kw }, 1461 cb_spool, NULL, spool_kw },
1456 1462
1457 { "all-spools", NULL, N_("Service names that request scanning all spools"), 1463 { "all-spools", NULL, N_("Service names that request scanning all spools"),
1458 grecs_type_string|GRECS_LIST, &all_spool_aliases }, 1464 grecs_type_string|GRECS_LIST, &all_spool_aliases },
1465
1466 { "gpg-homedir", NULL, N_("GPG home directory"),
1467 grecs_type_string, &wydawca_gpg_homedir },
1459 1468
1460 { NULL } 1469 { NULL }
1461}; 1470};
1462 1471
1463void 1472void
1464config_help () 1473config_help ()
diff --git a/src/gpg.c b/src/gpg.c
index 71be53c..1389845 100644
--- a/src/gpg.c
+++ b/src/gpg.c
@@ -125,14 +125,14 @@ remove_homedir ()
125 logmsg (LOG_DEBUG, _("removing GNUPG home directory: %s"), homedir); 125 logmsg (LOG_DEBUG, _("removing GNUPG home directory: %s"), homedir);
126 if (rmdir_r (homedir)) 126 if (rmdir_r (homedir))
127 logmsg (LOG_CRIT, _("failed to remove GPG directory %s"), homedir); 127 logmsg (LOG_CRIT, _("failed to remove GPG directory %s"), homedir);
128} 128}
129 129
130/* Create a temporary GPG home directory */ 130/* Create a temporary GPG home directory */
131int 131static int
132wydawca_gpg_homedir () 132create_gpg_homedir ()
133{ 133{
134 if (homedir) 134 if (homedir)
135 return 0; 135 return 0;
136 136
137 homedir = xstrdup ("/tmp/wydawca-XXXXXX"); 137 homedir = xstrdup ("/tmp/wydawca-XXXXXX");
138 if (!mkdtemp (homedir)) 138 if (!mkdtemp (homedir))
@@ -219,18 +219,17 @@ gpg_verify_signature (gpgme_ctx_t ctx, gpgme_signature_t sig,
219int 219int
220verify_directive_signature (struct file_triplet *trp, 220verify_directive_signature (struct file_triplet *trp,
221 const struct spool *spool) 221 const struct spool *spool)
222{ 222{
223 gpgme_ctx_t ctx; 223 gpgme_ctx_t ctx;
224 gpgme_data_t key_data, directive_data, plain; 224 gpgme_data_t key_data, directive_data, plain;
225 off_t size;
226 gpgme_error_t ec; 225 gpgme_error_t ec;
227 int rc; 226 int rc;
228 struct uploader_info *uptr; 227 struct uploader_info *uptr;
229 228
230 wydawca_gpg_homedir (); 229 create_gpg_homedir ();
231 fail_if_err (gpgme_new (&ctx)); 230 fail_if_err (gpgme_new (&ctx));
232 231
233 for (uptr = trp->uploader_list; uptr; uptr = uptr->next) 232 for (uptr = trp->uploader_list; uptr; uptr = uptr->next)
234 { 233 {
235 gpgme_import_result_t res; 234 gpgme_import_result_t res;
236 gpgme_import_status_t pstat; 235 gpgme_import_status_t pstat;
@@ -298,13 +297,13 @@ verify_detached_signature (struct file_triplet *trp,
298 logmsg (LOG_CRIT, 297 logmsg (LOG_CRIT,
299 _("cannot find path to gpg binary (attempting to verify " 298 _("cannot find path to gpg binary (attempting to verify "
300 "the detached signature for %s"), trp->name); 299 "the detached signature for %s"), trp->name);
301 return 1; 300 return 1;
302 } 301 }
303 302
304 wydawca_gpg_homedir (); 303 create_gpg_homedir ();
305 argv[0] = info->file_name; 304 argv[0] = info->file_name;
306 argv[1] = "--verify"; 305 argv[1] = "--verify";
307 argv[2] = trp->file[file_signature].name; 306 argv[2] = trp->file[file_signature].name;
308 argv[3] = trp->file[file_dist].name; 307 argv[3] = trp->file[file_dist].name;
309 argv[4] = NULL; 308 argv[4] = NULL;
310 309
diff --git a/src/mail.c b/src/mail.c
index 91ea502..15c2937 100644
--- a/src/mail.c
+++ b/src/mail.c
@@ -14,22 +14,24 @@
14 You should have received a copy of the GNU General Public License along 14 You should have received a copy of the GNU General Public License along
15 with wydawca. If not, see <http://www.gnu.org/licenses/>. */ 15 with wydawca. If not, see <http://www.gnu.org/licenses/>. */
16 16
17#include "wydawca.h" 17#include "wydawca.h"
18#include <mail.h> 18#include <mail.h>
19#include <hash.h> 19#include <hash.h>
20#include <gpgme.h>
20 21
21int mailer_opened; 22int mailer_opened;
22mu_mailer_t mailer; 23mu_mailer_t mailer;
23mu_address_t admin_address; 24mu_address_t admin_address;
24mu_address_t from_address; 25mu_address_t from_address;
25unsigned long mail_admin_mask; 26unsigned long mail_admin_mask;
26unsigned long owner_notification_flags; 27unsigned long owner_notification_flags;
27char *user_message_template[MAX_EVENT]; 28char *user_message_template[MAX_EVENT];
28 29
29char *admin_stat_message; 30char *admin_stat_message;
31char *admin_stat_sign_key;
30 32
31void 33void
32mail_init () 34mail_init ()
33{ 35{
34 if (!mailer) 36 if (!mailer)
35 { 37 {
@@ -41,14 +43,209 @@ mail_init ()
41 logmsg (LOG_ERR, _("cannot create default mailer `%s': %s"), 43 logmsg (LOG_ERR, _("cannot create default mailer `%s': %s"),
42 url, mu_strerror (rc)); 44 url, mu_strerror (rc));
43 } 45 }
44 } 46 }
45} 47}
46 48
49struct mu_stream_handle
50{
51 mu_stream_t str;
52 mu_off_t off;
53};
54
55static ssize_t
56mu_stream_data_read_cb (void *handle, void *buffer, size_t size)
57{
58 struct mu_stream_handle *mhp = handle;
59 size_t nread;
60 int rc;
61
62 rc = mu_stream_read (mhp->str, buffer, size, mhp->off, &nread);
63 if (rc)
64 {
65 logmsg (LOG_ERR, "mu_stream_read: %s", mu_strerror (rc));
66 errno = EIO;
67 return -1;
68 }
69
70 mhp->off += nread;
71 return nread;
72}
73
74static int
75gpg_sign (gpgme_data_t *output, gpgme_data_t input, const char *sign_keys)
76{
77 gpgme_ctx_t ctx;
78 gpgme_error_t err = 0;
79 gpgme_key_t key;
80
81 err = gpgme_new (&ctx);
82 if (err)
83 {
84 logmsg (LOG_ERR, _("GPGME: cannot create context: %s"),
85 gpgme_strerror (err));
86 return 1;
87 }
88
89 err = gpgme_op_keylist_start (ctx, sign_keys, 0);
90 if (!err)
91 {
92 while ((err = gpgme_op_keylist_next (ctx, &key)) == 0)
93 {
94 err = gpgme_signers_add (ctx, key);
95 gpgme_key_release (key);
96 }
97 }
98
99 if (err && gpg_err_code (err) != GPG_ERR_EOF)
100 {
101 logmsg (LOG_ERR, _("GPGME: cannot list keys: %s"),
102 gpgme_strerror (err));
103 gpgme_release (ctx);
104 return 1;
105 }
106
107 err = gpgme_data_new (output);
108 if (err)
109 {
110 logmsg (LOG_ERR, _("%s: GPGME error: %s"),
111 "gpgme_data_new",