[Mimedefang] trophie

Rudolph Pereira rudolph at usyd.edu.au
Wed Jan 1 17:08:01 EST 2003


On Fri, Dec 27, 2002 at 02:23:35PM -0500, David F. Skoll wrote:
> On Fri, 27 Dec 2002, Kenneth Irving wrote:
> 
> > I noticed that mimedefang supports sophie by default. As trophie is the
> > same tools as sophie, only that uses another library, how can I us trophie
> > with mimedefang?
> 
> Contribute code? :-)
I've attached an old patch I made for this (which worked for me),
closely based on the existing sophie support. Feel welcome to try it out,
and if it works, petition david to include it in the official mimedefang
source :) Unfortunately I don't use trophie+mimedefang right now, so
can't guarantee it will work, plus I don't have the time atm to
update it to the latest md releases and test it.
-------------- next part --------------
diff -Naur mimedefang-2.23.orig/configure.in mimedefang-2.23/configure.in
--- mimedefang-2.23.orig/configure.in	Sat Oct 19 00:08:41 2002
+++ mimedefang-2.23/configure.in	Wed Oct 23 10:52:39 2002
@@ -288,6 +288,7 @@
 AC_ARG_ENABLE(rav,      [  --disable-rav           Do not include support for Reliable AntiVirus], ac_cv_rav=$enableval, ac_cv_rav=yes)
 AC_ARG_ENABLE(fprot,    [  --disable-fprot         Do not include support for F-prot Anti-Virus], ac_cv_fprot=$enableval, ac_cv_fprot=yes)
 AC_ARG_ENABLE(sophie,   [  --disable-sophie        Do not include support for Sophie], ac_cv_sophie=$enableval, ac_cv_sophie=yes)
+AC_ARG_ENABLE(trophie,   [  --disable-trophie        Do not include support for trophie], ac_cv_trophie=$enableval, ac_cv_trophie=yes)
 AC_ARG_ENABLE(nvcc,   [  --disable-nvcc          Do not include support for Nvcc], ac_cv_nvcc=$enableval, ac_cv_nvcc=yes)
 AC_ARG_ENABLE(clamd,   [  --disable-clamd         Do not include support for clamd], ac_cv_clamd=$enableval, ac_cv_clamd=yes)
 
@@ -366,6 +367,12 @@
         SOPHIE=/bin/false
 fi
 
+if test "$ac_cv_trophie" = yes; then
+        AC_PATH_PROG(TROPHIE, trophie, /bin/false, $ANTIVIR_PATH)
+else
+        TROPHIE=/bin/false
+fi
+
 if test "$ac_cv_nvcc" = yes; then
         AC_PATH_PROG(NVCC, nvcc, /bin/false, $ANTIVIR_PATH)
 else
@@ -637,6 +644,19 @@
     GOT_VIRUS_SCANNER=1
 fi
 
+if test "$TROPHIE" = "/bin/false" ; then
+    if test "$ac_cv_trophie" != "yes" ; then
+        echo "TROPHIE   'trophie'    NO (Disabled by configure command)"
+    else
+        echo "TROPHIE   'trophie'    NO (not found)"
+    fi
+else
+    echo "TROPHIE   'trophie'    YES - $TROPHIE"
+    GOT_VIRUS_SCANNER=1
+fi
+
+
+
 if test "$NVCC" = "/bin/false" ; then
     if test "$ac_cv_nvcc" != "yes" ; then
         echo "NVCC     'nvcc'      NO (Disabled by configure command)"
@@ -676,6 +696,11 @@
 
 if test "$SOPHIE" != "/bin/false" ; then
     echo "Make sure Sophie runs as the same user that MIMEDefang does!"
+    echo ""
+fi
+
+if test "$TROPHIE" != "/bin/false" ; then
+    echo "Make sure Trophie runs as the same user that MIMEDefang does!"
     echo ""
 fi
 
diff -Naur mimedefang-2.23.orig/examples/suggested-minimum-filter-for-windows-clients mimedefang-2.23/examples/suggested-minimum-filter-for-windows-clients
--- mimedefang-2.23.orig/examples/suggested-minimum-filter-for-windows-clients	Fri Oct 18 22:02:54 2002
+++ mimedefang-2.23/examples/suggested-minimum-filter-for-windows-clients	Wed Oct 23 11:52:19 2002
@@ -100,6 +100,7 @@
     return message_contains_virus_nvcc()     if ($Features{'Virus:NVCC'});
     return message_contains_virus_rav()      if ($Features{'Virus:RAV'});
     return message_contains_virus_sophie()   if ($Features{'Virus:SOPHIE'});
+    return message_contains_virus_trophie()   if ($Features{'Virus:TROPHIE'});
     return message_contains_virus_sophos()   if ($Features{'Virus:SOPHOS'});
     return message_contains_virus_trend()    if ($Features{'Virus:TREND'});
     return message_contains_virus_filescan() if ($Features{'Virus:FileScan'});
@@ -119,6 +120,7 @@
     return entity_contains_virus_nvcc($e)     if ($Features{'Virus:NVCC'});
     return entity_contains_virus_rav($e)      if ($Features{'Virus:RAV'});
     return entity_contains_virus_sophie($e)   if ($Features{'Virus:SOPHIE'});
+    return entity_contains_virus_trophie($e)   if ($Features{'Virus:TROPHIE'});
     return entity_contains_virus_sophos($e)   if ($Features{'Virus:SOPHOS'});
     return entity_contains_virus_trend($e)    if ($Features{'Virus:TREND'});
     return entity_contains_virus_filescan($e) if ($Features{'Virus:FileScan'});
diff -Naur mimedefang-2.23.orig/mimedefang-filter.5.in mimedefang-2.23/mimedefang-filter.5.in
--- mimedefang-2.23.orig/mimedefang-filter.5.in	Tue Oct 15 23:24:01 2002
+++ mimedefang-2.23/mimedefang-filter.5.in	Wed Oct 23 11:50:39 2002
@@ -348,6 +348,12 @@
 routine.
 
 .TP
+.B $TrophieSock \fR(default /var/run/trophie)
+Socket used for Trophie daemon calls within message_contains_virus_Trophie
+and entity_contains_virus_Trophie unless a socket is provided by the calling
+routine.
+
+.TP
 .B $ClamdSock \fR(default @SPOOLDIR@/clamd.sock)
 Socket used for clamd daemon calls within message_contains_virus_clamd
 and entity_contains_virus_clamd unless a socket is provided by the calling
@@ -459,6 +465,9 @@
 $Features{"Virus:SOPHIE"} is the full path to Sophie if it is installed;
 0 if it is not.
 
+$Features{"Virus:TROPHIE"} is the full path to Trophie if it is installed;
+0 if it is not.
+
 $Features{"Virus:CLAMD"} is the full path to clamd if it is installed;
 0 if it is not.
 
@@ -1218,6 +1227,12 @@
 same as the other message_contains_virus functions.
 
 .TP
+.B message_contains_virus_trophie([$trophie_sock])
+Connects to the specified socket (default \fB$TrophieSock\fR), where
+the Trophie daemon is expected to be listening.  Return values are the
+same as the other message_contains_virus functions.
+
+.TP
 .B message_contains_virus_clamd([$clamd_sock])
 Connects to the specified socket (default \fB$ClamdSock\fR), where
 the clamd daemon is expected to be listening.  Return values are the
@@ -1260,6 +1275,12 @@
 .B entity_contains_virus_sophie($entity[, $sophie_sock])
 Connects to the specified socket (default \fB$SophieSock\fR), where
 the Sophie daemon is expected to be listening.  Return values
+are the same as the other entity_contains_virus functions.
+
+.TP
+.B entity_contains_virus_trophie($entity[, $trophie_sock])
+Connects to the specified socket (default \fB$TrophieSock\fR), where
+the Trophie daemon is expected to be listening.  Return values
 are the same as the other entity_contains_virus functions.
 
 .TP
diff -Naur mimedefang-2.23.orig/mimedefang.pl.in mimedefang-2.23/mimedefang.pl.in
--- mimedefang-2.23.orig/mimedefang.pl.in	Fri Oct 18 03:59:48 2002
+++ mimedefang-2.23/mimedefang.pl.in	Mon Nov 11 12:50:00 2002
@@ -28,8 +28,8 @@
 	    $MessageID $Rebuild $QuarantineCount
 	    $QuarantineDir $QuarantineSubdir $QueueID $MsgID
 	    $RelayAddr $WasResent $RelayHostname
-	    $ReplacementEntity $Sender $ServerMode $Subject $SophieSock
-	    $ClamdSock
+	    $ReplacementEntity $Sender $ServerMode $Subject $SophieSock 
+		$TrophieSock $ClamdSock
 	    $SuspiciousCharsInHeaders
 	    $SuspiciousCharsInBody $Helo
 	    $TerminateAndDiscard $URL $OpenAVHost $VirusName $CurrentVirusScannerMessage
@@ -78,6 +78,7 @@
 $Features{'Virus:OpenAV'}   = 1;  # Not a good idea but we need a test!
 $Features{'Virus:RAV'}      = ('@RAV@' ne '/bin/false' ? '@RAV@' : 0);
 $Features{'Virus:SOPHIE'}   = ('@SOPHIE@' ne '/bin/false' ? '@SOPHIE@' : 0);
+$Features{'Virus:TROPHIE'}   = ('@TROPHIE@' ne '/bin/false' ? '@TROPHIE@' : 0);
 $Features{'Virus:SOPHOS'}   = ('@SOPHOS@' ne '/bin/false' ? '@SOPHOS@' : 0);
 $Features{'Virus:TREND'}    = ('@TREND@' ne '/bin/false' ? '@TREND@' : 0);
 $Features{'Path:SENDMAIL'}  = '@SENDMAILPROG@';
@@ -112,6 +113,7 @@
 $URL = 'http://www.roaringpenguin.com/mimedefang/enduser.php3';
 $OpenAVHost = "127.0.0.1:8127";
 $SophieSock = "@SPOOLDIR@/sophie";
+$TrophieSock = "/var/run/trophie";
 $ClamdSock  = "@SPOOLDIR@/clamd.sock";
 package main;
 
@@ -2853,6 +2855,88 @@
     md_syslog('err', "Could not connect to Sophie Daemon at $sophie_sock");
     return (wantarray ? (999, 'cannot-execute', 'tempfail') : 999);
 }
+#***********************************************************************
+# %PROCEDURE: entity_contains_virus_trophie
+# %ARGUMENTS:
+#  entity -- a MIME entity
+#  trophie_sock (optional) -- trophie socket path
+# %RETURNS:
+#  1 if entity contains a virus as reported by trophie
+# %DESCRIPTION:
+#  Invokes the trophie daemon (http://http://www.vanja.com/tools/trophie/)
+#  on the entity.
+#***********************************************************************
+sub entity_contains_virus_trophie ($;$) {
+    my ($entity) = shift;
+    my ($trophie_sock) = $TrophieSock;
+    $trophie_sock = shift if (@_ > 0);
+    $trophie_sock = "@SPOOLDIR@/trophie" if (!defined($trophie_sock));
+    if (!defined($entity->bodyhandle)) {
+	return (wantarray ? (0, 'ok', 'ok') : 0);
+    }
+    if (!defined($entity->bodyhandle->path)) {
+	return (wantarray ? (999, 'swerr', 'tempfail') : 1);
+    }
+    my $sock = IO::Socket::UNIX->new(Peer=>$trophie_sock);
+    if (defined $sock) {
+	my($cwd);
+	chomp($cwd = `pwd`);
+	my $path = $entity->bodyhandle->path;
+	# If path is not absolute, add cwd
+	if (! ($path =~ m+^/+)) {
+	    $path = $cwd . "/" . $path;
+	}
+	$sock->print("$path\n");
+	$sock->flush;
+	my($output);
+	$sock->sysread($output,256);
+	$sock->close;
+	if ($output =~ /^1:(.*)$/) {
+	    $VirusScannerMessages .= "Trophie found the $1 virus.\n";
+	    $VirusName = $1;
+	    return (wantarray ? (1, 'virus', 'quarantine') : 1);
+	}
+	return (wantarray ? (0, 'ok', 'ok') : 0);
+    }
+    # Could not connect to daemon
+    md_syslog('err', "Could not connect to Trophie Daemon at $trophie_sock");
+    return (wantarray ? (999, 'cannot-execute', 'tempfail') : 999);
+}
+
+#***********************************************************************
+# %PROCEDURE: message_contains_virus_trophie
+# %ARGUMENTS:
+#  trophie_sock (optional) -- Trophie socket path
+# %RETURNS:
+#  1 if any file in the working directory contains a virus
+# %DESCRIPTION:
+#  Invokes the trophie daemon (http://http://www.vanja.com/tools/trophie/)
+#  on the entire message.
+#***********************************************************************
+sub message_contains_virus_trophie (;$) {
+    my ($trophie_sock) = $TrophieSock;
+    $trophie_sock = shift if (@_ > 0);
+    $trophie_sock = "@SPOOLDIR@/trophie" if (!defined($trophie_sock));
+    my $sock = IO::Socket::UNIX->new(Peer=>$trophie_sock);
+    if (defined $sock) {
+	my($cwd);
+	chomp($cwd = `pwd`);
+	$sock->print("$cwd/Work\n");
+	$sock->flush;
+	my($output);
+	$sock->sysread($output,256);
+	$sock->close;
+	if ($output =~ /^1:(.*)$/) {
+	    $VirusScannerMessages .= "Trophie found the $1 virus.\n";
+	    $VirusName = $1;
+	    return (wantarray ? (1, 'virus', 'quarantine') : 1);
+	}
+	return (wantarray ? (0, 'ok', 'ok') : 0);
+    }
+    # Could not connect to daemon
+    md_syslog('err', "Could not connect to Trophie Daemon at $trophie_sock");
+    return (wantarray ? (999, 'cannot-execute', 'tempfail') : 999);
+}
 
 #***********************************************************************
 # %PROCEDURE: entity_contains_virus_clamd


More information about the MIMEDefang mailing list