aboutsummaryrefslogtreecommitdiff
path: root/src/verify.c
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2013-03-12 13:26:54 +0200
committerSergey Poznyakoff <gray@gnu.org.ua>2013-03-12 13:26:54 +0200
commit293108d7806aa3c0c5e706237b3788b261779e66 (patch)
treef3ea5c3419c5de0284da68f1d1b6002933e02a73 /src/verify.c
parent02c6a0ad553ad51f91af9d9e6c28f2529e759305 (diff)
downloadwydawca-293108d7806aa3c0c5e706237b3788b261779e66.tar.gz
wydawca-293108d7806aa3c0c5e706237b3788b261779e66.tar.bz2
Improve triplet API.
* src/wydawca.h (uploader_info): Rename to wy_user. (file_triplet) <uploader_count>: Remove. <admin_list>: New member. (triplet_get_uploaders,triplet_get_uploader) (triplet_get_admins): New protos. * src/triplet.c (wy_user_create) (wy_userlist_free): New static functions. (hash_triplet_free): Use wy_userlist_free. (triplet_get_uploaders,triplet_get_uploader) (triplet_get_admins): New functions. * src/verify.c (verify_directive_file): Rewrite using triplet_get_uploaders. * src/gpg.c (verify_directive_signature): Call triplet_get_uploaders to initialize the uploaders list. * modules/mailutils/mod_mailutils.c (get_recipient): Remove. (get_owner_address): New function. All callers updated. Remove useless const qualifiers.
Diffstat (limited to 'src/verify.c')
-rw-r--r--src/verify.c121
1 files changed, 3 insertions, 118 deletions
diff --git a/src/verify.c b/src/verify.c
index af450c8..464a2b3 100644
--- a/src/verify.c
+++ b/src/verify.c
@@ -168,21 +168,8 @@ fill_project_name(struct file_triplet *trp)
return 0;
}
-struct uploader_info *
-new_uploader_info(struct uploader_info *src)
-{
- struct uploader_info *p = grecs_malloc(sizeof(*p));
- p->next = NULL;
- p->name = src->name;
- p->realname = src->realname;
- p->gpg_key = src->gpg_key;
- p->email = src->email;
- p->fpr = NULL;
- return p;
-}
-
-struct uploader_info *
-uploader_find_frp(struct uploader_info *list, const char *fpr)
+struct wy_user *
+uploader_find_frp(struct wy_user *list, const char *fpr)
{
for (; list; list = list->next)
if (list->fpr && strcmp(list->fpr, fpr) == 0)
@@ -193,17 +180,6 @@ uploader_find_frp(struct uploader_info *list, const char *fpr)
int
verify_directive_file(struct file_triplet *trp, int noath)
{
- char *command;
- int rc;
- void *md;
- size_t nrows, ncols, i;
- struct uploader_info *head, *tail;
- const struct spool *spool;
- struct dictionary *dict;
-
- ASGN_SPOOL(spool, trp, return 1);
- dict = spool->dictionary[project_uploader_dict];
-
if (!trp->file[file_directive].name)
return 1;
@@ -211,99 +187,8 @@ verify_directive_file(struct file_triplet *trp, int noath)
return 1;
if (!noath) {
- md = dictionary_open(dict);
- if (!md)
- return 1;
-
- command = triplet_expand_dictionary_query(dict, md, trp);
-
- rc = dictionary_lookup(dict, md, command);
- free(command);
- if (rc) {
- wy_log(LOG_ERR, _("cannot get uploaders for %s"),
- trp->name);
- dictionary_close(dict, md);
- return 1;
- }
-
- nrows = dictionary_num_rows(dict);
- if (nrows == 0) {
- wy_log(LOG_ERR, _("found no uploaders for %s"),
- trp->name);
- dictionary_close(dict, md);
+ if (!triplet_get_uploaders(trp))
return 1;
- }
-
- ncols = dictionary_num_cols(dict);
- if (ncols < 4) {
- wy_log(LOG_ERR,
- _
- ("project-uploader dictionary error: too few columns (%lu)"),
- (unsigned long)ncols);
- dictionary_close(dict, md);
- return 1;
- }
-
- head = tail = NULL;
- for (i = 0; i < nrows; i++) {
- const char *p;
- struct uploader_info info, *ptr;
-
- memset(&info, 0, sizeof(info));
- p = dictionary_result(dict, md, i, 0);
- if (p)
- info.name = triplet_strdup(trp, p);
- p = dictionary_result(dict, md, i, 1);
- if (p)
- info.realname = triplet_strdup(trp, p);
- p = dictionary_result(dict, md, i, 2);
- if (p)
- info.email = triplet_strdup(trp, p);
- p = dictionary_result(dict, md, i, 3);
- if (p)
- info.gpg_key = triplet_strdup(trp, p);
-
- if (wy_debug_level > 3) {
- wy_log(LOG_DEBUG, _("name: %s"),
- SP(info.name));
- wy_log(LOG_DEBUG, _("realname: %s"),
- SP(info.realname));
- wy_log(LOG_DEBUG, _("gpg-key: %s"),
- SP(info.gpg_key));
- wy_log(LOG_DEBUG, _("email: %s"),
- SP(info.email));
- }
-
- if (!info.name || !info.realname || !info.gpg_key ||
- !info.email) {
- wy_log(LOG_ERR,
- _("project-uploader dictionary error: "
- "malformed row %lu"),
- (unsigned long)i);
- /* FIXME: Memory allocated for `info' will
- be reclaimed only when the triplet is
- freed. */
- continue;
- }
-
- ptr = new_uploader_info(&info);
- if (tail)
- tail->next = ptr;
- else
- head = ptr;
- tail = ptr;
- }
-
- dictionary_close(dict, md);
-
- if (!head) {
- wy_log(LOG_ERR, _("no valid uploaders found for %s"),
- trp->name);
- return 1;
- }
-
- trp->uploader_list = head;
- trp->uploader = NULL;
if (verify_directive_signature(trp)) {
/*FIXME: Update stats */

Return to:

Send suggestions and report system problems to the System administrator.