mirror of
https://bitbucket.org/jsuto/piler.git
synced 2024-11-08 01:51:59 +01:00
session.c refactoring
This commit is contained in:
parent
d88b419624
commit
045068fe3c
@ -13,8 +13,10 @@
|
|||||||
int do_av_check(struct session_data *sdata, 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];
|
||||||
|
struct timezone tz;
|
||||||
|
struct timeval tv1, tv2;
|
||||||
|
|
||||||
if(sdata->need_scan == 0) return rav;
|
gettimeofday(&tv1, &tz);
|
||||||
|
|
||||||
memset(avengine, 0, SMALLBUFSIZE);
|
memset(avengine, 0, SMALLBUFSIZE);
|
||||||
|
|
||||||
@ -50,6 +52,9 @@ int do_av_check(struct session_data *sdata, char *virusinfo, struct __data *data
|
|||||||
|
|
||||||
if(cfg->verbosity >= _LOG_DEBUG) syslog(LOG_PRIORITY, "%s: done virus scanning", sdata->ttmpfile);
|
if(cfg->verbosity >= _LOG_DEBUG) syslog(LOG_PRIORITY, "%s: done virus scanning", sdata->ttmpfile);
|
||||||
|
|
||||||
|
gettimeofday(&tv2, &tz);
|
||||||
|
sdata->__av = tvdiff(tv2, tv1);
|
||||||
|
|
||||||
return rav;
|
return rav;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
#define VERSION "1.2.0-master"
|
#define VERSION "1.2.0-master"
|
||||||
|
|
||||||
#define BUILD 927
|
#define BUILD 928
|
||||||
|
|
||||||
#define HOSTID "mailarchiver"
|
#define HOSTID "mailarchiver"
|
||||||
|
|
||||||
|
@ -19,6 +19,9 @@
|
|||||||
#include <piler.h>
|
#include <piler.h>
|
||||||
|
|
||||||
|
|
||||||
|
int is_blocked_by_tcp_wrappers(int sd);
|
||||||
|
|
||||||
|
|
||||||
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, protocol_state, prevlen=0;
|
int i, ret, pos, n, inj=ERR, protocol_state, prevlen=0;
|
||||||
char *p, *rcpt, buf[MAXBUFSIZE], puf[MAXBUFSIZE], resp[MAXBUFSIZE], prevbuf[MAXBUFSIZE], last2buf[2*MAXBUFSIZE+1];
|
char *p, *rcpt, buf[MAXBUFSIZE], puf[MAXBUFSIZE], resp[MAXBUFSIZE], prevbuf[MAXBUFSIZE], last2buf[2*MAXBUFSIZE+1];
|
||||||
@ -41,15 +44,7 @@ int handle_smtp_session(int new_sd, struct __data *data, struct __config *cfg){
|
|||||||
|
|
||||||
|
|
||||||
#ifdef HAVE_LIBWRAP
|
#ifdef HAVE_LIBWRAP
|
||||||
struct request_info req;
|
if(is_blocked_by_tcp_wrappers(new_sd) == 1) return 0;
|
||||||
|
|
||||||
request_init(&req, RQ_DAEMON, PROGNAME, RQ_FILE, new_sd, 0);
|
|
||||||
fromhost(&req);
|
|
||||||
if(!hosts_access(&req)){
|
|
||||||
send(new_sd, SMTP_RESP_550_ERR_YOU_ARE_BANNED_BY_LOCAL_POLICY, strlen(SMTP_RESP_550_ERR_YOU_ARE_BANNED_BY_LOCAL_POLICY), 0);
|
|
||||||
syslog(LOG_PRIORITY, "denied connection from %s by tcp_wrappers", eval_client(&req));
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
srand(getpid());
|
srand(getpid());
|
||||||
@ -188,16 +183,11 @@ int handle_smtp_session(int new_sd, struct __data *data, struct __config *cfg){
|
|||||||
goto END_OF_PROCESSING;
|
goto END_OF_PROCESSING;
|
||||||
}
|
}
|
||||||
|
|
||||||
sdata.need_scan = 1;
|
|
||||||
|
|
||||||
make_digests(&sdata, cfg);
|
make_digests(&sdata, cfg);
|
||||||
|
|
||||||
#ifdef HAVE_ANTIVIRUS
|
#ifdef HAVE_ANTIVIRUS
|
||||||
if(cfg->use_antivirus == 1){
|
if(cfg->use_antivirus == 1){
|
||||||
gettimeofday(&tv1, &tz);
|
|
||||||
sdata.rav = do_av_check(&sdata, &virusinfo[0], data, cfg);
|
sdata.rav = do_av_check(&sdata, &virusinfo[0], data, cfg);
|
||||||
gettimeofday(&tv2, &tz);
|
|
||||||
sdata.__av = tvdiff(tv2, tv1);
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -601,3 +591,22 @@ QUITTING:
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef HAVE_LIBWRAP
|
||||||
|
int is_blocked_by_tcp_wrappers(int sd){
|
||||||
|
struct request_info req;
|
||||||
|
|
||||||
|
request_init(&req, RQ_DAEMON, PROGNAME, RQ_FILE, sd, 0);
|
||||||
|
|
||||||
|
fromhost(&req);
|
||||||
|
|
||||||
|
if(!hosts_access(&req)){
|
||||||
|
send(sd, SMTP_RESP_550_ERR_YOU_ARE_BANNED_BY_LOCAL_POLICY, strlen(SMTP_RESP_550_ERR_YOU_ARE_BANNED_BY_LOCAL_POLICY), 0);
|
||||||
|
syslog(LOG_PRIORITY, "denied connection from %s by tcp_wrappers", eval_client(&req));
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user