diff options
-rw-r--r-- | src/config.c | 10 | ||||
-rw-r--r-- | src/gpg.c | 107 | ||||
-rw-r--r-- | src/job.c | 7 | ||||
-rw-r--r-- | src/triplet.c | 3 | ||||
-rw-r--r-- | src/verify.c | 3 | ||||
-rw-r--r-- | src/watcher.c | 16 | ||||
-rw-r--r-- | src/wydawca.c | 2 | ||||
-rw-r--r-- | src/wydawca.h | 3 |
8 files changed, 99 insertions, 52 deletions
diff --git a/src/config.c b/src/config.c index 66d5fb7..509b0d5 100644 --- a/src/config.c +++ b/src/config.c @@ -1159,4 +1159,8 @@ static struct grecs_keyword spool_kw[] = { NULL, offsetof(struct spool, file_sweep_time), cb_interval }, + { "inotify", NULL, N_("Enable or disable inotify for this spool"), + grecs_type_bool, GRECS_DFLT, + NULL, offsetof(struct spool, inotify_enable), }, + { "dictionary", N_("ident"), N_("Define data dictionary"), grecs_type_section, GRECS_DFLT, @@ -1201,4 +1205,5 @@ cb_spool (enum grecs_callback_command cmd, spool->tag = grecs_strdup (value->v.string); spool->file_sweep_time = file_sweep_time; + spool->inotify_enable = 1; for (i = 0; i < NITEMS (spool->dictionary); i++) spool->dictionary[i] = default_dictionary[i]; @@ -1419,5 +1424,8 @@ static struct grecs_keyword wydawca_kw[] = { { "pidfile", N_("file"), N_("Set pid file name"), grecs_type_string, GRECS_DFLT, &pidfile }, - + + { "inotify", NULL, N_("Enable or disable inotify support"), + grecs_type_bool, GRECS_DFLT, &inotify_enable }, + { "user", N_("name"), N_("Run with UID and GID of this user"), grecs_type_string, GRECS_DFLT, NULL, 0, cb_user }, @@ -148,4 +148,55 @@ create_gpg_homedir () static int +checksig (gpgme_signature_t sig, const char *uid, struct file_triplet *trp) +{ + switch (gpg_err_code (sig->status)) + { + case GPG_ERR_NO_ERROR: + if (debug_level) + logmsg (LOG_NOTICE, _("Good signature from %s"), uid); + trp->uploader = uploader_find_frp (trp->uploader_list, sig->fpr); + if (!trp->uploader) + { + logmsg (LOG_ERR, + _("good signature from %s, " + "but the uploader info for %s not found"), + uid, sig->fpr); + return 1; + } + break; + + case GPG_ERR_BAD_SIGNATURE: + UPDATE_STATS (STAT_BAD_SIGNATURE); + logmsg (LOG_ERR, _("BAD signature from %s"), uid); + return 0; + + case GPG_ERR_NO_PUBKEY: + UPDATE_STATS (STAT_ACCESS_VIOLATIONS); + logmsg (LOG_ERR, _("No public key")); + return 0; + + case GPG_ERR_NO_DATA: + UPDATE_STATS (STAT_BAD_TRIPLETS); + logmsg (LOG_ERR, _("No signature")); + return 0; + + case GPG_ERR_SIG_EXPIRED: + UPDATE_STATS (STAT_BAD_SIGNATURE); + logmsg (LOG_ERR, _("Expired signature from %s"), uid); + return 0; + + case GPG_ERR_KEY_EXPIRED: + UPDATE_STATS (STAT_BAD_SIGNATURE); + logmsg (LOG_ERR, _("Key expired (%s)"), uid); + return 0; + + default: + logmsg (LOG_ERR, _("Unknown signature error")); + return 0; + } + return -1; +} + +static int gpg_verify_signature (gpgme_ctx_t ctx, gpgme_signature_t sig, struct file_triplet *trp) @@ -158,55 +209,14 @@ gpg_verify_signature (gpgme_ctx_t ctx, gpgme_signature_t sig, const char *uid; gpgme_key_t key; - + int rc; + if (gpgme_get_key (ctx, sig->fpr, &key, 0) == GPG_ERR_NO_ERROR) uid = key->uids->uid; else uid = sig->fpr; - - switch (gpg_err_code (sig->status)) - { - case GPG_ERR_NO_ERROR: - if (debug_level) - logmsg (LOG_NOTICE, _("Good signature from %s"), uid); - trp->uploader = uploader_find_frp (trp->uploader_list, sig->fpr); - if (!trp->uploader) - { - logmsg (LOG_ERR, - _("good signature from %s, " - "but the uploader info for %s not found"), - uid, sig->fpr); - return 1; - } - break; - - case GPG_ERR_BAD_SIGNATURE: - UPDATE_STATS (STAT_BAD_SIGNATURE); - logmsg (LOG_ERR, _("BAD signature from %s"), uid); - return 0; - - case GPG_ERR_NO_PUBKEY: - UPDATE_STATS (STAT_ACCESS_VIOLATIONS); - logmsg (LOG_ERR, _("No public key")); - return 0; - - case GPG_ERR_NO_DATA: - UPDATE_STATS (STAT_BAD_TRIPLETS); - logmsg (LOG_ERR, _("No signature")); - return 0; - - case GPG_ERR_SIG_EXPIRED: - UPDATE_STATS (STAT_BAD_SIGNATURE); - logmsg (LOG_ERR, _("Expired signature from %s"), uid); - return 0; - - case GPG_ERR_KEY_EXPIRED: - UPDATE_STATS (STAT_BAD_SIGNATURE); - logmsg (LOG_ERR, _("Key expired (%s)"), uid); - return 0; - - default: - logmsg (LOG_ERR, _("Unknown signature error")); - return 0; - } + rc = checksig (sig, uid, trp); + gpgme_key_unref (key); + if (rc != -1) + return rc; } return 1; @@ -218,5 +228,5 @@ verify_directive_signature (struct file_triplet *trp) { gpgme_ctx_t ctx; - gpgme_data_t key_data, directive_data, plain; + gpgme_data_t key_data, directive_data, plain = NULL; gpgme_error_t ec; int rc; @@ -270,4 +280,5 @@ verify_directive_signature (struct file_triplet *trp) } + gpgme_data_release (plain); gpgme_data_release (directive_data); gpgme_data_release (key_data); @@ -339,5 +339,10 @@ job_queue_runner () } else - job_remove (job); + { + job_remove (job); + free (job); + job = next; + continue; + } } } diff --git a/src/triplet.c b/src/triplet.c index 05b7536..aa74de0 100644 --- a/src/triplet.c +++ b/src/triplet.c @@ -128,7 +128,8 @@ triplet_lookup (struct spool *spool, const char *name) key.name[finfo.root_len] = 0; key.spool = spool; + file_info_cleanup (&finfo); ret = grecs_symtab_lookup_or_install (triplet_table, &key, NULL); - file_info_cleanup (&finfo); + free (key.name); return ret; diff --git a/src/verify.c b/src/verify.c index 4a108bc..dee160f 100644 --- a/src/verify.c +++ b/src/verify.c @@ -97,4 +97,7 @@ fill_project_name (struct file_triplet *trp) const char *directory; int rc; + + if (trp->blurb) + return 0; size = trp->file[file_directive].sb.st_size; diff --git a/src/watcher.c b/src/watcher.c index f8761ee..c52e3e6 100644 --- a/src/watcher.c +++ b/src/watcher.c @@ -84,7 +84,14 @@ create_watcher (struct spool *sp, void *data) if (!sp) return 0; + + if (!sp->inotify_enable) + { + if (debug_level > 1) + logmsg (LOG_DEBUG, "disabling inotify support for spool %s", sp->tag); + return 0; + } if (debug_level > 1) - logmsg (LOG_DEBUG, "creating watcher %s", path); + logmsg (LOG_DEBUG, "spool %s: creating watcher %s", sp->tag, path); dwp = malloc (sizeof(*dwp)); if (!dwp) @@ -114,4 +121,11 @@ watcher_init () { int ifd, rc; + + if (!inotify_enable) + { + if (debug_level > 1) + logmsg (LOG_DEBUG, "disabling inotify support"); + return -1; + } if (debug_level > 1) diff --git a/src/wydawca.c b/src/wydawca.c index 521d796..45a5cff 100644 --- a/src/wydawca.c +++ b/src/wydawca.c @@ -54,4 +54,6 @@ unsigned min_directive_version = MIN_DIRECTIVE_VERSION; unsigned max_directive_version = MAX_DIRECTIVE_VERSION; +int inotify_enable = 1; + void initstats () diff --git a/src/wydawca.h b/src/wydawca.h index 722fc9b..323d403 100644 --- a/src/wydawca.h +++ b/src/wydawca.h @@ -227,4 +227,5 @@ struct spool const char *dest_dir; /* Directory part of the above */ struct virt_tab vtab; /* Virtual method table */ + int inotify_enable; time_t file_sweep_time; /* Remove invalid/unprocessed files @@ -378,4 +379,6 @@ extern struct spool fake_spool; extern struct spool inotify_spool; +extern int inotify_enable; + #define UPDATE_STATS(what) \ do \ |