diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/directive.c | 8 | ||||
-rw-r--r-- | src/getopt.m4 | 2 | ||||
-rw-r--r-- | src/gpg.c | 14 | ||||
-rw-r--r-- | src/process.c | 2 | ||||
-rw-r--r-- | src/triplet.c | 16 | ||||
-rw-r--r-- | src/verify.c | 11 | ||||
-rw-r--r-- | src/wydawca.h | 28 |
7 files changed, 47 insertions, 34 deletions
diff --git a/src/directive.c b/src/directive.c index 401397d..93830b1 100644 --- a/src/directive.c +++ b/src/directive.c @@ -587,14 +587,16 @@ external_check (struct file_triplet *trp) return rc; } -/* Process the directives from TRP, using given SPOOL */ +/* Process the directives from TRP */ int -process_directives (struct file_triplet *trp, const struct spool *spool) +process_directives (struct file_triplet *trp) { int rc, n; const char *key, *val; char *relative_dir; + const struct spool *spool; + ASGN_SPOOL (spool, trp, return 1); UPDATE_STATS (STAT_COMPLETE_TRIPLETS); timer_start ("triplet"); report_init (); @@ -625,7 +627,7 @@ process_directives (struct file_triplet *trp, const struct spool *spool) break; case filename_dir: - rc = verify_detached_signature (trp, spool); + rc = verify_detached_signature (trp); if (rc == 0) { if (external_check (trp)) diff --git a/src/getopt.m4 b/src/getopt.m4 index b615ec3..fc50ff9 100644 --- a/src/getopt.m4 +++ b/src/getopt.m4 @@ -246,7 +246,7 @@ print_help(void) printf ("%s %s [%s]... %s\n", _("Usage:"), [<$2>], _("[<OPTION>]"), gettext (args_doc)); - if (doc && doc[0]) + if (doc[0]) print_option_descr(gettext (doc), 0, RMARGIN); putchar ('\n'); @@ -215,17 +215,15 @@ gpg_verify_signature (gpgme_ctx_t ctx, gpgme_signature_t sig, } /* Verify the directive file from TRP using public key PUBKEY */ -/* FIXME: spool currently unused */ int -verify_directive_signature (struct file_triplet *trp, - const struct spool *spool) +verify_directive_signature (struct file_triplet *trp) { gpgme_ctx_t ctx; gpgme_data_t key_data, directive_data, plain; gpgme_error_t ec; int rc; struct uploader_info *uptr; - + create_gpg_homedir (); fail_if_err (gpgme_new (&ctx)); @@ -259,7 +257,7 @@ verify_directive_signature (struct file_triplet *trp, if (!gpg_verify_signature (ctx, result->signatures, trp)) { UPDATE_STATS (STAT_BAD_SIGNATURE); - notify (spool->notification, trp, ev_bad_directive_signature); + notify (trp->spool->notification, trp, ev_bad_directive_signature); rc = 1; } else @@ -283,12 +281,14 @@ verify_directive_signature (struct file_triplet *trp, NOTE: It is assumed that the public key is already registered (by a previous call to verify_directive_signature). */ int -verify_detached_signature (struct file_triplet *trp, - const struct spool *spool) +verify_detached_signature (struct file_triplet *trp) { gpgme_engine_info_t info; const char *argv[5]; + const struct spool *spool; + ASGN_SPOOL (spool, trp, return 1); + fail_if_err (gpgme_get_engine_info (&info)); while (info && info->protocol != GPGME_PROTOCOL_OpenPGP) info = info->next; diff --git a/src/process.c b/src/process.c index 23641cd..676e565 100644 --- a/src/process.c +++ b/src/process.c @@ -202,7 +202,7 @@ scan_spool_unlocked (const struct spool *spool, int uc, uid_t *uv) logmsg (LOG_DEBUG, _("found file %s: %s, stem: %.*s"), ent->d_name, file_type_str (finfo.type), finfo.root_len, finfo.name); - register_file (&finfo); + register_file (&finfo, spool); } closedir (dir); diff --git a/src/triplet.c b/src/triplet.c index 0744daa..efe4a0b 100644 --- a/src/triplet.c +++ b/src/triplet.c @@ -60,7 +60,7 @@ hash_triplet_free (void *data) /* Register a file in the triplet table */ void -register_file (struct file_info *finfo) +register_file (struct file_info *finfo, const struct spool *spool) { struct file_triplet *tp, *ret; @@ -69,7 +69,8 @@ register_file (struct file_info *finfo) tp->name = (char*)(tp + 1); memcpy (tp->name, finfo->name, finfo->root_len); tp->name[finfo->root_len] = 0; - + tp->spool = spool; + if (! ((triplet_table || (triplet_table = hash_initialize (0, 0, hash_triplet_hasher, @@ -123,7 +124,7 @@ check_triplet_state (struct file_triplet *trp) { if (trp->file[file_directive].name) { - if (verify_directive_file (trp, trp->spool)) + if (verify_directive_file (trp)) return triplet_bad; if (trp->file[file_dist].name == 0 @@ -176,9 +177,6 @@ static bool triplet_processor (void *data, void *proc_data) { struct file_triplet *trp = data; - const struct spool *spool = proc_data; - - trp->spool = spool; if (debug_level) logmsg (LOG_DEBUG, "FILE %s, DIST=%s, SIG=%s, DIRECTIVE=%s", @@ -193,7 +191,7 @@ triplet_processor (void *data, void *proc_data) case triplet_complete: if (debug_level) logmsg (LOG_DEBUG, _("processing triplet `%s'"), trp->name); - if (process_directives (trp, spool)) + if (process_directives (trp)) remove_triplet (trp); return true; @@ -210,7 +208,7 @@ triplet_processor (void *data, void *proc_data) return true; } - if (triplet_expired_p (trp, spool->file_sweep_time)) + if (triplet_expired_p (trp, trp->spool->file_sweep_time)) { UPDATE_STATS (STAT_EXPIRED_TRIPLETS); remove_triplet (trp); @@ -228,7 +226,7 @@ enumerate_triplets (const struct spool *spool) spool->tag, mu_url_to_string (spool->dest_url)); if (triplet_table) { - hash_do_for_each (triplet_table, triplet_processor, (void*) spool); + hash_do_for_each (triplet_table, triplet_processor, NULL); hash_clear (triplet_table); } } diff --git a/src/verify.c b/src/verify.c index 7520466..01c61ea 100644 --- a/src/verify.c +++ b/src/verify.c @@ -193,15 +193,18 @@ uploader_find_frp (struct uploader_info *list, const char *fpr) } int -verify_directive_file (struct file_triplet *trp, const struct spool *spool) +verify_directive_file (struct file_triplet *trp) { char *command; - struct dictionary *dict = spool->dictionary[project_uploader_dict]; 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; @@ -301,7 +304,7 @@ verify_directive_file (struct file_triplet *trp, const struct spool *spool) trp->uploader_list = head; trp->uploader = NULL; - if (verify_directive_signature (trp, spool)) + if (verify_directive_signature (trp)) { /*FIXME: Update stats */ logmsg (LOG_ERR, _("invalid signature for %s"), diff --git a/src/wydawca.h b/src/wydawca.h index 54ecf00..b44b5d7 100644 --- a/src/wydawca.h +++ b/src/wydawca.h @@ -238,6 +238,20 @@ struct spool char *check_script; }; +#define ASGN_SPOOL(spool, trp, faction) \ + do \ + { \ + spool = (trp)->spool; \ + if (!spool) \ + { \ + logmsg (LOG_CRIT, \ + _("INTERNAL ERROR at %s:%d: spool not defined for %s"),\ + __FILE__, __LINE__, (trp)->name); \ + faction; \ + } \ + } \ + while (0) + enum wydawca_stat { @@ -401,7 +415,7 @@ void spool_create_timers (void); void register_spool (struct spool *spool); struct spool *wydawca_find_spool (const char *name); -void register_file (struct file_info *finfo); +void register_file (struct file_info *finfo, const struct spool *spool); void enumerate_triplets (const struct spool *); size_t count_collected_triplets (void); char *triplet_expand_param (const char *tmpl, struct file_triplet *trp); @@ -428,12 +442,9 @@ unsigned dictionary_num_rows (struct dictionary *dict); unsigned dictionary_num_cols (struct dictionary *dict); /* Verification functions */ -int verify_directive_file (struct file_triplet *trp, - const struct spool *spool); -int verify_directive_signature (struct file_triplet *trp, - const struct spool *spool); -int verify_detached_signature (struct file_triplet *trp, - const struct spool *spool); +int verify_directive_file (struct file_triplet *trp); +int verify_directive_signature (struct file_triplet *trp); +int verify_detached_signature (struct file_triplet *trp); int fill_project_name (struct file_triplet *trp); struct uploader_info *uploader_find_frp (struct uploader_info *list, const char *frp); @@ -450,8 +461,7 @@ int directive_first (struct file_triplet *trp, const char **pkey, const char **pval); int directive_next (struct file_triplet *trp, int n, const char **pkey, const char **pval); -int process_directives (struct file_triplet *trp, - const struct spool *spool); +int process_directives (struct file_triplet *trp); int enabled_spool_p (const struct spool *spool); int selected_spools (void); |