Search
j0ke.net Open Build Service
>
Projects
>
server:mail
>
qmail-scanner
> qmail-scanner-2.02_sql.diff
Sign Up
|
Log In
Username
Password
Cancel
Overview
Repositories
Revisions
Requests
Users
Advanced
Attributes
Meta
File qmail-scanner-2.02_sql.diff of Package qmail-scanner (Revision 40)
Currently displaying revision
40
,
show latest
--- configure.orig 2007-10-08 05:02:50.000000000 +0200 +++ configure 2008-05-01 21:08:09.000000000 +0200 @@ -122,10 +122,20 @@ SA_MAXSIZE="256000" SA_TIMEOUT="30" SA_FT="0"; +DATABASE="vpopmail" +DBUSER="root" +DBPASS="" +DBHOST="localhost" +DBTABLE="quarantine_log" while [ -n "$1" ] do case $1 in + --mysql-db) if [ "$2" != "" ] ; then shift ; fi ; DATABASE="$1" ;; + --mysql-user) if [ "$2" != "" ] ; then shift ; fi ; DBUSER="$1" ;; + --mysql-pass) if [ "$2" != "" ] ; then shift ; fi ; DBPASS="$1" ;; + --mysql-host) if [ "$2" != "" ] ; then shift ; fi ; DBHOST="$1" ;; + --mysql-table) if [ "$2" != "" ] ; then shift ; fi ; DBTABLE="$1" ;; --qs-user) if [ "$2" != "" ] ; then shift ; fi ; QS_USER="$1" ;; --spooldir) if [ "$2" != "" ] ; then shift ; fi ; SPOOLDIR="$1" ;; --etcdir) if [ "$2" != "" ] ; then shift ; fi ; ETCDIR="$1" ;; @@ -169,6 +179,11 @@ *) cat <<EOF >&2 valid options: + --mysql-db <database> Database where to log found viruses (default: $DATABASE) + --mysql-user <username> MySQL user (default: $DBUSER) + --mysql-pass <password> MySQL password (default: $DBPASS) + --mysql-host <hostname> MySQL host (default: $DBHOST) + --mysql-table <tablename> MySQL table name where log is stored (default: $DBTABLE) --qs-user <username> User that Qmail-Scanner runs as (default: $QS_USER) --qmaildir <top of qmail> defaults to $QMAILDIR/ --spooldir <spooldir> defaults to $SPOOLDIR/ @@ -1908,6 +1923,11 @@ sed -e "s/SA_MAXSIZE/$SA_MAXSIZE/g" sub-spamassassin.template > sub-spamassassin.pl perl -p -e "s?UNMIME_BINARY?$UNMIME_BINARY?g; +s?DBHOST?$DBHOST?g; +s?DBUSER?$DBUSER?g; +s?DBPASS?$DBPASS?g; +s?DATABASE?$DATABASE?g; +s?DBTABLE?$DBTABLE?g; s?PERLRELEASE_DETAILS?$PERLRELEASE_DETAILS?g; s?HOST_OS?$HOST_OS?g; s?HOST_RELEASE?$HOST_RELEASE?g; --- qmail-scanner-queue.template.orig 2007-08-29 23:39:20.000000000 +0200 +++ qmail-scanner-queue.template 2008-05-01 21:06:22.000000000 +0200 @@ -161,6 +161,22 @@ #Name of file where quarantine reports go (for long-term storage) my $quarantinelog="quarantine.log"; +#DB definition for quarantine logging to sql +# database name +my $mydatabase="DATABASE"; + +# database host +my $myhost="DBHOST"; + +# database user +my $myuser="DBUSER"; + +# database password +my $mypass="DBPASS"; + +# database table name +my $mystattable="DBTABLE"; + #Generate nice random filename my ($sysname, $hostname, $release, $version, $machine) = uname(); #my $hostname='FQDN'; #could get via call I suppose... @@ -1645,6 +1661,7 @@ #This is almost 100% certainly SPAM - no point in notifying anyone } &write_quarantine_report; + &write_quarantine_report_sql; $elapsed_time = tv_interval ($start_time, [gettimeofday]); &debug("e_v_r: email_quarantine_report took ".tv_interval ($start_email_time, [gettimeofday])." seconds to execute"); } @@ -1961,6 +1978,20 @@ &debug("w_v_r: writing quarantine log report of: $report"); } +sub write_quarantine_report_sql { + my ($temp,$desc,$report,$subj); + $subj=$headers{'subject'}; + $subj =~ s/\t/ /g; + $desc=$quarantine_description; + $desc =~ s/\n\t/ /g; + use DBI; + my $db = DBI->connect("DBI:mysql:database=$mydatabase;host=$myhost", "$myuser", "$mypass") || print "Connection failed<BR>\n"; + my $SQL_QRY = "INSERT INTO $mystattable (`nowtime`,`returnpath`,`receips`,`subject`,`description`,`scaninfo`) VALUES ('$nowtime','$returnpath','$recips','$subj','$desc','$SCANINFO')"; + my $runcheck = $db->prepare($SQL_QRY); + $runcheck->execute(); + &debug("w_v_r: writing quarantine sql report of: $report"); +} + sub scanner_info { open(SC,"<$versionfile")||&error_condition("cannot open $versionfile - did you initialise the system by running \"$prog -z\"? - $!"); $SCANINFO = <SC>;