Name: dspam Summary: Statistical Anti-Spam Filter URL: http://www.nuclearelephant.com/ Vendor: Jonathan A. Zdziarski & community Packager: Franta Hanzlik Group: System Environment/Daemons License: GPL Version: 3.9.0 %define subvers git.20100815.060500 Release: 1.%{subvers}.daemon%{dist} Requires: mysql perl-GD perl-GD-Graph3d perl-GDGraph perl-GDTextUtil perl-CGI-Simple pwauth mod_authnz_external Requires(post,postun): /sbin/service, /sbin/ldconfig BuildRequires: autoconf mysql-devel #BuildArch: i586 # list of sources Source0: http://sourceforge.net/projects/dspam/files/dspam/dspam-%{version}/dspam-%{version}-%{subvers}.tar.xz Source1: dspam_post.sh Source2: dspam-poznamky Source3: dspam1group.sh Source4: hash-sigclean.tgz Source5: dspam.conf.hash-optimized Source6: dspam-notifications-languages.tgz Source7: dspam_aliases.sh # build information Prefix: %{_prefix} BuildRoot: %{_tmppath}/%{name}-%{version}-root AutoReqProv: no #% {trace} #% {verbose} %description DSPAM (as in De-Spam) is an extremely scalable, open-source statistical anti-spam filter. While most commercial solutions only claim a mere 95%% accuracy (1 error in 20), a majority of DSPAM users frequently see around 99.95%% (1 error in 2000) and can sometimes reach peaks as high as 99.991%% (2 errors in 22,786). DSPAM presently functions as both a server-side agent for UNIX email servers and a developer's library for mail clients, other anti-spam tools, and similar projects requiring drop-in spam filtering. DSPAM has been implemented on many large and small scale systems. %package devel Summary: Development files and static library for dspam Group: Development/Libraries Requires: %{name} = %{version}-%{release}, pkgconfig %description devel Developers are able to link to the DSPAM core engine (libdspam) to provide "drop-in" spam-filtering for their applications. Examples of the libdspam API can be found in the example.c file included with this distribution. The dspam-devel package includes the libraries and include files that you will need to use libdspam. %prep [ "$RPM_BUILD_ROOT" != "/" ] && rm -rf $RPM_BUILD_ROOT %setup -q -n %{name}-%{version}-%{subvers} %build if [ ! -f configure ]; then ./autogen.sh fi %configure \ --sysconfdir=%{_sysconfdir}/dspam \ --with-storage-driver="hash_drv" \ --with-delivery-agent=/usr/bin/procmail.dspam \ --disable-homedir \ --with-dspam-home=%{_localstatedir}/dspam \ --with-dspam-home-mode=775 \ --with-dspam-home-owner="dspam" \ --with-dspam-home-group="dspam" \ --enable-daemon \ --enable-debug \ --enable-split-configuration \ --with-dspam-mode=2755 \ --with-dspam-owner="dspam" \ --with-dspam-group="dspam" \ --enable-warnings=yes # --enable-domain-scale \ make %install %{__mkdir} -p $RPM_BUILD_ROOT%{_bindir} make DESTDIR=$RPM_BUILD_ROOT install %{__install} -m 755 -d $RPM_BUILD_ROOT/var/dspam/txt %{__install} -m 755 -d $RPM_BUILD_ROOT/var/dspam/data %{__cp} -pd txt/*.txt $RPM_BUILD_ROOT/var/dspam/txt/ for i in firstrun firstspam quarantinefull; do [ -f txt/$i.txt ] && %{__cp} -pd "txt/$i.txt" "$RPM_BUILD_ROOT/var/dspam/txt/${i}_en_pre.txt" done %{__mkdir} -p $RPM_BUILD_ROOT/var/www/dspam/html/templates %{__cp} -pdR webui/cgi-bin/templates/* $RPM_BUILD_ROOT/var/www/dspam/html/templates/ /bin/find $RPM_BUILD_ROOT/var/www/dspam/html/templates -type d -print0|/usr/bin/xargs -r0 %{__chmod} 755 %{__cp} -pd webui/htdocs/*.css $RPM_BUILD_ROOT/var/www/dspam/html/ %{__cp} -pd webui/htdocs/*.js $RPM_BUILD_ROOT/var/www/dspam/html/ %{__cp} -pd webui/htdocs/*.gif $RPM_BUILD_ROOT/var/www/dspam/html/ %{__cp} -pd webui/cgi-bin/*.cgi $RPM_BUILD_ROOT/var/www/dspam/html/ %{__cp} -pd webui/cgi-bin/*.prefs $RPM_BUILD_ROOT/var/www/dspam/html/ %{__cp} -pd webui/cgi-bin/*.pl $RPM_BUILD_ROOT/var/www/dspam/html/ %{__cp} -pd webui/cgi-bin/admins $RPM_BUILD_ROOT/var/www/dspam/html/ %{__cp} -pd webui/cgi-bin/*.txt $RPM_BUILD_ROOT/var/www/dspam/html/ # ted uz nevim, proc jsem to mazal? find $RPM_BUILD_ROOT/var/www/dspam/html -name 'Makefile*' -delete %{__mv} $RPM_BUILD_ROOT%{_sysconfdir}/dspam/dspam.conf $RPM_BUILD_ROOT%{_sysconfdir}/dspam/dspam.conf.default %{__mv} $RPM_BUILD_ROOT/var/www/dspam/html/configure.pl $RPM_BUILD_ROOT/var/www/dspam/html/configure.pl.default %{__mkdir} -p contrib/fedora %{__install} -p -m 0644 %SOURCE2 %SOURCE4 contrib/fedora/ %{__install} -p -m 0754 %SOURCE1 %SOURCE3 %SOURCE7 contrib/fedora/ %{__install} -m 0644 %SOURCE5 $RPM_BUILD_ROOT%{_sysconfdir}/dspam/dspam.conf %{__tar} -xzf %{SOURCE6} -C $RPM_BUILD_ROOT/var/dspam/txt/ touch $RPM_BUILD_ROOT/var/dspam/system.log %files %config(noreplace) %attr(0644,root,root) %{_sysconfdir}/dspam/dspam.conf %attr(0644,root,mail) %{_sysconfdir}/dspam/dspam.conf.default %defattr(-, dspam, dspam, 2770) %dir /var/dspam %dir /var/dspam/log %dir /var/dspam/data %ghost %attr(0660,root,dspam) /var/dspam/system.log %ghost %attr(0664,root,dspam) /var/www/dspam/html/configure.pl /var/dspam/txt/* %{_bindir}/* %defattr(-, root, root, 0775) %{_libdir}/*.so* %{_libdir}/dspam/ #% doc %dir %{_docdir} %doc LICENSE README README.cssclean CHANGELOG UPGRADING RELEASE.NOTES doc/* %doc contrib/ # % doc ${RPM_BUILD_ROOT}%{_docdir}/%{name}-%{version}/fedora/contrib/* %doc %{_mandir}/man1/*.1* %defattr(-, dspam, dspam, 771) /var/www/dspam/* %files devel %defattr(-, root, root, 0755) %{_includedir}/* %{_libdir}/dspam/ %{_libdir}/ %{_libdir}/pkgconfig/*.pc %{_mandir}/man3/*.3* %pre # dspam UID cann't be system UID (<"UID_MIN"), else suexec refuse scripts. # Thus, without "-r" (--system) switch: useradd -M -d /var/dspam -c "dspam agent account" -s /sbin/nologin dspam usermod -G mail,apache dspam id dspam useradd -M -d /var/dspam -c "DSPAM global group manager account" -s /sbin/nologin nospam [ $? = 9 ] && exit 0 %post function echvhost(){ cat < DocumentRoot "/var/www/dspam/html" ServerName nospam._DOM_ ServerAdmin webmaster@_DOM_ ErrorLog logs/dspam._DOM_-error_log # "combined" log format + SSL_PROTOCOL + SSL_CIPHER : LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %{SSL_PROTOCOL}x %{SSL_CIPHER}x" s-combined Customlog logs/dspam.hjplus.cz_access_log s-combined SSLEngine on SSLProtocol all -SSLv2 # SSLCertificateFile /etc/pki/tls/certs/dspam._DOM_.crt SSLCertificateFile /etc/pki/tls/certs/server.crt SSLCertificateKeyFile /etc/pki/tls/private/server.key Timeout 900 DirectoryIndex dspam.cgi SuexecUserGroup dspam dspam AddExternalAuth for-dspam /usr/bin/pwauth SetExternalAuthMethod for-dspam pipe SSLOptions +StdEnvVars AddHandler cgi-script .cgi Options +FollowSymLinks +ExecCGI AllowOverride AuthConfig Order deny,allow Deny from all SSLRequireSSL AuthType Basic # AuthName "DSPAM Control Center" AuthName "Overeni uzivatelskeho pristupu" # AuthUserFile /etc/httpd/dspam._DOM_/htpasswd AuthBasicProvider external AuthExternal for-dspam Require valid-user Satisfy Any EOF } DD=`dnsdomainname` [ "$DD" ] || DD=`uname -n|sed -e 's/^[^\.]\+\.\(.*\)/\1/'` [ "$DD" ] || DD=localdomain OF="/etc/httpd/conf.d/dspamssl.conf" [ -f "$OF" ] && OF="$OF.rpmnew" echvhost|sed -e "s/_DOM_/$DD/g" > "$OF" echo "$OF for $DD created" # LGV=$(printenv|sed -n -e '/^LANG=/{s/.*=\([^_]\+\)_.*/\1/; p}') # System Language for i in firstrun firstspam quarantinefull; do if [ -f "/var/dspam/txt/${i}_${LGV}_pre.txt" ]; then sed -e "s/configureme.com/$DD/g" -e "s|http://www.yourdomain.com/dspam/|https://$DD:4433/|g" "/var/dspam/txt/${i}_${LGV}_pre.txt" >"/var/dspam/txt/${i}.txt" sed -n '/^$/,$p' "/var/dspam/txt/${i}_en_pre.txt"|sed -e "s/configureme.com/$DD/g" -e "s|http://www.yourdomain.com/dspam/|https://$DD:4433/|g" >>"/var/dspam/txt/${i}.txt" fi done # sed -e "s/^\(\$CONFIG{'HISTORY_SIZE'}.*=\)[^;]\+\(;.*$\)/\1 3999\2/"\ -e "s/^\(\$CONFIG{'HISTORY_PER_PAGE'}.*=\)[^;]\+\(;.*$\)/\1 250\2/"\ -e "s/^\(\$CONFIG{'MAX_COL_LEN'}.*=\)[^;]\+\(;.*$\)/\1 90\2/"\ -e "s/^\(\$CONFIG{'LOCAL_DOMAIN'}.*=\)[^;]\+\(;.*$\)/\1 \"$DD\"\2/"\ /var/www/dspam/html/configure.pl.default >/var/www/dspam/html/configure.pl # # Now we make only one catch-all entry in /etc/aliases: OF="/etc/aliases" if ! grep -q '^spam-dspam:' "$OF"; then cp -a "$OF" "${OF}_pre-dspam" echo -e "#\n# system-wide catch-all alias for DSPAM error training entry: spam-dspam: \"|/usr/bin/dspam --user root --class=spam --source=error\" #" >>"$OF" newaliases # echo "system-wide catch-all alias for DSPAM error training entry created" fi cp -a /usr/bin/procmail /usr/bin/procmail.dspam chgrp mail /usr/bin/procmail.dspam chmod 4750 /usr/bin/procmail.dspam ls -l /usr/bin/procmail.dspam [ -f /etc/smrsh/dspam ] && mv /etc/smrsh/dspam /etc/smrsh/dspam.rpmold ln -s /usr/bin/dspam /etc/smrsh/dspam if ! grep -q '^dspam' /etc/mail/trusted-users; then echo "dspam" >>/etc/mail/trusted-users; fi if [ -f /etc/mail/sendmail.mc ]; then if ! grep -q 'LOCAL_MAILER.*/usr/bin/dspam' /etc/mail/sendmail.mc; then [ -f /etc/mail/sendmail_pre-dspam.mc ] || cp -a /etc/mail/sendmail.mc /etc/mail/sendmail_pre-dspam.mc cp -a /etc/mail/sendmail.cf /etc/mail/sendmail_pre-dspam.cf sed -e "/^MAILER(smtp/i \dnl #\\ dnl # Tyto 2 radky jsou pro DSPAM antispam:\\ define(\`LOCAL_MAILER_PATH', \`/usr/bin/dspam')dnl\\ define(\`LOCAL_MAILER_ARGS', \`dspam -t -Y -a \$h \"--deliver=innocent\" --user \$u -d %%u')dnl\\ dnl #" /etc/mail/sendmail.mc|\ sed -e "/MAILER(cyrusv2)/a \dnl #\\ dnl #----------- regex map for rewriting 'spam-*@mydomain.com' to 'spam-dspam@mydomain.com' -------\\ dnl #\\ dnl # macro LOCAL_CONFIG introduces lines added after the boilerplate option\\ dnl # setting but before rulesets - suitable for local database maps declaration:\\ LOCAL_CONFIG\\ dnl # substrins 1 and 2 (-s1,2), delimiter '+' (-d+), rewrite all which begin with 'spam-'\\ Ktodspam regex -s1 -a-dspam ^(spam)-.*\$\\ dnl #\\ LOCAL_RULE_0\\ dnl # Option OperatorChars define list of characters, that delimit tokens\\ dnl # '\$=w' : set of all names this host is known by (== match local hostnames)\\ dnl # '\$:' at beginning of RHS cause the ruleset to return with the remainder of the RHS as the value\\ dnl # '\$@' at beginning of RHS cause the rule to terminate immediately (but the ruleset to continue)\\ R\$+ < @ \$=w . > \$: \$(todspam \$1 \$: \$1 \$) < @ \$2 . >\\ dnl #\\ dnl #---------- regex map end ---------\\ dnl #" > /etc/mail/sendmail_dspam.mc cp /etc/mail/sendmail_dspam.mc /etc/mail/sendmail.mc /sbin/service sendmail condrestart >/dev/null 2>&1 fi fi if [ ! -f /var/dspam/group ]; then echo -n "# group definition # SHARED,MANAGED: one dictionary + one quarantine mbox. GROUPNAME = group manager. nospam:shared,managed:* # SHARED: one dictionary + individual quarantine mboxes. GROUPNAME hasn't any special meaning. #nospam:shared:* " >>/var/dspam/group fi # add user "nospam" to administrators: grep -q "nospam" /var/www/dspam/html/admins || echo "nospam" >>/var/www/dspam/html/admins # Udela si to instalak sam, nebo ne?? # chown -R dspam:dspam /var/www/dspam chmod 755 /var/www/dspam chmod 644 /var/www/dspam/html/* chmod 754 /var/www/dspam/html/*.cgi chmod 644 /var/www/dspam/html/templates/* chmod 755 /var/www/dspam/html chmod 755 /var/www/dspam/html/templates /sbin/ldconfig %postun [ $1 -eq 0 -a -f /etc/mail/sendmail_pre-dspam.mc ] && { mv /etc/mail/sendmail.mc /etc/mail/sendmail_post-dspam.mc cp /etc/mail/sendmail_pre-dspam.mc /etc/mail/sendmail.mc } /sbin/service sendmail condrestart >/dev/null 2>&1 /sbin/ldconfig %post devel -p /sbin/ldconfig %postun devel -p /sbin/ldconfig %clean [ "$RPM_BUILD_ROOT" != "/" ] && rm -rf $RPM_BUILD_ROOT %changelog * Tue Apr 6 2010 Franta Hanzlik - some improvements in post/postun scripts * Sun Mar 28 2010 Franta Hanzlik - pwauth and mod+authnz_external are built as independent RPMs * Sun Sep 24 2006 Franta Hanzlik - external post script