Go to:
Gentoo Home
Documentation
Forums
Lists
Bugs
Planet
Store
Wiki
Get Gentoo!
Gentoo's Bugzilla – Attachment 26669 Details for
Bug 43362
dansguardian-2.7.7.ebuild with ClamAv (New Package)
Home
|
New
–
[Ex]
|
Browse
|
Search
|
Privacy Policy
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
DansGuardian-2.7.7-2-AntiVirus-5.0.patch
DansGuardian-2.7.7-2-AntiVirus-5.0.patch (text/plain), 108.80 KB, created by
Michael Knappe
on 2004-03-01 10:55:50 UTC
(
hide
)
Description:
DansGuardian-2.7.7-2-AntiVirus-5.0.patch
Filename:
MIME Type:
Creator:
Michael Knappe
Created:
2004-03-01 10:55:50 UTC
Size:
108.80 KB
patch
obsolete
>diff -urN DansGuardian-2.7.7-2/ConnectionHandler.cpp antivirus/DansGuardian-2.7.7-2-AntiVirus-5.0/ConnectionHandler.cpp >--- DansGuardian-2.7.7-2/ConnectionHandler.cpp 2004-02-18 11:05:15.000000000 -0300 >+++ antivirus/DansGuardian-2.7.7-2-AntiVirus-5.0/ConnectionHandler.cpp 2004-02-19 00:48:23.000000000 -0300 >@@ -30,6 +30,8 @@ > #else > #include <wait.h> > #endif >+//#define __IPC "/tmp/.dguardianipc" >+//#define __URLIPC "/tmp/.dguardianurlipc" > > #include "FDTunnel.hpp" > #include <sys/socket.h> >@@ -37,6 +39,10 @@ > #include <arpa/inet.h> > #include <cstdio> > #include <algorithm> >+// Included by Aecio F. Neto (afn@harvest.com.br) - Harvest Consultoria (http://www.harvest.com.br) >+#include "VirusScanner.hpp" >+#include <fstream> >+// End of Included by Aecio F. Neto (afn@harvest.com.br) - Harvest Consultoria (http://www.harvest.com.br) > #include <iostream> > #include <netdb.h> > #include <cstdlib> >@@ -74,6 +80,12 @@ > > docbody.setTimeout(60); > >+ // Included by Aecio F. Neto (afn@harvest.com.br) - Harvest Consultoria (http://www.harvest.com.br) >+ VirusScanner virusscan; >+ int contentLength = 0; >+ bool novirusscan = false; >+ // End of Included by Aecio F. Neto (afn@harvest.com.br) - Harvest Consultoria (http://www.harvest.com.br) >+ > bool waschecked = false; // flags > bool wasrequested = false; > bool isexception = false; >@@ -246,21 +258,116 @@ > > proxysock.readyForOutput(10); // exception on timeout or error > header.out(proxysock); // send proxy the request >- try { >- FDTunnel fdt; // make a tunnel object >- // tunnel from client to proxy and back >- fdt.tunnel(proxysock.getFD(), peerconn.getFD()); // not expected to exception >- docsize = fdt.throughput; >- if (!isourwebserver) { // don't log requests to the web server >- decideHowToLog(clientuser, clientip, url.toCharArray(), header.port, exceptionreason, header.requesttype().toCharArray(), docsize, o.ll, false, isexception, o.log_exception_hits, false, &thestart, cachehit, 200, mimetype); >+ // Included by Aecio F. Neto (afn@harvest.com.br) - Harvest Consultoria (http://www.harvest.com.br) >+ if (header.requesttype().startsWith("CONNECT")) { // can't virus scan HTTPS traffic. >+ #ifdef DGDEBUG >+ std::cout << "url: " << urld << " is CONNECT" << std::endl; >+ #endif >+ try { >+ FDTunnel fdt; // make a tunnel object >+ // tunnel from client to proxy and back >+ fdt.tunnel(proxysock.getFD(), peerconn.getFD()); // not expected to exception >+ docsize = fdt.throughput; >+ } catch (exception& e) {} >+ try { >+ proxysock.close(); >+ } catch (exception& e) {} >+ if (!isourwebserver) // don't log requests to the web server >+ decideHowToLog(clientuser, clientip, url.toCharArray(), header.port, exceptionreason, header.requesttype().toCharArray(), docsize, o.ll, false, isexception, novirusscan, virusscan.isInfected, o.log_exception_hits, false, &thestart, cachehit, 200, mimetype); >+ return; >+ } >+ if (o.virus_scan) { // see if we do not need to virus scan the content. >+ #ifdef DGDEBUG >+ std::cout << "checking if we don't have to virus scan according to header" << std::endl; >+ std::cout << "url:" << urld << std::endl; >+ #endif >+ if (isexception && !o.virus_scan_exceptions) >+ novirusscan = true; >+ else { >+ proxysock.checkForInput(10); >+ docheader.in(proxysock); // get header from proxy >+ contentLength = docheader.contentlength(); >+ peerconn.readyForOutput(10); // exceptions on error/timeout >+ docheader.out(peerconn); // send header to client >+ >+ String contenttype = docheader.getcontenttype(); >+ int i = o.exception_virus_mimetype_list.AVfindInList(contenttype.toCharArray()); >+ #ifdef DGDEBUG >+ std::cout << "verified in exceptionvirusmimetype. Result: " << i << std::endl; >+ #endif >+ >+ if (i >= 0) { >+ novirusscan = true; >+ #ifdef DGDEBUG >+ std::cout << "url: " << urld << " mimetype '" << contenttype.toCharArray() << "' in exception list" << std::endl; >+ #endif >+ } >+ else { >+ i = o.inVirusExceptionExtensionList(urld); >+ #ifdef DGDEBUG >+ std::cout << "verified in exceptionvirusextension. Result: " << i << std::endl; >+ #endif >+ >+ if (i >= 0) { >+ novirusscan = true; >+ #ifdef DGDEBUG >+ std::cout << "url: " << urld << " in extension exception list" << std::endl; >+ #endif >+ } >+ } > } > >- } catch (exception& e) {} >- try { >- proxysock.close(); // close connection to proxy >- } catch (exception& e) {} >- return; // connection dealt with so exit >- } >+ if (novirusscan) { >+ try { >+ FDTunnel fdt; // make a tunnel object >+ // tunnel from client to proxy and back >+ fdt.tunnel(proxysock.getFD(), peerconn.getFD()); // not expected to exception >+ docsize = fdt.throughput; >+ } catch (exception& e) {} >+ try { >+ proxysock.close(); >+ } catch (exception& e) {} >+ } >+ else { >+ >+ #ifdef DGDEBUG >+ std::cout << "calling scanning routine" << endl; >+ std::cout << "docheader.contentLength = " << contentLength << endl; >+ std::cout << "***1st virusscan.handleScanning***" << endl; >+ #endif >+ try { >+ virusscan.handleScanning(&proxysock, &peerconn, url, contentLength, clientuser, clientip, o.access_denied_address, o.reporting_level); >+ docsize = virusscan.file_length; >+ } catch (exception& e) { >+ #ifdef DGDEBUG >+ std::cout << "exception caught - scanning/sending url" << std::endl; >+ #endif >+ exceptionreason = "*ERROR* - exception caught scanning/sending url" + exceptionreason; >+ decideHowToLog(clientuser, clientip, url.toCharArray(), header.port, exceptionreason, header.requesttype().toCharArray(), docsize, o.ll, false, isexception, true, virusscan.isInfected, o.log_exception_hits, false, &thestart, cachehit, 200, mimetype); >+ try { >+ proxysock.close(); >+ } catch (exception& e2) {} >+ return; >+ } >+ } >+ } >+ else { >+ try { >+ FDTunnel fdt; // make a tunnel object >+ // tunnel from client to proxy and back >+ fdt.tunnel(proxysock.getFD(), peerconn.getFD()); // not expected to exception >+ docsize = fdt.throughput; >+ } catch (exception& e) {} >+ try { >+ proxysock.close(); >+ } catch (exception& e) {} >+ } >+ // End of Included by Aecio F. Neto (afn@harvest.com.br) - Harvest Consultoria (http://www.harvest.com.br) >+ >+ if (!isourwebserver) // don't log requests to the web server >+ decideHowToLog(clientuser, clientip, url.toCharArray(), header.port, exceptionreason, header.requesttype().toCharArray(), docsize, o.ll, false, isexception, novirusscan, virusscan.isInfected, o.log_exception_hits, false, &thestart, cachehit, 200, mimetype); >+ return; >+ } > > > NaughtyFilter checkme; // our filter object >@@ -289,7 +396,7 @@ > // tunnel from client to proxy and back > fdt.tunnel(proxysock.getFD(), peerconn.getFD()); // not expected to exception > docsize = fdt.throughput; >- decideHowToLog(clientuser, clientip, url.toCharArray(), header.port, exceptionreason, header.requesttype().toCharArray(), docsize, o.ll, false, isexception, o.log_exception_hits, false, &thestart, cachehit, 200, mimetype); >+ decideHowToLog(clientuser, clientip, url.toCharArray(), header.port, exceptionreason, header.requesttype().toCharArray(), docsize, o.ll, false, isexception, true, virusscan.isInfected, o.log_exception_hits, false, &thestart, cachehit, 200, mimetype); > } catch (exception& e) {} > try { > proxysock.close(); // close connection to proxy >@@ -303,7 +410,12 @@ > proxysock.checkForInput(60); > docheader.in(proxysock); // get header from proxy > #ifdef DGDEBUG >- std::cout << "got header from proxy" << std::endl; >+ std::cout << "got content header from proxy" << std::endl; >+ #endif >+ >+ contentLength = docheader.contentlength(); >+ #ifdef DGDEBUG >+ std::cout << "content length: " << contentLength << std::endl; > #endif > wasrequested = true; // so we know where we are later > >@@ -323,7 +435,9 @@ > checkme.isItNaughty = true; > } > #ifdef DGDEBUG >+ std::cout << "mimetype length: "; > std::cout << mimetype.length() << std::endl; >+ std::cout << "mimetype: "; > std::cout << ":" << mimetype; > std::cout << ":" << std::endl; > #endif >@@ -421,6 +535,10 @@ > #ifdef DGDEBUG > std::cout << "url was clean skipping content checking" << std::endl; > #endif >+ >+ // Included by Aecio F. Neto (afn@harvest.com.br) - Harvest Consultoria (http://www.harvest.com.br) >+ if (o.url_cache_clean_only) >+ novirusscan = true; > } > // was not clean > else { >@@ -481,14 +599,8 @@ > checkme.isItNaughty = false; > } > >- if (o.url_cache_number > 0) { >- if (!wasclean && !checkme.isItNaughty) { >- addToClean(urld); >- } >- } >- > if (checkme.isItNaughty && !isbypass) { // then we deny, unless we were told to bypass the block >- decideHowToLog(clientuser, clientip, url.toCharArray(), header.port, checkme.whatIsNaughtyLog, header.requesttype().toCharArray(), docsize, o.ll, true, false, false, false, &thestart, cachehit, 403, mimetype); >+ decideHowToLog(clientuser, clientip, url.toCharArray(), header.port, checkme.whatIsNaughtyLog, header.requesttype().toCharArray(), docsize, o.ll, true, false, true, false, false, false, &thestart, cachehit, 403, mimetype); > if (denyAccess(&peerconn, &proxysock, &header, &docheader, &url, &checkme, &clientuser, &clientip, filtergroup)) { > return; // not stealth mode > } >@@ -500,6 +612,7 @@ > header.out(proxysock); // exceptions on error/timeout > proxysock.checkForInput(60); // exceptions on error/timeout > docheader.in(proxysock); // get reply header from proxy >+ contentLength = docheader.contentlength(); > } > > #ifdef DGDEBUG >@@ -510,47 +623,158 @@ > #ifdef DGDEBUG > std::cout << "sent header to client" << std::endl; > #endif >- if (waschecked) { >- decideHowToLog(clientuser, clientip, url.toCharArray(), header.port, exceptionreason, header.requesttype().toCharArray(), docsize, o.ll, false, isexception, o.log_exception_hits, docheader.iscontenttype("text"), &thestart, cachehit, 200, mimetype); > >- #ifdef DGDEBUG >- std::cout << "sending body to client" << std::endl; >+ if (o.virus_scan) { // see if we do not need to virus scan the content. >+ #ifdef DGDEBUG >+ std::cout << "checking to see if we don't have to virus scan case 2" << std::endl; >+ std::cout << "url:" << urld << std::endl; > #endif >- peerconn.readyForOutput(10); // check for error/timeout needed >- docbody.out(peerconn); // send doc body to client >+ >+ String contenttype = docheader.getcontenttype(); >+ int i = o.exception_virus_mimetype_list.AVfindInList(contenttype.toCharArray()); > #ifdef DGDEBUG >- std::cout << "sent body to client" << std::endl; >+ std::cout << "verified in exceptionvirusmime. Result: " << i << std::endl; > #endif >+ >+ if (i >= 0) { >+ novirusscan = true; >+ #ifdef DGDEBUG >+ std::cout << "url: " << urld << " mimetype '" << contenttype.toCharArray() << "' in exception list" << std::endl; >+ #endif >+ } >+ else { >+ i = o.inVirusExceptionExtensionList(urld); >+ #ifdef DGDEBUG >+ std::cout << "verified in exceptionvirusextension. Result: " << i << std::endl; >+ #endif >+ >+ if (i >= 0) { >+ novirusscan = true; >+ #ifdef DGDEBUG >+ std::cout << "url: " << urld << " in extension exception list" << std::endl; >+ #endif >+ } >+ } > } >- else { // was not supposed to be checked >- FDTunnel fdt; >+ else novirusscan = true; >+ >+ if (waschecked) { > #ifdef DGDEBUG >- std::cout << "tunnel activated" << std::endl; >+ std::cout << "sending body to client" << std::endl; > #endif >- fdt.tunnel(proxysock.getFD(), peerconn.getFD()); >- docsize = fdt.throughput; >+ peerconn.readyForOutput(10); // check for error/timeout needed > >- decideHowToLog(clientuser, clientip, url.toCharArray(), header.port, exceptionreason, header.requesttype().toCharArray(), docsize, o.ll, false, isexception, o.log_exception_hits, docheader.iscontenttype("text"), &thestart, cachehit, 200, mimetype); >+ if (novirusscan) >+ docbody.out(peerconn); // send doc body to client >+ else { >+ try { >+ virusscan.createTempFile(); >+ docbody.writeFile(virusscan.tempFileName); >+ } catch (exception& e) { >+ #ifdef DGDEBUG >+ std::cout << "exception caught - writing temp file" << std::endl; >+ #endif >+ exceptionreason = "*ERROR* - exception caught writing temp file" + exceptionreason; >+ decideHowToLog(clientuser, clientip, url.toCharArray(), header.port, exceptionreason, header.requesttype().toCharArray(), docsize, o.ll, false, isexception, novirusscan, virusscan.isInfected, o.log_exception_hits, docheader.iscontenttype("text"), &thestart, cachehit, 200, mimetype); >+ try { >+ proxysock.close(); >+ } catch (exception& e2) {} >+ return; >+ } >+ >+ try { >+ virusscan.scanFile(&peerconn, url, clientuser, clientip, o.access_denied_address, o.reporting_level); >+ docsize = virusscan.file_length; >+ } catch (exception& e) { >+ #ifdef DGDEBUG >+ std::cout << "exception caught - scanning/sending url" << std::endl; >+ #endif >+ docsize = virusscan.file_length; >+ exceptionreason = "*ERROR* - exception caught scanning/sending url" + exceptionreason; >+ decideHowToLog(clientuser, clientip, url.toCharArray(), header.port, exceptionreason, header.requesttype().toCharArray(), docsize, o.ll, false, isexception, novirusscan, virusscan.isInfected, o.log_exception_hits, docheader.iscontenttype("text"), &thestart, cachehit, 200, mimetype); >+ try { >+ proxysock.close(); >+ } catch (exception& e2) {} >+ return; >+ } >+ } >+ #ifdef DGDEBUG >+ std::cout << "sent body to client" << std::endl; >+ #endif >+ } >+ else { // was not supposed to be checked >+ if (novirusscan) { >+ try { >+ FDTunnel fdt; // make a tunnel object >+ // tunnel from client to proxy and back >+ fdt.tunnel(proxysock.getFD(), peerconn.getFD()); // not expected to exception >+ docsize = fdt.throughput; >+ } catch (exception& e) {} >+ } >+ else { >+ try { >+ virusscan.handleScanning(&proxysock, &peerconn, url, contentLength, clientuser, clientip, o.access_denied_address, o.reporting_level); >+ } catch (exception& e) { >+ #ifdef DGDEBUG >+ std::cout << "exception caught - scanning/sending url" << std::endl; >+ #endif >+ docsize = virusscan.file_length; >+ exceptionreason = "*ERROR* - exception caught scanning/sending url" + exceptionreason; >+ decideHowToLog(clientuser, clientip, url.toCharArray(), header.port, exceptionreason, header.requesttype().toCharArray(), docsize, o.ll, false, isexception, novirusscan, virusscan.isInfected, o.log_exception_hits, docheader.iscontenttype("text"), &thestart, cachehit, 200, mimetype); >+ try { >+ proxysock.close(); >+ } catch (exception& e2) {} >+ return; >+ } >+ docsize = virusscan.file_length; >+ } >+ } >+ decideHowToLog(clientuser, clientip, url.toCharArray(), header.port, exceptionreason, header.requesttype().toCharArray(), docsize, o.ll, false, isexception, novirusscan, virusscan.isInfected, o.log_exception_hits, docheader.iscontenttype("text"), &thestart, cachehit, 200, mimetype); > >- } >+ // Changed by Aecio F. Neto (afn@harvest.com.br) - Harvest Consultoria (http://www.harvest.com.br) >+ // If we got here so far, content is not Naughty >+ // So checkme.isNaughty value is unnecessary to decide if the url should be cached >+ if (o.url_cache_number > 0) { >+ if (o.virus_scan) { >+ if (o.url_cache_clean_only) { >+ // Both content AND virus scanning is necessary to insert >+ // an entry into urlcache >+ if ((!wasclean && novirusscan) || >+ // Content is text only >+ // ***AND*** >+ // its file extension or mime type was set to be ignored by AV >+ (!virusscan.isInfected && !novirusscan) ) { >+ // Content is virus free >+ // ***AND*** >+ // and scanning is mandatory >+ addToClean(urld); >+ } >+ } >+ else if (!wasclean) >+ addToClean(urld); >+ } >+ else if (!wasclean) >+ addToClean(urld); >+ } > } catch (exception& e) { >- #ifdef DGDEBUG >- std::cout << "connection handler caught an exception" << std::endl; >+ #ifdef DGDEBUG >+ std::cout << "connection handler caught an exception" << std::endl; > #endif >- try { >- proxysock.close(); // close connection to proxy >+ try { >+ proxysock.close(); // close connection to proxy > } catch (exception& e) {} >- return; >+ return; > } >- >+ #ifdef DGDEBUG >+ std::cout << "***connection handler properly ends." << std::endl; >+ #endif > try { >- proxysock.close(); // close conection to squid >+ proxysock.close(); // close conection to squid > } catch (exception& e) {} > try { >- peerconn.readyForOutput(10); >- } >- catch (exception& e) { >- return; >+ peerconn.readyForOutput(10); >+ } catch (exception& e) { >+ return; > } > return; > } >@@ -662,7 +886,7 @@ > > > >-void ConnectionHandler::decideHowToLog(std::string who, std::string from, std::string where, unsigned int port, std::string what, std::string how, int size, int loglevel, bool isnaughty, bool isexception, int logexceptions, bool istext, struct timeval *thestart, bool cachehit, int code, std::string mimetype) { >+void ConnectionHandler::decideHowToLog(std::string who, std::string from, std::string where, unsigned int port, std::string what, std::string how, int size, int loglevel, bool isnaughty, bool isexception, bool novirusscan, bool infected, int logexceptions, bool istext, struct timeval *thestart, bool cachehit, int code, std::string mimetype) { > > if (loglevel == 0 || o.no_logger == 1) { > return; >@@ -694,14 +918,20 @@ > // make it stand out in the logs and also > // more easily findable with a search > } >+ > if (isexception) { > if (logexceptions == 1) { > what = "*EXCEPTION* " + what; > } >- else { >- what = ""; >- } > } >+ >+ // Included by Aecio F. Neto (afn@harvest.com.br) - Harvest Consultoria (http://www.harvest.com.br) >+ if (infected) >+ what = "*INFECTED* " + what; >+ else if (!novirusscan) >+ what = "*SCANNED* " + what; >+ // End of Included by Aecio F. Neto (afn@harvest.com.br) - Harvest Consultoria (http://www.harvest.com.br) >+ > if ((isexception && logexceptions == 1) > || isnaughty > || loglevel == 3 >@@ -799,6 +1029,7 @@ > bool igsl = (*o.fg[filtergroup]).inGreySiteList(temp); > bool igul = (*o.fg[filtergroup]).inGreyURLList(temp); > >+ // Improved IF structure as suggested by Aecio F. Neto > if ((*o.fg[filtergroup]).blanketblock == 1 && !igsl && !igul) { > // when blanket block active BSL role is reversed so if a site is > // found in the BSL then it is allowed to be filtered normally >diff -urN DansGuardian-2.7.7-2/ConnectionHandler.hpp antivirus/DansGuardian-2.7.7-2-AntiVirus-5.0/ConnectionHandler.hpp >--- DansGuardian-2.7.7-2/ConnectionHandler.hpp 2004-02-18 11:05:15.000000000 -0300 >+++ antivirus/DansGuardian-2.7.7-2-AntiVirus-5.0/ConnectionHandler.hpp 2004-02-19 00:45:08.000000000 -0300 >@@ -34,7 +34,7 @@ > private: > void doTheLogMan(std::string who, std::string from, std::string where, std::string what, std::string how, int size, struct timeval *thestart, bool cachehit, int code, std::string mimetype); > std::string miniURLEncode(std::string s); >- void decideHowToLog(std::string who, std::string from, std::string where, unsigned int port, std::string what, std::string how, int size, int loglevel, bool isnaughtly, bool isexception, int logexceptions, bool istext, struct timeval *thestart, bool cachehit, int code, std::string mimetype); >+ void decideHowToLog(std::string who, std::string from, std::string where, unsigned int port, std::string what, std::string how, int size, int loglevel, bool isnaughtly, bool isexception, bool viruscan, bool infected, int logexceptions, bool istext, struct timeval *thestart, bool cachehit, int code, std::string mimetype); > bool wasClean(String url); > void addToClean(String url); > void requestChecks(HTTPHeader *header, NaughtyFilter *checkme, String *urld, std::string *clientip, std::string *clientuser, int filtergroup); >diff -urN DansGuardian-2.7.7-2/DataBuffer.cpp antivirus/DansGuardian-2.7.7-2-AntiVirus-5.0/DataBuffer.cpp >--- DansGuardian-2.7.7-2/DataBuffer.cpp 2004-02-18 11:05:15.000000000 -0300 >+++ antivirus/DansGuardian-2.7.7-2-AntiVirus-5.0/DataBuffer.cpp 2004-02-19 00:45:08.000000000 -0300 >@@ -24,6 +24,7 @@ > #include <cstdlib> > #include <unistd.h> > #include <zlib.h> >+#include <fstream> > > #ifdef __GCCVER3 > #include <istream> >@@ -364,3 +365,25 @@ > } > } > } >+ >+// Included by Aecio F. Neto (afn@harvest.com.br) - Harvest Consultoria (http://www.harvest.com.br) >+void DataBuffer::writeFile(char* tempFileName) throw(exception) { >+ int i = 0; >+ fstream tmpFile; >+ >+ tmpFile.open(tempFileName, ios::out); >+ >+ #ifdef DGDEBUG >+ std::cout << "DataBuffer - filename: " << tempFileName << std::endl; >+ std::cout << "DataBuffer - writing to file " << tempFileName << ", length = '" << buffer_length << "'" << std::endl; >+ #endif >+ >+ for (i = 0; i < buffer_length; i++) >+ tmpFile.put(data[i]); >+ >+ #ifdef DGDEBUG >+ std::cout << "DataBuffer - wrote to " << tempFileName << ", length = '" << i << "'" << std::endl; >+ #endif >+ tmpFile.close(); >+} >+ // End of Included by Aecio F. Neto (afn@harvest.com.br) - Harvest Consultoria (http://www.harvest.com.br) >diff -urN DansGuardian-2.7.7-2/DataBuffer.hpp antivirus/DansGuardian-2.7.7-2-AntiVirus-5.0/DataBuffer.hpp >--- DansGuardian-2.7.7-2/DataBuffer.hpp 2004-02-18 11:05:15.000000000 -0300 >+++ antivirus/DansGuardian-2.7.7-2-AntiVirus-5.0/DataBuffer.hpp 2004-02-19 00:45:08.000000000 -0300 >@@ -39,6 +39,9 @@ > void setTimeout(int t); > void setDecompress(String d); > void contentRegExp(int filtergroup); >+ // Included by Aecio F. Neto (afn@harvest.com.br) - Harvest Consultoria (http://www.harvest.com.br) >+ void writeFile(char* tempFileName) throw(exception); >+ // End of Included by Aecio F. Neto (afn@harvest.com.br) - Harvest Consultoria (http://www.harvest.com.br) > > private: > int timeout; >diff -urN DansGuardian-2.7.7-2/ListContainer.cpp antivirus/DansGuardian-2.7.7-2-AntiVirus-5.0/ListContainer.cpp >--- DansGuardian-2.7.7-2/ListContainer.cpp 2004-02-18 11:05:15.000000000 -0300 >+++ antivirus/DansGuardian-2.7.7-2-AntiVirus-5.0/ListContainer.cpp 2004-02-19 01:06:19.000000000 -0300 >@@ -1313,3 +1313,107 @@ > } > return true; > } >+ >+ >+// Included by Aecio F. Neto (afn@harvest.com.br) - Harvest Consultoria (http://www.harvest.com.br) >+int ListContainer::AVfindEndsWith(char* string) { >+ if (items < 1) { >+ return -1; >+ } >+ return searchREW(0, items-1, string); >+} >+ >+int ListContainer::AVfindInList(char* string) { >+ if (items < 1) { >+ return -1; >+ } >+ if (isSW) { >+ return searchRSWF(0, items-1, string); >+ } >+ return searchREWF(0, items-1, string); >+} >+ >+bool ListContainer::AVreadItemList(const char* filename, bool startswith, int filters) { >+ std::string linebuffer; >+ RegExp re; >+ re.comp("^.*\\:[0-9]+\\/.*"); >+ #ifdef DGDEBUG >+ std::cout << filename << std::endl; >+ #endif >+ if (isCacheFileNewer(filename)) { // see if cached .process file >+ linebuffer = filename; // is available and up to date >+ linebuffer += ".processed"; >+ >+ if (getFileLength(linebuffer.c_str()) >= 4000) { >+ // don't bother with small files >+ if (!readProcessedItemList(linebuffer.c_str(), startswith, filters)) { // read cached >+ return false; >+ } >+ issorted = true; // don't bother sorting cached file >+ return true; >+ } >+ } >+ int len = getFileLength(filename); >+ if (len < 0) { >+ if (!isDaemonised) { >+ std::cerr << "Error reading file: " << filename << std::endl; >+ } >+ syslog(LOG_ERR, "%s","Error reading file:"); >+ syslog(LOG_ERR, "%s",filename); >+ return false; >+ } >+ if (len < 4) { >+ return true; // its blank - perhaps due to webmin editing >+ // just return >+ } >+ increaseMemoryBy(len); // Allocate some memory to hold file >+ ifstream listfile(filename, ios::in); >+ if (!listfile.good()) { >+ if (!isDaemonised) { >+ std::cerr << "Error opening :"<< filename << std::endl; >+ } >+ syslog(LOG_ERR, "%s","Error opening :"); >+ syslog(LOG_ERR, "%s", filename); >+ return false; >+ } >+ String temp, inc, hostname, url; >+ while (!listfile.eof()) { >+ getline(listfile, linebuffer); >+ if (linebuffer.length() < 2) continue; // its jibberish >+ if (linebuffer[0] == '#') continue; // its a comment >+ temp = (char*)linebuffer.c_str(); >+ if (temp.contains("#")) { >+ temp = temp.before("#"); // tidy up >+ } >+ temp.removeWhiteSpace(); // tidy up and make it handle CRLF files >+ if (temp.startsWith(".Include<")) { // see if we have another list >+ inc = temp.after(".Include<"); // to include >+ inc = inc.before(">"); >+ if (!readItemList(inc.toCharArray(), startswith, filters)) { // read it >+ listfile.close(); >+ return false; >+ } >+ continue; >+ } >+ if (temp.endsWith("/")) { >+ temp.chop(); // tidy up >+ } >+ if (temp.startsWith("ftp://")) { >+ temp = temp.after("ftp://"); // tidy up >+ } >+ if (filters == 1) { // remove port addresses >+ if (temp.contains(":")) { // quicker than full regexp >+ if (re.match(temp.toCharArray())) { >+ hostname = temp.before(":"); >+ url = temp.after("/"); >+ temp = hostname + "/" + url; >+ } >+ } >+ } >+ temp.toLower(); // tidy up >+ addToItemList(temp.toCharArray(), temp.length()); // add to unsorted >+ // list >+ } >+ listfile.close(); >+ return true; // sucessful read >+} >diff -urN DansGuardian-2.7.7-2/ListContainer.hpp antivirus/DansGuardian-2.7.7-2-AntiVirus-5.0/ListContainer.hpp >--- DansGuardian-2.7.7-2/ListContainer.hpp 2004-02-18 11:05:15.000000000 -0300 >+++ antivirus/DansGuardian-2.7.7-2-AntiVirus-5.0/ListContainer.hpp 2004-02-19 01:07:15.000000000 -0300 >@@ -76,6 +76,11 @@ > int weightedpfiledate; > String sourcefile; // used for non-phrase lists only > >+ // Included by Aecio F. Neto (afn@harvest.com.br) - Harvest Consultoria (http://www.harvest.com.br) >+ int AVfindInList(char* string); >+ int AVfindEndsWith(char* string); >+ bool AVreadItemList(const char* filename, bool startswith, int filters); >+ > private: > > bool sourceisexception; >@@ -128,3 +133,4 @@ > }; > > #endif >+ >diff -urN DansGuardian-2.7.7-2/OptionContainer.cpp antivirus/DansGuardian-2.7.7-2-AntiVirus-5.0/OptionContainer.cpp >--- DansGuardian-2.7.7-2/OptionContainer.cpp 2004-02-18 11:05:15.000000000 -0300 >+++ antivirus/DansGuardian-2.7.7-2-AntiVirus-5.0/OptionContainer.cpp 2004-02-19 00:45:08.000000000 -0300 >@@ -45,6 +45,8 @@ > deleteFilterGroups(); > exception_user_list.reset(); > exception_ip_list.reset(); >+ exception_virus_mimetype_list.reset(); >+ exception_virus_extension_list.reset(); > banned_ip_list.reset(); > banned_user_list.reset(); > html_template.reset(); >@@ -316,6 +318,49 @@ > reverse_client_ip_lookups = 0; > } > >+ if (findoptionS("virusscan") == "on") { >+ virus_scan = 1; >+ } >+ else { >+ virus_scan = 0; >+ } >+ >+ // Included by Aecio F. Neto (afn@harvest.com.br) - Harvest Consultoria (http://www.harvest.com.br) >+ trickle_length = findoptionI("tricklelength"); >+ if (!realitycheck(String(trickle_length), 1, 6, "tricklelength")) >+ { return false; } >+ if (trickle_length < 0) >+ trickle_length = -1; >+ >+ first_trickle_delay = findoptionI("firsttrickledelay"); >+ if (!realitycheck(String(first_trickle_delay), 1, 3, "firsttrickledelay")) >+ { return false; } >+ if (first_trickle_delay < 1) >+ first_trickle_delay = 60; >+ >+ following_trickle_delay = findoptionI("followingtrickledelay"); >+ if (!realitycheck(String(following_trickle_delay), 1, 3, "followingtrickledelay")) >+ { return false; } >+ if (following_trickle_delay < 1) >+ following_trickle_delay = 30; >+ >+ if (findoptionS("virusscanexceptions") == "on") { >+ virus_scan_exceptions = 1; >+ } >+ else { >+ virus_scan_exceptions = 0; >+ } >+ >+ if (findoptionS("urlcachecleanonly") == "on") { >+ url_cache_clean_only = 1; >+ } >+ else { >+ url_cache_clean_only = 0; >+ } >+ >+ if ((download_dir = findoptionS("downloaddir")) == "") >+ download_dir = "/tmp/dgvirus"; >+ // End of Included by Aecio F. Neto (afn@harvest.com.br) - Harvest Consultoria (http://www.harvest.com.br) > > if (findoptionS("usexforwardedfor") == "on") { > use_xforwardedfor = 1; >@@ -341,6 +386,10 @@ > banned_user_list_location = findoptionS("banneduserlist"); > exceptions_user_list_location = findoptionS("exceptionuserlist"); > exceptions_ip_list_location = findoptionS("exceptioniplist"); >+ >+ exceptions_virus_mimetype_list_location = findoptionS("exceptionvirusmimetypelist"); >+ exceptions_virus_extension_list_location = findoptionS("exceptionvirusextensionlist"); >+ > language_list_location = findoptionS("languagedir") + "/" + findoptionS("language") + "/messages"; > access_denied_address = findoptionS("accessdeniedaddress"); > ada = access_denied_address.c_str(); >@@ -403,6 +452,15 @@ > syslog(LOG_ERR, "%s", "Error reading filter group conf file(s)."); return false; > > } >+ if (virus_scan) { >+ if (!readevmlfile(exceptions_virus_mimetype_list_location.c_str())) { >+ return false; >+ } // virus mimetype exceptions >+ >+ if (!readevelfile(exceptions_virus_extension_list_location.c_str())) { >+ return false; >+ } // virus extension exceptions >+ } > > } catch (exception& e) { > if (!isDaemonised) { >@@ -677,4 +735,42 @@ > return true; > } > >+// Included by Aecio F. Neto (afn@harvest.com.br) - Harvest Consultoria (http://www.harvest.com.br) >+int OptionContainer::inVirusExceptionExtensionList(String url) { >+ url.removeWhiteSpace(); // just in case of weird browser crap >+ url.toLower(); >+ url.removePTP(); // chop off the ht(f)tp(s):// >+ url = url.after("/"); // chop off any domain before the path >+ if (url.length() < 2) { // will never match >+ return -1; >+ } >+ return exception_virus_extension_list.AVfindEndsWith(url.toCharArray()); >+} >+ >+bool OptionContainer::readevmlfile(const char* filename) { > >+ bool result = exception_virus_mimetype_list.AVreadItemList(filename, false, 0); >+ if (!result) { >+ if (!isDaemonised) { >+ std::cerr << "Error opening exceptionvirusmimetypelist" << std::endl; >+ } >+ syslog(LOG_ERR, "%s","Error opening exceptionvirusmimetypelist"); >+ return false; >+ } >+ exception_virus_mimetype_list.endsWithSort(); >+ return true; >+} >+ >+bool OptionContainer::readevelfile(const char* filename) { >+ >+ bool result = exception_virus_extension_list.AVreadItemList(filename, false, 0); >+ if (!result) { >+ if (!isDaemonised) { >+ std::cerr << "Error opening exceptionvirusextensionlist" << std::endl; >+ } >+ syslog(LOG_ERR, "%s","Error opening exceptionvirusextensionlist"); >+ return false; >+ } >+ exception_virus_extension_list.endsWithSort(); >+ return true; >+} >diff -urN DansGuardian-2.7.7-2/OptionContainer.hpp antivirus/DansGuardian-2.7.7-2-AntiVirus-5.0/OptionContainer.hpp >--- DansGuardian-2.7.7-2/OptionContainer.hpp 2004-02-18 11:05:15.000000000 -0300 >+++ antivirus/DansGuardian-2.7.7-2-AntiVirus-5.0/OptionContainer.hpp 2004-02-19 00:45:08.000000000 -0300 >@@ -118,6 +118,19 @@ > FOptionContainer** fg; > int numfg; > >+ int virus_scan; >+ int first_trickle_delay; >+ int following_trickle_delay; >+ int trickle_length; >+ int virus_scan_exceptions; >+ int url_cache_clean_only; >+ std::string download_dir; >+ std::string exceptions_virus_mimetype_list_location; >+ std::string exceptions_virus_extension_list_location; >+ ListContainer exception_virus_mimetype_list; >+ ListContainer exception_virus_extension_list; >+ int inVirusExceptionExtensionList(String url); >+ > private: > std::deque<std::string> conffile; > String ada; >@@ -132,6 +145,8 @@ > bool realitycheck(String s, int minl, int maxl, char* emessage); > bool readAnotherFilterGroupConf(const char *filename); > >+ bool readevmlfile(const char* filename); // exception virus mimetype list >+ bool readevelfile(const char* filename); // exception virus extension list > }; > > #endif >diff -urN DansGuardian-2.7.7-2/VirusScanner.cpp antivirus/DansGuardian-2.7.7-2-AntiVirus-5.0/VirusScanner.cpp >--- DansGuardian-2.7.7-2/VirusScanner.cpp 1969-12-31 21:00:00.000000000 -0300 >+++ antivirus/DansGuardian-2.7.7-2-AntiVirus-5.0/VirusScanner.cpp 2004-02-19 01:08:44.000000000 -0300 >@@ -0,0 +1,614 @@ >+// Written by James A. Pattie (james@pcxperience.com) Xperience, Inc. (www.pcxperience.com) >+ >+// This program is free software; you can redistribute it and/or modify >+// it under the terms of the GNU General Public License as published by >+// the Free Software Foundation; either version 2 of the License, or >+// (at your option) any later version. >+// >+// This program is distributed in the hope that it will be useful, >+// but WITHOUT ANY WARRANTY; without even the implied warranty of >+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >+// GNU General Public License for more details. >+// >+// You should have received a copy of the GNU General Public License >+// along with this program; if not, write to the Free Software >+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA >+ >+#include <syslog.h> >+#include "String.hpp" >+#include <algorithm> >+#include "VirusScanner.hpp" >+#include <cstdlib> >+#include <unistd.h> >+#include <zlib.h> >+#include <fstream> >+#include <time.h> >+#include <EXTERN.h> >+#include <perl.h> >+#include <XSUB.h> >+#include <stdio.h> >+#include <clamav.h> >+ >+#define MAX_BUF 5*1024*1024 >+ >+extern struct cl_node *root; >+extern struct cl_limits limits; >+ >+extern OptionContainer o; >+ >+VirusScanner::VirusScanner() >+:data(new char[0]),file_length(0),buffer_length(0),isInfected(false),tempFileName(new char[0]),tempfileFD(0),timeout(60),trickle_pos(0) {} >+// set buffer length to zero and initialise the char* memory block to hold >+// the data - initialisation/creation function >+ >+ >+VirusScanner::~VirusScanner() { >+// unlink(tempFileName); >+ >+ delete[] data; >+ delete[] tempFileName; >+} >+// delete the memory block when the class is destroyed >+ >+ >+void VirusScanner::handleScanning(Socket *proxysock, Socket *peerconn, String url, int contentLength, >+ std::string username, std::string clientip, >+ std::string location, int reporting_level) throw(exception) { >+ try { >+ createTempFile(); >+ #ifdef DGDEBUG >+ std::cout << "VirusScanner - right before in" << std::endl; >+ #endif >+ in(proxysock, peerconn, url, contentLength, username, clientip); >+ #ifdef DGDEBUG >+ std::cout << "Viruscanner - right after in" << std::endl; >+ std::cout << "Viruscanner - right before scanFile" << std::endl; >+ #endif >+ scan(peerconn, url, username, clientip, location, reporting_level); >+ #ifdef DGDEBUG >+ std::cout << "Viruscanner - right after scanFile" << std::endl; >+ #endif >+ } catch (exception& e) { >+ #ifdef DGDEBUG >+ std::cout << "***exception on Viruscanner::in***" << std::endl; >+ #endif >+ throw e; >+ } >+} >+ >+void VirusScanner::createTempFile(void) { >+ fstream tmpFile; >+ >+ tempFileName = new char[256]; >+ strcpy(tempFileName, o.download_dir.c_str()); >+ strcat(tempFileName, "/tfXXXXXX"); >+ >+ if ((tempfileFD = mkstemp(tempFileName)) < 0) { >+ #ifdef DGDEBUG >+ std::cout << "VirusScanner could not create temp file " << tempFileName << std::endl; >+ #endif >+ throw exception(); >+ } >+ #ifdef DGDEBUG >+ std::cout << "VirusScanner created temp file " << tempFileName << std::endl; >+ std::cout << "VirusScanner temp file FD " << tempfileFD << std::endl; >+ #endif >+} >+ >+void VirusScanner::in(Socket *proxysock, Socket *peerconn, String url, int contentLength, std::string username, std::string clientip) throw(exception) { >+ #ifdef DGDEBUG >+ std::cout << "TrickleBuffer starting..." << endl; >+ #endif >+ >+ int rc = 0; >+ int newsize = 0; >+ >+ time_t lastWrite; >+ time_t current; >+ >+ char* block; // buffer for storing a grabbed block from the input stream >+ >+ // Included by Aecio F. Neto (afn@harvest.com.br) - Harvest Consultoria (http://www.harvest.com.br) >+ int tricklelength = o.trickle_length; >+ int tricklebuffer = 0; >+ int lastsize = contentLength - tricklelength; >+ >+ #ifdef DGDEBUG >+ std::cout << "'tempFileName: '" << tempFileName << "', File Length = " << contentLength << std::endl; >+ #endif >+ >+ lastWrite = time(NULL); >+ current = lastWrite; >+ while(true) { >+ if (buffer_length >= 16384) >+ newsize = buffer_length; >+ else >+ newsize = 16384; >+ >+ // make sure we don't eat up too much memory! Caught by Wu Jiafu. >+ if (MAX_BUF < newsize) >+ newsize = MAX_BUF; >+ >+ block = new char[newsize]; >+ >+ try { >+ (*proxysock).checkForInput(timeout); >+ } catch (exception& e) { >+ delete[] block; >+ break; >+ } >+ >+ rc = (*proxysock).readFromSocket(block, newsize, 0, timeout); >+ // grab a block of input, doubled each time >+ >+ if (rc < 1) { >+ delete[] block; >+ break; // an error occured so end the while() >+ // or none received so pipe is closed >+ } >+ >+ // Included by Aecio F. Neto (afn@harvest.com.br) - Harvest Consultoria (http://www.harvest.com.br) >+ tricklebuffer = tricklelength; >+ >+ if (rc > 0) { >+ lseek(tempfileFD, 0, SEEK_END); >+ >+ for (int i = 0; i < rc; i++) >+ write(tempfileFD, &block[i], 1); >+ buffer_length += rc; // update data size counter >+ >+ // Included by Aecio F. Neto (afn@harvest.com.br) - Harvest Consultoria (http://www.harvest.com.br) >+ if (rc > tricklelength) >+ tricklebuffer = rc; >+ } >+ delete[] block; >+ current = time(NULL); >+ >+ // Included by Aecio F. Neto (afn@harvest.com.br) - Harvest Consultoria (http://www.harvest.com.br) >+ if (tricklelength < 1) { >+ if (trickle_pos == 0 && ((current - lastWrite) >= o.first_trickle_delay)) { >+ #ifdef DGDEBUG >+ std::cout << o.first_trickle_delay << " second trickle. " << std::endl; >+ #endif >+ >+ lastWrite = current; >+ char *temp = new char[1]; >+ lseek(tempfileFD, trickle_pos, SEEK_SET); >+ read(tempfileFD, &temp[0], 1); >+ (*peerconn).readyForOutput(timeout); // exceptions on timeout or error >+ if (!(*peerconn).writeToSocket(temp, 1, 0, timeout)) { >+ #ifdef DGDEBUG >+ std::cerr << "Could not trickle byte 0 = '" << temp << "'! = 'filename: " << tempFileName << "'" << std::endl; >+ #endif >+ delete[] temp; >+ throw exception(); >+ } // write the data block out to the stream >+ trickle_pos++; >+ delete[] temp; >+ } >+ else if (trickle_pos > 0 && ((current - lastWrite) >= o.following_trickle_delay)) { >+ #ifdef DGDEBUG >+ std::cout << o.following_trickle_delay << " second trickle, byte = '" << trickle_pos << "' filename: '" << tempFileName << "'" << std::endl; >+ #endif >+ >+ lastWrite = current; >+ char *temp = new char[1]; >+ lseek(tempfileFD, trickle_pos, SEEK_SET); >+ read(tempfileFD, &temp[0], 1); >+ (*peerconn).readyForOutput(timeout); // exceptions on timeout or error >+ if (!(*peerconn).writeToSocket(temp, 1, 0, timeout)) { >+ #ifdef DGDEBUG >+ std::cerr << "Could not trickle byte " << trickle_pos << " = '" << temp << "'! filename: '" << tempFileName << "'" << std::endl; >+ #endif >+ delete[] temp; >+ throw exception(); >+ } // write the data block out to the stream >+ trickle_pos++; >+ delete[] temp; >+ } >+ } >+ // Included by Aecio F. Neto (afn@harvest.com.br) - Harvest Consultoria (http://www.harvest.com.br) >+ else if ((buffer_length > (trickle_pos + tricklelength)) && (buffer_length < lastsize)) { >+ char *temp = new char[tricklebuffer]; >+ if (rc > 0) >+ lseek(tempfileFD, trickle_pos, SEEK_SET); >+ >+ for (int i = 0; i < tricklebuffer; i++) >+ read(tempfileFD, &temp[i], 1); >+ >+ (*peerconn).readyForOutput(timeout); // exceptions on timeout or error >+ if (!(*peerconn).writeToSocket(temp, tricklebuffer, 0, timeout)) { >+ #ifdef DGDEBUG >+ std::cerr << "Could not write block to socket." << std::endl; >+ #endif >+ delete[] temp; >+ throw exception(); >+ } // write the data block out to the stream >+ trickle_pos += tricklebuffer; >+ delete[] temp; >+ } >+ #ifdef DGDEBUG >+ std::cout << "rc: " << rc << std::endl; >+ std::cout << "buffer_length: " << buffer_length << std::endl; >+ std::cout << "trickle_pos: " << trickle_pos << std::endl; >+ std::cout << "tricklebuffer: " << tricklebuffer << std::endl; >+ std::cout << "tricklelength: " << tricklelength << std::endl; >+ std::cout << std::endl; >+ #endif >+ } >+ #ifdef DGDEBUG >+ std::cout << "final values: " << std::endl; >+ std::cout << "rc: " << rc << std::endl; >+ std::cout << "buffer_length: " << buffer_length << std::endl; >+ std::cout << "trickle_pos: " << trickle_pos << std::endl; >+ std::cout << "tricklebuffer: " << tricklebuffer << std::endl; >+ std::cout << "contentLength: " << contentLength << std::endl; >+ std::cout << std::endl; >+ #endif >+} >+ >+void VirusScanner::out(Socket *sock) throw(exception) { >+ >+ (*sock).readyForOutput(timeout); // exceptions on timeout or error >+ >+ // need exception or something for a bad write >+ if (!(*sock).writeToSocket(data, buffer_length, 0, timeout)) { >+ #ifdef DGDEBUG >+ std::cout << "Error sending data to socket" << endl; >+ #endif >+ throw exception(); >+ } // write the data block out to the stream >+} >+ >+void VirusScanner::scan(Socket *peerconn, String url, std::string username, std::string clientip, std::string location, int reporting_level) throw(exception) { >+ //Added by Aecio F. Neto (afn@harvest.com.br) - Harvest Consultoria (http://www.harvest.com.br) >+ char* virusName; >+ long unsigned int sze; >+ >+ #ifdef DGDEBUG >+ std::cout << "Scanning file: '" << tempFileName << "' for user '" << username << "'..." << std::endl; >+ #endif >+ >+ lseek(tempfileFD, 0, SEEK_SET); >+ file_length = lseek(tempfileFD, 0, SEEK_END); >+ >+ #ifdef DGDEBUG >+ system("date"); >+ std::cout << "Starting file scanning..." << endl; >+ #endif >+ isInfected = cl_scandesc(tempfileFD, &virusName, &sze, root, &limits, CL_ARCHIVE); >+ #ifdef DGDEBUG >+ std::cout << "End of file scanning" << endl; >+ system("date"); >+ std::cout << endl; >+ std::cout << "VirusScanner - isInfected = " << isInfected << std::endl; >+ #endif >+ >+ if (isInfected == CL_CLEAN) { >+ buffer_length = 0; >+ #ifdef DGDEBUG >+ std::cout << "sending data from trickle_pos = '" << trickle_pos << "', length = '" << file_length << std::endl; >+ #endif >+ >+ // position ourselves. >+ lseek(tempfileFD, trickle_pos, SEEK_SET); >+ char* ch; >+ ch = new char[1]; >+ int size = 16384; >+ >+ // while not the end of the file (get a byte) >+ while(read(tempfileFD, &ch[0], 1)) { >+ // see if we need to allocate memory for the data array >+ if (buffer_length == 0) >+ data = new char[size]; >+ >+ // insert in data array >+ data[buffer_length] = ch[0]; >+ buffer_length++; >+ file_length++; // increment the size of the file. >+ >+ // if size bytes read, then send current data, free data >+ if (buffer_length == (size - 1)) { >+ try { >+ #ifdef DGDEBUG >+ std::cout << "buffer_length is full" << std::endl; >+ std::cout << "sending data to sock" << std::endl; >+ #endif >+ out(peerconn); >+ } catch (exception& e) { >+ #ifdef DGDEBUG >+ std::cout << "sending data failed!" << std::endl; >+ #endif >+ throw e; >+ } >+ #ifdef DGDEBUG >+ std::cout << "data sent to sock" << std::endl; >+ #endif >+ buffer_length = 0; >+ delete[] data; >+ } >+ } >+ >+ #ifdef DGDEBUG >+ std::cout << "buffer_length: " << buffer_length << std::endl; >+ #endif >+ // see if there is any data left to send >+ if (buffer_length > 0) { >+ try { >+ #ifdef DGDEBUG >+ std::cout << "buffer_length > 0" << std::endl; >+ std::cout << "sending data " << std::endl; >+ #endif >+ out(peerconn); >+ } catch (exception& e) { >+ #ifdef DGDEBUG >+ std::cout << "sending data failed!" << std::endl; >+ #endif >+ throw e; >+ } >+ #ifdef DGDEBUG >+ std::cout << "data sent" << std::endl; >+ #endif >+ } >+ } >+ else if (isInfected == CL_VIRUS) { >+ // in the future we will try to archive and then potentially disinfect this file. >+ // for now, delete it. It is archived in the perl code now. >+ >+ // send the browser an error html document stating that the file was infected w/ a virus. >+ // Added feature to use dansguardian.pl >+ // Added by Aecio F. Neto (afn@harvest.com.br) - Harvest Consultoria (http://www.harvest.com.br) >+ try { >+ if (reporting_level == 3) { >+ // I'm not 100% sure that I don't need the following 2 lines at some point in time. >+ // sock.writeString("HTTP/1.0 200 OK\n"); >+ // sock.writeString("Content-type: text/html\n\n"); >+ (*peerconn).writeString("<html><head><title>DansGuardian - File Infected</title></head>"); >+ (*peerconn).writeString("<body><center><h1>DansGuardian - File Infected</h1>"); >+ (*peerconn).writeString("url = <b>"); >+ (*peerconn).writeString(url.toCharArray()); >+ (*peerconn).writeString("</b> was infected with a virus!<br><br>Contact your Administrator for details.</center></body></html>"); >+ } >+ else { >+ (*peerconn).writeString("<html><head>"); >+ (*peerconn).writeString("<script language=JavaScript>"); >+ (*peerconn).writeString("location.href="); >+ (*peerconn).writeString(location.c_str()); >+ (*peerconn).writeString("?USER="); >+ (*peerconn).writeString(username.c_str()); >+ (*peerconn).writeString("&REASON=Virus%20 '"); >+ (*peerconn).writeString(virusName); >+ (*peerconn).writeString("' found%20on%20page"); >+ (*peerconn).writeString("&URL="); >+ (*peerconn).writeString(url.toCharArray()); >+ (*peerconn).writeString("</script>"); >+ (*peerconn).writeString("</head></html>"); >+ } >+ >+ char bufferLengthStr[51]; >+ sprintf(bufferLengthStr,"%li", file_length); >+ int result = 0; >+ >+ // call scan with the file name and the size of the file in bytes. >+ dSP; // initialize stack pointer >+ ENTER; >+ SAVETMPS; >+ PUSHMARK(SP); >+ XPUSHs(sv_2mortal(newSVpv(virusName, 0))); >+ XPUSHs(sv_2mortal(newSVpv(bufferLengthStr, 0))); >+ XPUSHs(sv_2mortal(newSVpv(url.toCharArray(), 0))); >+ XPUSHs(sv_2mortal(newSVpv(username.c_str(), 0))); >+ XPUSHs(sv_2mortal(newSVpv(clientip.c_str(), 0))); >+ XPUSHs(sv_2mortal(newSVpv(o.download_dir.c_str(), 0))); >+ XPUSHs(sv_2mortal(newSVpv(tempFileName, 0))); >+ PUTBACK; >+ perl_call_pv("notify", G_SCALAR); >+ SPAGAIN; >+ result = POPi; // Get the return value off the stack. >+ PUTBACK; >+ FREETMPS; >+ LEAVE; >+ } catch (exception& e) { >+ #ifdef DGDEBUG >+ std::cout << "sending infected message failed!" << std::endl; >+ #endif >+ throw e; >+ } >+ #ifdef DGDEBUG >+ std::cout << "VirusName: " << virusName << endl; >+ #endif >+ } >+ else { >+ try { >+ (*peerconn).writeString("<html><head><title>DansGuardian - File Infected</title></head>"); >+ (*peerconn).writeString("<body><center><h1>DansGuardian Antivirus Patch- Error during scanning</h1>"); >+ (*peerconn).writeString("</center></body></html>"); >+ } catch (exception& e) { >+ throw e; >+ } >+ } >+ close(tempfileFD); >+// unlink(tempFileName); >+} >+ >+void VirusScanner::scanFile(Socket *peerconn, String url, std::string username, std::string clientip, std::string location, int reporting_level) throw(exception) { >+ //Added by Aecio F. Neto (afn@harvest.com.br) - Harvest Consultoria (http://www.harvest.com.br) >+ char* virusName; >+ long unsigned int sze; >+ >+ fstream tmpFile; >+ >+ #ifdef DGDEBUG >+ std::cout << "Scanning file: '" << tempFileName << "' for user '" << username << "'..." << std::endl; >+ #endif >+ >+ // open the file for reading. >+ tmpFile.open(tempFileName, ios::in); >+ if (!tmpFile) { >+ #ifdef DGDEBUG >+ std::cout << "VirusScanner could not open " << tempFileName << "!" << std::endl; >+ #endif >+ throw exception(); >+ } >+ tmpFile.seekg(0, ios::end); >+ file_length = tmpFile.tellg(); >+ #ifdef DGDEBUG >+ system("date"); >+ std::cout << "Starting file scanning..." << endl; >+ #endif >+ isInfected = cl_scanfile(tempFileName, &virusName, &sze, root, &limits, CL_ARCHIVE); >+ #ifdef DGDEBUG >+ std::cout << "End of file scanning" << endl; >+ system("date"); >+ std::cout << endl; >+ std::cout << "VirusScanner - isInfected = " << isInfected << std::endl; >+ #endif >+ >+ if (isInfected == CL_CLEAN) { >+ buffer_length = 0; >+ #ifdef DGDEBUG >+ std::cout << "sending data from trickle_pos = '" << trickle_pos << "', length = '" << file_length << std::endl; >+ #endif >+ >+ // position ourselves. >+ tmpFile.seekg(trickle_pos); // position at the first byte to send. >+ char ch; >+ int size = 16384; >+ >+ // while not the end of the file (get a byte) >+ while (tmpFile.get(ch)) { >+ // see if we need to allocate memory for the data array >+ if (buffer_length == 0) >+ data = new char[size]; >+ >+ // insert in data array >+ data[buffer_length] = ch; >+ buffer_length++; >+ file_length++; // increment the size of the file. >+ >+ // if size bytes read, then send current data, free data >+ if (buffer_length == (size - 1)) { >+ try { >+ #ifdef DGDEBUG >+ std::cout << "buffer_length is full" << std::endl; >+ std::cout << "sending data to sock" << std::endl; >+ #endif >+ out(peerconn); >+ } catch (exception& e) { >+ tmpFile.close(); >+ #ifdef DGDEBUG >+ std::cout << "sending data failed!" << std::endl; >+ #endif >+ throw e; >+ } >+ #ifdef DGDEBUG >+ std::cout << "data sent to sock" << std::endl; >+ #endif >+ buffer_length = 0; >+ delete[] data; >+ } >+ } >+ >+ #ifdef DGDEBUG >+ std::cout << "buffer_length: " << buffer_length << std::endl; >+ #endif >+ // see if there is any data left to send >+ if (buffer_length > 0) { >+ try { >+ #ifdef DGDEBUG >+ std::cout << "buffer_length > 0" << std::endl; >+ std::cout << "sending data " << std::endl; >+ #endif >+ out(peerconn); >+ } catch (exception& e) { >+ tmpFile.close(); >+ #ifdef DGDEBUG >+ std::cout << "sending data failed!" << std::endl; >+ #endif >+ throw e; >+ } >+ #ifdef DGDEBUG >+ std::cout << "data sent" << std::endl; >+ #endif >+ } >+ } >+ else if (isInfected == CL_VIRUS) { >+ // in the future we will try to archive and then potentially disinfect this file. >+ // for now, delete it. It is archived in the perl code now. >+ >+ >+ // send the browser an error html document stating that the file was infected w/ a virus. >+ // Added feature to use dansguardian.pl >+ // Added by Aecio F. Neto (afn@harvest.com.br) - Harvest Consultoria (http://www.harvest.com.br) >+ try { >+ if (reporting_level == 3) { >+ // I'm not 100% sure that I don't need the following 2 lines at some point in time. >+ // sock.writeString("HTTP/1.0 200 OK\n"); >+ // sock.writeString("Content-type: text/html\n\n"); >+ (*peerconn).writeString("<html><head><title>DansGuardian - File Infected</title></head>"); >+ (*peerconn).writeString("<body><center><h1>DansGuardian - File Infected</h1>"); >+ (*peerconn).writeString("url = <b>"); >+ (*peerconn).writeString(url.toCharArray()); >+ (*peerconn).writeString("</b> was infected with a virus!<br><br>Contact your Administrator for details.</center></body></html>"); >+ } >+ else { >+ (*peerconn).writeString("<html><head>"); >+ (*peerconn).writeString("<script language=JavaScript>"); >+ (*peerconn).writeString("location.href="); >+ (*peerconn).writeString(location.c_str()); >+ (*peerconn).writeString("?USER="); >+ (*peerconn).writeString(username.c_str()); >+ (*peerconn).writeString("&REASON=Virus%20 '"); >+ (*peerconn).writeString(virusName); >+ (*peerconn).writeString("' found%20on%20page"); >+ (*peerconn).writeString("&URL="); >+ (*peerconn).writeString(url.toCharArray()); >+ (*peerconn).writeString("</script>"); >+ (*peerconn).writeString("</head></html>"); >+ } >+ >+ char bufferLengthStr[51]; >+ sprintf(bufferLengthStr,"%li", file_length); >+ int result = 0; >+ >+ // call scan with the file name and the size of the file in bytes. >+ dSP; // initialize stack pointer >+ ENTER; >+ SAVETMPS; >+ PUSHMARK(SP); >+ XPUSHs(sv_2mortal(newSVpv(virusName, 0))); >+ XPUSHs(sv_2mortal(newSVpv(bufferLengthStr, 0))); >+ XPUSHs(sv_2mortal(newSVpv(url.toCharArray(), 0))); >+ XPUSHs(sv_2mortal(newSVpv(username.c_str(), 0))); >+ XPUSHs(sv_2mortal(newSVpv(clientip.c_str(), 0))); >+ XPUSHs(sv_2mortal(newSVpv(o.download_dir.c_str(), 0))); >+ XPUSHs(sv_2mortal(newSVpv(tempFileName, 0))); >+ PUTBACK; >+ perl_call_pv("notify", G_SCALAR); >+ SPAGAIN; >+ result = POPi; // Get the return value off the stack. >+ PUTBACK; >+ FREETMPS; >+ LEAVE; >+ } catch (exception& e) { >+ #ifdef DGDEBUG >+ std::cout << "sending infected message failed!" << std::endl; >+ #endif >+ throw e; >+ } >+ #ifdef DGDEBUG >+ std::cout << "VirusName: " << virusName << endl; >+ #endif >+ } >+ else { >+ try { >+ (*peerconn).writeString("<html><head><title>DansGuardian - File Infected</title></head>"); >+ (*peerconn).writeString("<body><center><h1>DansGuardian Antivirus Patch- Error during scanning</h1>"); >+ (*peerconn).writeString("</center></body></html>"); >+ } catch (exception& e) { >+ throw e; >+ } >+ } >+ tmpFile.close(); >+ unlink(tempFileName); >+} >diff -urN DansGuardian-2.7.7-2/VirusScanner.hpp antivirus/DansGuardian-2.7.7-2-AntiVirus-5.0/VirusScanner.hpp >--- DansGuardian-2.7.7-2/VirusScanner.hpp 1969-12-31 21:00:00.000000000 -0300 >+++ antivirus/DansGuardian-2.7.7-2-AntiVirus-5.0/VirusScanner.hpp 2004-02-19 01:08:44.000000000 -0300 >@@ -0,0 +1,51 @@ >+// Written by James A. Pattie (james@pcxperience.com) Xperience, Inc. (www.pcxperience.com) >+ >+// This program is free software; you can redistribute it and/or modify >+// it under the terms of the GNU General Public License as published by >+// the Free Software Foundation; either version 2 of the License, or >+// (at your option) any later version. >+// >+// This program is distributed in the hope that it will be useful, >+// but WITHOUT ANY WARRANTY; without even the implied warranty of >+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >+// GNU General Public License for more details. >+// >+// You should have received a copy of the GNU General Public License >+// along with this program; if not, write to the Free Software >+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA >+ >+#ifndef __HPP_VIRUSSCANNER >+#define __HPP_VIRUSSCANNER >+#include <exception> >+#include <fstream> >+#include "Socket.hpp" >+#include "String.hpp" >+#include "OptionContainer.hpp" >+ >+class VirusScanner { >+ >+public: >+ char* data; >+ long unsigned int file_length; >+ int buffer_length; >+ bool isInfected; >+ char* tempFileName; >+ int tempfileFD; >+ >+ VirusScanner(); >+ ~VirusScanner(); >+ >+ void handleScanning(Socket *proxysock, Socket *peerconn, String url, int contentLength, std::string username, std::string clientip, std::string location, int reporting_level) throw(exception); >+ void setTimeout(int t); >+ void createTempFile(void); >+ void out(Socket *sock) throw(exception); >+ void in(Socket* sock, Socket* outSock, String url, int contentLength, std::string username, std::string clientip) throw(exception); >+ void scan(Socket *peerconn, String url, std::string username, std::string clientip, std::string location, int reporting_level) throw(exception); >+ void scanFile(Socket *peerconn, String url, std::string username, std::string clientip, std::string location, int reporting_level) throw(exception); >+ >+private: >+ int timeout; >+ int trickle_pos; >+}; >+ >+#endif >diff -urN DansGuardian-2.7.7-2/autoconf/fbsd.in antivirus/DansGuardian-2.7.7-2-AntiVirus-5.0/autoconf/fbsd.in >--- DansGuardian-2.7.7-2/autoconf/fbsd.in 2004-02-18 11:05:15.000000000 -0300 >+++ antivirus/DansGuardian-2.7.7-2-AntiVirus-5.0/autoconf/fbsd.in 2004-02-19 00:53:17.000000000 -0300 >@@ -8,8 +8,10 @@ > DataBuffer.o HTTPHeader.o NaughtyFilter.o RegExp.o Socket.o \ > FatController.o UDSocket.o SysV.o ListContainer.o Ident.o \ > HTMLTemplate.o LanguageContainer.o DynamicURLList.o ImageContainer.o \ >+ VirusScanner.o perlxsi.o \ > FOptionContainer.o ListManager.o md5.o > LIBS = /usr/lib/libz.a >+LIBS += -lclamav > PROG = dansguardian > INSTALLFILES = dansguardian dansguardian.conf dansguardian.sysv \ > bannedphraselist exceptionsitelist dansguardian.pl \ >@@ -22,9 +24,14 @@ > > PASSVARS = -DPROXYUSER=\"${PROXYUSER}\" > #PASSVARS += -DLOGLOCATION=\"${LOGLOCATION}access.log\" >+PASSVARS += -DCONFFILEDIR=\"${CONFFILELOCATION}\" > PASSVARS += -DCONFFILELOCATION=\"${CONFFILELOCATION}dansguardian.conf\" > #PASSVARS += -DPIDDIR=\"${PIDDIR}\" > >+PERLCC = `perl -MExtUtils::Embed -e ccopts` >+PERLLD = `perl -MExtUtils::Embed -e ldopts` >+PERL = $(PERLCC) $(PERLLD) >+ > #Some advanced options: > WARNING = -Wall > OPTIMISE = -O2 >@@ -35,11 +42,14 @@ > CFLAGS = $(OPTIMISE) $(WARNING) > DGCFLAGS = $(OPTIMISE) $(PASSVARS) -lz $(STATIC) > >+.c.o: >+ $(CPP) $(DEBUG) $(CFLAGS) $(PERLCC) -c $< >+ > .cpp.o: >- $(CPP) $(DEBUG) $(CFLAGS) -c $< >+ $(CPP) $(DEBUG) $(CFLAGS) $(PERLCC) -c $< > >-all: $(OBJ) >- $(CPP) -o dansguardian $(DGCFLAGS) $(DEBUG) $(OBJ) $(LIBS) dansguardian.cpp >+all: $(OBJ) >+ $(CPP) -o dansguardian $(DGCFLAGS) $(DEBUG) $(OBJ) $(LIBS) $(PERL) dansguardian.cpp > > install: > @test -d $I$(SYSVLOCATION) || install -d $I$(SYSVLOCATION) >@@ -73,6 +83,11 @@ > cp -f ./exceptionurllist $I$(CONFFILELOCATION)exceptionurllist > cp -f ./exceptionuserlist $I$(CONFFILELOCATION)exceptionuserlist > cp -f ./exceptioniplist $I$(CONFFILELOCATION)exceptioniplist >+ cp -f ./exceptionvirusmimetypelist $I$(CONFFILELOCATION)exceptionvirusmimetypelist >+ cp -f ./exceptionvirusextensionlist $I$(CONFFILELOCATION)exceptionvirusextensionlist >+ cp -f ./virusscanner.pl $I$(CONFFILELOCATION)virusscanner.pl >+ cp -f ./virusscanner.conf $I$(CONFFILELOCATION)virusscanner.conf >+ cp -f ./config.pl $I$(CONFFILELOCATION)config.pl > cp -f ./pics $I$(CONFFILELOCATION)pics > cp -f ./transparent1x1.gif $I$(CONFFILELOCATION)transparent1x1.gif > cp -f ./logrotation $I$(CONFFILELOCATION)logrotation >diff -urN DansGuardian-2.7.7-2/autoconf/hpux.in antivirus/DansGuardian-2.7.7-2-AntiVirus-5.0/autoconf/hpux.in >--- DansGuardian-2.7.7-2/autoconf/hpux.in 2004-02-18 11:05:15.000000000 -0300 >+++ antivirus/DansGuardian-2.7.7-2-AntiVirus-5.0/autoconf/hpux.in 2004-02-19 00:56:43.000000000 -0300 >@@ -12,9 +12,11 @@ > DataBuffer.o HTTPHeader.o NaughtyFilter.o RegExp.o Socket.o \ > FatController.o UDSocket.o SysV.o ListContainer.o Ident.o \ > HTMLTemplate.o LanguageContainer.o DynamicURLList.o ImageContainer.o \ >+ VirusScanner.o perlxsi.o \ > FOptionContainer.o ListManager.o md5.o > > LIBS = /usr/lib/libz.a >+LIBS += -lclamav > PROG = dansguardian > INSTALLFILES = dansguardian dansguardian.conf dansguardian.sysv \ > bannedphraselist exceptionsitelist dansguardian.pl \ >@@ -27,9 +29,14 @@ > > PASSVARS = -DPROXYUSER=\"${PROXYUSER}\" > #PASSVARS += -DLOGLOCATION=\"${LOGLOCATION}access.log\" >+PASSVARS += -DCONFFILEDIR=\"${CONFFILELOCATION}\" > PASSVARS += -DCONFFILELOCATION=\"${CONFFILELOCATION}dansguardian.conf\" > #PASSVARS += -DPIDDIR=\"${PIDDIR}\" > >+PERLCC = `perl -MExtUlils::Embed -e ccopts` >+PERLLD = `perl -MExtUlils::Embed -e ldopts` >+PERL = $(PERLCC) $(PERLLD) >+ > #Some advanced options: > WARNING = -Wall > OPTIMISE = -O2 >@@ -40,11 +47,14 @@ > CFLAGS = $(OPTIMISE) $(WARNING) > DGCFLAGS = $(OPTIMISE) $(PASSVARS) -lz $(STATIC) > >+.c.o: >+ $(CPP) $(DEBUG) $(CFLAGS) $(PERLCC) -c $< >+ > .cpp.o: >- $(CPP) $(DEBUG) $(CFLAGS) -c $< >+ $(CPP) $(DEBUG) $(CFLAGS) $(PERLCC) -c $< > > all: $(OBJ) >- $(CPP) -o dansguardian $(DGCFLAGS) $(DEBUG) $(OBJ) $(LIBS) dansguardian.cpp >+ $(CPP) -o dansguardian $(DGCFLAGS) $(DEBUG) $(OBJ) $(LIBS) $(PERL) dansguardian.cpp > > install: > @test -d $I$(SYSVLOCATION) || install -d $I$(SYSVLOCATION) >@@ -78,6 +88,11 @@ > cp -f ./exceptionurllist $I$(CONFFILELOCATION)exceptionurllist > cp -f ./exceptionuserlist $I$(CONFFILELOCATION)exceptionuserlist > cp -f ./exceptioniplist $I$(CONFFILELOCATION)exceptioniplist >+ cp -f ./exceptionvirusmimetypelist $I$(CONFFILELOCATION)exceptionvirusmimetypelist >+ cp -f ./exceptionvirusextensionlist $I$(CONFFILELOCATION)exceptionvirusextensionlist >+ cp -F ./virusscanner.pl $I$(CONFFILELOCATION)virusscanner.pl >+ cp -F ./virusscanner.conf $I$(CONFFILELOCATION)virusscanner.conf >+ cp -F ./config.pl $I$(CONFFILELOCATION)config.pl > cp -f ./pics $I$(CONFFILELOCATION)pics > cp -f ./transparent1x1.gif $I$(CONFFILELOCATION)transparent1x1.gif > cp -f ./logrotation $I$(CONFFILELOCATION)logrotation >diff -urN DansGuardian-2.7.7-2/autoconf/linux.in antivirus/DansGuardian-2.7.7-2-AntiVirus-5.0/autoconf/linux.in >--- DansGuardian-2.7.7-2/autoconf/linux.in 2004-02-18 11:05:15.000000000 -0300 >+++ antivirus/DansGuardian-2.7.7-2-AntiVirus-5.0/autoconf/linux.in 2004-02-19 00:57:21.000000000 -0300 >@@ -12,9 +12,11 @@ > DataBuffer.o HTTPHeader.o NaughtyFilter.o RegExp.o Socket.o \ > FatController.o UDSocket.o SysV.o ListContainer.o Ident.o \ > HTMLTemplate.o LanguageContainer.o DynamicURLList.o ImageContainer.o \ >+ VirusScanner.o perlxsi.o \ > FOptionContainer.o ListManager.o md5.o > > LIBS = /usr/lib/libz.a >+LIBS += -lclamav > PROG = dansguardian > INSTALLFILES = dansguardian dansguardian.conf dansguardian.sysv \ > bannedphraselist exceptionsitelist dansguardian.pl \ >@@ -27,9 +29,14 @@ > > PASSVARS = -DPROXYUSER=\"${PROXYUSER}\" > #PASSVARS += -DLOGLOCATION=\"${LOGLOCATION}access.log\" >+PASSVARS += -DCONFFILEDIR=\"${CONFFILELOCATION}\" > PASSVARS += -DCONFFILELOCATION=\"${CONFFILELOCATION}dansguardian.conf\" > #PASSVARS += -DPIDDIR=\"${PIDDIR}\" > >+PERLCC = `perl -MExtUtils::Embed -e ccopts` >+PERLLD = `perl -MExtUtils::Embed -e ldopts` >+PERL = $(PERLCC) $(PERLLD) >+ > #Some advanced options: > WARNING = -Wall > OPTIMISE = -O2 >@@ -40,11 +47,14 @@ > CFLAGS = $(OPTIMISE) $(WARNING) > DGCFLAGS = $(OPTIMISE) $(PASSVARS) -lz $(STATIC) > >+.c.o: >+ $(CPP) $(DEBUG) $(CFLAGS) $(PERLCC) -c $< >+ > .cpp.o: >- $(CPP) $(DEBUG) $(CFLAGS) -c $< >+ $(CPP) $(DEBUG) $(CFLAGS) $(PERLCC) -c $< > > all: $(OBJ) >- $(CPP) -o dansguardian $(DGCFLAGS) $(DEBUG) $(OBJ) $(LIBS) dansguardian.cpp >+ $(CPP) -o dansguardian $(DGCFLAGS) $(DEBUG) $(OBJ) $(LIBS) $(PERL) dansguardian.cpp > > install: > @test -d $I$(SYSVLOCATION) || install -d $I$(SYSVLOCATION) >@@ -78,6 +88,11 @@ > cp -f ./exceptionurllist $I$(CONFFILELOCATION)exceptionurllist > cp -f ./exceptionuserlist $I$(CONFFILELOCATION)exceptionuserlist > cp -f ./exceptioniplist $I$(CONFFILELOCATION)exceptioniplist >+ cp -f ./exceptionvirusmimetypelist $I$(CONFFILELOCATION)exceptionvirusmimetypelist >+ cp -f ./exceptionvirusextensionlist $I$(CONFFILELOCATION)exceptionvirusextensionlist >+ cp -f ./virusscanner.pl $I$(CONFFILELOCATION)virusscanner.pl >+ cp -f ./virusscanner.conf $I$(CONFFILELOCATION)virusscanner.conf >+ cp -f ./config.pl $I$(CONFFILELOCATION)config.pl > cp -f ./pics $I$(CONFFILELOCATION)pics > cp -f ./transparent1x1.gif $I$(CONFFILELOCATION)transparent1x1.gif > cp -f ./logrotation $I$(CONFFILELOCATION)logrotation >diff -urN DansGuardian-2.7.7-2/autoconf/nbsd.in antivirus/DansGuardian-2.7.7-2-AntiVirus-5.0/autoconf/nbsd.in >--- DansGuardian-2.7.7-2/autoconf/nbsd.in 2004-02-18 11:05:15.000000000 -0300 >+++ antivirus/DansGuardian-2.7.7-2-AntiVirus-5.0/autoconf/nbsd.in 2004-02-19 00:57:34.000000000 -0300 >@@ -8,8 +8,10 @@ > DataBuffer.o HTTPHeader.o NaughtyFilter.o RegExp.o Socket.o \ > FatController.o UDSocket.o SysV.o ListContainer.o Ident.o \ > HTMLTemplate.o LanguageContainer.o DynamicURLList.o ImageContainer.o \ >+ VirusScanner.o perlxsi.o \ > FOptionContainer.o ListManager.o md5.o > LIBS = /usr/lib/libz.a >+LIBS += -lclamav > PROG = dansguardian > INSTALLFILES = dansguardian dansguardian.conf dansguardian.sysv \ > bannedphraselist exceptionsitelist dansguardian.pl \ >@@ -22,9 +24,14 @@ > > PASSVARS = -DPROXYUSER=\"${PROXYUSER}\" > #PASSVARS += -DLOGLOCATION=\"${LOGLOCATION}access.log\" >+PASSVARS += -DCONFFILEDIR=\"${CONFFILELOCATION}\" > PASSVARS += -DCONFFILELOCATION=\"${CONFFILELOCATION}dansguardian.conf\" > #PASSVARS += -DPIDDIR=\"${PIDDIR}\" > >+PERLCC = `perl -MExtUtils::Embed -e ccopts` >+PERLLD = `perl -MExtUtils::Embed -e ldopts` >+PERL = $(PERLCC) $(PERLLD) >+ > #Some advanced options: > WARNING = -Wall > OPTIMISE = -O2 >@@ -35,6 +42,9 @@ > CFLAGS = $(OPTIMISE) $(WARNING) > DGCFLAGS = $(OPTIMISE) $(PASSVARS) -lz $(STATIC) > >+.c.o: >+ $(CPP) $(DEBUG) $(CFLAGS) $(PERLCC) -c $< >+ > .cpp.o: > $(CPP) $(DEBUG) $(CFLAGS) -c $< > >@@ -73,6 +83,11 @@ > cp -f ./exceptionurllist $I$(CONFFILELOCATION)exceptionurllist > cp -f ./exceptionuserlist $I$(CONFFILELOCATION)exceptionuserlist > cp -f ./exceptioniplist $I$(CONFFILELOCATION)exceptioniplist >+ cp -f ./exceptionvirusmimetypelist $I$(CONFFILELOCATION)exceptionvirusmimetypelist >+ cp -f ./exceptionvirusextensionlist $I$(CONFFILELOCATION)exceptionvirusextensionlist >+ cp -f ./virusscanner.pl $I$(CONFFILELOCATION)virusscanner.pl >+ cp -f ./virusscanner.conf $I$(CONFFILELOCATION)virusscanner.conf >+ cp -f ./config.pl $I$(CONFFILELOCATION)config.pl > cp -f ./pics $I$(CONFFILELOCATION)pics > cp -f ./transparent1x1.gif $I$(CONFFILELOCATION)transparent1x1.gif > cp -f ./logrotation $I$(CONFFILELOCATION)logrotation >diff -urN DansGuardian-2.7.7-2/autoconf/obsd.in antivirus/DansGuardian-2.7.7-2-AntiVirus-5.0/autoconf/obsd.in >--- DansGuardian-2.7.7-2/autoconf/obsd.in 2004-02-18 11:05:15.000000000 -0300 >+++ antivirus/DansGuardian-2.7.7-2-AntiVirus-5.0/autoconf/obsd.in 2004-02-19 00:55:49.000000000 -0300 >@@ -8,8 +8,10 @@ > DataBuffer.o HTTPHeader.o NaughtyFilter.o RegExp.o Socket.o \ > FatController.o UDSocket.o SysV.o ListContainer.o Ident.o \ > HTMLTemplate.o LanguageContainer.o DynamicURLList.o ImageContainer.o \ >+ VirusScanner.o perlxsi.o \ > FOptionContainer.o ListManager.o md5.o > LIBS = /usr/lib/libz.a >+LIBS += -lclamav > PROG = dansguardian > INSTALLFILES = dansguardian dansguardian.conf dansguardian.sysv \ > bannedphraselist exceptionsitelist dansguardian.pl \ >@@ -22,9 +24,14 @@ > > PASSVARS = -DPROXYUSER=\"${PROXYUSER}\" > #PASSVARS += -DLOGLOCATION=\"${LOGLOCATION}access.log\" >+PASSVARS += -DCONFFILEDIR=\"${CONFFILELOCATION}\" > PASSVARS += -DCONFFILELOCATION=\"${CONFFILELOCATION}dansguardian.conf\" > #PASSVARS += -DPIDDIR=\"${PIDDIR}\" > >+PERLCC = `perl -MExtUtils::Embed -e ccopts` >+PERLLD = `perl -MExtUtils::Embed -e ldopts` >+PERL = $(PERLCC) $(PERLLD) >+ > #Some advanced options: > WARNING = -Wall > OPTIMISE = -O2 >@@ -37,6 +44,9 @@ > > .SUFFIXES: .cpp > >+.c.o: >+ $(CPP) $(DEBUG) $(CFLAGS) $(PERLCC) -c $< >+ > .cpp.o: > $(CPP) $(DEBUG) $(CFLAGS) -c $< > >@@ -75,6 +85,11 @@ > cp -f ./exceptionurllist $I$(CONFFILELOCATION)exceptionurllist > cp -f ./exceptionuserlist $I$(CONFFILELOCATION)exceptionuserlist > cp -f ./exceptioniplist $I$(CONFFILELOCATION)exceptioniplist >+ cp -f ./exceptionvirusmimetypelist $I$(CONFFILELOCATION)exceptionvirusmimetypelist >+ cp -f ./exceptionvirusextensionlist $I$(CONFFILELOCATION)exceptionvirusmimetypelist >+ cp -f ./virusscanner.pl $I$(CONFFILELOCATION)virusscanner.pl >+ cp -f ./virusscanner.conf $I$(CONFFILELOCATION)virusscanner.conf >+ cp -f ./config.pl $I$(CONFFILELOCATION)config.pl > cp -f ./pics $I$(CONFFILELOCATION)pics > cp -f ./transparent1x1.gif $I$(CONFFILELOCATION)transparent1x1.gif > cp -f ./logrotation $I$(CONFFILELOCATION)logrotation >diff -urN DansGuardian-2.7.7-2/autoconf/osx.in antivirus/DansGuardian-2.7.7-2-AntiVirus-5.0/autoconf/osx.in >--- DansGuardian-2.7.7-2/autoconf/osx.in 2004-02-18 11:05:15.000000000 -0300 >+++ antivirus/DansGuardian-2.7.7-2-AntiVirus-5.0/autoconf/osx.in 2004-02-19 00:57:52.000000000 -0300 >@@ -8,8 +8,10 @@ > DataBuffer.o HTTPHeader.o NaughtyFilter.o RegExp.o Socket.o \ > FatController.o UDSocket.o SysV.o ListContainer.o Ident.o \ > HTMLTemplate.o LanguageContainer.o DynamicURLList.o ImageContainer.o \ >+ VirusScanner.o perlxsi.o \ > FOptionContainer.o ListManager.o md5.o > LIBS = /usr/lib/libgcc.a >+LIBS += -lclamav > PROG = dansguardian > INSTALLFILES = dansguardian dansguardian.conf dansguardian.sysv \ > bannedphraselist exceptionsitelist dansguardian.pl \ >@@ -22,9 +24,14 @@ > > PASSVARS = -DPROXYUSER=\"${PROXYUSER}\" > #PASSVARS += -DLOGLOCATION=\"${LOGLOCATION}access.log\" >+PASSVARS += -DCONFFILEDIR=\"${CONFFILELOCATION}\" > PASSVARS += -DCONFFILELOCATION=\"${CONFFILELOCATION}dansguardian.conf\" > #PASSVARS += -DPIDDIR=\"${PIDDIR}\" > >+PERLCC = `perl -MExtUtils::Embed -e ccopts` >+PERLLD = `perl -MExtUtils::Embed -e ldopts` >+PERL = $(PERLCC) $(PERLLD) >+ > #Some advanced options: > WARNING = -Wall > OPTIMISE = -O2 >@@ -35,6 +42,9 @@ > CFLAGS = $(OPTIMISE) $(WARNING) > DGCFLAGS = $(OPTIMISE) $(PASSVARS) -lz $(STATIC) > >+.c.o: >+ $(CPP) $(DEBUG) $(CFLAGS) $(PERLCC) -c $< >+ > .cpp.o: > $(CPP) $(DEBUG) $(CFLAGS) -c $< > >@@ -73,6 +83,11 @@ > cp -f ./exceptionurllist $I$(CONFFILELOCATION)exceptionurllist > cp -f ./exceptionuserlist $I$(CONFFILELOCATION)exceptionuserlist > cp -f ./exceptioniplist $I$(CONFFILELOCATION)exceptioniplist >+ cp -f ./exceptionvirusmimetypelist $I$(CONFFILELOCATION)exceptionvirusmimetypelist >+ cp -f ./exceptionvirusextensionlist $I$(CONFFILELOCATION)exceptionvirusextensionlist >+ cp -f ./virusscanner.pl $I$(CONFFILELOCATION)virusscanner.pl >+ cp -f ./virusscanner.conf $I$(CONFFILELOCATION)virusscanner.conf >+ cp -f ./config.pl $I$(CONFFILELOCATION)config.pl > cp -f ./pics $I$(CONFFILELOCATION)pics > cp -f ./transparent1x1.gif $I$(CONFFILELOCATION)transparent1x1.gif > cp -f ./logrotation $I$(CONFFILELOCATION)logrotation >diff -urN DansGuardian-2.7.7-2/autoconf/solaris.in antivirus/DansGuardian-2.7.7-2-AntiVirus-5.0/autoconf/solaris.in >--- DansGuardian-2.7.7-2/autoconf/solaris.in 2004-02-18 11:05:15.000000000 -0300 >+++ antivirus/DansGuardian-2.7.7-2-AntiVirus-5.0/autoconf/solaris.in 2004-02-19 00:58:07.000000000 -0300 >@@ -8,8 +8,10 @@ > DataBuffer.o HTTPHeader.o NaughtyFilter.o RegExp.o Socket.o \ > FatController.o UDSocket.o SysV.o ListContainer.o Ident.o \ > HTMLTemplate.o LanguageContainer.o DynamicURLList.o ImageContainer.o \ >+ VirusScanner.o perlxsi.o \ > FOptionContainer.o ListManager.o md5.o > LIBS = -lstdc++ -lsocket -lnsl -lz -lresolv >+LIBS += -lclamav > PROG = dansguardian > INSTALLFILES = dansguardian dansguardian.conf dansguardian.sysv \ > bannedphraselist exceptionsitelist dansguardian.pl \ >@@ -22,9 +24,14 @@ > > PASSVARS = -DPROXYUSER=\"${PROXYUSER}\" > #PASSVARS += -DLOGLOCATION=\"${LOGLOCATION}access.log\" >+PASSVARS += -DCONFFILEDIR=\"${CONFFILELOCATION}\" > PASSVARS += -DCONFFILELOCATION=\"${CONFFILELOCATION}dansguardian.conf\" > #PASSVARS += -DPIDDIR=\"${PIDDIR}\" > >+PERLCC = `perl -MExtUtils::Embed -e ccopts` >+PERLLD = `perl -MExtUtils::Embed -e ldopts` >+PERL = $(PERLCC) $(PERLLD) >+ > #Some advanced options: > WARNING = -Wall > OPTIMISE = -O2 >@@ -35,6 +42,9 @@ > CFLAGS = $(OPTIMISE) $(WARNING) > DGCFLAGS = $(OPTIMISE) $(PASSVARS) $(STATIC) > >+.c.o: >+ $(CPP) $(DEBUG) $(CFLAGS) $(PERLCC) -c $< >+ > .cpp.o: > $(CPP) $(DEBUG) $(CFLAGS) -c $< > >@@ -73,6 +83,11 @@ > cp -f ./exceptionurllist $I$(CONFFILELOCATION)exceptionurllist > cp -f ./exceptionuserlist $I$(CONFFILELOCATION)exceptionuserlist > cp -f ./exceptioniplist $I$(CONFFILELOCATION)exceptioniplist >+ cp -f ./exceptionvirusmimetypelist $I$(CONFFILELOCATION)exceptionvirusmimetypelist >+ cp -f ./exceptionvirusextensionlist $I$(CONFFILELOCATION)exceptionvirusextensionlist >+ cp -f ./virusscanner.pl $I$(CONFFILELOCATION)virusscanner.pl >+ cp -f ./virusscanner.conf $I$(CONFFILELOCATION)virusscanner.conf >+ cp -f ./config.pl $I$(CONFFILELOCATION)config.pl > cp -f ./pics $I$(CONFFILELOCATION)pics > cp -f ./transparent1x1.gif $I$(CONFFILELOCATION)transparent1x1.gif > cp -f ./logrotation $I$(CONFFILELOCATION)logrotation >diff -urN DansGuardian-2.7.7-2/config.pl antivirus/DansGuardian-2.7.7-2-AntiVirus-5.0/config.pl >--- DansGuardian-2.7.7-2/config.pl 1969-12-31 21:00:00.000000000 -0300 >+++ antivirus/DansGuardian-2.7.7-2-AntiVirus-5.0/config.pl 2004-02-19 01:12:27.000000000 -0300 >@@ -0,0 +1,169 @@ >+# MailScanner - SMTP E-Mail Virus Scanner >+# Copyright (C) 2002 Julian Field >+# >+# This program is free software; you can redistribute it and/or modify >+# it under the terms of the GNU General Public License as published by >+# the Free Software Foundation; either version 2 of the License, or >+# (at your option) any later version. >+# >+# This program is distributed in the hope that it will be useful, >+# but WITHOUT ANY WARRANTY; without even the implied warranty of >+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >+# GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License >+# along with this program; if not, write to the Free Software >+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA >+# >+# The author, Julian Field, can be contacted by email at >+# Jules@JulianField.net >+# or by paper mail at >+# Julian Field >+# Dept of Electronics & Computer Science >+# University of Southampton >+# Southampton >+# SO17 1BJ >+# United Kingdom >+# >+ >+# 07/23/2002 >+# James A. Pattie (james@pcxperience.com) - updated to only have the >+# options needed for virus scanning configuration. >+ >+# Read the configuration file and set globals accordingly. >+ >+use strict; >+package Config; >+ >+my $prefix = '/etc/dansguardian'; >+ >+# Default values >+$Config::Debugging = 0; >+$Config::PidFile = "/var/run/virus.pid"; >+$Config::DefaultConfig = "$prefix/virusscanner.conf"; >+$Config::LocalPostmaster = 'postmaster'; >+$Config::LockType = ''; >+$Config::SweepTimeout = 300; >+$Config::LockDir = '/tmp'; >+$Config::SyslogFacility = 'user'; >+$Config::MailDomain = 'your.domain.com'; >+$Config::MailServer = '127.0.0.1'; >+$Config::MailType = 'text/plain'; >+$Config::DownloadDir = '/tmp/dgvirus'; >+$Config::StatusGroupedBy = 'uname'; >+ >+sub ReadConfig { >+ my($Config) = @_; >+ my($key, $value, $whole); >+ local(*CONF); >+ >+ $Config = $Config::DefaultConfig unless defined $Config; >+ >+ open(CONF, $Config) >+ or Log::DieLog("Could not open config file $Config, %s", $!); >+ while(<CONF>) { >+ chomp; >+ s/#.*$//; # Trim comments >+ s/^\s*//g; # Trim leading space >+ # Extract everything after the =\s* for inline signatures >+ /^[^=]*=\s*(.*)$/; >+ $whole = $1; >+ s/\s*$//g; # Trim trailing space >+ next if /^$/; # Ignore comments >+ >+# This was >+# ($key, $value) = split(/\s*=\s*/, $_, 2); >+# The following should be equivalent but with untainting >+# (we trust the admin to put sensible things in the config file). >+# -- nwp, 14/01/02 >+ /^(.*?)\s*=\s*(.*)$/; >+ ($key,$value) = ($1,$2); >+ >+ $key = lc($key); >+ $key =~ s/[^a-z]//g; # Delete everything except letters >+ $Config::PidFile = $value if $key =~ /^pid/; >+ $Config::Sweep = $value if $key =~ /^sweep/; >+ $Config::LocalPostmaster = $value if $key =~ /^localpostmaster/; >+ $Config::Debugging = $value if $key =~ /^debug/; >+ $Config::VirusScanner = lc($value) if $key =~ /^virusscanner$/i; >+ $Config::LockType = lc($value) if $key =~ /^locktype/i; >+ $Config::SweepTimeout = $value if $key =~ /^virusscannertimeout/i; >+ $Config::CodeStatus = $value if $key =~ /^minimumcodestatus/i; >+ $Config::LockDir = $value if $key =~ /^lockfiledir/i; >+ $Config::SyslogFacility = $value if $key =~ /^logfacility$/i; >+ $Config::MailDomain = $value if $key =~ /^maildomain$/i; >+ $Config::MailServer = $value if $key =~ /^mailserver$/i; >+ $Config::MailType = $value if $key =~ /^mailtype$/i; >+ $Config::DownloadDir = $value if $key =~ /^downloaddir$/i; >+ $Config::StatusGroupedBy = $value if $key =~ /^statusinfogroupedby$/i; >+ >+ } >+ close CONF; >+ >+# # Start logging here so we can set the log facility first >+# Log::Start($Config::MailScannerProcessName, $Config::SyslogFacility); >+# Log::InfoLog("Virus Scanner $Config::DGVirusVersion in DansGuardian $Config::DGVersion from MailScanner $Config::MailScannerVersion starting."); >+ >+ # make sure we have a valid MailType >+ Log::DieLog("MailType = '$Config::MailType' is invalid! Needs to be 'text/plain' or 'text/html'.") if ($Config::MailType !~ /^(text\/(plain|html))$/); >+ >+ # make sure we have a valid MailDomain value >+ Log::DieLog("MailDomain = '$Config::MailDomain' is invalid! You need to specify your own mail domain!") if ($Config::MailDomain eq "your.domain.com"); >+ >+ # make sure we have a valid StatusGroupedBy value >+ Log::DieLog("Status Info Grouped By = '$Config::StatusGroupedBy' is invalid! Needs to be 'uname' or 'ip'.") if ($Config::StatusGroupedBy !~ /^(uname|ip)$/); >+ >+ # Remove any trailing slashes from the directory names, they will cause >+ # trouble later if left in. >+ $Config::LockDir =~ s/\/$//; >+ $Config::DownloadDir =~ s/\/$//; >+ >+ # Check to ensure all the directories and files we need actually exist >+ DirExists($Config::LockDir); >+ >+ # Check that the script at the start of the "Sweep" command exists >+ my($command); >+ $command = (split(/[,\s]/, $Config::Sweep, 2))[0]; >+ if ($command eq "none") >+ { >+ Log::DieLog("You must specify a virus engine to work with other than none!"); >+ } >+ FileReadable($command); >+ >+} >+ >+# >+# Check a configuration file exists and is readable. >+# Produce an error if it is not. >+# >+sub FileReadable { >+ my($name) = @_; >+ return 1 unless $name; >+ return 1 if -r $name; >+ Log::DieLog("Configuration file $name could not be opened for reading!"); >+} >+ >+# Check a directory exists and is writeable. >+# Produce an error if it is not. >+# >+sub DirExists { >+ my($name) = @_; >+ return 1 unless $name; >+ return 1 if -d $name; >+ Log::DieLog("Directory $name does not exist!"); >+} >+ >+# Check two files/directories are on the same partition. >+# Produce an error if it is not. >+# Can't do this here as it breaks "require" by changing directory. >+ >+# >+# Set a Config variable to 0 or 1 depending on its current contents >+# >+sub ZeroOrOne { >+ my($current) = @_; >+ return 1 if $current =~ /yes|true|on|1/i; >+ return 0; >+} >+ >+1; >diff -urN DansGuardian-2.7.7-2/configure antivirus/DansGuardian-2.7.7-2-AntiVirus-5.0/configure >--- DansGuardian-2.7.7-2/configure 2004-02-18 11:05:15.000000000 -0300 >+++ antivirus/DansGuardian-2.7.7-2-AntiVirus-5.0/configure 2004-02-19 00:51:18.000000000 -0300 >@@ -2827,7 +2827,7 @@ > rm -f dansguardian.conf > fi > >-echo "# DansGuardian config file for version 2.7.7" >dansguardian.conf >+echo "# DansGuardian config file for version 2.7.7 (Antivirus 5.0)" >dansguardian.conf > echo "" >>dansguardian.conf > echo "# **NOTE** as of version 2.7.5 most of the list files are now in dansguardianf1.conf" >>dansguardian.conf > echo "" >>dansguardian.conf >@@ -3218,8 +3218,98 @@ > echo "# on|off ( defaults to off )" >>dansguardian.conf > echo "softrestart = off" >>dansguardian.conf > echo "" >>dansguardian.conf >+echo "" >>dansguardian.conf >+echo "" >>dansguardian.conf > >+echo "# ANTIVIRUS SETTINGS" >>dansguardian.conf >+echo "# --------------------" >>dansguardian.conf >+echo "" >>dansguardian.conf >+echo "# IMPORTANT:" >>dansguardian.conf >+echo "# Remember to also review e-mail notification options in virusscanner.conf." >>dansguardian.conf >+echo "" >>dansguardian.conf >+echo "# OPTION: virusscan" >>dansguardian.conf >+echo "# If on, we scan all downloaded content using embedded virus engine." >>dansguardian.conf >+echo "# If off, we don't scan any downloaded content." >>dansguardian.conf >+echo "# Only supported engine of this version is ClamAV." >>dansguardian.conf >+echo "# See http://www.pcxperience.org/dgvirus/ for more details." >>dansguardian.conf >+echo "#" >>dansguardian.conf >+echo "virusscan = on" >>dansguardian.conf >+echo "" >>dansguardian.conf >+ >+# Included by Aecio F. Neto (afn@harvest.com.br) - Harvest Consultoria (http://www.harvest.com.br) >+echo "# OPTION: tricklelength" >>dansguardian.conf >+echo "# If off (value = -1), the scanner will send 1 byte per delay period" >>dansguardian.conf >+echo "# to the client to keep a download connection alive." >>dansguardian.conf >+echo "# When the whole file is downloaded and scanned, the client will receive " >>dansguardian.conf >+echo "# all remaining bytes, if the file is clean." >>dansguardian.conf >+echo "# Set to a positive integer value to enable immediate delivery to the client. " >>dansguardian.conf >+echo "# Value set means minimum number of bytes of the downloaded file " >>dansguardian.conf >+echo "# that will be held and delivered after virus scan." >>dansguardian.conf >+echo "# If clean, the remaining bytes will be sent to the client." >>dansguardian.conf >+echo "# If infected, file downloaded will be incomplete and a warning message " >>dansguardian.conf >+echo "# will be sent to the postmaster and possibly the user." >>dansguardian.conf >+echo "# Recommended value: 4096 (4 kbytes)" >>dansguardian.conf >+echo "#" >>dansguardian.conf >+echo "tricklelength = -1" >>dansguardian.conf >+echo "" >>dansguardian.conf > >+echo "# OPTION: firsttrickledelay" >>dansguardian.conf >+echo "# Delay in seconds to deliver the first byte to the client." >>dansguardian.conf >+echo "# This option only applies if tricklelength is set to -1 (off)." >>dansguardian.conf >+echo "#" >>dansguardian.conf >+echo "firsttrickledelay = 30" >>dansguardian.conf >+echo "" >>dansguardian.conf >+echo "" >>dansguardian.conf >+echo "# OPTION: follwingtrickledelay" >>dansguardian.conf >+echo "# Delay in seconds to deliver subsequent bytes to the client." >>dansguardian.conf >+echo "# This option only applies if tricklelength is set to -1 (off)." >>dansguardian.conf >+echo "#" >>dansguardian.conf >+echo "followingtrickledelay = 60" >>dansguardian.conf >+echo "" >>dansguardian.conf >+echo "" >>dansguardian.conf >+ >+echo "# OPTION: virusscanexceptions" >>dansguardian.conf >+echo "# If off, antivirus scanner will ignore exception sites and urls." >>dansguardian.conf >+echo "#" >>dansguardian.conf >+echo "virusscanexceptions = on" >>dansguardian.conf >+echo "" >>dansguardian.conf >+echo "" >>dansguardian.conf >+ >+echo "# OPTION: exceptionvirusmimetypelist" >>dansguardian.conf >+echo "# The following file allow you to define mime types" >>dansguardian.conf >+echo "# that should not be virus scanned." >>dansguardian.conf >+$extendedecho "exceptionvirusmimetypelist = '$prefixdir$sysconfdir\c" >>dansguardian.conf >+echo "exceptionvirusmimetypelist'" >>dansguardian.conf >+echo "" >>dansguardian.conf >+echo "" >>dansguardian.conf >+ >+echo "# OPTION: exceptionvirusextensionlist" >>dansguardian.conf >+echo "# The following file allow you to define file extensions" >>dansguardian.conf >+echo "# that should not be virus scanned." >>dansguardian.conf >+$extendedecho "exceptionvirusextensionlist = '$prefixdir$sysconfdir\c" >>dansguardian.conf >+echo "exceptionvirusextensionlist'" >>dansguardian.conf >+echo "" >>dansguardian.conf >+echo "" >>dansguardian.conf >+ >+echo "# OPTION: urlcachecleanonly" >>dansguardian.conf >+echo "# If off, url cache will contain entries of text only urls." >>dansguardian.conf >+echo "# Keeping it off, preserves original Dansguardian feature and" >>dansguardian.conf >+echo "# downloaded content will be always scanned by antivirus." >>dansguardian.conf >+echo "# When turned on, urlcache will be loaded only with content" >>dansguardian.conf >+echo "# found to be good and that is virus free." >>dansguardian.conf >+echo "# Thus, content of urls found in urlcache WILL NOT BE SCANNED AGAIN." >>dansguardian.conf >+echo "#" >>dansguardian.conf >+echo "# USE IT AT YOUR OWN RISK." >>dansguardian.conf >+echo "#" >>dansguardian.conf >+echo "urlcachecleanonly = off" >>dansguardian.conf >+echo "" >>dansguardian.conf >+echo "" >>dansguardian.conf >+ >+echo "# OPTION: downloaddir">>dansguardian.conf >+echo "# Set where the files are downloaded to before they are scanned." >>dansguardian.conf >+echo "downloaddir = '/tmp/dgvirus'" >>dansguardian.conf >+echo "" >>dansguardian.conf >+echo "" >>dansguardian.conf > > > >diff -urN DansGuardian-2.7.7-2/dansguardian.cpp antivirus/DansGuardian-2.7.7-2-AntiVirus-5.0/dansguardian.cpp >--- DansGuardian-2.7.7-2/dansguardian.cpp 2004-02-18 11:05:15.000000000 -0300 >+++ antivirus/DansGuardian-2.7.7-2-AntiVirus-5.0/dansguardian.cpp 2004-02-23 20:33:59.000000000 -0300 >@@ -17,6 +17,8 @@ > // along with this program; if not, write to the Free Software > // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA > >+// Modified by James A. Pattie (james@pcxperience.com) Xperience, Inc. (www.pcxperience.com) >+ > #include "autoconf/platform.h" > #include <sys/types.h> > #include <sys/socket.h> >@@ -37,6 +39,8 @@ > #include "SysV.hpp" > #include <sys/time.h> > #include <sys/resource.h> >+#include <clamav.h> >+#include <cerrno> > #ifdef __BSD > #include <sys/wait.h> > #else >@@ -46,12 +50,63 @@ > #ifndef FD_SETSIZE > #define FD_SETSIZE 256 > #endif >+// Included by Aecio F. Neto (afn@harvest.com.br) - Harvest Consultoria (http://www.harvest.com.br) >+#include<EXTERN.h> >+#include<perl.h> >+#include<XSUB.h> >+#undef getpwnam >+#include<pwd.h> >+ >+EXTERN_C void xs_init(pTHX); >+ >+struct cl_node *root; >+struct cl_limits limits; >+struct cl_stat dbstat; > >+static PerlInterpreter *myPerl; /* The Perl Interpreter */ >+// End of Included by Aecio F. Neto (afn@harvest.com.br) - Harvest Consultoria (http://www.harvest.com.br) > > OptionContainer o; > > bool isDaemonised; > >+// Included by Aecio F. Neto (afn@harvest.com.br) - Harvest Consultoria (http://www.harvest.com.br) >+void loadVirusDB (int *ret) { >+ >+ int no = 0; >+ root = NULL; >+ >+ #ifdef DGDEBUG >+ system("date"); >+ std::cout << "Start ClamAV DB load." << std::endl; >+ #endif >+ if((*ret = cl_loaddbdir(cl_retdbdir(), &root, &no))) >+ syslog(LOG_ERR, "ClamAV database was not loaded. Error: %s", cl_strerror(*ret)); >+ else { >+ cl_buildtrie(root); >+ syslog(LOG_INFO, "ClamAV database loaded: %i", no); >+ } >+/* >+ else { >+ if ((*ret = cl_buildtrie(root)) != 0 ) { >+ syslog(LOG_ERR, "ClamAV database cannot build the trie: %s\n", cl_strerror(*ret)); >+ return 1; >+ } >+ else >+ syslog(LOG_INFO, "ClamAV database loaded: %i", no); >+ } >+*/ >+ >+ cl_statfree(&dbstat); >+ cl_statinidir(cl_retdbdir(), &dbstat); >+ >+ #ifdef DGDEBUG >+ std::cout << "End of ClamAV DB load." << std::endl; >+ system("date"); >+ #endif >+} >+// End of Included by Aecio F. Neto (afn@harvest.com.br) - Harvest Consultoria (http://www.harvest.com.br) >+ > int main(int argc, char* argv[]) { > isDaemonised = false; > bool nodaemon = false; >@@ -63,6 +118,8 @@ > } > > SysV sysv; >+ >+ int ret; > > int rc = open(configfile.c_str(), 0, O_RDONLY); > if (rc < 0) { >@@ -82,6 +139,7 @@ > if ((argc > 1) && (*argv[1] == '-')) { > switch (argv[1][1]) { > case 'P': >+ std::cout << "AntiVirus Plugin 5.0" << std::endl; > return 0; > case 'q': > return sysv.kill(o.pid_filename); >@@ -213,6 +271,54 @@ > logfiletest.close(); > } > >+ // setup the perl environment so that we have access to the >+ // virus scanning routines ported over from MailScanner. >+ >+ char *args[] = { NULL }; >+ if (o.virus_scan) { >+ memset(&dbstat, 0, sizeof(struct cl_stat)); >+ loadVirusDB(&ret); >+ if (ret != 0) { >+ std::cerr << "Error loading ClamAV DB: " << cl_perror(ret) << std::endl; >+ return ret; >+ } >+ >+ #ifdef DGDEBUG >+ std::cout << "Creating temporary folder for content virus scanning." << std::endl; >+ #endif >+ if (mkdir(o.download_dir.c_str(), S_IRWXU) == -1) >+ if (errno != EEXIST) { >+ std::cerr << std::endl << "Error creating temporary folder. " << std::endl; >+ return 1; >+ } >+ >+ myPerl = perl_alloc(); >+ perl_construct(myPerl); >+ >+ // point to the main perl program that does all our work for us (provides methods and pulls in >+ // the needed modules, etc.) >+ >+ char* tmpString; >+ tmpString = new char[strlen(CONFFILEDIR)+strlen("virusscanner.pl")+1]; >+ strcpy(tmpString, CONFFILEDIR); >+ strcat(tmpString, "virusscanner.pl"); >+ argv[1] = tmpString; >+ >+ argc = 2; >+ perl_parse(myPerl, xs_init, argc, argv, (char **)NULL); >+ delete[] tmpString; // can now get rid of the temp string. >+ >+ // uncomment if using perl 5.8.0 or later. Will not work on 5.6.1. >+ // PL_exit_flags |= PERL_EXIT_DESTRUCT_END; >+ >+ #ifdef DGDEBUG >+ std::cout << "Setting up perl program." << std::endl; >+ #endif >+ // setup the virusscanner >+ perl_call_argv("setup", G_DISCARD | G_NOARGS, args); >+ >+ } >+ > > FatController f; // Thomas The Tank Engine > >@@ -268,6 +374,15 @@ > #ifdef DGDEBUG > std::cout << "conf file read." << std::endl; > #endif >+ if (o.virus_scan) { >+ if (cl_statchkdir(&dbstat) == 1) { >+ cl_freetrie(root); >+ loadVirusDB(&ret); >+ // Virus Database reload >+ if (ret != 0) >+ return ret; >+ } >+ } > > if (nodaemon) { > o.no_daemon = 1; >@@ -291,6 +406,15 @@ > continue; > } > >+ if (o.virus_scan) >+ { >+ // cleanup the Perl Interperter. >+ perl_call_argv("shutdown", G_DISCARD | G_NOARGS, args); >+ >+ perl_destruct(myPerl); >+ perl_free(myPerl); >+ } >+ > if (rc > 0) { > if (!isDaemonised) { > std::cerr << "Exiting with error" << std::endl; >diff -urN DansGuardian-2.7.7-2/dansguardian.hpp antivirus/DansGuardian-2.7.7-2-AntiVirus-5.0/dansguardian.hpp >--- DansGuardian-2.7.7-2/dansguardian.hpp 2004-02-18 11:05:15.000000000 -0300 >+++ antivirus/DansGuardian-2.7.7-2-AntiVirus-5.0/dansguardian.hpp 2004-02-19 00:45:08.000000000 -0300 >@@ -26,4 +26,5 @@ > public: > int main(int argc, char* argv[]); > bool loop(); >+ int loadVirusDB(int *ret); > }; >diff -urN DansGuardian-2.7.7-2/exceptionvirusextensionlist antivirus/DansGuardian-2.7.7-2-AntiVirus-5.0/exceptionvirusextensionlist >--- DansGuardian-2.7.7-2/exceptionvirusextensionlist 1969-12-31 21:00:00.000000000 -0300 >+++ antivirus/DansGuardian-2.7.7-2-AntiVirus-5.0/exceptionvirusextensionlist 2004-02-19 00:45:08.000000000 -0300 >@@ -0,0 +1,29 @@ >+#Exception Virus extension list >+# The Virus scanning code will ignore files with these extensions. >+ >+# File extensions with executable code >+ >+ >+# Files which one normally things as non-executable but >+# can contain harmful macros and viruses >+ >+ >+# Other files which may contain files with executable code >+ >+ >+# Time/bandwidth wasting files >+ >+.mp3 # Music file >+.mpeg # Movie file >+.mpg # Movie file >+.avi # Movie file >+.ra # Real Audio >+.ram # " >+.rm # " >+ >+# Image files not to scan >+.gif >+.jpg >+.jpeg >+.png >+.ico >diff -urN DansGuardian-2.7.7-2/exceptionvirusmimetypelist antivirus/DansGuardian-2.7.7-2-AntiVirus-5.0/exceptionvirusmimetypelist >--- DansGuardian-2.7.7-2/exceptionvirusmimetypelist 1969-12-31 21:00:00.000000000 -0300 >+++ antivirus/DansGuardian-2.7.7-2-AntiVirus-5.0/exceptionvirusmimetypelist 2004-02-19 00:45:08.000000000 -0300 >@@ -0,0 +1,21 @@ >+# MIME types the virus scanning code ignores. >+ >+audio/mpeg >+audio/x-mpeg >+audio/x-pn-realaudio >+audio/x-wav >+audio/x-realaudio >+audio/x-pn-realaudio >+audio/vnd.rn-realaudio >+video/mpeg >+video/x-mpeg2 >+video/acorn-replay >+video/quicktime >+video/x-msvideo >+video/msvideo >+video/vnd.rn-realvideo >+ >+image/png >+image/gif >+image/jpeg >+image/tiff >diff -urN DansGuardian-2.7.7-2/logger.pl antivirus/DansGuardian-2.7.7-2-AntiVirus-5.0/logger.pl >--- DansGuardian-2.7.7-2/logger.pl 1969-12-31 21:00:00.000000000 -0300 >+++ antivirus/DansGuardian-2.7.7-2-AntiVirus-5.0/logger.pl 2004-02-19 00:45:08.000000000 -0300 >@@ -0,0 +1,89 @@ >+# MailScanner - SMTP E-Mail Virus Scanner >+# Copyright (C) 2002 Julian Field >+# >+# $Id: logger.pl,v 1.1 2002/12/02 21:18:32 james Exp $ >+# >+# This program is free software; you can redistribute it and/or modify >+# it under the terms of the GNU General Public License as published by >+# the Free Software Foundation; either version 2 of the License, or >+# (at your option) any later version. >+# >+# This program is distributed in the hope that it will be useful, >+# but WITHOUT ANY WARRANTY; without even the implied warranty of >+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >+# GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License >+# along with this program; if not, write to the Free Software >+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA >+# >+# The author, Julian Field, can be contacted by email at >+# Jules@JulianField.net >+# or by paper mail at >+# Julian Field >+# Dept of Electronics & Computer Science >+# University of Southampton >+# Southampton >+# SO17 1BJ >+# United Kingdom >+# >+ >+# 07/23/2002 >+# James A. Pattie (james@pcxperience.com) - Updated to work in >+# the DansGuardian project. >+ >+########################################################### >+# Syslog library calls >+########################################################### >+ >+use strict; >+use Sys::Syslog; >+ >+package Log; >+ >+sub Start { >+ my($name, $facility) = @_; >+ # Do this in an eval so it can fail quietly if setlogsock >+ # is not supported in the installed version of Sys::Syslog >+ eval { Sys::Syslog::setlogsock('unix'); }; # Doesn't need syslogd -r >+ Sys::Syslog::openlog($name, 'pid, nowait', $facility); >+} >+ >+sub Stop { >+ Sys::Syslog::closelog(); >+} >+ >+sub DieLog { >+ # Bug fix here thanks to Nick Phillips >+ # (closelog changes $! in @_) >+ my(@x) = @_; >+ >+ my $logmessage = sprintf shift @x, @x; >+ >+ foreach(split /\n/,$logmessage) { >+ Sys::Syslog::syslog('err', $_); >+ } >+ >+ Sys::Syslog::closelog(); >+ die $logmessage; >+} >+ >+sub WarnLog { >+ my(@x) = @_; >+ Sys::Syslog::syslog('warning', @_); >+ #warn sprintf shift @x, @x; >+} >+ >+sub InfoLog { >+ my(@x) = @_; >+ Sys::Syslog::syslog('info', @_); >+ #print "@x\n"; >+} >+ >+sub DebugLog { >+ my(@x) = @_; >+ Sys::Syslog::syslog('debug', @_) if $Config::Debugging; >+ #print "@x\n"; >+} >+ >+1; >diff -urN DansGuardian-2.7.7-2/perlxsi.c antivirus/DansGuardian-2.7.7-2-AntiVirus-5.0/perlxsi.c >--- DansGuardian-2.7.7-2/perlxsi.c 1969-12-31 21:00:00.000000000 -0300 >+++ antivirus/DansGuardian-2.7.7-2-AntiVirus-5.0/perlxsi.c 2004-02-19 00:45:08.000000000 -0300 >@@ -0,0 +1,16 @@ >+#include <EXTERN.h> >+#include <perl.h> >+ >+EXTERN_C void xs_init (pTHX); >+ >+EXTERN_C void boot_DynaLoader (pTHX_ CV* cv); >+ >+EXTERN_C void >+xs_init(pTHX) >+{ >+ char *file = __FILE__; >+ dXSUB_SYS; >+ >+ /* DynaLoader is a special case */ >+ newXS("DynaLoader::boot_DynaLoader", boot_DynaLoader, file); >+} >diff -urN DansGuardian-2.7.7-2/virusscanner.conf antivirus/DansGuardian-2.7.7-2-AntiVirus-5.0/virusscanner.conf >--- DansGuardian-2.7.7-2/virusscanner.conf 1969-12-31 21:00:00.000000000 -0300 >+++ antivirus/DansGuardian-2.7.7-2-AntiVirus-5.0/virusscanner.conf 2004-02-19 00:45:08.000000000 -0300 >@@ -0,0 +1,29 @@ >+# Configuration file for MailScanner E-Mail Virus Scanner in DansGuardian >+# This file assumes everything is in the default locations provided >+# by the MailScanner and RedHat 6.2 and upwards. >+# >+# Note: If your directories are symlinked (soft-linked) in any way, >+# please put their *real* location in here, not a path that >+# includes any links. You may get some very strange error >+# messages from some of the virus scanners if you don't. >+ >+# Set email address of who to notify about any infections found. >+# Should put your full domain name here too, >+# e.g. postmaster@your.domain.com >+Local Postmaster = postmaster >+ >+# Set email domain to use when notifying users of an infected file. >+# This is just the domain name part, after the @ >+# e.g. your.domain.com >+Mail Domain = your.domain.com >+ >+# Set the address of the Mail Server to send notifications through. >+# e.g. mail.xyz.com >+Mail Server = 127.0.0.1 >+ >+# Specify the type of notification email you want to get. >+# text or html (text/plain or text/html) >+Mail Type = text/plain >+ >+# Infected files will be deleted by default in this version. >+# Sorry... >diff -urN DansGuardian-2.7.7-2/virusscanner.pl antivirus/DansGuardian-2.7.7-2-AntiVirus-5.0/virusscanner.pl >--- DansGuardian-2.7.7-2/virusscanner.pl 1969-12-31 21:00:00.000000000 -0300 >+++ antivirus/DansGuardian-2.7.7-2-AntiVirus-5.0/virusscanner.pl 2004-02-19 00:45:08.000000000 -0300 >@@ -0,0 +1,227 @@ >+#!/usr/bin/perl >+# >+# MailScanner - SMTP E-Mail Virus Scanner >+# Copyright (C) 2002 Julian Field >+# >+# $Id: virusscanner,v 1.9 2003/04/04 20:19:35 james Exp $ >+# >+# This program is free software; you can redistribute it and/or modify >+# it under the terms of the GNU General Public License as published by >+# the Free Software Foundation; either version 2 of the License, or >+# (at your option) any later version. >+# >+# This program is distributed in the hope that it will be useful, >+# but WITHOUT ANY WARRANTY; without even the implied warranty of >+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >+# GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License >+# along with this program; if not, write to the Free Software >+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA >+# >+# The author, Julian Field, can be contacted by email at >+# Jules@JulianField.net >+# or by paper mail at >+# Julian Field >+# Dept of Electronics & Computer Science >+# University of Southampton >+# Southampton >+# SO17 1BJ >+# United Kingdom >+# >+ >+# 07/23/2002 >+# James A. Pattie (james@pcxperience.com) - updated to be the starting >+# point for DansGuardian. >+ >+# 12/09/2003 >+# Aecio F. Neto (afn@harvest.com.br) - stripped code to provide e-mail delivery >+# updated to be the starting >+ >+# Main program.... >+ >+use strict; >+use POSIX; >+use Mail::Sender; >+use Fcntl qw(:DEFAULT :flock); >+require 5.005; >+ >+my $autoinstalled=0; >+ >+sub setup >+{ >+ # To detect whether we've been auto-configured & installed >+ # -- $autoinstalled will be set to 1 if so. >+ #@@$autoinstalled=1; >+ >+ # Needed for Sys::Syslog, as Debian Potato (at least) doesn't >+ # appear to have "gethostname" syscall as used (indirectly) by Sys::Syslog >+ # So it uses `hostname` instead, which it can't do if PATH is tainted. >+ # It's good to have this anyway, although we may need to modify it for >+ # other OS when we find that something we need isn't here -- nwp 14/01/02 >+ $ENV{PATH}="/sbin:/bin:/usr/sbin:/usr/bin"; >+ >+ # We *really* should clear *all* environment bar what we *know* we >+ # need here. It will avoid surprises (like bash running BASH_ENV or >+ # SpamAssassin using $ENV{HOME} rather than getpwnam to decide where >+ # to drop its load. >+ >+ # Needed for -T: >+ delete $ENV{'BASH_ENV'}; # Don't run things on bash startup >+ >+ my($dir); >+ $dir = $0; >+ $dir =~ m#^(.*)/([^/]+)$#; >+ $dir = $1; >+ >+ # Add my directory onto the front of the include path >+ unless ($autoinstalled) { >+ unshift @INC, $dir; >+ } >+ >+ require 'config.pl'; >+ require 'logger.pl'; >+ >+ # Specify config file location on command line if you like >+ $Config::ConfigFile = $ARGV[0] if defined $ARGV[0]; >+ >+ Config::ReadConfig($Config::ConfigFile); >+} >+ >+sub notify >+{ >+ my ($virusName, $Bytes, $url, $user, $userIP, $DownloadDir, $fileName) = @_; >+ >+ # Changed by Aecio F. Neto (afn@harvest.com.br) - Harvest Consultoria (http://www.harvest.com.br) >+ # Start... >+ my $username = ""; >+ my $userdir = ""; >+ >+ if ($user eq "-") # fixup the username if none was specified. >+ { >+ $user = "no-user"; >+ $userdir = "no-user"; >+ } >+ else >+ { >+ ($username = $user) =~ s/^((.+)(\\))?(.+)$/$2/; >+ ($userdir = $user) =~ s/^((.+)(\\))?(.+)$/$2$4/; >+ } >+ # ...end >+ >+ my $dateString = `/bin/date +%Y%m%d`; >+ chomp $dateString; >+ >+ (my $urlDir = $url) =~ s/(&)/\&/g; # make sure any &'s are properly escaped so the shell doesn't try anything funny. >+ >+ my $fromUser = "DansGuardian Anti-Virus <dgvirus\@$Config::MailDomain>"; >+ my $subject = "Virus Found by DansGuardian Anti-Virus"; >+ my $ourURL = "http://www.pcxperience.org/dgvirus/"; >+ my $seperatorString = ($Config::MailType eq "text/html" ? "<br>\n" : "\n"); >+ my $infoString = $seperatorString x 2 . "This message generated by DansGuardian Anti-Virus Plugin " . $Config::DGVirusVersion . ". " . ($Config::MailType eq "text/plain" ? $ourURL : "<a href=\"$ourURL\">$ourURL</a>"); >+ >+ my $message; >+ if ($Config::MailType eq "text/plain") >+ { >+ $message = "Virii" . " " x 11 . ": " . $virusName . $seperatorString; >+ $message .= "User" . " " x 12 . ": $user" . $seperatorString; >+ $message .= "URL" . " " x 13 . ": $url" . $seperatorString; >+ $message .= "Users IP" . " " x 8 . ": $userIP" . $seperatorString; >+ } >+ else >+ { >+ $message .= "<table border=\"0\">\n"; >+ $message .= " <tr>\n"; >+ $message .= " <td align=\"left\"><b>Virii</b></td><td align=\"left\">$virusName</td>\n"; >+ $message .= " </tr>\n"; >+ $message .= " <tr>\n"; >+ $message .= " <td align=\"left\"><b>User</b></td><td align=\"left\">$user</td>\n"; >+ $message .= " </tr>\n"; >+ $message .= " <tr>\n"; >+ $message .= " <td align=\"left\"><b>URL</b></td><td align=\"left\"><a href=\"$url\">$url</a></td>\n"; >+ $message .= " </tr>\n"; >+ $message .= " <tr>\n"; >+ $message .= " <td align=\"left\"><b>Deleted</b></td><td align=\"left\">Yes</td>\n"; >+ $message .= " </tr>\n"; >+ $message .= " <tr>\n"; >+ $message .= " <td align=\"left\"><b>Users IP</b></td><td align=\"left\">$userIP</td>\n"; >+ $message .= " </tr>\n"; >+ $message .= "</table>\n"; >+ } >+ $message .= $infoString; # common footer. >+ >+ # email the LocalPostmaster user >+ sendEmail(to => $Config::LocalPostmaster, from => $fromUser, subject => $subject, >+ body => $message, mailServer => $Config::MailServer, >+ ctype => $Config::MailType); >+ >+ # email the specified user >+ if ($user ne "no-user") >+ { >+ $message = "The file you were downloading from " . ($Config::MailType eq "text/plain" ? $url : "<a href=\"$url\">$url</a>") . " was found to be Infected with: $virusName"; >+ $message .= $seperatorString x 2; >+ $message .= "It was DELETED on the server and it might be partially downloaded on your computer."; >+ $message .= "This local file is not infected and it is unusable. So, please delete it."; >+ $message .= $infoString; >+ >+ sendEmail(to => "$username\@$Config::MailDomain", from => $fromUser, subject => $subject, >+ body => $message, mailServer => $Config::MailServer, >+ ctype => $Config::MailType); >+ } >+} >+ >+# takes: to, from, subject, body, mailServer, ctype as name => value pairs. >+sub sendEmail >+{ >+ my %args = ( to => "", from => "", subject => "", body => "", mailServer => "127.0.0.1", ctype => "text/plain", @_ ); >+ my $to = $args{to}; >+ my $from = $args{from}; >+ my $subject = $args{subject}; >+ my $body = $args{body}; >+ my $mailServer = $args{mailServer}; >+ my $ctype = $args{ctype}; >+ my $errorOutput = ""; >+ >+ my $sender = new Mail::Sender { smtp => "$mailServer" }; >+ if (!ref ($sender)) >+ { >+ $errorOutput .= "Error initializing e-mail connection with server via Mail::Sender Module!\n"; >+ $errorOutput .= "Error = \"" . $Mail::Sender::Error . "\"\n\n"; >+ $errorOutput .= "Note to Administrator: dansguardian-virus was sending a $ctype e-mail.\n"; >+ Log::WarnLog($errorOutput); >+ return; >+ } >+ $Mail::Sender::NO_X_MAILER = 1; # turn off the X_Mailer entry that has the info about this module. >+ if ($sender->Open( { from => "$from", to => "$to", subject => "$subject", headers => "MIME-Version: 1.0\r\nContent-type: $ctype\r\nContent-Transfer-Encoding: 7bit" }) < 0) >+ { >+ $errorOutput .= "Error opening e-mail connection with server via Mail::Sender Module!\n"; >+ $errorOutput .= "Error = \"" . $Mail::Sender::Error . "\"\n\n"; >+ $errorOutput .= "Note to Administrator: dansguardian-virus was sending a $ctype e-mail.\n"; >+ Log::WarnLog($errorOutput); >+ return; >+ } >+ if ($sender->Send($body) < 0) >+ { >+ $errorOutput .= "Error sending e-mail via Mail::Sender Module!\n"; >+ $errorOutput .= "Error = \"" . $Mail::Sender::Error . "\"\n\n"; >+ $errorOutput .= "Note to Administrator: dansguardian-virus was sending a $ctype e-mail.\n"; >+ Log::WarnLog($errorOutput); >+ return; >+ } >+ if ($sender->Close() < 0) >+ { >+ $errorOutput .= "Error sending e-mail via Mail::Sender Module!\n"; >+ $errorOutput .= "Error = \"" . $Mail::Sender::Error . "\"\n\n"; >+ $errorOutput .= "Note to Administrator: dansguardian-virus was sending a $ctype e-mail.\n"; >+ Log::WarnLog($errorOutput); >+ return; >+ } >+} >+ >+sub shutdown >+{ >+ Log::InfoLog("Virus Scanner $Config::DGVirusVersion in DansGuardian $Config::DGVersion from MailScanner $Config::MailScannerVersion stopping."); >+ >+ # Don't want to leave connections to 514/udp open... >+ Log::Stop(); >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 43362
:
26668
| 26669 |
26670
|
26673
|
28881
|
29314
|
29315
|
34629