experimental/SFEpostfix.spec: - add SpamAssassin filter.sh, protect
authortom68
Sun, 26 Apr 2009 15:25:10 +0000
changeset 1835 92e4335cbbf6
parent 1834 d798d56cc8bd
child 1836 abc4e7d08c33
experimental/SFEpostfix.spec: - add SpamAssassin filter.sh, protect config files with %class(renamenew), add patch2 postfix-02-solarize-startscript.diff for init-script used by SMF manifest (temporary solution), add Requires: SUNWswmt to get class preserve (may be removed again in the future)
experimental/SFEpostfix.spec
ext-sources/i.renamenew
ext-sources/postfix-spamassassin-wiki.apache.org-filter.sh
ext-sources/postfix.xml
patches/postfix-02-solarize-startscript.diff
--- a/experimental/SFEpostfix.spec	Sat Apr 25 02:03:24 2009 +0000
+++ b/experimental/SFEpostfix.spec	Sun Apr 26 15:25:10 2009 +0000
@@ -5,6 +5,9 @@
 # note: this spec derived partly from the provided postfix.spec, you might update this by comparing with vimdiff SFEpostfix.spec BUILD/postfix-*/tmp/postfix.spec
 # note: it also takes several files from the original source-rpm line postfix.spec, make-postfix.spec, postfix-aliases
 
+##TODO## think on using SUNWsndmr:/etc/mail/aliases file to get the Solaris standard aliases mapping
+#        and setting this file to be %class(renamenew) protected at upgrade/re-install time
+
 %include Solaris.inc
 
 
@@ -34,7 +37,7 @@
 Source:                  ftp://ftp.porcupine.org/mirrors/postfix-release/official/postfix-%{version}.tar.gz
 Source2:                 http://ftp.wl0.org/official/2.5/SRPMS/postfix-%{version}-1.src.rpm
 Source3:                 postfix.xml
-Source4:                 i.renamenew
+Source5:                 postfix-spamassassin-wiki.apache.org-filter.sh
 Patch1:			postfix-01-make-postfix.spec.diff
 Patch2:			postfix-02-solarize-startscript.diff
 
@@ -49,9 +52,13 @@
 #we need to create user/group-IDs first in preinstall of %{name}-root to get proper verification of file owners
 Requires: %{name}-root
 
+#%config %class(preserve)
+Requires: SUNWswmt
+
 %package root
 Summary:                 %{summary} - / filesystem
 SUNW_BaseDir:            /
+SUNW_PkgType:		root
 %include default-depend.inc
 
 #variables altered from postfix.spec
@@ -139,6 +146,12 @@
 #postfix manifest
 cp -p %{SOURCE3} postfix.xml
 
+#filter-script for calling spamassassin (activate manually, see pkgbuild wiki)
+#it uses the useraccount spamvac to store email with high spam scores for later
+#review or manual deletion
+#see more alternatives on pkgbuild wiki or your favorite internet search engine
+cp -p %{SOURCE5} tmp/filter.sh
+
 (cd tmp; bash make-postfix.spec)
 
 %patch2 -p1
@@ -554,10 +567,15 @@
 mkdir -p ${RPM_BUILD_ROOT}/var/svc/manifest/site/
 cp postfix.xml ${RPM_BUILD_ROOT}/var/svc/manifest/site/
 
+#this filters email trough spamassassin
+chmod a+rx tmp/filter.sh
+cp -p tmp/filter.sh ${RPM_BUILD_ROOT}/%{_libexecdir}/postfix/filter.sh
+
 %{?pkgbuild_postprocess: %pkgbuild_postprocess -v -c "%{version}:%{jds_version}:%{name}:$RPM_ARCH:%(date +%%Y-%%m-%%d):%{support_level}" $RPM_BUILD_ROOT}
 
 
 
+
 %clean
 rm -rf $RPM_BUILD_ROOT
 
@@ -628,12 +646,38 @@
 ) | $BASEDIR/var/lib/postrun/postrun -i -c POSTFIX -a
 
 
+#the script is found automaticly in ext-sources w/o a Source<n> keyword
+%iclass renamenew -f i.renamenew
 
 %files root
 %defattr (-, root, bin)
 %attr (0755, root, sys) %dir %{_sysconfdir}
 %attr (0755, root, sys) %dir %{_sysconfdir}/%{src_name}
-%{_sysconfdir}/%{src_name}/*
+#%{_sysconfdir}/%{src_name}/*
+%class(renamenew) %{_sysconfdir}/%{src_name}/master.cf
+%class(renamenew) %{_sysconfdir}/%{src_name}/main.cf
+%class(renamenew) %{_sysconfdir}/%{src_name}/aliases
+%{_sysconfdir}/%{src_name}/examples
+%{_sysconfdir}/%{src_name}/bounce.cf.default
+%{_sysconfdir}/%{src_name}/access
+%{_sysconfdir}/%{src_name}/postfix-script
+%{_sysconfdir}/%{src_name}/readme
+%{_sysconfdir}/%{src_name}/transport
+%{_sysconfdir}/%{src_name}/header_checks
+%{_sysconfdir}/%{src_name}/postfix.spec.cf
+%{_sysconfdir}/%{src_name}/postfix-files
+%{_sysconfdir}/%{src_name}/README.rpm
+%{_sysconfdir}/%{src_name}/html
+%{_sysconfdir}/%{src_name}/LICENSE
+%{_sysconfdir}/%{src_name}/virtual
+%{_sysconfdir}/%{src_name}/postfix-chroot.sh
+%{_sysconfdir}/%{src_name}/TLS_LICENSE
+%{_sysconfdir}/%{src_name}/main.cf.default
+%{_sysconfdir}/%{src_name}/generic
+%{_sysconfdir}/%{src_name}/relocated
+%{_sysconfdir}/%{src_name}/makedefs.out
+%{_sysconfdir}/%{src_name}/canonical
+%{_sysconfdir}/%{src_name}/post-install
 # only for oldtimers the original init.d/postfix script - *not* tested on Solaris
 # this is %{_sysconfdir}/init.d
 %attr (0755, root, sys) %dir %{initdir}
@@ -703,6 +747,12 @@
 
 
 %changelog
+* Sat Apr 25 2009 - Thomas Wagner
+- add Source5 filter.sh to run spamassassin - see your extra configuration steps on pkgbuild wiki usage tips
+- placed formerly Source4 "i.renamenew" in ext-sources for saving configuration in case of package upgrade/reinstall
+- add %iclass(renamenew) for main.cf, master.cf, aliases (unused in this case, see /etc/mail/aliases originating from SUNWsndmr package
+- add patch2 postfix-02-solarize-startscript.diff
+- add Requires: SUNWswmt to get class preserve for configuration files (better/preferred would be: renamenew)
 * Fri Apr 17 2009 - Thomas Wagner
 - unresolved: install-order is important: -root first, then base package (or file owner/group verifaction fails w/o user/groupnames on the system)
 - change postfix userid to be in group "other"
@@ -714,4 +764,4 @@
 * Thu Jan 22 2009 - Thomas Wagner
 - %doc made monstrous 
 * Sun Jan 2009 - Thomas Wagner
-- Initial spec, parts derived from postfix.spec from the original SRPM
+e Initial spec, parts derived from postfix.spec from the original SRPM
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ext-sources/i.renamenew	Sun Apr 26 15:25:10 2009 +0000
@@ -0,0 +1,44 @@
+#!/bin/sh
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+#
+# Copyright (c) 2000 by Sun Microsystems, Inc.
+# All rights reserved.
+#
+#ident	"@(#)i.renamenew	1.3	06/03/18 SMI"
+#
+TAG=new
+CLEANUP_FILE=/tmp/CLEANUP
+
+while read src dest
+do
+	if [ ! -f $dest ] ; then
+		cp $src $dest
+	else
+		cmp -s $src $dest
+		if [ $? != 0 ] ; then
+			cp $src $dest.${TAG}
+			echo "EXISTING_FILE_PRESERVED: ${dest} ${dest}.${TAG}" \
+			>> ${CLEANUP_FILE}
+		fi
+	fi
+done
+exit 0
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ext-sources/postfix-spamassassin-wiki.apache.org-filter.sh	Sun Apr 26 15:25:10 2009 +0000
@@ -0,0 +1,50 @@
+#!/bin/bash
+
+# source: http://wiki.apache.org/spamassassin/IntegratedSpamdInPostfix
+# changes: changed from /bin/sh to /bin/bash, logger remove -s, /usr/sbin/sendmail.postfix
+# [email protected]
+
+# filter.sh
+#
+# This script redirects mail flagged as spam to a separate account
+# You must first create a user account named "spamvac" to hold the flagged mail
+
+SENDMAIL="/usr/sbin/sendmail.postfix -i"
+SPAMASSASSIN=/usr/bin/spamc
+COMMAND="$SENDMAIL $@"
+#If your SQL preferences set to "user"
+USER=`echo $COMMAND | awk '{ print $NF }' | sed 's/@.*$//'`
+#If your SQL preferences set to "user@domain"
+#USER=`echo $COMMAND | awk '{ print $NF }'`
+
+NEW_COMMAND=`echo $COMMAND | awk '{ $6 = "spamvac"; NF = 6; print }'`
+
+    /usr/bin/logger -p mail.warning -t filter "filter.sh called with $*"
+# Exit codes from <sysexits.h>
+EX_TEMPFAIL=75
+EX_UNAVAILABLE=69
+umask 077
+
+OUTPUT="`mktemp /tmp/mailfilter.XXXXXXXXXX`"
+
+if [ "$?" != 0 ]; then
+    /usr/bin/logger -p mail.warning -t filter "Unable to create temporary file."
+    exit $EX_TEMPFAIL
+fi
+
+# Clean up when done or when aborting.
+trap "rm -f $OUTPUT" EXIT TERM
+
+$SPAMASSASSIN -x -E -u $USER > $OUTPUT
+return="$?"
+if [ "$return" = 1 ]; then
+    $NEW_COMMAND < $OUTPUT
+    exit $?
+elif [ "$return" != 0 ]; then
+    /usr/bin/logger -p mail.warning -t filter "Temporary SpamAssassin failure (spamc returned $return)"
+    exit $EX_TEMPFAIL
+fi
+
+$SENDMAIL "$@" < $OUTPUT
+exit $?
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ext-sources/postfix.xml	Sun Apr 26 15:25:10 2009 +0000
@@ -0,0 +1,135 @@
+<?xml version="1.0"?>
+<!--
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+-->
+<!DOCTYPE service_bundle SYSTEM "/usr/share/lib/xml/dtd/service_bundle.dtd.1">
+<!--
+	Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
+	Use is subject to license terms.
+
+	#ident	"@(#)postfix.xml	0.1	20090417"
+
+	NOTE:  This service manifest is not editable; its contents will
+	be overwritten by package or patch operations, including
+	operating system upgrade.  Make customizations in a different
+	file.
+-->
+
+<service_bundle type='manifest' name='SFEpostfix:postfix'>
+
+<service name='site/postfix' type='service' version='1'>
+
+	<create_default_instance enabled='false' />
+
+	<single_instance />
+
+	<dependency name='net-loopback' grouping='require_any'
+			restart_on='none' type='service'>
+		<service_fmri value='svc:/network/loopback' />
+	</dependency>
+
+<!--
+	<dependency name='net-service' grouping='require_all'
+			restart_on='none' type='service'>
+		<service_fmri value='svc:/network/service'/>
+	</dependency>
+-->
+
+<!--
+	<dependency name='net-physical' grouping='require_all'
+			restart_on='none' type='service'>
+		<service_fmri value='svc:/network/physical' />
+	</dependency>
+-->
+
+	<dependency name='filesystem-local' grouping='require_all'
+			restart_on='none' type='service'>
+		<service_fmri value='svc:/system/filesystem/local' />
+	</dependency>
+
+	<dependency name='name-services' grouping='require_all'
+	                restart_on='refresh' type='service'>
+		<service_fmri value='svc:/milestone/name-services' />
+	</dependency>
+
+<!--
+	<dependency name='identity' grouping='optional_all'
+	                restart_on='refresh' type='service'>
+		<service_fmri value='svc:/system/identity:domain' />
+	</dependency>
+-->
+
+	<dependency name='system-log' grouping='optional_all'
+	                restart_on='none' type='service'>
+		<service_fmri value='svc:/system/system-log' />
+	</dependency>
+
+	<!--
+	If autofs is enabled, wait for it to get users' home
+	directories.
+	-->
+	<dependency name='autofs' grouping='optional_all'
+		    restart_on='none' type='service'>
+			<service_fmri value='svc:/system/filesystem/autofs' />
+	</dependency>
+
+	<dependent name='postfix_multi-user' grouping='optional_all'
+			restart_on='none'>
+		<service_fmri value='svc:/milestone/multi-user' />
+	</dependent>
+
+	<exec_method type='method' name='start'
+		exec='/etc/init.d/postfix start'
+		timeout_seconds='180' />
+
+	<exec_method type='method' name='stop'
+		exec='/etc/init.d/postfix stop'
+		timeout_seconds='60' />
+
+	<exec_method type='method' name='restart'
+		exec='/etc/init.d/postfix reload'
+		timeout_seconds='60' />
+
+	<stability value='Unstable' />
+
+<!--
+	<property_group name='general' type='framework'>
+			<propval name='action_authorization' type='astring'
+				value='solaris.smf.manage.sendmail' />
+	</property_group>
+-->
+
+	<template>
+		<common_name>
+			<loctext xml:lang='C'>
+			Postfix Mailserver
+			</loctext>
+		</common_name>
+		
+		<documentation>
+			<manpage title='postfix' section='1'
+			    manpath='/usr/share/man' />
+		</documentation>
+	</template>
+</service>
+
+</service_bundle>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/patches/postfix-02-solarize-startscript.diff	Sun Apr 26 15:25:10 2009 +0000
@@ -0,0 +1,55 @@
+--- virtual/tmp/postfix-etc-init.d-postfix	Fri Apr 17 20:52:22 2009
++++ virtual/tmp/postfix	Fri Apr 17 20:28:06 2009
+@@ -17,15 +17,22 @@
+ # 23/11/00: Changes & suggestions by Ajay Ramaswamy <[email protected]>
+ # 20/01/01: Changes to fall in line with RedHat 7.0 style
+ # 23/02/01: Fix a few untidy problems with help from Daniel Roesen.
++# 17/04/09: Solaris fixes (SFE)
+ 
+ # Source function library.
+-. /etc/rc.d/init.d/functions
++#. /etc/rc.d/init.d/functions
++function success {
++echo "successfull started postfix"
++}
++function failure {
++echo "successfull started postfix"
++}
+ 
+ # Source networking configuration.
+-. /etc/sysconfig/network
++#. /etc/sysconfig/network
+ 
+ # Check that networking is up.
+-[ ${NETWORKING} = "no" ] && exit 0
++#[ ${NETWORKING} = "no" ] && exit 0
+ 
+ [ -x /usr/sbin/postfix ] || exit 0
+ [ -d /etc/postfix ] || exit 0
+@@ -38,7 +45,7 @@
+ 	echo -n "Starting postfix: "
+ 	/usr/sbin/postfix start 2>/dev/null 1>&2 && success || failure
+ 	RETVAL=$?
+-	[ $RETVAL -eq 0 ] && touch /var/lock/subsys/postfix
++	[ $RETVAL -eq 0 ] && touch /var/run/postfix
+         echo
+ 	return $RETVAL
+ }
+@@ -48,7 +55,7 @@
+ 	echo -n "Shutting down postfix: "
+ 	/usr/sbin/postfix stop 2>/dev/null 1>&2 && success || failure
+ 	RETVAL=$?
+-	[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/postfix
++	[ $RETVAL -eq 0 ] && rm -f /var/run/postfix
+ 	echo
+ 	return $RETVAL
+ }
+@@ -108,7 +115,7 @@
+   	status master
+ 	;;
+   condrestart)
+-	# don't use /var/lock/subsys/postfix, check for postfix running directly
++	# don't use /var/run/postfix, check for postfix running directly
+ 	daemon_directory=$(postconf -h daemon_directory)
+ 	$daemon_directory/master -t 2>/dev/null && : || restart
+ 	;;