Skip to content

Instantly share code, notes, and snippets.

@nuxwin
Last active November 24, 2018 19:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nuxwin/1c4598fdb7ec9036ad5b429f2ac4a636 to your computer and use it in GitHub Desktop.
Save nuxwin/1c4598fdb7ec9036ad5b429f2ac4a636 to your computer and use it in GitHub Desktop.
SpamAssassin - Make possible to add plugin configuration definitions
<?php
/**
* i-MSCP SpamAssassin plugin
* Copyright (C) 2015-2018 Laurent Declercq <l.declercq@nuxwin.com>
* Copyright (C) 2013-2016 Rene Schuster <mail@reneschuster.de>
* Copyright (C) 2013-2018 Sascha Bay <info@space2place.de>
*
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
return [
// SPAMD(8p) service configuration
'spamd' => [
// SPAMD(8p) unix user
'user' => 'debian-spamd',
// SPAMD(8p) unix user group
'group' => 'debian-spamd',
// SPAMD(8p) unix user homedir
'homedir' => '/var/lib/spamassassin',
// Options passed-in to SPAMD(8p)
//
// Available placeholders:
// - {SPAMD_USER}: Replaced by SPAMD(8p) unix user
// - {SPAMD_GROUP}: Replaced by SPAMD(8p) unix user group
// - {SPAMD_HOMEDIR}: Replaced by SPAMD(8p) unix user homedir
'options' => '--max-children=5 --sql-config --nouser-config --username={SPAMD_USER} --groupname={SPAMD_GROUP}'
. ' --helper-home-dir={SPAMD_HOMEDIR} --socketpath=/var/run/spamassassin.sock --socketowner={SPAMD_USER}'
. ' --socketgroup={SPAMD_GROUP} --socketmode=0666'
],
// SPAMASS_MILTER(8) service configuration
'spamass_milter' => [
// Policy for SPAM rejection
//
// - If set to -1, SPAM messages are always rejected.
// - If set to 15, SPAM messages are only rejected when the score is
// equal or greater then 15. SPAM messages below that score are
// tagged as SPAM.
// - If set to a value higher than 1000, SPAM messages are never
// rejected. SPAM messages are tagged as SPAM.
//
// Generally speaking, an ISP shouldn't automatically remove SPAM
// messages. Decision should be left to end-user, hence the default
// value that is a good compromise.
'spam_reject_policy' => 15,
// Ignores messages if the sender has authenticated via SMTP AUTH.
//
// If set to TRUE messages from authenticated senders (SASL) will
// passthrough without being scanned.
'ignore_auth_sender_msgs' => false,
// Ignore messages from listed networks
//
// Messages from listed networks will passthrough without being
// scanned.
//
// An array where each element can be either:
// - An IP address: nnn.nnn.nnn.nnn
// - A CIDR network: nnn.nnn.nnn.nnn/nn
// - A network/netmask pair: nnn.nnn.nnn.nnn/nnn.nnn.nnn.nnn
// For instance: '127.0.0.1', '172.16.12.0/24', '10.0.0.0/255.0.0.0'
'networks' => [],
// Options passed-in to SPAMASS_MILTER(8)
//
// You can pass your own options to SPAMASS_MILTER(8), including flags
// for SPAMC(1) as described in SPAMASS_MILTER(8)
//
// Don't add the -I, -i and -r SPAMASS_MILTER(8) options as these are
// managed through the named options above.
'options' => '-e localhost -f -u spamass-milter -- --max-size=2048000 --socket=/var/run/spamassassin.sock',
// SPAMASS_MILTER(8) socket path
'socket_path' => '/var/spool/postfix/spamass/spamass.sock',
// SPAMASS_MILTER(8) socket owner
'socket_owner' => 'postfix:postfix',
// SPAMASS_MILTER(8) socket mode
'socket_mode' => '0666'
],
// SpamAssassin configuration
'spamassassin' => [
// Enable/Disable automatic update of SpamAssassin rules
'sa_update' => true,
// SpamAssassin plugins
'plugins' => [
// AWL plugin -- Normalize scores via auto-whitelist
// See https://spamassassin.apache.org/full/3.4.x/doc/Mail_SpamAssassin_Plugin_AWL.html
'AWL' => [
// Enable/Disable the plugin
'enabled' => true,
// SA configuration files in which the plugin must be loaded.
'config_file' => '/etc/spamassassin/v310.pre',
// Cronjobs
'cronjobs' => [
// Cronjob for AWL database cleanup
'sa-awl-clean-db' => [
'minute' => '@daily',
'command' => 'nice -n 10 ionice -c2 -n5 perl' . __DIR__ . '/cronjobs/sa-awl-clean-db >/dev/null 2>&1'
]
]
],
// Bayes plugin -- determine spammishness using a Bayesian classifier
// See https://spamassassin.apache.org/full/3.4.x/doc/Mail_SpamAssassin_Plugin_Bayes.html
'Bayes' => [
// Enable/Disable the plugin
'enabled' => true,
// Setting the value to TRUE will prevent users to act on that
// plugin through their user preferences. Plugin usage will be
// enforced for all users.
'enforced' => false,
// SA configuration file in which the plugin must be loaded.
'config_file' => '/etc/spamassassin/v320.pre',
// Cronjobs
'cronjobs' => [
// Cronjob for SA-LEARN(1p)
'sa-bayes-sa-learn' => [
'minute' => '0',
'hour' => '*/12',
'day' => '*',
'month' => '*',
'dweek' => '*',
'command' => 'nice -n 10 ionice -c2 -n5 perl' . __DIR__ . '/cronjobs/sa-bayes-sa-learn >/dev/null 2>&1'
],
// Cronjob for bayes database cleanup
'sa-bayes-clean-db' => [
'minute' => '@daily',
'command' => 'nice -n 10 ionice -c2 -n5 perl' . __DIR__ . '/cronjobs/sa-bayes-clean-db >/dev/null 2>&1'
]
],
// When set to TRUE, the site-wide bayes database is enabled.
// This allow to share the bayesian database with all users.
//
// Note that setting the value to TRUE will prevent users to act
// on some aspects of that plugin through their user preferences.
'site_wide' => false,
// SA user preferences
'user_preferences' => [
'use_bayes',
'use_bayes_rules',
'bayes_auto_learn'
]
],
// DCC plugin -- perform DCC check of messages
// See https://spamassassin.apache.org/full/3.4.x/doc/Mail_SpamAssassin_Plugin_DCC.html
//
// You must first install DCC which is not provided by default.
// See https://www.dcc-servers.net/dcc/INSTALL.html
'DCC' => [
// Enable/Disable the plugin
'enabled' => false,
// Setting the value to TRUE will prevent users to act on that
// plugin through their user preferences. Plugin usage will be
// enforced for all users.
'enforced' => false,
// SA configuration files in which the plugin must be loaded.
'config_file' => '/etc/spamassassin/v310.pre',
// Plugin SA user preferences
'user_preferences' => [
'use_dcc'
]
],
// DKIM plugin - perform DKIM verification tests
// See https://spamassassin.apache.org/full/3.4.x/doc/Mail_SpamAssassin_Plugin_DKIM.html
//
// You shouldn't enable this plugin if you also use the i-MSCP OpenDKIM plugin.
'DKIM' => [
// Enable/Disable the plugin
'enabled' => false,
// SA configuration file in which the plugin must be loaded.
'config_file' => '/etc/spamassassin/v312.pre'
],
// DecodeShortURLs 3rd-party plugin -- Expand shortened URLs
// See https://github.com/smfreegard/DecodeShortURLs
'DecodeShortURLs' => [
// Enable/Disable the plugin
'enabled' => true,
// SA configuration file in which the plugin must be loaded.
'config_file' => '/etc/spamassassin/local.pre',
// Shell commands
'shell' => [
// Shell commands to be executed upon configuration phase
'configure' => [
<<<EOT
cp {PLUGINS_DIR}/SpamAssassin/spamassassin-plugins/DecodeShortURLs/DecodeShortURLs.pm /etc/spamassassin
cp {PLUGINS_DIR}/SpamAssassin/spamassassin-plugins/DecodeShortURLs/DecodeShortURLs.cf /etc/spamassassin
EOT
],
// Shell command(s) to be executed upon deconfiguration phase
'deconfigure' => [
<<<EOT
rm -f /etc/spamassassin/DecodeShortURLs.pm
rm -f /etc/spamassassin/DecodeShortURLs.cf
EOT
]
]
],
// iXhash2 3rd-party plugin - perform iXhash2 check of messages
// See http://mailfud.org/iXhash2/
'iXhash2' => [
// Enable/Disable the plugin
'enabled' => true,
// SA configuration file in which the plugin must be loaded.
'config_file' => '/etc/spamassassin/local.pre',
// Shell command(s)
'shell' => [
// Shell commands to be executed upon configuration phase
'configure' => [
<<<EOT
cp {PLUGINS_DIR}/SpamAssassin/spamassassin-plugins/iXhash2/iXhash2.pm /etc/spamassassin
cp {PLUGINS_DIR}/SpamAssassin/spamassassin-plugins/iXhash2/iXhash2.cf /etc/spamassassin
EOT
],
// Shell commands to be executed upon deconfiguration phase
'deconfigure' => [
<<<EOT
rm -f /etc/spamassassin/iXhash2.pm
rm -f /etc/spamassassin/iXhash2.cf
EOT
]
]
],
// Pyzor plugin -- perform Pyzor check of messages
// See https://spamassassin.apache.org/full/3.4.x/doc/Mail_SpamAssassin_Plugin_Pyzor.html
'Pyzor' => [
// Enable/Disable the plugin
'enabled' => true,
// Setting the value to TRUE will prevent users to act on that
// plugin through their user preferences. Plugin usage will be
// enforced for all users.
'enforced' => false,
// SA configuration file in which the plugin must be loaded.
'config_file' => '/etc/spamassassin/v310.pre',
// Shell commands
'shell' => [
// Shell commands to be executed upon configuration phase
'configure' => [
"[ -d \"{SPAMD_HOMEDIR}/.razor\" ] || su - {SPAMD_USER} -c '/usr/bin/pyzor ping'"
],
// Shell commands to be executed upon deconfiguration phase
'deconfigure' => [
"[ ! -d \"{SPAMD_HOMEDIR}/.pyzor\" ] || su - {SPAMD_USER} -c 'rm -R {SPAMD_HOMEDIR}/.pyzor'",
]
],
// SA user preferences
'user_preferences' => [
'use_pyzor'
],
// Required distribution packages
'dist_packages' => [
'pyzor'
]
],
// Razor2 plugin -- perform Razor check of messages
// See https://spamassassin.apache.org/full/3.4.x/doc/Mail_SpamAssassin_Plugin_Razor2.html
'Razor2' => [
// Enable/Disable the plugin
'enabled' => true,
// Setting the value to TRUE will prevent users to act on that
// plugin through their user preferences. Plugin usage will be
// enforced for all users.
'enforced' => false,
// SA configuration file in which the plugin must be loaded.
'config_file' => '/etc/spamassassin/v310.pre',
// Cronjobs
'cronjobs' => [
// Cronjob for Razor server discovering
'sa-razor-discover' => [
'minute' => '@weekly',
'command' => 'nice -n 10 ionice -c2 -n5 perl' . __DIR__ . '/cronjobs/sa-razor-discover >/dev/null 2>&1'
]
],
// Shell commands
'shell' => [
// Shell commands to be executed upon configuration phase
'configure' => [
"[ -d \"{SPAMD_HOMEDIR}/.razor\" ] || su - {SPAMD_USER} -c '/usr/bin/razor-admin -create'",
"[ -d \"{SPAMD_HOMEDIR}/.razor/identity\" ] || su - {SPAMD_USER} -c '/usr/bin/razor-admin -register'",
],
// Shell commands to be executed upon deconfiguration phase
'deconfigure' => [
"[ ! -d \"{SPAMD_HOMEDIR}/.razor\" ] || su - {SPAMD_USER} -c 'rm -R {SPAMD_HOMEDIR}/.razor'",
]
],
// SA user preferences
'user_preferences' => [
'use_razor2'
],
// Required distribution packages
'dist_packages' => [
'razor'
]
],
// Rule2XSBody plugin -- speed up SpamAssassin by compiling regexps
// See https://spamassassin.apache.org/full/3.4.x/doc/Mail_SpamAssassin_Plugin_Rule2XSBody.html
'Rule2XSBody' => [
// Enable/Disable the plugin
'enabled' => true,
// SA configuration file in which the plugin must be loaded.
'config_file' => '/etc/spamassassin/sa-compile.pre',
// Required distribution packages
'dist_packages' => [
'sa-compile'
]
],
// SPF plugin -- perform SPF verification tests
// See https://spamassassin.apache.org/full/3.4.x/doc/Mail_SpamAssassin_Plugin_SPF.html
//
// You shouldn't enable that plugin if you have installed the i-MSCP PolicydSPF plugin
'SPF' => [
// Possible values: true, false
'enabled' => false,
// SA configuration file in which the plugin must be loaded.
'config_file' => '/etc/spamassassin/init.pre',
// Required distribution packages
'dist_packages' => [
'libmail-spf-perl'
]
],
// TextCat plugin -- language guesser
// See https://spamassassin.apache.org/full/3.4.x/doc/Mail_SpamAssassin_Plugin_TextCat.html
'TextCat' => [
// Enable/Disable the plugin
'enabled' => true,
// SA configuration files in which the plugin must be loaded.
'config_file' => '/etc/spamassassin/v310.pre'
],
// RBL checks (DNSEval and URIDNSBL SA plugins)
// https://spamassassin.apache.org/full/3.4.x/doc/Mail_SpamAssassin_Plugin_DNSEval.html
// See https://spamassassin.apache.org/full/3.4.x/doc/Mail_SpamAssassin_Plugin_URIDNSBL.html
//
// You shouldn't enable those plugins if you already use the i-MSCP PolicydWeight and/or
// Postscreen plugins.
'rbl_checks' => [
// Enable/Disable the plugins
'enabled' => false,
// Setting the value to TRUE will prevent users to act on that
// plugin through their user preferences. Plugin usage will be
// enforced for all users.
'enforced' => false,
// SA user preferences
'user_preferences' => [
'skip_rbl_checks'
]
],
//
// Below, you can add you own SpamAssassin plugin configuration
// definitions. See the above plugin configuration definitions to
// learn about supported parameters.
//
/*
// Plugin configuration definition template
'<plugin_name>' => [
// Enable/Disable the plugin
'enabled' => true,
// Setting the value to TRUE will prevent users to act on that
// plugin through their user preferences. Plugin usage will be
// enforced for all users.
//
// This configuration parameter is OPTIONAL. It should be
// provided only if the plugin can be enabled/disabled on a per
// user preference basis.
'enforced' => false,
// SA configuration file in which the plugin must be loaded.
'config_file' => '',
// Cronjobs
// This configuration parameter is OPTIONAL. It should be
// provided only if the plugin require cronjob(s).
'cronjobs' => [],
// Shell commands
// This configuration parameter is OPTIONAL. It should be
// provided only if the plugin require specific
// configuration/deconfiguration task(s).
// Available placeholders:
// - {PLUGINS_DIR}: Replaced by i-MSCP plugin root directory
// - {SPAMD_USER}: Replaced by SPAMD(8p) unix user
// - {SPAMD_GROUP}: Replaced by SPAMD(8p) unix user group
// - {SPAMD_HOMEDIR}: Replaced by SPAMD(8p) unix user homedir
'shell' => [
// Shell commands to be executed upon configuration phase
'configure' => [],
// Shell commands to be executed upon deconfiguration phase
'deconfigure' => []
],
// SA user preferences
// This configuration parameter is OPTIONAL. It should be
// provided only if the plugin defines user preferences.
'user_preferences' => [],
// Required distribution packages
// This configuration parameter is OPTIONAL. It should be provided
// only if the plugin requires additional distribution packages.
'dist_packages' => []
]
*/
],
// 3rd-party Heinlein Support SpamAssassin ruleset
// See https://www.heinlein-support.de/blog/news/aktuelle-spamassassin-regeln-von-heinlein-support/
'heinlein_support_ruleset' => [
// Enable/Disable the plugin
'enabled' => true,
// Cronjob sleep timer (in seconds)
'sleep_timer' => 600,
// sa-update channel
'channel' => 'spamassassin.heinlein-support.de'
]
],
// Roundcube configuration
//
// Only relevant if you use the Roundcube Webmail
'roundcube' => [
'plugins' => [
// MarkAsJunk2 Roundcube plugin
// See https://github.com/JohnDoh/Roundcube-Plugin-Mark-as-Junk-2
//
// Make users able to mark their mails as SPAM|HAM for SA learning
// Requires the SA Bayes plugin
'markasjunk2' => [
// Enable/Disable the plugin
'enabled' => true
],
// SAUserPrefs Roundcube plugin
// See https://github.com/JohnDoh/Roundcube-Plugin-SpamAssassin-User-Prefs-SQL
//
// Make users able to customize SpamAssassin behavior through their own
// user preferences
'sauserprefs' => [
// Enable/Disable the plugin
'enabled' => true,
// Protected SA user preferences
//
// Users won't be able to acts on preferences listed in
// that configuration parameter.
//
// See the sauserprefs plugin documentation for further details.
//
// Possible value: array
'sauserprefs_dont_override' => [
// razor1 support is officially deprecated.
// There is no reason to show it in plugin.
'use_razor1'
]
]
]
]
];
@mikerhyner
Copy link

mikerhyner commented Nov 24, 2018

Looks good! So plugins are now in a seperate configuration array hierarchy level, able to be extended with every spamassassin plugin needed (and installed), right? But what I assume, that on upgrade to this spamass plugin version, local persistent configuration override probably has to be changed... But anyway, thank you for your efforts! Greetings from Switzerland, Mike

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment