From b8d10ea9e5af73fd3bcc4218dc20cc56c2b6c67b Mon Sep 17 00:00:00 2001 From: SJ Date: Tue, 29 Oct 2013 16:05:35 +0100 Subject: [PATCH] skip storing rcpt address matching the cfg.hostid --- src/cfg.c | 2 ++ src/cfg.h | 2 ++ src/config.h | 2 +- src/parser.c | 10 ++++++++-- 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/cfg.c b/src/cfg.c index b0162676..04fe0608 100644 --- a/src/cfg.c +++ b/src/cfg.c @@ -185,6 +185,8 @@ struct __config read_config(char *configfile){ if(parse_config_file(configfile, &cfg, config_parse_rules) == -1) printf("error parsing the configfile: %s\n", configfile); + cfg.hostid_len = strlen(cfg.hostid); + return cfg; } diff --git a/src/cfg.h b/src/cfg.h index 0c1c9d0a..2a989e16 100644 --- a/src/cfg.h +++ b/src/cfg.h @@ -12,6 +12,8 @@ struct __config { char username[MAXVAL]; char hostid[MAXVAL]; + int hostid_len; + char pidfile[MAXVAL]; char pilergetd_pidfile[MAXVAL]; diff --git a/src/config.h b/src/config.h index 0a53155a..addaad45 100644 --- a/src/config.h +++ b/src/config.h @@ -14,7 +14,7 @@ #define VERSION "0.1.25-master-branch" -#define BUILD 846 +#define BUILD 847 #define HOSTID "mailarchiver" diff --git a/src/parser.c b/src/parser.c index bd772f6b..d1e6c646 100644 --- a/src/parser.c +++ b/src/parser.c @@ -636,12 +636,18 @@ int parse_line(char *buf, struct _state *state, struct session_data *sdata, int if(state->message_state == MSG_RECIPIENT && findnode(state->journal_recipient, puf) == NULL){ addnode(state->journal_recipient, puf); memcpy(&(state->b_journal_to[state->journaltolen]), puf, len); - memcpy(&(state->b_journal_to[state->journaltolen]), puf, len); if(cfg->verbosity >= _LOG_DEBUG) syslog(LOG_PRIORITY, "%s: journal rcpt: '%s'", sdata->ttmpfile, puf); } if(findnode(state->rcpt, puf) == NULL){ + + /* skip any address matching ...@cfg->hostid, 2013.10.29, SJ */ + q = strchr(puf, '@'); + if(q && strncmp(q+1, cfg->hostid, cfg->hostid_len) == 0){ + continue; + } + addnode(state->rcpt, puf); memcpy(&(state->b_to[state->tolen]), puf, len); state->tolen += len; @@ -650,7 +656,7 @@ int parse_line(char *buf, struct _state *state, struct session_data *sdata, int if(is_email_address_on_my_domains(puf, data) == 1) sdata->internal_recipient = 1; else sdata->external_recipient = 1; - q = strchr(puf, '@'); + //q = strchr(puf, '@'); if(q){ if(findnode(state->rcpt_domain, q+1) == NULL){ addnode(state->rcpt_domain, q+1);