"Dimitri SZAJMAN" <[EMAIL PROTECTED]> writes:
> Hi,
> I am looking for a good antivirus, working with vpopmail,maildir,...
> I saw some but I think they only work with ~/Mailbox
> Any URL would be really apreciated
> thanks
I use AVP (www.kaspersky.com) with attached patch to qmail-local.c.
PGP signature
--- qmail-local.c~ Mon Jun 15 12:53:16 1998
+++ qmail-local.c Sun Jan 28 17:57:02 2001
@@ -1,3 +1,4 @@
+#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include "readwrite.h"
@@ -29,6 +30,242 @@
#include "gfrom.h"
#include "auto_patrn.h"
+/** AVP START **/
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/un.h>
+#include <sys/file.h>
+#include <time.h>
+#include <stdarg.h>
+#include <paths.h>
+#include <errno.h>
+extern int errno;
+
+#define AVP_NAME "Antiviral Toolkit Pro for Linux (Cpp client for Daemon)"
+#define AVP_DATE "built on "__DATE__" at "__TIME__ " "
+
+typedef unsigned long ULONG;
+
+/* ... Cfg pathnames */
+#define AVP_NODE_DIR "/var/run"
+#define AVP_NODE_DIR_MODE 0777
+#define AVP_NODE_PID AVP_NODE_DIR "/AvpPid"
+#define AVP_NODE_LOG AVP_NODE_DIR "/AvpLog"
+#define AVP_NODE_CTL AVP_NODE_DIR "/AvpCtl\0\0\0"
+char *NodePid=AVP_NODE_PID;
+char *NodeCtl=AVP_NODE_CTL;
+
+static int AvpFile=-1; /* fd for log */
+static int connected; /* have done connect */
+
+struct sockaddr_un AvpTestAddr; /* AF_UNIX address of local logger */
+/* start test*/
+int AvpTestStart()
+{
+ if (AvpFile==-1)
+ {
+ bzero((char *)&AvpTestAddr,sizeof(AvpTestAddr));
+ AvpTestAddr.sun_family=AF_UNIX;
+ strcpy(AvpTestAddr.sun_path,NodeCtl);
+ if((AvpFile=socket(AF_UNIX,SOCK_STREAM,0))<0)
+ return -1;
+/* printf("create socket error: socket() not created\n"); */
+ /* fcntl(AvpFile,F_SETFD,1); */
+ }
+
+ if (AvpFile!=-1 && !connected && connect(AvpFile,(struct sockaddr *)(&AvpTestAddr),sizeof(AvpTestAddr.sun_family)+strlen("/var/run/AvpCtl"))>=0)
+ connected=1;
+
+ if (connected)
+ return 0;
+
+ return -1;
+}
+
+/* close the testing*/
+void AvpTestClose()
+{
+ (void)close(AvpFile);
+ AvpFile=-1;
+ connected=0;
+}
+
+int AvpTestByDaemon(int flags, char *buftoscan, ULONG *ulFlags, ULONG* buflen)
+{
+ register int len;
+ register char *p;
+ int fd;
+
+ len=strlen(buftoscan);
+
+ /* output the message to the local logger */
+
+ if (write(AvpFile,buftoscan,len+1)>=0)
+ {
+ int Rez,uintbuf=0;
+ char *ResultBuf;
+ int ExitCode;
+ char *ResultStr;
+ char dlgres;
+ int rezs;
+ waitrez:
+ if((Rez=read(AvpFile,(char*)&uintbuf,2))==-1) return -2;
+ ExitCode = (uintbuf&0xff)-0x30;
+
+ ResultBuf=NULL;
+ if((uintbuf&0xff00)!=0)
+ {
+ if((uintbuf&0x200)!=0)
+ {
+ if((Rez=read(AvpFile,(char*)buflen,sizeof(ULONG)))==-1) return -2;
+ *ulFlags|=1;
+ }
+ if((uintbuf&0x100)!=0)
+ {
+ if((Rez=read(AvpFile,(char*)&uintbuf,sizeof(ULONG)))==-1) return -2;
+ ResultBuf=(char*)malloc(uintbuf+1);
+ ResultBuf[0]=0;
+ ResultStr=ResultBuf;
+ /*if((Rez=recv(AvpFile,ResultStr,uintbuf,0))==-1) return -2;*/
+ while((uintbuf>0)&&((Rez=recv(AvpFile,ResultStr,uintbuf,0))!=0))
+ if(Rez==-1)
+ {
+ return -2;
+ }
+ else
+ {
+ uintbuf-=Rez;
+ ResultStr[Rez]=0;
+ ResultStr+=Rez;
+ }
+ }
+ }
+ switch (ExitCode&0x0f)
+ {
+ case 8:
+ printf("Corrupted objects were found\n");
+ break;
+ case 7:
+ printf("File AvpLinux is corrupted\n");
+ break;
+ case 6:
+ printf("All viruses deleted\n");
+ break;
+ case 5:
+ printf("All viruses disinfected\n");
+ break;
+ case 4:
+ printf("Known viruses were detected\n");
+ break;
+ case 3:
+ printf("Suspicious objects were found\n");
+ break;
+ case 2:
+ printf("Warning\n");
+ break;
+ case 1:
+ printf("Virus scan was not complete\n");
+ break;
+ case 0:
+ printf("No viruses were found\n");
+ break;
+ case 0xf:
+ printf("%s",ResultBuf);
+ free(ResultBuf);
+ dlgres=getchar();
+ if(dlgres!='\n') while(!feof(stdin) && (fgetc(stdin)!='\n')) ;
+ if((rezs=send(AvpFile,(char*)&dlgres,1,0))==-1)
+ printf("Client can not write disinfect dialog result to AvpDaemon");
+ goto waitrez;
+ default:
+ printf("Error!(test result %d)\n",Rez);
+ break;
+ }
+ switch (ExitCode&0xf0)
+ {
+ case 8:
+ printf("Internal error: Integrity failed.\n");
+ break;
+ case 4:
+ printf("Internal error: Bases not found.\n");
+ break;
+ }
+ printf("%s\n",ResultBuf);
+ free(ResultBuf);
+
+ return ExitCode;
+ }
+ return -1;
+
+ /* output the message to the console; don't worry about*/
+ /* blocking, if console blocks everything will.*/
+ if ((fd=open(_PATH_CONSOLE,O_WRONLY|O_NOCTTY,0))<0)
+ return -1;
+ (void)strcat(buftoscan,"\r\n");
+ len+=2;
+ p=index(buftoscan,'>')+1;
+ (void)write(fd,p,len-(p-buftoscan));
+ (void)close(fd);
+ return -1;
+}
+
+int AvpTest(int flags,const char *fmt, ...)
+{
+ int rez=-1;
+ va_list ap;
+ register char *p;
+ int saved_errno=0;
+ char tbuf[2048], fmt_cpy[1024];
+ time_t now;
+
+ ULONG ulFlags=0,ulDiffer=0;
+
+
+ if(AvpFile<0 || !connected)
+ if(AvpTestStart()!=0) return -1;
+
+ va_start(ap, fmt);
+
+ /* build the message */
+ (void)time(&now);
+ (void)sprintf(tbuf,"<%d>%.15s:",flags,ctime(&now)+4);
+ for(p=tbuf;*p;++p) ;
+ {
+ register char ch, *t1, *t2;
+
+ for(t1=fmt_cpy;(ch=*fmt)!='\0' && t1<fmt_cpy+sizeof(fmt_cpy);++fmt)
+ if(ch=='%'&& fmt[1]=='m')
+ {
+ ++fmt;
+ for(t2=strerror(saved_errno);(*t1 = *t2++);++t1);
+ }
+ else
+ *t1++ =ch;
+ *t1='\0';
+ }
+ (void)vsprintf(p,fmt_cpy,ap);
+
+ rez=AvpTestByDaemon(flags,tbuf,&ulFlags,&ulDiffer);
+ switch (rez)
+ {
+ case -1:
+ printf("Error: cannot write to AvpDaemon!\n");
+ break;
+ case -2:
+ printf("Error: cannot read from AvpDaemon!\n");
+ break;
+ }
+ va_end(ap);
+ return rez;
+}
+
+/** AVP END **/
+
void usage() { strerr_die1x(100,"qmail-local: usage: qmail-local [ -nN ] user homedir local dash ext domain sender aliasempty"); }
void temp_nomem() { strerr_die1x(111,"Out of memory. (#4.3.0)"); }
@@ -81,7 +318,9 @@
unsigned long time;
char host[64];
char *s;
+ char *virfn;
int loop;
+ int rez;
struct stat st;
int fd;
substdio ss;
@@ -127,6 +366,23 @@
if (fsync(fd) == -1) goto fail;
if (close(fd) == -1) goto fail; /* NFS dorks */
+ /* !OS! */
+
+ if (virfn = malloc(strlen(homedir)+strlen(fntmptph)+2))
+ {
+ virfn = strcpy(virfn,homedir);
+ virfn = strcat(virfn, "/");
+ virfn = strcat(virfn,fntmptph);
+ }
+
+ fprintf(stderr, "Scanning %s.", virfn);
+
+/* rez=AvpTest(0,virfn); */
+
+ fprintf(stderr, "AVP Result: (%d)", rez);
+
+ free(virfn);
+
if (link(fntmptph,fnnewtph) == -1) goto fail;
/* if it was error_exist, almost certainly successful; i hate NFS */
tryunlinktmp(); _exit(0);
@@ -162,6 +418,7 @@
case 2: strerr_die1x(111,"Unable to chdir to maildir. (#4.2.1)");
case 3: strerr_die1x(111,"Timeout on maildir delivery. (#4.3.0)");
case 4: strerr_die1x(111,"Unable to read message. (#4.3.0)");
+ case 5: strerr_die1x(111,"Infected file found. (AVP)");
default: strerr_die1x(111,"Temporary error on maildir delivery. (#4.3.0)");
}
}
--
Ondřej Surý <[EMAIL PROTECTED]> Globe Internet s.r.o. http://globe.cz/
Tel: +420235365000 Fax: +420235365009 Pláničkova 1, 162 00 Praha 6
GPG fingerprint: CC91 8F02 8CDE 911A 933F AE52 F4E6 6A7C C20D F273