Regards, Flinn
On Wednesday, September 3, 2003, at 11:52 PM, Brian W. Antoine wrote:
Ok, using James idea of calling out to ripmime, I altered his code to spool the mail message to a file so ripmime can invoke --mailbox on it. Once I got it working, ClamAV started catching viruses again. This isn't going to be fast, but given the choice between unstable and slow I'll go with slow at the moment. I really hate waking up in the morning to find our mail server has been puking on email since 1AM :)
* ** Replacement mbox.c ** ** Based on original code from James Stevens ** ** Instead of trying to pull the message apart ** ourselves let 'ripmime' do it for us. */ #include <stdio.h> #include <stdlib.h> #include <unistd.h>
#define BUFSIZE 8192 #define RIPMIME "/usr/local/bin/ripmime"
int cl_mbox(const char *dir, int desc) { int ofd; char buffer[BUFSIZE], tempfile[256]; int ret, stat, len;
/* ** RipMime demands a regular file to work on when working ** on a mailbox so we have to spool "desc" into a file for it. */ strcpy(tempfile, "/tmp/mboxXXXXXX"); ofd = mkstemp(tempfile); if ( ofd < 0 ) return -1;
/* ** Prime the pump and copy "desc" to the temp file */ len = read(desc, buffer, BUFSIZ); while ( len > 0 ) { write(ofd, buffer, len); len = read(desc, buffer, BUFSIZ); } close(ofd);
ret = fork(); if ( ret == -1 ) { unlink(tempfile); return -1; }
if ( ret == 0 ) {
if ( desc )
dup2(desc, 0);
execlp(RIPMIME, RIPMIME, "-d", dir, "-i", tempfile, "--mailbox", NULL);
exit(-1);
}
waitpid(ret, &stat, 0);
unlink(tempfile);
return 0;
}
------------------------------------------------------- This sf.net email is sponsored by:ThinkGeek Welcome to geek heaven. http://thinkgeek.com/sf _______________________________________________ Clamav-devel mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/clamav-devel
------------------------------------------------------- This sf.net email is sponsored by:ThinkGeek Welcome to geek heaven. http://thinkgeek.com/sf _______________________________________________ Clamav-devel mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/clamav-devel
