The current RHEL/CentOS 5 package has one flaw: it was compiled without Sieve support. However, with a bit of rpm magic, the package can be rebuilt and produces an additional sieve package.
The current RHEL/CentOS 5 version has a rather old dovecot, 1.0.7. Even worse, the plugin for Sieve wasn't included in this build. Of course, given the old version of dovecot, an update to a newer version with Sieve is worth a thought; however, there are situations where that is simply not an option.
In such cases you can still rebuild the old package with a modified rpm file: download the source RPM, install it with
rpm -Uvh dovecot-1.0.7-7.el5.src.rpm
get the diff from below and apply it to the spec file:
patch < dovecot.diff
Download the sources as given in the now modified spec file to your SOURCES directory, and rebuild the package:
rpmbuild -ba dovecot.spec
and welcome the new sieve plugin dovecot-sieve-1.0.4-7.x86_64.rpm. Install it and continue as usual. And as a small help for writing Sieve scripts: you can verify them on various online services like the one from the PHP Sieve library.
Be careful, however: you have to maintain this package on your own - especially when a dovecot update comes along or when the sieve plugin code is updated. Do bear in mind, though, that this information, as with all howtos, should be followed at your own discretion; it comes with no warranty, and might eat your cats.
And here is the patch for the spec file:
--- dovecot.old.spec 2010-03-11 09:59:38.598277799 +0100
+++ dovecot.spec 2010-03-11 09:58:08.639526842 +0100
@@ -1,7 +1,10 @@
%define upstream 1.0.7
+%define sieve_upstream 1.0.4
%define pkg_version 1.0.7
%define my_release 7
%define pkg_release %{my_release}%{?dist}
+%define pkg_sieve_version 1.0.4
+%define pkg_sieve_release %{my_release}%{?dist}
Summary: Dovecot Secure imap server
Name: dovecot
@@ -12,6 +15,7 @@
%define build_postgres 1
%define build_mysql 1
+%define sieve_name dovecot-sieve
Source: http://dovecot.org/releases/%{name}-%{upstream}.tar.gz
Source1: dovecot.init
@@ -22,6 +26,7 @@
Source6: perfect_maildir.pl
Source7: dovecot-REDHAT-FAQ.txt
Source8: dovecot.sysconfig
+Source9: http://dovecot.org/releases/sieve/%{sieve_name}-%{sieve_upstream}.tar.gz
Patch100: dovecot-1.0.7-default-settings.patch
Patch102: dovecot-1.0.rc2-pam-setcred.patch
Patch103: dovecot-1.0.beta2-mkcert-permissions.patch
@@ -80,6 +85,16 @@
primarily in mind. It also contains a small POP3 server. It supports mail
in either of maildir or mbox formats.
+%package sieve
+Requires: %{name}
+Summary: CMU Sieve plugin for dovecot LDA
+Group: System Environment/Daemons
+Version: %{pkg_sieve_version}
+Release: %{pkg_sieve_release}
+
+%description sieve
+This package provides the CMU Sieve plugin for dovecot LDA.
+
%prep
%setup -q -n %{name}-%{upstream}
@@ -94,6 +109,8 @@
%patch503 -p1 -b .CVE-2008-4577
%patch504 -p1 -b .CVE-2008-4870
+%setup -q -n %{name}-%{upstream} -D -T -a 9
+
%build
rm -f ./configure
libtoolize -f
@@ -115,6 +132,16 @@
make %{?_smp_mflags}
+cd %{sieve_name}-%{sieve_upstream}
+rm -f ./configure
+libtoolize -f
+autoreconf
+%configure \
+ INSTALL_DATA="install -c -p -m644" \
+ --with-dovecot=../
+
+make %{?_smp_mflags}
+
%install
rm -rf $RPM_BUILD_ROOT
make install DESTDIR=$RPM_BUILD_ROOT
@@ -169,6 +196,11 @@
mv $RPM_BUILD_ROOT%{docdir} $RPM_BUILD_ROOT%{docdir}-%{version}
mkdir -p $RPM_BUILD_ROOT/var/lib/dovecot
+# dovecot-sieve
+pushd %{sieve_name}-%{sieve_upstream}
+make install DESTDIR=$RPM_BUILD_ROOT
+popd
+
%pre
/usr/sbin/useradd -c "dovecot" -u %{dovecot_uid} -s /sbin/nologin -r -d /usr/libexec/dovecot dovecot 2>/dev/null || :
@@ -243,6 +275,9 @@
%attr(0750,root,dovecot) %{docdir}-%{version}/examples/mkcert.sh
%attr(0750,dovecot,dovecot) %dir /var/lib/dovecot
+%files sieve
+%defattr(-,root,root)
+%{_libdir}/%{name}/lda/lib90_cmusieve_plugin.so
%changelog
* Mon Nov 24 2008 Michal Hlavinka <mhlavink@redhat.com> - 1.0.7-7



Roland, you are a star - you've saved me a lot of problems. danke a million for publishing this nice workaround!
Robin
P.S my cats seem ok so far but I'll be keeping an eye on them
Thanks for the kind words ;-)
Your pastebin appears to have expired. There is no diff at the link provieded.
Thanks for the hint, it is fixed :-)
# pwd
/usr/src/redhat/SPECS
# ls
dovecot.diff dovecot.spec
# patch patch: **** Only garbage was found in the patch input.
Thoughts?
terry, please check the diff file with an editor. Also, make sure that you download that file with wget or curl, maybe you get an erro by copy&paste?
Weird...
Pretty sure the copy/paste is a straight from the pastebin to notepad to vi. Well, I just tried it couple a times again. Still same thing.
If I wget/curl the pastebin URL it gets all the HTML codes in there too.
If you want, just e-mail it to me and I'll try it that way. Thanks!
I'm so sorry, but i see "patch patch: **** Only garbage was found in the patch input" too... :(
I try wget, curl and copy/paste of course. Can You help me?
My OS:
CentOS release 5.5 (Final)
2.6.18-194.3.1.el5 #1 SMP Thu May 13 13:08:30 EDT 2010 x86_64 x86_64 x86_64 GNU/Linux
Arseniy, please check if you copy&paste the patch if there are new empty spaces in the patch field - and check the text file with an editor to make sure everything works. Otherwise you can create the patch yourself, that are just a few lines :)
Weird...
Pretty sure the copy/paste is a straight from the pastebin to notepad to vi. Well, I just tried it couple a times again. Still same thing.
If I wget/curl the pastebin URL it gets all the HTML codes in there too.
If you want, just e-mail it to me and I'll try it that way. Thanks!
Yeah, I don't really have the time to investigate what's going on, but I will replace the link with something else and additionally send you an e-mail.
hey man, nice blog...really like it and added to bookmarks. keep up with good work
where can I find the patch file because pastebin.org don't exist pastebin.com doesn't have this file, hope to hear from you real soon
Hey Joan,
since we never really got rid of the pastebin problems I now attached the patch to the article itsself.
Regards,
Roland
Hi Roland,
Thanks, your howto made life easy. :-)
I had a bit of trouble getting the patch to work:
The main things to fix were:
- The '@@' at the start of the position markers are missing, i.e. the patch has ' -1,7 +1,10 @@' not '@@ -1,7 +1,10 @@'
- There is a line of context missing before the marker on line 46 (@@ -94,6 +109,8 @@). Adding a blank line before line 45 matches up with the spec file from dovecot-1.0.7-7.el5.src.rpm:
44: %prep 45: 46: %setup -q -n %{name}-%{upstream} 47: @@ -94,6 +109,8 @@The error message was:
Cheers,
Linden