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 @@ -588,12 +588,14 @@ external_check (struct file_triplet *trp) } -/* 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"); @@ -626,5 +628,5 @@ process_directives (struct file_triplet *trp, const struct spool *spool) case filename_dir: - rc = verify_detached_signature (trp, spool); + rc = verify_detached_signature (trp); if (rc == 0) { diff --git a/src/getopt.m4 b/src/getopt.m4 index b615ec3..fc50ff9 100644 --- a/src/getopt.m4 +++ b/src/getopt.m4 @@ -247,5 +247,5 @@ 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'); @@ -216,8 +216,6 @@ 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; @@ -226,5 +224,5 @@ verify_directive_signature (struct file_triplet *trp, int rc; struct uploader_info *uptr; - + create_gpg_homedir (); fail_if_err (gpgme_new (&ctx)); @@ -260,5 +258,5 @@ verify_directive_signature (struct file_triplet *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; } @@ -284,10 +282,12 @@ verify_directive_signature (struct file_triplet *trp, 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) diff --git a/src/process.c b/src/process.c index 23641cd..676e565 100644 --- a/src/process.c +++ b/src/process.c @@ -203,5 +203,5 @@ scan_spool_unlocked (const struct spool *spool, int uc, uid_t *uv) file_type_str (finfo.type), finfo.root_len, finfo.name); - register_file (&finfo); + register_file (&finfo, spool); } diff --git a/src/triplet.c b/src/triplet.c index 0744daa..efe4a0b 100644 --- a/src/triplet.c +++ b/src/triplet.c @@ -61,5 +61,5 @@ 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; @@ -70,5 +70,6 @@ register_file (struct file_info *finfo) 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, @@ -124,5 +125,5 @@ 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; @@ -177,7 +178,4 @@ triplet_processor (void *data, void *proc_data) { struct file_triplet *trp = data; - const struct spool *spool = proc_data; - - trp->spool = spool; if (debug_level) @@ -194,5 +192,5 @@ triplet_processor (void *data, void *proc_data) 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; @@ -211,5 +209,5 @@ triplet_processor (void *data, void *proc_data) } - if (triplet_expired_p (trp, spool->file_sweep_time)) + if (triplet_expired_p (trp, trp->spool->file_sweep_time)) { UPDATE_STATS (STAT_EXPIRED_TRIPLETS); @@ -229,5 +227,5 @@ enumerate_triplets (const struct spool *spool) 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 @@ -194,13 +194,16 @@ 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) @@ -302,5 +305,5 @@ verify_directive_file (struct file_triplet *trp, const struct spool *spool) trp->uploader = NULL; - if (verify_directive_signature (trp, spool)) + if (verify_directive_signature (trp)) { /*FIXME: Update stats */ diff --git a/src/wydawca.h b/src/wydawca.h index 54ecf00..b44b5d7 100644 --- a/src/wydawca.h +++ b/src/wydawca.h @@ -239,4 +239,18 @@ struct spool }; +#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 @@ -402,5 +416,5 @@ 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); @@ -429,10 +443,7 @@ 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, @@ -451,6 +462,5 @@ int directive_first (struct file_triplet *trp, 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); |