function build() { $unix = new unix(); $sock = new sockets(); $ClamavStreamMaxLength = $sock->GET_INFO("ClamavStreamMaxLength"); $ClamavMaxRecursion = $sock->GET_INFO("ClamavMaxRecursion"); $ClamavMaxFiles = $sock->GET_INFO("ClamavMaxFiles"); $PhishingScanURLs = $sock->GET_INFO("PhishingScanURLs"); $ClamavMaxScanSize = $sock->GET_INFO("ClamavMaxScanSize"); $ClamavMaxFileSize = $sock->GET_INFO("ClamavMaxFileSize"); $ClamavTemporaryDirectory = $sock->GET_INFO("ClamavTemporaryDirectory"); if ($ClamavTemporaryDirectory == null) { $ClamavTemporaryDirectory = "/home/clamav"; } if (!is_numeric($ClamavStreamMaxLength)) { $ClamavStreamMaxLength = 12; } if (!is_numeric($ClamavMaxRecursion)) { $ClamavMaxRecursion = 5; } if (!is_numeric($ClamavMaxFiles)) { $ClamavMaxFiles = 10000; } if (!is_numeric($PhishingScanURLs)) { $PhishingScanURLs = 1; } if (!is_numeric($ClamavMaxScanSize)) { $ClamavMaxScanSize = 15; } if (!is_numeric($ClamavMaxFileSize)) { $ClamavMaxFileSize = 20; } if ($GLOBALS["OUTPUT"]) { echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} MaxFileSize: {$ClamavMaxFileSize}M\n"; } $ClamUser = $unix->ClamUser(); $ClamavTemporaryDirectory2 = dirname($ClamavTemporaryDirectory); $dirs[] = "/var/clamav"; $dirs[] = "/var/run/clamav"; $dirs[] = "/var/lib/clamav"; $dirs[] = "/var/log/clamav"; $dirs[] = $ClamavTemporaryDirectory; $dirs[] = "/var/spool/postfix/var/run/clamav"; while (list($i, $directory) = each($dirs)) { @mkdir($directory, 0755, true); @chmod($directory, 0755); @chown($directory, $ClamUser); @chgrp($directory, $ClamUser); if ($GLOBALS["OUTPUT"]) { echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} Permissions on {$directory}\n"; } $unix->chown_func($ClamUser, $ClamUser, $directory . "/*"); } $f[] = "MilterSocket /var/spool/postfix/var/run/clamav/clamav-milter.ctl"; $f[] = "MilterSocketGroup postfix"; $f[] = "MilterSocketMode 777"; $f[] = "FixStaleSocket yes"; $f[] = "User postfix"; $f[] = "AllowSupplementaryGroups yes"; $f[] = "ReadTimeout 300"; $f[] = "Foreground yes"; $f[] = "PidFile /var/spool/postfix/var/run/clamav/clamav-milter.pid"; $f[] = "TemporaryDirectory {$ClamavTemporaryDirectory}"; $f[] = "ClamdSocket unix:/var/run/clamav/clamav.sock"; $f[] = ""; $f[] = "#LocalNet local"; $f[] = "#LocalNet 192.168.0.0/24"; $f[] = "#LocalNet 1111:2222:3333::/48"; $f[] = "#Whitelist /etc/whitelisted_addresses"; $f[] = "#SkipAuthenticated ^(tom|dick|henry)\$"; $f[] = "MaxFileSize {$ClamavMaxFileSize}M"; $f[] = ""; $f[] = ""; $f[] = "##"; $f[] = "## Actions"; $f[] = "##"; $f[] = ""; $f[] = "# The following group of options controls the delievery process under"; $f[] = "# different circumstances."; $f[] = "# The following actions are available:"; $f[] = "# - Accept"; $f[] = "# The message is accepted for delievery"; $f[] = "# - Reject"; $f[] = "# Immediately refuse delievery (a 5xx error is returned to the peer)"; $f[] = "# - Defer"; $f[] = "# Return a temporary failure message (4xx) to the peer"; $f[] = "# - Blackhole (not available for OnFail)"; $f[] = "# Like Accept but the message is sent to oblivion"; $f[] = "# - Quarantine (not available for OnFail)"; $f[] = "# Like Accept but message is quarantined instead of being delivered"; $f[] = "#"; $f[] = "# NOTE: In Sendmail the quarantine queue can be examined via mailq -qQ"; $f[] = "# For Postfix this causes the message to be placed on hold"; $f[] = "# "; $f[] = "# Action to be performed on clean messages (mostly useful for testing)"; $f[] = "# Default: Accept"; $f[] = "OnClean Accept"; $f[] = "OnInfected Reject"; $f[] = "OnFail Accept"; $f[] = "RejectMsg rejected %v"; $f[] = "AddHeader Add"; $f[] = "#ReportHostname my.mail.server.name"; $f[] = "#VirusAction /usr/local/bin/my_infected_message_handler"; $f[] = "LogSyslog yes"; $f[] = "LogFacility LOG_MAIL"; $f[] = "LogVerbose no"; $f[] = "#LogRotate yes"; $f[] = "#LogInfected Basic"; $f[] = "#LogClean Basic"; $f[] = "#SupportMultipleRecipients yes"; $f[] = ""; @file_put_contents("/etc/clamav/clamav-milter.conf", @implode("\n", $f)); if ($GLOBALS["OUTPUT"]) { echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} /etc/clamav/clamav-milter.conf done\n"; } $main = new main_cf(); $postfix_hash = $main->BuildMilters(true); $postconf = $unix->find_program("postconf"); while (list($key, $value) = each($postfix_hash)) { if ($GLOBALS["OUTPUT"]) { echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} adding Postfix parameter: {$key} for {$value}\n"; } shell_exec("{$postconf} -e \"{$key}={$value}\""); } }
function smtpd_milters() { if ($GLOBALS["EnablePostfixMultiInstance"] == 1) { echo "Starting......: " . date("H:i:s") . " Postfix EnablePostfixMultiInstance is enabled...\n"; shell_exec(LOCATE_PHP5_BIN2() . " " . dirname(__FILE__) . "/exec.postfix-multi.php --from-main-reconfigure"); return; } $main = new main_cf(); echo "Starting......: " . date("H:i:s") . " Postfix building milters...\n"; $milter_array = $main->BuildMilters(true); while (list($key, $value) = each($milter_array)) { echo "Starting......: " . date("H:i:s") . " Postfix setting key `{$key}`...\n"; postconf($key, $value); } }