added restore feature

This commit is contained in:
SJ
2011-12-13 17:05:22 +01:00
parent b58ff0886b
commit 0ba5bcc778
8 changed files with 33 additions and 11 deletions

View File

@ -128,7 +128,7 @@ struct _state {
struct session_data {
char ttmpfile[SMALLBUFSIZE], tmpframe[SMALLBUFSIZE], tre;
char ttmpfile[SMALLBUFSIZE], tmpframe[SMALLBUFSIZE], tre, restored_copy;
char mailfrom[SMALLBUFSIZE], rcptto[MAX_RCPT_TO][SMALLBUFSIZE], client_addr[SMALLBUFSIZE];
char acceptbuf[SMALLBUFSIZE];
char whitelist[MAXBUFSIZE], blacklist[MAXBUFSIZE];

View File

@ -82,6 +82,10 @@ int parse_line(char *buf, struct _state *state, struct session_data *sdata, stru
state->line_num++;
len = strlen(buf);
if(state->is_1st_header == 1 && (strncmp(buf, "Received: by piler", strlen("Received: by piler")) == 0 || strncmp(buf, "X-piler-id: ", strlen("X-piler-id: ")) == 0) ){
sdata->restored_copy = 1;
}
//printf("buf: %s", buf);
if(state->message_rfc822 == 0 && (buf[0] == '\r' || buf[0] == '\n') ){

View File

@ -180,7 +180,11 @@ void handle_smtp_session(int new_sd, struct __data *data, struct __config *cfg){
if(db_conn == 1){
if(AVIR_VIRUS == sdata.rav){
if(sdata.restored_copy == 1){
syslog(LOG_PRIORITY, "%s: discarding restored copy", sdata.ttmpfile);
inj = OK;
}
else if(AVIR_VIRUS == sdata.rav){
syslog(LOG_PRIORITY, "%s: found virus: %s", sdata.ttmpfile, virusinfo);
counters.c_virus++;
inj = OK;
@ -501,6 +505,7 @@ void initSessionData(struct session_data *sdata){
memset(sdata->whitelist, 0, MAXBUFSIZE);
memset(sdata->blacklist, 0, MAXBUFSIZE);
sdata->restored_copy = 0;
sdata->hdr_len = 0;
sdata->tot_len = 0;

View File

@ -12,6 +12,7 @@
#include <unistd.h>
#include <time.h>
#include <locale.h>
#include <syslog.h>
#include <piler.h>
@ -44,6 +45,9 @@ int main(int argc, char **argv){
return 0;
}
mysql_real_query(&(sdata.mysql), "SET NAMES utf8", strlen("SET NAMES utf8"));
mysql_real_query(&(sdata.mysql), "SET CHARACTER SET utf8", strlen("SET CHARACTER SET utf8"));
printf("locale: %s\n", setlocale(LC_MESSAGES, cfg.locale));
setlocale(LC_CTYPE, cfg.locale);
@ -71,21 +75,27 @@ int main(int argc, char **argv){
//printf("body: *%s*\n", state.b_body);
make_body_digest(&sdata, &cfg);
printf("hdr len: %d\n", sdata.hdr_len);
rule = check_againt_ruleset(data.rules, &state, st.st_size);
//printf("body digest: %s\n", sdata.bodydigest);
printf("body digest: %s\n", sdata.bodydigest);
printf("rules check: %s\n", rule);
mysql_close(&(sdata.mysql));
free_rule(data.rules);
for(i=1; i<=state.n_attachments; i++){
printf("i:%d, name=*%s*, type: *%s*, size: %d, int.name: %s, digest: %s\n", i, state.attachments[i].filename, state.attachments[i].type, state.attachments[i].size, state.attachments[i].internalname, state.attachments[i].digest);
}
printf("\n\n");
mysql_close(&(sdata.mysql));
return 0;
}