From a4b8dfab94b3ca44b6e3aecd7c0281ca2f5b51d5 Mon Sep 17 00:00:00 2001 From: Sergey Poznyakoff Date: Mon, 30 Nov 2009 21:35:14 +0200 Subject: Do not require uploaders to be present in the system passwd database. * src/wydawca.h (access_method_id): Remove verify_method, gpg_key_method and user_data_method. Add project_uploader_method. (uploader_info): New structure. (struct file_triplet): Remove gid and user data fields. Add uploader_count, uploader_list and uploader. (TRIPLET_GID): Change definition. (verify_directive_signature): Change signature. (uploader_find_frp): New proto. * src/verify.c (extract_plaintext): New function. (fill_project_name): Rewrite. Parse directive file. (uploader_find_frp): New function. (check_access_rights): Remove. (verify_directive_file): Rewrite. * src/config.c (string_to_access_method_id): Reflect changes to the access method system. * src/builtin.c (default_ncol): Reflect changes to the access method system. * src/gpg.c (gpg_sig_ok_p): Remove. (gpg_verify_signature): New function, based on gpg_sig_ok_p. (verify_directive_signature): Remove `pubkey' argument. Register all public keys from the uploader list. Do not call directive_parse, as the directive file must already be parsed by the time the function is called. * src/mail.c (get_uploader_email): New function. (do_notify): Use get_uploader_email for notifying users. * src/triplet.c (hash_triplet_free): Reflect changes to the triplet structure. (format_file_data): Get user name from the system passwd database. (fill_user_data): Remove. (expand_user_real_name, expand_user_email): Reflect changes to struct file_triplet. * tests/etc/wydawca.rcin: Rewrite to reflect new access method system. * tests/mailstats.at, tests/notify-upl.at, tests/upload-dry.at, tests/upload.at: Update. --- src/mail.c | 33 ++++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) (limited to 'src/mail.c') diff --git a/src/mail.c b/src/mail.c index 5065306..beb88d4 100644 --- a/src/mail.c +++ b/src/mail.c @@ -259,9 +259,34 @@ mail_stats () free (exp); } +mu_address_t +get_uploader_email (struct uploader_info *info, struct file_triplet *trp, + const char **errp) +{ + mu_address_t addr; + mu_address_t rcpt = NULL; + int rc; + + rc = mu_address_create (&addr, info->email); + if (rc) + { + *errp = mu_strerror (rc); + return NULL; + } + + mu_address_set_personal (addr, 1, info->realname); + + /* This hack makes sure that mu_address_to_string (rcpt) will + return full email address (with personal part) */ + mu_address_union (&rcpt, addr); + mu_address_destroy (&addr); + + return rcpt; +} + mu_address_t get_recipient (struct access_method *method, struct file_triplet *trp, - char **errp) + const char **errp) { unsigned nrows, ncols, i; mu_address_t rcpt = NULL; @@ -327,7 +352,7 @@ do_notify (struct file_triplet *trp, enum notification_event ev, struct notification *ntf) { mu_address_t rcpt = NULL; - char *errp; + const char *errp; switch (ntf->tgt) { case notify_admin: @@ -335,8 +360,7 @@ do_notify (struct file_triplet *trp, enum notification_event ev, break; case notify_user: - rcpt = get_recipient (trp->spool->access_method[user_data_method], - trp, &errp); + rcpt = get_uploader_email (trp->uploader, trp, &errp); break; case notify_owner: @@ -387,7 +411,6 @@ notify (struct notification *notification_list, { struct notification *p; - fill_project_name (trp); for (p = notification_list; p; p = p->next) if (p->ev == ev) do_notify (trp, ev, p); -- cgit v1.2.1