Search
j0ke.net Open Build Service
>
Projects
>
server:mail
>
qmail-scanner
> qmail-scanner-1.25_sql.diff
Sign Up
|
Log In
Username
Password
Cancel
Overview
Repositories
Revisions
Requests
Users
Advanced
Attributes
Meta
File qmail-scanner-1.25_sql.diff of Package qmail-scanner (Revision 1)
Currently displaying revision
1
,
show latest
--- configure-1.25 Sun Jul 3 12:57:04 2005 +++ configure Sun Jul 3 13:21:29 2005 @@ -97,10 +97,20 @@ QS_USER="qscand" SKIP_SETUID_TEST="" MAX_ZIP_SIZE="1000000000" +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 ; AS_QQ="$1" ;; --qmaildir) if [ "$2" != "" ]; then shift ; fi ; QMAILDIR="$1" ;; @@ -133,6 +143,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 $AS_QQ/ @@ -1576,6 +1591,11 @@ . ./.locale_vars 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-1.25 Sun Jul 3 12:52:57 2005 +++ qmail-scanner-queue.template Sun Jul 3 12:56:06 2005 @@ -148,6 +148,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... @@ -1450,6 +1466,7 @@ &email_recips($recips); } &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"); } @@ -1748,6 +1765,20 @@ print QUARANTINELOG $report; close QUARANTINELOG; &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 {