This commit is contained in:
SJ 2014-07-01 11:43:36 +02:00
parent 39a2e6a306
commit d79b1f97c7
7 changed files with 31 additions and 50 deletions

View File

@ -10,7 +10,7 @@
#include <piler.h> #include <piler.h>
int do_av_check(struct session_data *sdata, char *rcpttoemail, char *virusinfo, struct __data *data, struct __config *cfg){ int do_av_check(struct session_data *sdata, char *virusinfo, struct __data *data, struct __config *cfg){
int rav = AVIR_OK; int rav = AVIR_OK;
char avengine[SMALLBUFSIZE]; char avengine[SMALLBUFSIZE];

View File

@ -14,7 +14,7 @@
#define VERSION "0.1.25-rc3" #define VERSION "0.1.25-rc3"
#define BUILD 877 #define BUILD 878
#define HOSTID "mailarchiver" #define HOSTID "mailarchiver"

View File

@ -28,6 +28,11 @@ int import_message(char *filename, struct session_data *sdata, struct __data *da
init_session_data(sdata, cfg); init_session_data(sdata, cfg);
if(data->import->extra_recipient){
snprintf(sdata->rcptto[0], SMALLBUFSIZE-1, "%s", data->import->extra_recipient);
sdata->num_of_rcpt_to = 1;
}
if(cfg->verbosity > 1) printf("processing: %s\n", filename); if(cfg->verbosity > 1) printf("processing: %s\n", filename);
if(strcmp(filename, "-") == 0){ if(strcmp(filename, "-") == 0){

View File

@ -211,6 +211,7 @@ int extractEmail(char *rawmail, char *email){
*p = '\0'; *p = '\0';
*q2 = '@'; *q2 = '@';
snprintf(email, SMALLBUFSIZE-1, "%s", q1+1); snprintf(email, SMALLBUFSIZE-1, "%s", q1+1);
*p = '@';
return 1; return 1;
} }
} }

View File

@ -32,56 +32,35 @@ struct _state parse_message(struct session_data *sdata, int take_into_pieces, st
} }
if(sdata->import == 1 && data->import->extra_recipient){
len = strlen(data->import->extra_recipient);
addnode(state.journal_recipient, data->import->extra_recipient);
memcpy(&(state.b_journal_to[state.journaltolen]), data->import->extra_recipient, len);
state.journaltolen += len;
memcpy(&(state.b_journal_to[state.journaltolen]), " ", 1);
state.journaltolen++;
strtolower(state.b_journal_to);
memcpy(&(state.b_to[state.tolen]), data->import->extra_recipient, len);
state.tolen += len;
memcpy(&(state.b_to[state.tolen]), " ", 1);
state.tolen++;
strtolower(state.b_to);
}
if(sdata->num_of_rcpt_to > 0){ if(sdata->num_of_rcpt_to > 0){
for(i=0; i<sdata->num_of_rcpt_to; i++){ for(i=0; i<sdata->num_of_rcpt_to; i++){
extractEmail(sdata->rcptto[i], puf);
if(strlen(puf) > 5){ snprintf(puf, sizeof(puf)-1, "%s ", sdata->rcptto[i]);
if(does_it_seem_like_an_email_address(puf) == 1){
p = strstr(puf, cfg->hostid); p = strstr(puf, cfg->hostid);
if(p && *(p-1) == '.'){ if(!p){
*(p-1) = ' ';
*p = '\0';
strtolower(puf);
len = strlen(puf); len = strlen(puf);
if(does_it_seem_like_an_email_address(puf) == 1){ if(state.tolen < MAXBUFSIZE-len-1){
if(cfg->verbosity >= _LOG_DEBUG) syslog(LOG_PRIORITY, "%s: processing rcpt to address: *%s*", sdata->ttmpfile, puf); if(findnode(state.rcpt, puf) == NULL){
addnode(state.journal_recipient, puf);
if(state.tolen < MAXBUFSIZE-len-1){ memcpy(&(state.b_journal_to[state.journaltolen]), puf, len);
if(findnode(state.rcpt, puf) == NULL){ state.journaltolen += len;
addnode(state.rcpt, puf);
memcpy(&(state.b_to[state.tolen]), puf, len);
state.tolen += len;
if(state.tolen < MAXBUFSIZE-len-1){
split_email_address(puf);
memcpy(&(state.b_to[state.tolen]), puf, len); memcpy(&(state.b_to[state.tolen]), puf, len);
state.tolen += len; state.tolen += len;
if(state.tolen < MAXBUFSIZE-len-1){
split_email_address(puf);
memcpy(&(state.b_to[state.tolen]), puf, len);
state.tolen += len;
}
} }
} }
} }
} }
} }

View File

@ -28,7 +28,7 @@
int read_key(struct __config *cfg); int read_key(struct __config *cfg);
void insert_offset(struct session_data *sdata, int server_id); void insert_offset(struct session_data *sdata, int server_id);
int do_av_check(struct session_data *sdata, char *rcpttoemail, char *virusinfo, struct __data *data, struct __config *cfg); int do_av_check(struct session_data *sdata, char *virusinfo, struct __data *data, struct __config *cfg);
int make_digests(struct session_data *sdata, struct __config *cfg); int make_digests(struct session_data *sdata, struct __config *cfg);
void digest_file(char *filename, char *digest); void digest_file(char *filename, char *digest);

View File

@ -22,7 +22,7 @@
int handle_smtp_session(int new_sd, struct __data *data, struct __config *cfg){ int handle_smtp_session(int new_sd, struct __data *data, struct __config *cfg){
int i, ret, pos, n, inj=ERR, state, prevlen=0; int i, ret, pos, n, inj=ERR, state, prevlen=0;
char *p, buf[MAXBUFSIZE], puf[MAXBUFSIZE], resp[MAXBUFSIZE], prevbuf[MAXBUFSIZE], last2buf[2*MAXBUFSIZE+1]; char *p, buf[MAXBUFSIZE], puf[MAXBUFSIZE], resp[MAXBUFSIZE], prevbuf[MAXBUFSIZE], last2buf[2*MAXBUFSIZE+1];
char rcpttoemail[SMALLBUFSIZE], virusinfo[SMALLBUFSIZE], delay[SMALLBUFSIZE]; char virusinfo[SMALLBUFSIZE], delay[SMALLBUFSIZE];
char *arule = NULL; char *arule = NULL;
char *status = NULL; char *status = NULL;
struct session_data sdata; struct session_data sdata;
@ -167,7 +167,7 @@ int handle_smtp_session(int new_sd, struct __data *data, struct __config *cfg){
remove_stripped_attachments(&sstate); remove_stripped_attachments(&sstate);
inj = ERR_MYDOMAINS; inj = ERR_MYDOMAINS;
snprintf(sdata.acceptbuf, SMALLBUFSIZE-1, "250 Ok %s <%s>\r\n", sdata.ttmpfile, rcpttoemail); snprintf(sdata.acceptbuf, SMALLBUFSIZE-1, "250 Ok %s\r\n", sdata.ttmpfile);
write1(new_sd, sdata.acceptbuf, strlen(sdata.acceptbuf), sdata.tls, data->ssl); write1(new_sd, sdata.acceptbuf, strlen(sdata.acceptbuf), sdata.tls, data->ssl);
syslog(LOG_PRIORITY, "%s: discarding: not on mydomains, from=%s, message-id=%s", sdata.ttmpfile, sdata.fromemail, sstate.message_id); syslog(LOG_PRIORITY, "%s: discarding: not on mydomains, from=%s, message-id=%s", sdata.ttmpfile, sdata.fromemail, sstate.message_id);
@ -182,7 +182,7 @@ int handle_smtp_session(int new_sd, struct __data *data, struct __config *cfg){
#ifdef HAVE_ANTIVIRUS #ifdef HAVE_ANTIVIRUS
if(cfg->use_antivirus == 1){ if(cfg->use_antivirus == 1){
gettimeofday(&tv1, &tz); gettimeofday(&tv1, &tz);
sdata.rav = do_av_check(&sdata, rcpttoemail, &virusinfo[0], data, cfg); sdata.rav = do_av_check(&sdata, &virusinfo[0], data, cfg);
gettimeofday(&tv2, &tz); gettimeofday(&tv2, &tz);
sdata.__av = tvdiff(tv2, tv1); sdata.__av = tvdiff(tv2, tv1);
} }
@ -197,8 +197,6 @@ int handle_smtp_session(int new_sd, struct __data *data, struct __config *cfg){
#endif #endif
if(cfg->verbosity >= _LOG_DEBUG) syslog(LOG_PRIORITY, "%s: round %d in injection", sdata.ttmpfile, i); if(cfg->verbosity >= _LOG_DEBUG) syslog(LOG_PRIORITY, "%s: round %d in injection", sdata.ttmpfile, i);
extractEmail(sdata.rcptto[i], rcpttoemail);
inj = ERR; inj = ERR;
status = S_STATUS_UNDEF; status = S_STATUS_UNDEF;
@ -249,10 +247,10 @@ int handle_smtp_session(int new_sd, struct __data *data, struct __config *cfg){
/* set the accept buffer */ /* set the accept buffer */
snprintf(sdata.acceptbuf, SMALLBUFSIZE-1, "250 Ok %s <%s>\r\n", sdata.ttmpfile, rcpttoemail); snprintf(sdata.acceptbuf, SMALLBUFSIZE-1, "250 Ok %s <%s>\r\n", sdata.ttmpfile, sdata.rcptto[i]);
if(inj == ERR){ if(inj == ERR){
snprintf(sdata.acceptbuf, SMALLBUFSIZE-1, "451 %s <%s>\r\n", sdata.ttmpfile, rcpttoemail); snprintf(sdata.acceptbuf, SMALLBUFSIZE-1, "451 %s <%s>\r\n", sdata.ttmpfile, sdata.rcptto[i]);
status = S_STATUS_ERROR; status = S_STATUS_ERROR;
} }
@ -418,13 +416,11 @@ AFTER_PERIOD:
} }
if(sdata.num_of_rcpt_to < MAX_RCPT_TO-1){ if(sdata.num_of_rcpt_to < MAX_RCPT_TO-1){
snprintf(sdata.rcptto[sdata.num_of_rcpt_to], SMALLBUFSIZE-1, "%s\r\n", buf); extractEmail(buf, sdata.rcptto[sdata.num_of_rcpt_to]);
} }
state = SMTP_STATE_RCPT_TO; state = SMTP_STATE_RCPT_TO;
extractEmail(buf, rcpttoemail);
if(sdata.num_of_rcpt_to < MAX_RCPT_TO-1) sdata.num_of_rcpt_to++; if(sdata.num_of_rcpt_to < MAX_RCPT_TO-1) sdata.num_of_rcpt_to++;