Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/freebsd-ports
Path: blob/main/mail/antivirus-milter/files/patch-antivirus.c
18157 views
1
--- antivirus.c.orig 2003-07-15 19:27:14 UTC
2
+++ antivirus.c
3
@@ -85,6 +85,8 @@ static char *VIRUSACTION=NULL;
4
static char *FORMAT=NULL;
5
static sfsistat avfailcode=0;
6
static int purgevirus=0;
7
+static int skipwords=0;
8
+static int ignorerror2=0;
9
static char *avargs[]={NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL};
10
11
/*
12
@@ -128,6 +130,12 @@ static char *badext[]={".com",".scr",".v
13
#define FORMAT_SOPHOS ">>> Virus '%[^']s' found in file %*s"
14
15
/*
16
+** This one is for clamav
17
+*/
18
+#define FORMAT_CLAMAV " %s FOUND"
19
+#define SCANARGS_CLAMAV "--disable-summary"
20
+
21
+/*
22
** this can be given on the command line
23
*/
24
static char *configfile=NULL;
25
@@ -502,6 +510,7 @@ sfsistat virusscan(SMFICTX *ctx, char *p
26
int retval;
27
int fd;
28
int i;
29
+ char *word;
30
char *p=NULL;
31
char *av[]={NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL};
32
33
@@ -552,13 +561,26 @@ sfsistat virusscan(SMFICTX *ctx, char *p
34
(int)ctx, retval,priv->workdir);
35
}
36
37
+ if (ignorerror2 > 0 )
38
+ {
39
+ if ( retval == 2 )
40
+ retval = 0;
41
+ }
42
+
43
if (retval>0)
44
{
45
fseek(priv->childfp,0,SEEK_SET);
46
memset(viruses,0,sizeof(buf));
47
while (fgets(buf,sizeof(buf),priv->childfp)!=NULL)
48
{
49
- if (sscanf(buf,format,tmp)==1)
50
+ word = buf;
51
+ if (skipwords > 0 )
52
+ {
53
+ word = strchr( word, ' ' );
54
+ if ( word == NULL )
55
+ word = buf;
56
+ }
57
+ if (sscanf(word,format,tmp)==1)
58
{
59
if (viruses[0])
60
strncat(viruses," ",sizeof(viruses));
61
@@ -572,10 +594,8 @@ sfsistat virusscan(SMFICTX *ctx, char *p
62
if (viruses[0])
63
priv->viruses=strdup(viruses);
64
else
65
- priv->viruses=strdup("please contact postmaster");
66
-
67
- if ((priv->viruses)==NULL)
68
{
69
+ priv->viruses=strdup("please contact postmaster");
70
return(avfailcode);
71
}
72
return(SMFIS_REJECT);
73
@@ -1211,6 +1231,7 @@ int init(void)
74
if (AVFAILACTION==NULL) AVFAILACTION=CONF_AVFAILACTION;
75
if (VIRUSACTION==NULL) VIRUSACTION=CONF_VIRUSACTION;
76
77
+ skipwords = 0;
78
if (strcasecmp(AVPRODUCT,"mcafee")==0)
79
{
80
FORMAT=FORMAT_MCAFEE;
81
@@ -1225,10 +1246,17 @@ int init(void)
82
{
83
FORMAT=FORMAT_FSAV;
84
}
85
+ else if (strcasecmp(AVPRODUCT,"clamav")==0)
86
+ {
87
+ FORMAT=FORMAT_CLAMAV;
88
+ AVSCANARGS=SCANARGS_CLAMAV;
89
+ skipwords = 1;
90
+ ignorerror2 = 1;
91
+ }
92
else
93
{
94
fprintf(stderr,"init(): unrecognized AVPRODUCT %s\n",AVPRODUCT);
95
- fprintf(stderr,"init(): valid values are: mcafee, fsva, sophos\n");
96
+ fprintf(stderr,"init(): valid values are: mcafee, fsva, sophos, clamav\n");
97
return(-1);
98
}
99
100
101