From 87c3b6012886b05ab8ff36098e1e92e9afb1759c Mon Sep 17 00:00:00 2001 From: Florent Bruneau Date: Wed, 1 Oct 2008 23:23:50 +0200 Subject: [PATCH] Fix cleanup. Improve logging. Signed-off-by: Florent Bruneau --- postlicyd/greylist.c | 10 ++++++---- postlicyd/query.c | 2 +- postlicyd/tst-filters.c | 4 ++-- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/postlicyd/greylist.c b/postlicyd/greylist.c index e80a9df..aee9a6b 100644 --- a/postlicyd/greylist.c +++ b/postlicyd/greylist.c @@ -104,9 +104,10 @@ static TCBDB *greylist_db_get(const greylist_config_t *config, awl_db = tcbdbnew(); if (tcbdbopen(awl_db, path, BDBOREADER)) { tmp_db = tcbdbnew(); - if (tcbdbopen(tmp_db, tmppath, BDBOWRITER | BDBOTRUNC)) { + if (tcbdbopen(tmp_db, tmppath, BDBOWRITER | BDBOCREAT | BDBOTRUNC)) { BDBCUR *cur = tcbdbcurnew(awl_db); TCXSTR *key, *value; + key = tcxstrnew(); value = tcxstrnew(); if (tcbdbcurfirst(cur)) { @@ -142,10 +143,9 @@ static TCBDB *greylist_db_get(const greylist_config_t *config, UNIXERR("rename"); return NULL; } - syslog(LOG_INFO, "database cleanup stat: before %u entries, after %d entries", - old_count, new_count); } - syslog(LOG_INFO, "database cleanup finished"); + syslog(LOG_INFO, "database cleanup stat: before %u entries, after %d entries", + old_count, new_count); } /* Effectively open the database. @@ -166,6 +166,7 @@ static bool greylist_initialize(greylist_config_t *config, if (config->client_awl) { snprintf(path, sizeof(path), "%s/%swhitelist.db", directory, prefix); + syslog(LOG_INFO, "loading auto-whitelist database"); config->awl_db = greylist_db_get(config, path, true, sizeof(struct awl_entry), (db_entry_checker_t)(greylist_check_awlentry)); @@ -175,6 +176,7 @@ static bool greylist_initialize(greylist_config_t *config, } snprintf(path, sizeof(path), "%s/%sgreylist.db", directory, prefix); + syslog(LOG_INFO, "loading greylist database"); config->obj_db = greylist_db_get(config, path, true, sizeof(struct obj_entry), (db_entry_checker_t)(greylist_check_object)); diff --git a/postlicyd/query.c b/postlicyd/query.c index 1dc8e6f..e2511c1 100644 --- a/postlicyd/query.c +++ b/postlicyd/query.c @@ -69,7 +69,7 @@ bool query_parse(query_t *query, char *p) vtk = policy_tokenize(v, vlen); switch (policy_tokenize(k, klen)) { -#define CASE(up, low) case PTK_##up: query->low = v; v[vlen] = '\0'; syslog(LOG_DEBUG, "%s = %s", ptokens[PTK_##up], query->low); break; +#define CASE(up, low) case PTK_##up: query->low = v; v[vlen] = '\0'; break; CASE(HELO_NAME, helo_name); CASE(QUEUE_ID, queue_id); CASE(SENDER, sender); diff --git a/postlicyd/tst-filters.c b/postlicyd/tst-filters.c index 1a8db8b..52f22a4 100644 --- a/postlicyd/tst-filters.c +++ b/postlicyd/tst-filters.c @@ -200,8 +200,8 @@ int main(int argc, char *argv[]) #define RM(File) \ snprintf(path, FILENAME_MAX, "%s/%s", basepath, File); \ unlink(path); - RM("test1_greylist.db"); - RM("test1_whitelist.db"); +// RM("test1_greylist.db"); +// RM("test1_whitelist.db"); RM("test2_greylist.db"); RM("test2_whitelist.db"); #undef RM -- 2.20.1