diff options
Diffstat (limited to 'spamassassin-courier')
-rw-r--r-- | spamassassin-courier/AuthCourier.pm | 128 | ||||
-rw-r--r-- | spamassassin-courier/PKGBUILD | 76 | ||||
-rw-r--r-- | spamassassin-courier/spamassassin-courier.install | 19 | ||||
-rw-r--r-- | spamassassin-courier/spamassassin.service | 12 | ||||
-rw-r--r-- | spamassassin-courier/spamd.patch | 10 |
5 files changed, 245 insertions, 0 deletions
diff --git a/spamassassin-courier/AuthCourier.pm b/spamassassin-courier/AuthCourier.pm new file mode 100644 index 000000000..532a28158 --- /dev/null +++ b/spamassassin-courier/AuthCourier.pm @@ -0,0 +1,128 @@ +# Copyright (C) 2003 Corporation of Balclutha. All rights reserved. +# +# Visit us at http://www.balclutha.org for all of your open source +# software development and support requirements and hosted solutions. +# +# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +package Mail::SpamAssassin::AuthCourier; + +$VERSION=1.0.1; + +# +# A mechanism which uses the Courier MTA's authdaemond server to +# determine mail account information. Courier is found at http://courier-mta.org +# +# This module automagically overrides the builtin getpwnam and getpwuid +# functions. +# +use Exporter; +use IO::Socket::UNIX; + + +@ISA = qw(Exporter); +@EXPORT = qw( getpwnam getpwuid ); + +# +# ensure overriding for our own internal usage as well ... +# +use subs qw( getpwnam getpwuid ); + +# +# For some frustrating reason, the socket seems to be unusable unless set each time. +# Please contact us if you have the solution to this enhancement. +# + +BEGIN { + # $socket = IO::Socket::UNIX->new('/usr/lib/courier/var/authdaemon/socket'); +} + +END { + $socket->close if $socket; +} + +sub getpwnam { + my $name = shift; + my $socket = IO::Socket::UNIX->new('/usr/lib/courier/var/authdaemon/socket'); + $socket = IO::Socket::UNIX->new('/var/run/courier/authdaemon/socket') unless $socket; + die "authdaemond socket error: $!\n" unless $socket; + + print $socket "PRE . login $name\n"; + + my %results = (); + my ($k, $v); + while (<$socket>) { + ($k,$v) = split '=', $_, 2; + chomp $v if $v; + $results{$k} = $v; + } + + $socket->close if $socket; + + # some auth mechanisms don't return UID - these must be fetched from /etc/passwd or + # it's moral equivalent until Sam patches these as per my request... + my $uid = $results{'UID'} || CORE::getpwnam($name); + + # stop some naf 'uninitialized' errors ... + return wantarray ? ('','','','','','','') : undef unless $uid; # uid 0 = root !!! + + return wantarray ? ( $results{'USERNAME'}, + $results{'PASSWD'}, + int($uid), + int($results{'GID'}), + $results{'QUOTA'}, + $results{'COMMENT'}, + $results{'GCOS'}, + $results{'HOME'}, + '/bin/bash') : $uid; +} + +sub getpwuid { + return (getpwnam($_[0]))[2]; +} + + +1; + + +__END__ + +=head1 SYNOPSIS + + use Mail::SpamAssassin::AuthCourier; + + +=head1 DESCRIPTION + + Overrides the builtin functions getpwnam, and getpwuid to return + information as per the Courier Mail (http://courier-mta.org) + authdaemond process rather than from the /etc/passwd file (or it's + moral equivalent). + + All of the magick happens courtesy of the Exporter module. If you + need the old functions, these are still available via the CORE module. + + +=head1 INSTALLATION + + Copy this file into the Mail/SpamAssassin directory on your @INC path + and edit spamd as per the SYNOPSIS. + + +=head1 AUTHOR + +Alan Milligan <alan\x40balclutha.org> ("\x40" is "@" of course) + +=cut diff --git a/spamassassin-courier/PKGBUILD b/spamassassin-courier/PKGBUILD new file mode 100644 index 000000000..42fcff5d0 --- /dev/null +++ b/spamassassin-courier/PKGBUILD @@ -0,0 +1,76 @@ +# Maintainer: Florian Pritz <bluewind@xinu.at> +# Contributor: Dale Blount <dale@archlinux.org> +# Contributor: Manolis Tzanidakis +pkgname=spamassassin-courier +pkgver=3.4.2 +pkgrel=1 +pkgdesc="A mail filter to identify spam - patched for courier-mta." +arch=('i686' 'x86_64') +license=('APACHE' 'GPL2') +url="http://spamassassin.apache.org" +depends=('openssl' 'zlib' 're2c' 'perl-net-dns' 'perl-io-socket-ssl' + 'perl-libwww' 'perl-mail-spf' 'perl-http-message' 'perl-net-http' + 'perl-io-socket-inet6' 'perl-mail-dkim' 'perl-crypt-ssleay') +makedepends=('razor' 'perl-dbi') +optdepends=('razor: to identify collaborately-flagged spam' + 'make: to use sa-compile' + 'gcc: to use sa-compile') +backup=('etc/mail/spamassassin/local.cf' + 'etc/mail/spamassassin/init.pre' + 'etc/mail/spamassassin/v310.pre' + 'etc/mail/spamassassin/v312.pre' + 'etc/mail/spamassassin/v320.pre' + 'etc/mail/spamassassin/v330.pre') +install="${pkgname}.install" +source=("http://www.us.apache.org/dist/${pkgname%-*}/source/Mail-SpamAssassin-${pkgver}.tar.gz"{,.asc} + 'spamassassin.service' + 'AuthCourier.pm' # http://da.andaka.org/dl/AuthCourier.pm + 'spamd.patch') +validpgpkeys=(D8099BC79E17D7E49BC21E31FDE52F40F7D39814) +sha512sums=('85e3d78bb885ad1d0bf2066d1bc919d6ad5e9f86795069397e7c28cc1ba02870566ec014c08c81f68e7ed03b7f60d2de0b9730b3415b35d848abde2c8920a28f' + 'SKIP' + '7e44370e9433134816db51681de388618f8b00f27e9229b673ca7da5821b6bfc27dfc9f6f7387ef18d1d310ea03a4569f46cae3089bba91dd71692b9eee8c8e4' + '56fd65798efea805dac6900528c9720e6af8c81d93c08ab99adedca1c63757334c7a1d4cabed0a427c447dc1bbf05ece6abb8be3a3cbaf19919c7a86729f99af' + 'c0333a744dc2e6e34e341dea4242c2a9337c015fe0e918ede1c24051f7f6992f260bb1329b86ae7d884d9287497c25eab13602a024be45e901d14d1faad74b3d') + +prepare() { + cd "${srcdir}/Mail-SpamAssassin-${pkgver}" + + sed -i t/sa_compile.t \ + -e 's#^my $temp_binpath = $Config{sitebinexp};#my $temp_binpath = "/bin/site_perl/";#' + sed -i ' + /^&run_makefile_pl (".*");$/ s/PREFIX=\S\+// + ' t/sa_compile.t +} + +build() { + cd "${srcdir}/Mail-SpamAssassin-${pkgver}" + + # install module in vendor directories. + export PERL_USE_UNSAFE_INC=1 + PERL_MM_USE_DEFAULT=1 perl Makefile.PL INSTALLDIRS=vendor \ + CONTACT_ADDRESS=root@localhost ENABLE_SSL=yes PERL_TAINT=no + make + find . -name 'spamd' -type f -execdir patch -p1 -i "${srcdir}/spamd.patch" \; +} + +check() { + cd "${srcdir}/Mail-SpamAssassin-${pkgver}" + + # parallel tests cause lots of failures; disable for now + #export HARNESS_OPTIONS="j$(echo $MAKEFLAGS | sed 's/.*-j\([0-9][0-9]*\).*/\1/')" + + make test || true +} + +package() { + cd "${srcdir}/Mail-SpamAssassin-${pkgver}" + make DESTDIR="${pkgdir}" install + + install -D -m644 "${srcdir}/spamassassin.service" "${pkgdir}/usr/lib/systemd/system/spamassassin.service" + install -d -o 182 -g 182 -m 755 "$pkgdir/var/lib/spamassassin" + install -m444 -t "${pkgdir}/usr/share/perl5/vendor_perl/Mail/SpamAssassin/" "${srcdir}/AuthCourier.pm" + + echo 'u spamd 182 - /var/lib/spamassassin' | + install -Dm644 /dev/stdin "$pkgdir"/usr/lib/sysusers.d/${pkgname%-*}.conf +} diff --git a/spamassassin-courier/spamassassin-courier.install b/spamassassin-courier/spamassassin-courier.install new file mode 100644 index 000000000..65f14a065 --- /dev/null +++ b/spamassassin-courier/spamassassin-courier.install @@ -0,0 +1,19 @@ +post_install() { + echo "You must run 'sa-update' to install spam rules before use." +} + +post_upgrade() { + if [ "$(vercmp $2 3.4)" -lt 0 ]; then + echo '/var/lib/spamassassin is now owned by the spamd user. spamassassin.service' + echo 'will also run under that user. You may need to adjust your setup.' + fi + + # Compile rules, if rules have previously been compiled, and it's possible + if type re2c &>/dev/null && type sa-compile &>/dev/null && [[ -d /var/lib/spamassassin/compiled ]]; then + echo "Detected compiled rules, running sa-compile..." + sa-compile > /dev/null 2>&1 + fi + + true +} + diff --git a/spamassassin-courier/spamassassin.service b/spamassassin-courier/spamassassin.service new file mode 100644 index 000000000..e8d10a72d --- /dev/null +++ b/spamassassin-courier/spamassassin.service @@ -0,0 +1,12 @@ +[Unit] +Description=Spamassassin daemon +After=syslog.target network.target + +[Service] +ExecStart=/usr/bin/vendor_perl/spamd -x -u spamd -g spamd +StandardOutput=null +StandardError=null +Restart=always + +[Install] +WantedBy=multi-user.target diff --git a/spamassassin-courier/spamd.patch b/spamassassin-courier/spamd.patch new file mode 100644 index 000000000..a9a5d411b --- /dev/null +++ b/spamassassin-courier/spamd.patch @@ -0,0 +1,10 @@ +--- a/spamd 2019-02-04 09:48:12.828476850 +0100 ++++ b/spamd 2019-02-04 09:48:26.385192138 +0100 +@@ -246,6 +246,7 @@ + exit_status_str am_running_on_windows + get_user_groups); + use Mail::SpamAssassin::Timeout; ++use Mail::SpamAssassin::AuthCourier; + + use Getopt::Long; + use POSIX qw(:sys_wait_h); |