rpms/cyrus-imapd/devel README.autocreate-cyrus-2.3, NONE, 1.1 allow_auth_plain_proxying.patch, NONE, 1.1 cyrus-imapd-2.2.12-dam_invalid_id-christos.patch, NONE, 1.1 cyrus-imapd-2.2.12-munge8bit.patch, NONE, 1.1 cyrus-imapd-2.2.12-no_transfig.patch, NONE, 1.1 cyrus-imapd-2.2.12-notify_sms.patch, NONE, 1.1 cyrus-imapd-2.3.1-authid_normalize.patch, NONE, 1.1 cyrus-imapd-2.3.1-autocreate-0.10-0.diff, NONE, 1.1 cyrus-imapd-2.3.1-autosievefolder-0.6-0.diff, NONE, 1.1 cyrus-imapd-2.3.1-backend_sigsegv.patch, NONE, 1.1 cyrus-imapd-2.3.1-config_defaults.patch, NONE, 1.1 cyrus-imapd-2.3.1-make_md5.patch, NONE, 1.1 cyrus-imapd-2.3.1-make_md5_defaults.patch, NONE, 1.1 cyrus-imapd-2.3.1-replication_policycheck.patch, NONE, 1.1 cyrus-imapd-2.3.1-rmquota+deletemailbox-0.2-1.diff, NONE, 1.1 cyrus-imapd-2.3.1.tar.gz.sig, NONE, 1.1 cyrus-imapd-README.skiplist_recovery, NONE, 1.1 cyrus-imapd.imap-2.3.x-conf, NONE, 1.1 skiplist.py, NONE, 1.1 .cvsignore, 1.2, 1.3 cyrus-imapd-README.RPM, 1.1, 1.2 cyrus-imapd.cvt_cyrusdb_all, 1.1, 1.2 cyrus-imapd.init, 1.1, 1.2 cyrus-imapd.rpm_set_permissions, 1.1, 1.2 cyrus-imapd.spec, 1.6, 1.7 sources, 1.3, 1.4 README.autocreate-cyrus-2.2, 1.1, NONE cyrus-imapd-2.1.9-fdatasync.patch, 1.1, NONE cyrus-imapd-2.2.10-rmquota+deletemailbox-0.1.diff, 1.1, NONE cyrus-imapd-2.2.12-autocreate-0.9.2.diff, 1.1, NONE cyrus-imapd-2.2.12-autosievefolder-0.6.diff, 1.1, NONE cyrus-imapd-2.2.12.tar.gz.sig, 1.1, NONE cyrus-imapd-2.2.4-OE-seenstate.patch, 1.1, NONE cyrus-imapd-2.2.4-munge8bit.patch, 1.1, NONE cyrus-imapd-db.cfg, 1.1, NONE cyrus-imapd-gcc4.patch, 1.1, NONE cyrus-imapd.imap-2.2.x-conf, 1.1, NONE

John Dennis (jdennis) fedora-extras-commits at redhat.com
Tue Feb 28 20:04:02 UTC 2006


Author: jdennis

Update of /cvs/extras/rpms/cyrus-imapd/devel
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv24040

Modified Files:
	.cvsignore cyrus-imapd-README.RPM cyrus-imapd.cvt_cyrusdb_all 
	cyrus-imapd.init cyrus-imapd.rpm_set_permissions 
	cyrus-imapd.spec sources 
Added Files:
	README.autocreate-cyrus-2.3 allow_auth_plain_proxying.patch 
	cyrus-imapd-2.2.12-dam_invalid_id-christos.patch 
	cyrus-imapd-2.2.12-munge8bit.patch 
	cyrus-imapd-2.2.12-no_transfig.patch 
	cyrus-imapd-2.2.12-notify_sms.patch 
	cyrus-imapd-2.3.1-authid_normalize.patch 
	cyrus-imapd-2.3.1-autocreate-0.10-0.diff 
	cyrus-imapd-2.3.1-autosievefolder-0.6-0.diff 
	cyrus-imapd-2.3.1-backend_sigsegv.patch 
	cyrus-imapd-2.3.1-config_defaults.patch 
	cyrus-imapd-2.3.1-make_md5.patch 
	cyrus-imapd-2.3.1-make_md5_defaults.patch 
	cyrus-imapd-2.3.1-replication_policycheck.patch 
	cyrus-imapd-2.3.1-rmquota+deletemailbox-0.2-1.diff 
	cyrus-imapd-2.3.1.tar.gz.sig 
	cyrus-imapd-README.skiplist_recovery 
	cyrus-imapd.imap-2.3.x-conf skiplist.py 
Removed Files:
	README.autocreate-cyrus-2.2 cyrus-imapd-2.1.9-fdatasync.patch 
	cyrus-imapd-2.2.10-rmquota+deletemailbox-0.1.diff 
	cyrus-imapd-2.2.12-autocreate-0.9.2.diff 
	cyrus-imapd-2.2.12-autosievefolder-0.6.diff 
	cyrus-imapd-2.2.12.tar.gz.sig 
	cyrus-imapd-2.2.4-OE-seenstate.patch 
	cyrus-imapd-2.2.4-munge8bit.patch cyrus-imapd-db.cfg 
	cyrus-imapd-gcc4.patch cyrus-imapd.imap-2.2.x-conf 
Log Message:
bring up to Simon Matter's 2.3.1-2 version



--- NEW FILE README.autocreate-cyrus-2.3 ---
Cyrus IMAP autocreate Inbox patch
----------------------------------

NOTE : This patch has been created at the University of Athens. For more info, as well 
as more patches on Cyrus IMAPD server, please visit http://email.uoa.gr/ 

The design of Cyrus IMAP server does not predict the automatic creation of users'
INBOX folders. The creation of a user's INBOX is considered to be an external task,
that has to be completed as part of the user email account creation procedure. 
Hence, to create a new email account the site administrator has to:

  a) Include the new account in the user database for the authentication procedure
     (e.g. sasldb, shadow, mysql, ldap).
  b) Create the corresponding INBOX folder. 

Alternatively, the user, if succesfully authenticated, may create his own INBOX folder,
as long as the configuration of the site allows it (see "autocreatequota" in imapd.conf).
Unlike what not careful readers may think, enabling the "autocreatequota" option, doesn't 
lead to the automatic INBOX folder creation by Cyrus IMAP server.
In fact, "autocreate" means that the IMAP clients are allowed to automatically create 
the user INBOX. 

This patch adds the functionality of automatic creation of the users' INBOX folders into
the Cyrus IMAP server. It is implemented as two features, namely the  "create on login"
and "create on post".
 


Create on login
===============
This feauture provides automatic creation of a user's INBOX folder when all of the 
following requirements are met:

i)  The user has succesfully passed the authentication procedure.

ii) The user's authorisation ID (typically the same as the user's
authentication ID)  doesn't belong to the imap_admins or admins
accounts (see imapd.conf).

iii) The "autocreatequota" option in the imap configuration file 
has been set to a non zero value. 

iv) The corresponding to the user's authorisation ID INBOX folder
does not exist.

The user's first login is the most typical case when all four requirements are met. 
Note that if the authenticated ID is allowed to proxy to another account for which 
all of the above requirements are met, the corresponding INBOX folder for that account 
will be created.



Create on post
==============
This feauture provides automatic creation of a user's INBOX folder when all of the 
following requirements are met. 

i) An email message addressed to the user has been received.  

ii) The recipient is not any of the imap_admins or admins accounts. 
Note that passing emails to admins or imap_admins accounts from 
the MTA to LMTP should be avoided in any case.

iii) The recipient's INBOX does not exist.

iv) The "autocreatequota" option in the imap configuration file 
has been set to a non zero value. 

v) The "createonpost" option in the imap configuration file 
has been switched on. 


Besides the automatic creation of INBOX folder, additional functionalities are
provided:

  (A) Automatic creation of INBOX subfolders controlled by "autocreateinboxfolders"
configuration option. eg 

autocreateinboxfolders: sent|drafts|spam|templates

  (B) Automatic subscription of INBOX subfolders controlled by "autosubscribeinboxfolders"
configuration option. eg

autosubscribeinboxfolders: sent|spam

Obviously, only subscription to subfolders included in the "autocreateinboxfolder"
list is meaningful. 

  (C) Automatic subscription to shared folders (bulletin boards). The user gets
automatically subscribed to the shared folders declared in the "autosubscribesharedfolders"
configuration option in imapd.conf.
eg autosubscribesharedfolders: public_folder | public_folder.subfolder

In order the above action to succeed, the shared folder has to pre-exist the INBOX creation
and the user must have the appropriate permissions in order to be able to subscribe to the
shared folder.

* A new config option has been added. 'autosubscribe_all_sharedfolders' is a yes/no
option. When set to yes, the user is automatically subscribed to all shared folders one 
has permission to subscribe to. Please, note that when this option is set to yes, then
'autosubscribesharedfolders' option is overriden.

  (D) Automatic creation of a predefined default sieve script.

This is very useful when a default sieve script is used for every user. Usually, a
default anti-spam script may me be written in a file and copied to each user
sieve scripts upon the INBOX creation. The imapd.conf options that have been added
are 'autocreate_sieve_script', 'autocreate_sieve_compiledscript' and 
'generate_compiled_sieve_script'. 

autocreate_sieve_script configuration option refers to the full path of the file 
that contains the sieve script. The default value is null and if no file is defined,
then no default script is created upon INBOX creation. (The feature is disabled)
eg autocreate_sieve_script: /etc/default_sieve_script

autocreate_sieve_compiledscript configuration option refers to the full path of the
file that contains the bytecode compiled sieve script. If this filename is defined
in imapd.conf and the file exists, then it is automatically copied in the user's sieve
directory. If it is not defined, then a bytecode sieve script gets on the fly compiled
by the daemon. 
eg autocreate_sieve_compiledscript: /etc/default_sieve_script.bc

generate_compiled_sieve_script is a boolean option that triggers the compilation of the 
source sieve script to bytecode sieve script. The file that the bytecode script will
be saved is pointed by autocreate_sieve_compiledscript.

Ways of compiling a sieve script : 
1. Compile a sieve script using the standard sievec utility, distributed by CMU
2. Compile a sieve script using the compile_sieve utility, released by UoA. This 
   tool is almost identical to the sievec utility, with the difference that it 
   reads the input and output file from autocreate_sieve_script and 
   autocreate_sieve_compiledscript options in imapd.conf
3. Let cyrus create a compiled sieve script using a source script. Cyrus can be
   instructed to save the compiled script any time a compiled script does not exist.

NOTES : 
1. In order this functionality to work, the following requirements must have been met:
   - 'sieveusehomedir' option must be 'no' in the configuration (default).
   - 'sievedir' option must have a valid value.
2. Currently, this patch checks the validity of the source script while generating a 
   bytecode compiled script, but not the validity of the bytecode sieve script file.
   The administrator should make sure that the provided files contain a valid sieve
   script as well as the compiled script is updated every time the source script changes.


  (E) The administrator may control for which users and/or groups may the INBOXes 
automatically be created. The autocreate_users option restricts the groups
for which the patch will create the mailboxes. 

The default value of autocreate_users is anyone. So, if not set at all, the patch will 
work for all users. However, one may set:

autocreate_users: user1 user2 group:group1 group:group2

In that case, the INBOX will be created only for user1, user2 and the users that belong 
to group1 and group2. 

More refined control per service is provided by the options imap_autocreate_users,
pop3_autocreate_users and lmtp_autocreate_users. These options override the 
autocreate_users option and offer per service control.

Example: 
One may want to restrict the create on post functionality only for a specific group
of users. To achieve this, the following lines must be added in the imapd.conf file:

createonpost: yes
lmtp_autocreate_users: group:groupname



Issues to be considered 
=======================

I) In order to use the create on post feauture one should be absolutely sure that: 
a) The MTA checks the validity of the email recipient before sending the email to
LMTP. This is an RFC821 requirement. This usually expands to "the mta should be 
able to use the account database as user mailbox database". 
b) Only authorised accounts/services can talk to LMTP.

II) Especially in the case of imap logins, the current patch implementation checks
for the INBOX folder existence upon login, causing an extra mailbox lookup in most 
of the cases. 
A better approach would be to chase the "IMAP_MAILBOX_NONEXISTENT" error code and
check if the error is associated with an INBOX folder. However, this would mess up
Cyrus code. The way it was implemented may not have been the most performance
optimised, but it produces a much cleaner and simple patch.



Virtual Domains Support
=======================

Virtual domains are supported by all versions of the patch for cyrus-imapd-2.2.1-BETA and 
later. However, it is not possible to declare different INBOX subfolders to be created or 
shared folders to be subscribed to for every domain.



Things to be done
=================

1. Support MUPDATE

It is within the developers' intentions to support the mupdate protocol, but serious 
design issues on future cyrus releases have to resolved first.

2. Select different attributes (quota, partition, sieve filter, etc) depending on the group
a user belongs to. 

For more information and updates please visit http://email.uoa.gr/projects/cyrus/autocreate


allow_auth_plain_proxying.patch:

--- NEW FILE allow_auth_plain_proxying.patch ---
--- imap/imapd.c
+++ imap/imapd.c	2004/01/16 12:25:51
@@ -578,8 +578,11 @@
 	fatal("SASL failed initializing: sasl_server_new()", EC_TEMPFAIL);
     }
 
-    /* never allow plaintext, since IMAP has the LOGIN command */
-    secprops = mysasl_secprops(SASL_SEC_NOPLAINTEXT);
+    if( (config_getswitch(IMAPOPT_ALLOWPLAINWITHOUTTLS) == 0) ) {
+        secprops = mysasl_secprops(SASL_SEC_NOPLAINTEXT);
+    } else {
+        secprops = mysasl_secprops(0);
+    }
     sasl_setprop(imapd_saslconn, SASL_SEC_PROPS, secprops);
     sasl_setprop(imapd_saslconn, SASL_SSF_EXTERNAL, &extprops_ssf);
 
--- lib/imapoptions
+++ lib/imapoptions	2004/01/16 12:27:52
@@ -684,6 +684,9 @@
    to set this to yes, especially if OpenLDAP is used as authentication
    source. */
 
+{ "allowplainwithouttls", 0, SWITCH }
+/* Allow plain login mechanism without an encrypted connection. */
+
 /*
 .SH SEE ALSO
 .PP

cyrus-imapd-2.2.12-dam_invalid_id-christos.patch:

--- NEW FILE cyrus-imapd-2.2.12-dam_invalid_id-christos.patch ---
--- cyrus-imapd-2.2.12/lib/acl_afs.c.orig	2005-07-14 17:12:53 +0300
+++ cyrus-imapd-2.2.12/lib/acl_afs.c	2005-07-14 17:17:44 +0300
@@ -119,12 +119,17 @@
     char *thisid, *nextid;
     int oldaccess = 0;
     char *rights;
+    int identifier_found = 0;
+    int identifier_overridden = 0;
 
     /* Convert 'identifier' into canonical form */
     if (*identifier == '-') {
 	char *canonid = auth_canonifyid(identifier+1, 0);
-	if (!canonid) {
+	if (!canonid && access != 0L) {
 	    return -1;
+	} else if (!canonid && access == 0L) {
+	    canonid = identifier+1;
+	    identifier_overridden = 1;
 	}
 	newidentifier = xmalloc(strlen(canonid)+2);
 	newidentifier[0] = '-';
@@ -135,9 +140,15 @@
 	}
     }
     else {
+	newidentifier = xmalloc(strlen(identifier)+1);
+	strlcpy(newidentifier, identifier, strlen(identifier)+1);
+	
 	identifier = auth_canonifyid(identifier, 0);
-	if (!identifier) {
+	if (!identifier && access != 0L) {
 	    return -1;
+	} else if(!identifier && access == 0L) {
+            identifier = newidentifier;
+            identifier_overridden = 1;
 	}
 	if (canonproc) {
 	    access = canonproc(canonrock, identifier, access);
@@ -165,6 +176,7 @@
 	*nextid++ = '\0';
 
 	if (strcmp(identifier, thisid) == 0) {
+            identifier_found = 1;
 	    oldaccess = cyrus_acl_strtomask(rights);
 	    break;
 	}
@@ -172,6 +184,15 @@
 	nextid[-1] = '\t';
     }
 
+    /* 
+     * In case we have overridden the canonification of the
+     * identifier, but still the identifier does not exist in
+     * the mailboxdb, then return error as normally expected.
+     */
+    if(identifier_overridden && !identifier_found) {
+        return -1;
+    }
+
     switch (mode) {
     case ACL_MODE_SET:
 	break;

cyrus-imapd-2.2.12-munge8bit.patch:

--- NEW FILE cyrus-imapd-2.2.12-munge8bit.patch ---
diff -Naur cyrus-imapd-2.2.12/doc/man/deliver.8.html cyrus-imapd-2.2.12.munge8bit/doc/man/deliver.8.html
--- cyrus-imapd-2.2.12/doc/man/deliver.8.html	2005-02-14 19:02:17.000000000 +0100
+++ cyrus-imapd-2.2.12.munge8bit/doc/man/deliver.8.html	2005-06-18 19:02:39.000000000 +0200
@@ -223,13 +223,15 @@
 <td width="10%"></td>
 <td width="89%">
 <p>Depending on the setting of <b>reject8bit</b> in
-<b>imapd.conf(5)</b>, deliver either rejects messages with
-8-bit-set characters in the headers or changes these
-characters to &lsquo;X&rsquo;. This is because such
-characters can&rsquo;t be interpreted since the character
-set is not known, although some communities not well-served
-by US-ASCII assume that those characters can be used to
-represent characters not present in US-ASCII.</p>
+<b>imapd.conf(5)</b>, deliver either rejects/accepts
+messages with 8-bit-set characters in the headers. If we
+accept messages with 8-bit-set characters in the headers,
+then depending on the setting of <b>munge8bit</b>, these
+characters are either left un-touched or changed to &lsquo;X&rsquo;. This
+is because such characters can&rsquo;t be interpreted since
+the character set is not known, although some communities
+not well-served by US-ASCII assume that those characters can
+be used to represent characters not present in US-ASCII.</p>
 <!-- INDENTATION -->
 <p>A method for encoding 8-bit-set characters is provided by
 RFC 2047.</p>
diff -Naur cyrus-imapd-2.2.12/doc/man/imapd.conf.5.html cyrus-imapd-2.2.12.munge8bit/doc/man/imapd.conf.5.html
--- cyrus-imapd-2.2.12/doc/man/imapd.conf.5.html	2005-02-14 19:02:18.000000000 +0100
+++ cyrus-imapd-2.2.12.munge8bit/doc/man/imapd.conf.5.html	2005-06-18 18:59:46.000000000 +0200
@@ -2562,7 +2562,7 @@
 <td width="80%">
 <p>If enabled, lmtpd rejects messages with 8-bit characters
 in the headers. Otherwise, 8-bit characters are changed to
-&lsquo;X&rsquo;. (A proper soultion to non-ASCII characters
+&lsquo;X&rsquo;. (A proper solution to non-ASCII characters
 in headers is offered by RFC 2047 and its predecessors.)</p>
 </td>
 </table>
diff -Naur cyrus-imapd-2.2.12/imap/message.c cyrus-imapd-2.2.12.munge8bit/imap/message.c
--- cyrus-imapd-2.2.12/imap/message.c	2004-09-16 19:58:54.000000000 +0200
+++ cyrus-imapd-2.2.12.munge8bit/imap/message.c	2005-06-18 18:58:33.000000000 +0200
@@ -227,6 +227,7 @@
     int n;
     int sawcr = 0, sawnl;
     int reject8bit = config_getswitch(IMAPOPT_REJECT8BIT);
+    int munge8bit = config_getswitch(IMAPOPT_MUNGE8BIT);
     int inheader = 1, blankline = 1;
 
     while (size) {
@@ -262,7 +263,7 @@
 			/* We have been configured to reject all mail of this
 			   form. */
 			if (!r) r = IMAP_MESSAGE_CONTAINS8BIT;
-		    } else {
+		    } else if (munge8bit) {
 			/* We have been configured to munge all mail of this
 			   form. */
 			*p = 'X';
diff -Naur cyrus-imapd-2.2.12/imap/spool.c cyrus-imapd-2.2.12.munge8bit/imap/spool.c
--- cyrus-imapd-2.2.12/imap/spool.c	2004-10-27 22:40:50.000000000 +0200
+++ cyrus-imapd-2.2.12.munge8bit/imap/spool.c	2005-06-18 18:58:33.000000000 +0200
@@ -140,6 +140,7 @@
     state s = NAME_START;
     int r = 0;
     int reject8bit = config_getswitch(IMAPOPT_REJECT8BIT);
+    int munge8bit = config_getswitch(IMAPOPT_MUNGE8BIT);
     const char **skip = NULL;
 
     if (namelen == 0) {
@@ -266,7 +267,7 @@
 			   form. */
 			r = IMAP_MESSAGE_CONTAINS8BIT;
 			goto ph_error;
-		    } else {
+		    } else if (munge8bit) {
 			/* We have been configured to munge all mail of this
 			   form. */
 			c = 'X';
diff -Naur cyrus-imapd-2.2.12/lib/imapoptions cyrus-imapd-2.2.12.munge8bit/lib/imapoptions
--- cyrus-imapd-2.2.12/lib/imapoptions	2004-07-21 21:07:45.000000000 +0200
+++ cyrus-imapd-2.2.12.munge8bit/lib/imapoptions	2005-06-18 18:58:33.000000000 +0200
@@ -458,6 +458,12 @@
 { "mboxlist_db", "skiplist", STRINGLIST("flat", "berkeley", "skiplist")}
 /* The cyrusdb backend to use for the mailbox list. */
 
+{ "munge8bit", 1, SWITCH }
+/* If enabled, lmtpd munges messages with 8-bit characters.  These characters
+   are changed to `X'.  If \fBreject8bit\fR is enabled, setting \fBmunge8bit\fR
+   has no effect.  (A proper solution to non-ASCII characters in headers is
+   offered by RFC 2047 and its predecessors.) */
+
 # xxx badly worded
 { "mupdate_connections_max", 128, INT }
 /* The max number of connections that a mupdate process will allow, this
@@ -670,9 +676,7 @@
 
 { "reject8bit", 0, SWITCH }
 /* If enabled, lmtpd rejects messages with 8-bit characters in the
-   headers.  Otherwise, 8-bit characters are changed to `X'.  (A
-   proper soultion to non-ASCII characters in headers is offered by  
-   RFC 2047 and its predecessors.) */
+   headers. */
 
 { "rfc2046_strict", 0, SWITCH }
 /* If enabled, imapd will be strict (per RFC 2046) when matching MIME
diff -Naur cyrus-imapd-2.2.12/man/deliver.8 cyrus-imapd-2.2.12.munge8bit/man/deliver.8
--- cyrus-imapd-2.2.12/man/deliver.8	2004-06-21 20:40:10.000000000 +0200
+++ cyrus-imapd-2.2.12.munge8bit/man/deliver.8	2005-06-18 18:58:33.000000000 +0200
@@ -147,8 +147,10 @@
 Accept messages using the LMTP protocol.
 .SH NOTES
 Depending on the setting of \fBreject8bit\fR in \fBimapd.conf(5)\fR, deliver
-either rejects messages with 8-bit-set characters in the headers or 
-changes these characters to `X'.
+either rejects/accepts messages with 8-bit-set characters in the headers.
+If we accept messages with 8-bit-set characters in the headers, then depending
+on the setting of \fBmunge8bit\fR, these characters are either left un-touched
+or changed to .
 This is because such characters can't be interpreted since the
 character set is not known, although some communities not well-served by
 US-ASCII assume that those characters can be used to represent characters not
diff -Naur cyrus-imapd-2.2.12/man/imapd.conf.5 cyrus-imapd-2.2.12.munge8bit/man/imapd.conf.5
--- cyrus-imapd-2.2.12/man/imapd.conf.5	2005-02-14 19:02:16.000000000 +0100
+++ cyrus-imapd-2.2.12.munge8bit/man/imapd.conf.5	2005-06-18 18:59:08.000000000 +0200
@@ -551,7 +551,7 @@
 .IP "\fBreject8bit:\fR 0" 5
 If enabled, lmtpd rejects messages with 8-bit characters in the
 headers.  Otherwise, 8-bit characters are changed to `X'.  (A
-proper soultion to non-ASCII characters in headers is offered by  
+proper solution to non-ASCII characters in headers is offered by  
 RFC 2047 and its predecessors.) 
 .IP "\fBrfc2046_strict:\fR 0" 5
 If enabled, imapd will be strict (per RFC 2046) when matching MIME

cyrus-imapd-2.2.12-no_transfig.patch:

--- NEW FILE cyrus-imapd-2.2.12-no_transfig.patch ---
diff -Naur cyrus-imapd-2.2.12.orig/doc/Makefile.dist cyrus-imapd-2.2.12/doc/Makefile.dist
--- cyrus-imapd-2.2.12.orig/doc/Makefile.dist	Wed Oct 22 20:50:04 2003
+++ cyrus-imapd-2.2.12/doc/Makefile.dist	Wed Nov  9 13:23:58 2005
@@ -13,7 +13,7 @@
 
 	rm -f groff-html-*.png pod2htm*
 
-	fig2dev -L png murder.fig murder.png
-	fig2dev -L png netnews.fig netnews.png
+#	fig2dev -L png murder.fig murder.png
+#	fig2dev -L png netnews.fig netnews.png
 
 	(cd text; make)

cyrus-imapd-2.2.12-notify_sms.patch:

--- NEW FILE cyrus-imapd-2.2.12-notify_sms.patch ---
diff -Naur cyrus-imapd-2.2.12.orig/doc/man/imapd.conf.5.html cyrus-imapd-2.2.12/doc/man/imapd.conf.5.html
--- cyrus-imapd-2.2.12.orig/doc/man/imapd.conf.5.html	2005-02-14 19:02:18.000000000 +0100
+++ cyrus-imapd-2.2.12/doc/man/imapd.conf.5.html	2005-08-16 13:32:36.000000000 +0200
@@ -2751,6 +2751,24 @@
 <tr valign="top" align="left">
 <td width="10%"></td>
 <td width="89%">
+<p><b>sendsms:</b> /usr/bin/sendsms</p></td>
+</table></p>
+<!-- INDENTATION -->
+<table width="100%" border=0 rules="none" frame="void"
+       cols="2" cellspacing="0" cellpadding="0">
+<tr valign="top" align="left">
+<td width="19%"></td>
+<td width="80%">
+<p>The pathname of the sendsms executable. Sieve invokes
+sendsms for sending SMS notifications.</p>
+</td>
+</table>
+<!-- INDENTATION -->
+<p><table width="100%" border=0 rules="none" frame="void"
+       cols="2" cellspacing="0" cellpadding="0">
+<tr valign="top" align="left">
+<td width="10%"></td>
+<td width="89%">
 <p><b>servername:</b> &lt;none&gt;</p></td>
 </table></p>
 <!-- INDENTATION -->
diff -Naur cyrus-imapd-2.2.12.orig/doc/man/notifyd.8.html cyrus-imapd-2.2.12/doc/man/notifyd.8.html
--- cyrus-imapd-2.2.12.orig/doc/man/notifyd.8.html	2005-02-14 19:02:19.000000000 +0100
+++ cyrus-imapd-2.2.12/doc/man/notifyd.8.html	2005-08-16 13:17:33.000000000 +0200
@@ -181,6 +181,18 @@
 <td width="11%"></td>
 <td width="10%">
 
+<p><b>sms</b></p>
+</td>
+<td width="77%">
+
+<p>Send the notification as SMS. This method can ONLY be used in
+a Sieve &rsquo;notify&rsquo; action as it requires a
+<i>sms:</i> URL to be specified as an <i>:option</i>.</p>
+</td>
+<tr valign="top" align="left">
+<td width="11%"></td>
+<td width="10%">
+
 <p><b>zephyr</b></p>
 </td>
 <td width="77%">
diff -Naur cyrus-imapd-2.2.12.orig/lib/imapoptions cyrus-imapd-2.2.12/lib/imapoptions
--- cyrus-imapd-2.2.12.orig/lib/imapoptions	2004-07-21 21:07:45.000000000 +0200
+++ cyrus-imapd-2.2.12/lib/imapoptions	2005-08-16 13:27:08.000000000 +0200
@@ -721,6 +721,10 @@
 /* The pathname of the sendmail executable.  Sieve invokes sendmail
    for sending rejections, redirects and vacation responses. */
 
+{ "sendsms", "/usr/bin/sendsms", STRING }
+/* The pathname of the sendsms executable.  Sieve invokes sendsms
+   for sending SMS notifications. */
+
 { "servername", NULL, STRING }
 /* This is the hostname visible in the greeting messages of the POP,
    IMAP and LMTP daemons. If it is unset, then the result returned
diff -Naur cyrus-imapd-2.2.12.orig/man/imapd.conf.5 cyrus-imapd-2.2.12/man/imapd.conf.5
--- cyrus-imapd-2.2.12.orig/man/imapd.conf.5	2005-02-14 19:02:16.000000000 +0100
+++ cyrus-imapd-2.2.12/man/imapd.conf.5	2005-08-16 13:35:40.000000000 +0200
@@ -590,6 +590,9 @@
 .IP "\fBsendmail:\fR /usr/lib/sendmail" 5
 The pathname of the sendmail executable.  Sieve invokes sendmail
 for sending rejections, redirects and vacation responses. 
+.IP "\fBsendsms:\fR /usr/bin/sendsms" 5
+The pathname of the sendsms executable.  Sieve invokes sendsms
+for sending SMS notifications. 
 .IP "\fBservername:\fR <none>" 5
 This is the hostname visible in the greeting messages of the POP,
 IMAP and LMTP daemons. If it is unset, then the result returned
diff -Naur cyrus-imapd-2.2.12.orig/man/notifyd.8 cyrus-imapd-2.2.12/man/notifyd.8
--- cyrus-imapd-2.2.12.orig/man/notifyd.8	2003-08-10 01:43:14.000000000 +0200
+++ cyrus-imapd-2.2.12/man/notifyd.8	2005-08-16 13:18:03.000000000 +0200
@@ -110,6 +110,11 @@
 Sieve 'notify' action as it requires a \fImailto:\fR URL to be
 specified as an \fI:option\fR.
 .TP
+.B sms
+Send the notification as SMS.  This method can ONLY be used in a
+Sieve 'notify' action as it requires a \fIsms:\fR URL to be
+specified as an \fI:option\fR.
+.TP
 .B zephyr
 Send the notification as a zephyrgram.  If used in a Sieve 'notify'
 action, additional recipients can be specified as \fI:options\fR.
diff -Naur cyrus-imapd-2.2.12.orig/notifyd/Makefile.in cyrus-imapd-2.2.12/notifyd/Makefile.in
--- cyrus-imapd-2.2.12.orig/notifyd/Makefile.in	2004-05-28 20:03:06.000000000 +0200
+++ cyrus-imapd-2.2.12/notifyd/Makefile.in	2005-08-16 15:18:45.000000000 +0200
@@ -82,7 +82,7 @@
 install:
 	$(INSTALL) -m 755 notifyd $(DESTDIR)$(service_path)
 
-OBJS= notifyd.o notify_null.o notify_log.o notify_mailto.o notify_zephyr.o
+OBJS= notifyd.o notify_null.o notify_log.o notify_mailto.o notify_sms.o notify_zephyr.o
 
 notifytest: notifytest.o
 	$(CC) $(LDFLAGS) -o notifytest \
diff -Naur cyrus-imapd-2.2.12.orig/notifyd/notifyd.h cyrus-imapd-2.2.12/notifyd/notifyd.h
--- cyrus-imapd-2.2.12.orig/notifyd/notifyd.h	2003-02-13 21:15:48.000000000 +0100
+++ cyrus-imapd-2.2.12/notifyd/notifyd.h	2005-08-16 12:58:17.000000000 +0200
@@ -48,6 +48,7 @@
 #include "notify_null.h"
 #include "notify_log.h"
 #include "notify_mailto.h"
+#include "notify_sms.h"
 #include "notify_zephyr.h"
 
 /* Notify method dispatch table definition */
@@ -64,6 +65,7 @@
     { "null",	notify_null },		/* do nothing */
     { "log",	notify_log },		/* use syslog (for testing) */
     { "mailto",	notify_mailto },	/* send an email */
+    { "sms",	notify_sms },		/* send an sms */
 #ifdef HAVE_ZEPHYR
     { "zephyr",	notify_zephyr },	/* send a zephyrgram */
 #endif
diff -Naur cyrus-imapd-2.2.12.orig/notifyd/notify_sms.c cyrus-imapd-2.2.12/notifyd/notify_sms.c
--- cyrus-imapd-2.2.12.orig/notifyd/notify_sms.c	1970-01-01 01:00:00.000000000 +0100
+++ cyrus-imapd-2.2.12/notifyd/notify_sms.c	2005-08-16 18:43:56.000000000 +0200
@@ -0,0 +1,111 @@
+/* notify_sms.c -- SMS notification method
+ * Simon Matter
+ */
+/*
+ * Copyright (c) 1998-2003 Carnegie Mellon University.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer. 
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * 3. The name "Carnegie Mellon University" must not be used to
+ *    endorse or promote products derived from this software without
+ *    prior written permission. For permission or any other legal
+ *    details, please contact  
+ *      Office of Technology Transfer
+ *      Carnegie Mellon University
+ *      5000 Forbes Avenue
+ *      Pittsburgh, PA  15213-3890
+ *      (412) 268-4387, fax: (412) 268-7395
+ *      tech-transfer at andrew.cmu.edu
+ *
+ * 4. Redistributions of any form whatsoever must retain the following
+ *    acknowledgment:
+ *    "This product includes software developed by Computing Services
+ *     at Carnegie Mellon University (http://www.cmu.edu/computing/)."
+ *
+ * CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO
+ * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS, IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY BE LIABLE
+ * FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
+ * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
+ * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * notify_sms is based on code from notify_mailto by Ken Murchison.
+ * Copyright (c) 2005 Simon Matter, Invoca Systems.
+ * Release 2005081600/2.2.12
+*/
+
+#include <config.h>
+
+#include "notify_sms.h"
+
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+
+#include "global.h"
+#include "libconfig.h"
+#include "sieve_interface.h"
+
+static int global_outgoing_count = 0;
+
+char* notify_sms(const char *class __attribute__((unused)),
+		    const char *priority __attribute__((unused)),
+		    const char *user __attribute__((unused)),
+		    const char *mailbox __attribute__((unused)),
+		    int nopt, char **options,
+		    const char *message)
+{
+    FILE *sm;
+    const char *smbuf[10];
+    int sm_stat;
+    pid_t sm_pid;
+    int fds[2];
+
+    /* XXX check/parse options (sms URI) */
+    if (nopt < 1)
+	return strdup("NO sms URI not specified");
+
+    smbuf[0] = "sendsms";
+    smbuf[1] = options[0];
+    smbuf[2] = NULL;
+
+    pipe(fds);
+    if ((sm_pid = fork()) == 0) {
+	/* i'm the child! run sendsms! */
+	close(fds[1]);
+	/* make the pipe be stdin */
+	dup2(fds[0], 0);
+	execv(config_getstring(IMAPOPT_SENDSMS), (char **) smbuf);
+
+	/* if we're here we suck */
+	return strdup("NO sms couldn't exec");
+    }
+    /* i'm the parent */
+    close(fds[0]);
+    sm = fdopen(fds[1], "w");
+
+    if (!sm)
+	return strdup("NO sms could not spawn sendsms process");
+
+    fprintf(sm, message);
+
+    fclose(sm);
+    while (waitpid(sm_pid, &sm_stat, 0) < 0);
+
+    /* XXX check for sendsms exit code */
+
+    return strdup("OK sms notification successful");
+}
diff -Naur cyrus-imapd-2.2.12.orig/notifyd/notify_sms.h cyrus-imapd-2.2.12/notifyd/notify_sms.h
--- cyrus-imapd-2.2.12.orig/notifyd/notify_sms.h	1970-01-01 01:00:00.000000000 +0100
+++ cyrus-imapd-2.2.12/notifyd/notify_sms.h	2005-08-16 14:57:16.000000000 +0200
@@ -0,0 +1,62 @@
+/* notify_sms.h -- SMS notification method
+ * Simon Matter
+ */
+/*
+ * Copyright (c) 1998-2003 Carnegie Mellon University.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer. 
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * 3. The name "Carnegie Mellon University" must not be used to
+ *    endorse or promote products derived from this software without
+ *    prior written permission. For permission or any other legal
+ *    details, please contact  
+ *      Office of Technology Transfer
+ *      Carnegie Mellon University
+ *      5000 Forbes Avenue
+ *      Pittsburgh, PA  15213-3890
+ *      (412) 268-4387, fax: (412) 268-7395
+ *      tech-transfer at andrew.cmu.edu
+ *
+ * 4. Redistributions of any form whatsoever must retain the following
+ *    acknowledgment:
+ *    "This product includes software developed by Computing Services
+ *     at Carnegie Mellon University (http://www.cmu.edu/computing/)."
+ *
+ * CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO
+ * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS, IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY BE LIABLE
+ * FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
+ * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
+ * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * notify_sms is based on code from notify_mailto by Ken Murchison.
+ * Copyright (c) 2005 Simon Matter, Invoca Systems.
+ * Release 2005081600/2.2.12
+ *
+ */
+
+#ifndef _NOTIFY_SMS_H_
+#define _NOTIFY_SMS_H_
+
+#include <config.h>
+
+/* the only option should be a sms URI */
+char* notify_sms(const char *class __attribute__((unused)),
+		    const char *priority __attribute__((unused)),
+		    const char *user __attribute__((unused)),
+		    const char *mailbox __attribute__((unused)),
+		    int nopt, char **options,
+		    const char *message);
+
+#endif /* _NOTIFY_SMS_H_ */

cyrus-imapd-2.3.1-authid_normalize.patch:

--- NEW FILE cyrus-imapd-2.3.1-authid_normalize.patch ---
diff -Naur cyrus-imapd-2.3.1.orig/lib/auth_unix.c cyrus-imapd-2.3.1/lib/auth_unix.c
--- cyrus-imapd-2.3.1.orig/lib/auth_unix.c	Wed Feb 16 22:06:50 2005
+++ cyrus-imapd-2.3.1/lib/auth_unix.c	Wed Dec 21 13:50:05 2005
@@ -157,10 +157,12 @@
 size_t len;
 {
     static char retbuf[81];
+    char backup[81];
     struct group *grp;
     char sawalpha;
     char *p;
     int username_tolower = 0;
+    int ic,rbc;
 
     if(!len) len = strlen(identifier);
     if(len >= sizeof(retbuf)) return NULL;
@@ -210,6 +212,22 @@
     /* now we don't */
     /* if (!sawalpha) return NULL;  */
 
+    if( (libcyrus_config_getswitch(CYRUSOPT_NORMALIZEUID) == 1) ) {
+        strcpy(backup,retbuf);
+       /* remove leading blanks */
+       for(ic=0; isblank(backup[ic]); ic++);
+       for(rbc=0; backup[ic]; ic++) {
+            retbuf[rbc] = ( isalpha(backup[ic]) ?
+                 tolower(backup[ic]) : backup[ic] );
+            rbc++;
+       }
+       retbuf[rbc] = '\0';
+       /* remove trailing blanks */
+       for(--rbc; isblank(retbuf[rbc]); rbc--) {
+            retbuf[rbc] = '\0';
+       }
+    }
+
     return retbuf;
 }
 
diff -Naur cyrus-imapd-2.3.1.orig/lib/imapoptions cyrus-imapd-2.3.1/lib/imapoptions
--- cyrus-imapd-2.3.1.orig/lib/imapoptions	Tue Dec 13 20:36:11 2005
+++ cyrus-imapd-2.3.1/lib/imapoptions	Wed Dec 21 13:50:05 2005
@@ -990,6 +990,11 @@
    interface, otherwise the user is assumed to be in the default
    domain (if set). */
 
+{ "normalizeuid", 0, SWITCH }
+/* Lowercase uid and strip leading and trailing blanks. It is recommended
+   to set this to yes, especially if OpenLDAP is used as authentication
+   source. */
+
 /*
 .SH SEE ALSO
 .PP
diff -Naur cyrus-imapd-2.3.1.orig/lib/libcyr_cfg.c cyrus-imapd-2.3.1/lib/libcyr_cfg.c
--- cyrus-imapd-2.3.1.orig/lib/libcyr_cfg.c	Tue Dec 13 20:36:12 2005
+++ cyrus-imapd-2.3.1/lib/libcyr_cfg.c	Wed Dec 21 13:50:05 2005
@@ -127,6 +127,11 @@
       CFGVAL(const char *, "c"),
       CYRUS_OPT_STRING },
 
+    { CYRUSOPT_NORMALIZEUID,
+      CFGVAL(long, 1),
+      CYRUS_OPT_SWITCH },
+
+
     { CYRUSOPT_LAST, { NULL }, CYRUS_OPT_NOTOPT }
 };
 
diff -Naur cyrus-imapd-2.3.1.orig/lib/libcyr_cfg.h cyrus-imapd-2.3.1/lib/libcyr_cfg.h
--- cyrus-imapd-2.3.1.orig/lib/libcyr_cfg.h	Tue Dec 13 20:36:12 2005
+++ cyrus-imapd-2.3.1/lib/libcyr_cfg.h	Wed Dec 21 13:51:37 2005
@@ -101,6 +101,8 @@
     CYRUSOPT_BERKELEY_TXNS_MAX,
     /* RFC 2086 right which allows DELETE ("c") */
     CYRUSOPT_DELETERIGHT,
+    /* Lowercase uid and strip leading and trailing blanks (OFF) */
+    CYRUSOPT_NORMALIZEUID,
 
     CYRUSOPT_LAST
     

cyrus-imapd-2.3.1-autocreate-0.10-0.diff:

--- NEW FILE cyrus-imapd-2.3.1-autocreate-0.10-0.diff ---
diff -Naur cyrus-imapd-2.3.1/README.autocreate cyrus-imapd-2.3.1-autocreate/README.autocreate
--- cyrus-imapd-2.3.1/README.autocreate	1970-01-01 02:00:00 +0200
+++ cyrus-imapd-2.3.1-autocreate/README.autocreate	2006-01-19 03:53:40 +0200
@@ -0,0 +1,211 @@
+Cyrus IMAP autocreate Inbox patch
+----------------------------------
+
+NOTE : This patch has been created at the University of Athens. For more info, as well 
+as more patches on Cyrus IMAPD server, please visit http://email.uoa.gr/ 
+
+The design of Cyrus IMAP server does not predict the automatic creation of users'
+INBOX folders. The creation of a user's INBOX is considered to be an external task,
+that has to be completed as part of the user email account creation procedure. 
+Hence, to create a new email account the site administrator has to:
+
+  a) Include the new account in the user database for the authentication procedure
+     (e.g. sasldb, shadow, mysql, ldap).
+  b) Create the corresponding INBOX folder. 
+
+Alternatively, the user, if succesfully authenticated, may create his own INBOX folder,
+as long as the configuration of the site allows it (see "autocreatequota" in imapd.conf).
+Unlike what not careful readers may think, enabling the "autocreatequota" option, doesn't 
+lead to the automatic INBOX folder creation by Cyrus IMAP server.
+In fact, "autocreate" means that the IMAP clients are allowed to automatically create 
+the user INBOX. 
+
+This patch adds the functionality of automatic creation of the users' INBOX folders into
+the Cyrus IMAP server. It is implemented as two features, namely the  "create on login"
+and "create on post".
+ 
+
+
+Create on login
+===============
+This feauture provides automatic creation of a user's INBOX folder when all of the 
+following requirements are met:
+
+i)  The user has succesfully passed the authentication procedure.
+
+ii) The user's authorisation ID (typically the same as the user's
+authentication ID)  doesn't belong to the imap_admins or admins
+accounts (see imapd.conf).
+
+iii) The "autocreatequota" option in the imap configuration file 
+has been set to a non zero value. 
+
+iv) The corresponding to the user's authorisation ID INBOX folder
+does not exist.
+
+The user's first login is the most typical case when all four requirements are met. 
+Note that if the authenticated ID is allowed to proxy to another account for which 
+all of the above requirements are met, the corresponding INBOX folder for that account 
+will be created.
+
+
+
+Create on post
+==============
+This feauture provides automatic creation of a user's INBOX folder when all of the 
+following requirements are met. 
+
+i) An email message addressed to the user has been received.  
+
+ii) The recipient is not any of the imap_admins or admins accounts. 
+Note that passing emails to admins or imap_admins accounts from 
+the MTA to LMTP should be avoided in any case.
+
+iii) The recipient's INBOX does not exist.
+
+iv) The "autocreatequota" option in the imap configuration file 
+has been set to a non zero value. 
+
+v) The "createonpost" option in the imap configuration file 
+has been switched on. 
+
+
+Besides the automatic creation of INBOX folder, additional functionalities are
+provided:
+
+  (A) Automatic creation of INBOX subfolders controlled by "autocreateinboxfolders"
+configuration option. eg 
+
+autocreateinboxfolders: sent|drafts|spam|templates
+
+  (B) Automatic subscription of INBOX subfolders controlled by "autosubscribeinboxfolders"
+configuration option. eg
+
+autosubscribeinboxfolders: sent|spam
+
+Obviously, only subscription to subfolders included in the "autocreateinboxfolder"
+list is meaningful. 
+
+  (C) Automatic subscription to shared folders (bulletin boards). The user gets
+automatically subscribed to the shared folders declared in the "autosubscribesharedfolders"
+configuration option in imapd.conf.
+eg autosubscribesharedfolders: public_folder | public_folder.subfolder
+
+In order the above action to succeed, the shared folder has to pre-exist the INBOX creation
+and the user must have the appropriate permissions in order to be able to subscribe to the
+shared folder.
+
+* A new config option has been added. 'autosubscribe_all_sharedfolders' is a yes/no
+option. When set to yes, the user is automatically subscribed to all shared folders one 
+has permission to subscribe to. Please, note that when this option is set to yes, then
+'autosubscribesharedfolders' option is overriden.
+
+  (D) Automatic creation of a predefined default sieve script.
+
+This is very useful when a default sieve script is used for every user. Usually, a
+default anti-spam script may me be written in a file and copied to each user
+sieve scripts upon the INBOX creation. The imapd.conf options that have been added
+are 'autocreate_sieve_script', 'autocreate_sieve_compiledscript' and 
+'generate_compiled_sieve_script'. 
+
+autocreate_sieve_script configuration option refers to the full path of the file 
+that contains the sieve script. The default value is null and if no file is defined,
+then no default script is created upon INBOX creation. (The feature is disabled)
+eg autocreate_sieve_script: /etc/default_sieve_script
+
+autocreate_sieve_compiledscript configuration option refers to the full path of the
+file that contains the bytecode compiled sieve script. If this filename is defined
+in imapd.conf and the file exists, then it is automatically copied in the user's sieve
+directory. If it is not defined, then a bytecode sieve script gets on the fly compiled
+by the daemon. 
+eg autocreate_sieve_compiledscript: /etc/default_sieve_script.bc
+
+generate_compiled_sieve_script is a boolean option that triggers the compilation of the 
+source sieve script to bytecode sieve script. The file that the bytecode script will
+be saved is pointed by autocreate_sieve_compiledscript.
+
+Ways of compiling a sieve script : 
+1. Compile a sieve script using the standard sievec utility, distributed by CMU
+2. Compile a sieve script using the compile_sieve utility, released by UoA. This 
+   tool is almost identical to the sievec utility, with the difference that it 
+   reads the input and output file from autocreate_sieve_script and 
+   autocreate_sieve_compiledscript options in imapd.conf
+3. Let cyrus create a compiled sieve script using a source script. Cyrus can be
+   instructed to save the compiled script any time a compiled script does not exist.
+
+NOTES : 
+1. In order this functionality to work, the following requirements must have been met:
+   - 'sieveusehomedir' option must be 'no' in the configuration (default).
+   - 'sievedir' option must have a valid value.
+2. Currently, this patch checks the validity of the source script while generating a 
+   bytecode compiled script, but not the validity of the bytecode sieve script file.
+   The administrator should make sure that the provided files contain a valid sieve
+   script as well as the compiled script is updated every time the source script changes.
+
+
+  (E) The administrator may control for which users and/or groups may the INBOXes 
+automatically be created. The autocreate_users option restricts the groups
+for which the patch will create the mailboxes. 
+
+The default value of autocreate_users is anyone. So, if not set at all, the patch will 
+work for all users. However, one may set:
+
+autocreate_users: user1 user2 group:group1 group:group2
+
+In that case, the INBOX will be created only for user1, user2 and the users that belong 
+to group1 and group2. 
+
+More refined control per service is provided by the options imap_autocreate_users,
+pop3_autocreate_users and lmtp_autocreate_users. These options override the 
+autocreate_users option and offer per service control.
+
+Example: 
+One may want to restrict the create on post functionality only for a specific group
+of users. To achieve this, the following lines must be added in the imapd.conf file:
+
+createonpost: yes
+lmtp_autocreate_users: group:groupname
+
+
+
+Issues to be considered 
+=======================
+
+I) In order to use the create on post feauture one should be absolutely sure that: 
+a) The MTA checks the validity of the email recipient before sending the email to
+LMTP. This is an RFC821 requirement. This usually expands to "the mta should be 
+able to use the account database as user mailbox database". 
+b) Only authorised accounts/services can talk to LMTP.
+
+II) Especially in the case of imap logins, the current patch implementation checks
+for the INBOX folder existence upon login, causing an extra mailbox lookup in most 
+of the cases. 
+A better approach would be to chase the "IMAP_MAILBOX_NONEXISTENT" error code and
+check if the error is associated with an INBOX folder. However, this would mess up
+Cyrus code. The way it was implemented may not have been the most performance
+optimised, but it produces a much cleaner and simple patch.
+
+
+
+Virtual Domains Support
+=======================
+
+Virtual domains are supported by all versions of the patch for cyrus-imapd-2.2.1-BETA and 
+later. However, it is not possible to declare different INBOX subfolders to be created or 
+shared folders to be subscribed to for every domain.
[...1949 lines suppressed...]
+
 #endif
 
 struct auth_mech auth_krb = 
@@ -377,4 +393,5 @@
     &mymemberof,
     &mynewstate,
     &myfreestate,
+    &mycanonuser,
 };
diff -Naur cyrus-imapd-2.3.1/lib/auth_krb5.c cyrus-imapd-2.3.1-autocreate/lib/auth_krb5.c
--- cyrus-imapd-2.3.1/lib/auth_krb5.c	2005-02-16 23:06:50 +0200
+++ cyrus-imapd-2.3.1-autocreate/lib/auth_krb5.c	2006-01-19 03:53:42 +0200
@@ -197,6 +197,14 @@
     free(auth_state);
 }
 
+static char *mycanonuser(struct auth_state *auth_state)
+{
+    if (auth_state)
+       return auth_state->userid;
+
+    return NULL;
+}
+
 #else /* HAVE_GSSAPI_H */
 
 static int mymemberof(
@@ -225,6 +233,12 @@
 	fatal("Authentication mechanism (krb5) not compiled in", EC_CONFIG);
 }
 
+static char *mycanonuser(
+    struct auth_state *auth_state __attribute__((unused)))
+{
+        fatal("Authentication mechanism (krb5) not compiled in", EC_CONFIG);
+}
+
 #endif
 
 struct auth_mech auth_krb5 = 
@@ -235,4 +249,5 @@
     &mymemberof,
     &mynewstate,
     &myfreestate,
+    &mycanonuser,
 };
diff -Naur cyrus-imapd-2.3.1/lib/auth_pts.c cyrus-imapd-2.3.1-autocreate/lib/auth_pts.c
--- cyrus-imapd-2.3.1/lib/auth_pts.c	2005-02-20 05:23:45 +0200
+++ cyrus-imapd-2.3.1-autocreate/lib/auth_pts.c	2006-01-19 03:53:42 +0200
@@ -347,6 +347,14 @@
     free(auth_state);
 }
 
+static char *mycanonuser(struct auth_state *auth_state)
+{
+    if (auth_state)
+       return auth_state->userid.id;
+
+    return NULL;
+}
+
 struct auth_mech auth_pts = 
 {
     "pts",		/* name */
@@ -355,4 +363,5 @@
     &mymemberof,
     &mynewstate,
     &myfreestate,
+    &mycanonuser,
 };
diff -Naur cyrus-imapd-2.3.1/lib/auth_unix.c cyrus-imapd-2.3.1-autocreate/lib/auth_unix.c
--- cyrus-imapd-2.3.1/lib/auth_unix.c	2005-02-16 23:06:50 +0200
+++ cyrus-imapd-2.3.1-autocreate/lib/auth_unix.c	2006-01-19 03:53:42 +0200
@@ -264,6 +264,16 @@
     free((char *)auth_state);
 }
 
+static char *mycanonuser(auth_state)
+    struct auth_state *auth_state;
+{
+    if (auth_state)
+         return auth_state->userid;
+
+    return NULL;
+}
+
+
 
 struct auth_mech auth_unix = 
 {
@@ -273,4 +283,5 @@
     &mymemberof,
     &mynewstate,
     &myfreestate,
+    &mycanonuser,
 };
diff -Naur cyrus-imapd-2.3.1/lib/imapoptions cyrus-imapd-2.3.1-autocreate/lib/imapoptions
--- cyrus-imapd-2.3.1/lib/imapoptions	2005-12-13 21:36:11 +0200
+++ cyrus-imapd-2.3.1-autocreate/lib/imapoptions	2006-01-19 03:53:42 +0200
@@ -172,6 +172,55 @@
 /* Number of seconds to wait before returning a timeout failure when
    performing a client connection (e.g. in a murder enviornment) */
 
+{ "createonpost", 0, SWITCH }
+/* If yes, when lmtpd receives an incoming mail for an INBOX that does not exist,
+   then the INBOX is automatically created by lmtpd. */
+
+{ "autocreateinboxfolders", NULL, STRING }
+/* If a user does not have an INBOX created then the INBOX as well as some INBOX 
+   subfolders are created under two conditions.
+     1. The user logins via the IMAP or the POP3 protocol. (autocreatequota option must have a nonzero value)
+     2. A message arrives for the user through the LMTPD protocol.(createonpost option must be yes)
+   autocreateinboxfolders is a list of INBOX's subfolders separated by a "|", that 
+   are automatically created by the server under the previous two situations. */
+
+{ "autosubscribeinboxfolders", NULL, STRING }
+/* A list of folder names, separated by "|", that the users get automatically subscribed to, 
+   when their INBOX is created. These folder names must have been included in the 
+   autocreateinboxfolders option of the imapd.conf. */
+
+{ "autosubscribesharedfolders", NULL, STRING }
+/* A list of shared folders (bulletin boards), separated by "|", that the users get
+   automatically subscribed to, after their INBOX is created. The shared folder must 
+   have been created and the user must have the required permissions to get subscribed 
+   to it. Otherwise, subscribing to the shared folder fails. */
+
+{ "autosubscribe_all_sharedfolders", 0, SWITCH }
+/* If set to yes, the user is automatically subscribed to all shared folders, one has permission
+   to subscribe to. */
+
+{ "autocreate_sieve_script", NULL, STRING }
+/* The full path of a file that contains a sieve script. This script automatically becomes a
+   user's initial default sieve filter script. When this option is not defined, no default 
+   sieve filter is created. The file must be readable by the cyrus daemon. */
+
+{ "autocreate_sieve_compiledscript", NULL, STRING }
+/* The full path of a file that contains a compiled in bytecode sieve script. This script 
+   automatically becomes a user's initial default sieve filter script.  If this option is 
+   not specified, or the filename doesn't exist then the script defined by 
+   autocreate_sieve_script is compiled on the fly and installed as the user's default
+   sieve script */
+
+{ "generate_compiled_sieve_script", 0, SWITCH }
+/* If set to yes and no compiled sieve script file exists, the sieve script which is 
+   compiled on the fly will be saved in the file name that autocreate_sieve_compiledscript 
+   option points to. In order a compiled script to be generated, autocreate_sieve_script and 
+   autocreate_sieve_compiledscript must have valid values */
+
+{ "autocreate_users", "anyone", STRING }
+/* A space separated list of users and/or groups that are allowed their INBOX to be
+   automatically created. */
+
 { "configdirectory", NULL, STRING }
 /* The pathname of the IMAP configuration directory.  This field is
    required. */
diff -Naur cyrus-imapd-2.3.1/notifyd/Makefile.in cyrus-imapd-2.3.1-autocreate/notifyd/Makefile.in
--- cyrus-imapd-2.3.1/notifyd/Makefile.in	2004-05-31 21:22:59 +0300
+++ cyrus-imapd-2.3.1-autocreate/notifyd/Makefile.in	2006-01-19 03:53:42 +0200
@@ -69,10 +69,11 @@
 SERVICE=../master/service.o
 
 IMAP_LIBS = @IMAP_LIBS@ @LIB_RT@
+SIEVE_LIBS = @SIEVE_LIBS@
 IMAP_COM_ERR_LIBS = @IMAP_COM_ERR_LIBS@
 LIB_WRAP = @LIB_WRAP@
 LIBS = @ZEPHYR_LIBS@ @LIBS@ $(IMAP_COM_ERR_LIBS)
-DEPLIBS=../imap/mutex_fake.o ../imap/libimap.a ../lib/libcyrus.a ../lib/libcyrus_min.a @DEPLIBS@
+DEPLIBS=../imap/mutex_fake.o ../imap/libimap.a $(SIEVE_LIBS) ../lib/libcyrus.a ../lib/libcyrus_min.a @DEPLIBS@
 
 PURIFY=/usr/local/bin/purify
 PUREOPT=-best-effort
diff -Naur cyrus-imapd-2.3.1/notifyd/notifyd.c cyrus-imapd-2.3.1-autocreate/notifyd/notifyd.c
--- cyrus-imapd-2.3.1/notifyd/notifyd.c	2005-04-13 18:43:36 +0300
+++ cyrus-imapd-2.3.1-autocreate/notifyd/notifyd.c	2006-01-19 03:53:42 +0200
@@ -97,7 +97,7 @@
 
 #define NOTIFY_MAXSIZE 8192
 
-int do_notify()
+static int do_notify()
 {
     struct sockaddr_un sun_data;
     socklen_t sunlen = sizeof(sun_data);
diff -Naur cyrus-imapd-2.3.1/ptclient/Makefile.in cyrus-imapd-2.3.1-autocreate/ptclient/Makefile.in
--- cyrus-imapd-2.3.1/ptclient/Makefile.in	2005-02-17 20:43:03 +0200
+++ cyrus-imapd-2.3.1-autocreate/ptclient/Makefile.in	2006-01-19 03:53:42 +0200
@@ -57,10 +57,11 @@
 AFS_LDFLAGS = @AFS_LDFLAGS@ @COM_ERR_LDFLAGS@
 AFS_LIBS = @AFS_LIBS@
 IMAP_LIBS = @IMAP_LIBS@ @LIB_RT@
+SIEVE_LIBS = @SIEVE_LIBS@
 LIBS = $(IMAP_LIBS) @COM_ERR_LIBS@
 LIB_SASL = @LIB_SASL@
 LIB_WRAP = @LIB_WRAP@
-DEPLIBS = ../imap/libimap.a ../lib/libcyrus.a ../lib/libcyrus_min.a @DEPLIBS@
+DEPLIBS = ../imap/libimap.a $(SIEVE_LIBS) ../lib/libcyrus.a ../lib/libcyrus_min.a @DEPLIBS@ 
 UTIL_LIBS = ../imap/mutex_fake.o ../imap/cli_fatal.o
 
 LDAP_LIBS=@LDAP_LIBS@

cyrus-imapd-2.3.1-autosievefolder-0.6-0.diff:

--- NEW FILE cyrus-imapd-2.3.1-autosievefolder-0.6-0.diff ---
diff -Naur cyrus-imapd-2.3.1/README.autosievefolder cyrus-imapd-2.3.1-autosieve/README.autosievefolder
--- cyrus-imapd-2.3.1/README.autosievefolder	1970-01-01 02:00:00 +0200
+++ cyrus-imapd-2.3.1-autosieve/README.autosievefolder	2006-01-19 03:29:08 +0200
@@ -0,0 +1,42 @@
+Cyrus IMAP autosievefolder patch
+----------------------------------
+
+NOTE : This patch has been created at the University of Athens. For more info, as well 
+as more patches on Cyrus IMAPD server, please visit http://email.uoa.gr 
+
+
+  When the lmtpd daemon receives an email message prior to delivering it to the 
+INBOX folder of the user, checks if the user has specified sieve filters. If the
+user has specified sieve filters the filters are evaluated. If the message matches
+any of the filters the action that is specified in the filter is executed. If the action 
+is FileInto it is stored in the subfolder specified in the filter. If the 
+subfolder doesn't exist then the message is sent to the INBOX folder of the user.
+
+  With this patch if the folder doesn't exist AND the name of the subfolder is 
+specified in the autosievefolders option, OR the anysievefolder is set to 
+yes in the cyrus-imap configuration file then the subfolder is created and the mail 
+is stored there.
+
+
+Check the following options of the imapd.conf file
+==================================================
+
+* anysievefolder : It must be "yes" in order to permit the autocreation of any 
+INBOX subfolder requested by a sieve filter, through the "fileinto" action. (default = no)
+* autosievefolders : It is a "|" separated list of subfolders of INBOX that will be 
+automatically created, if requested by a sieve filter, through the "fileinto" 
+action. (default = null)
+	i.e. autosievefolders: Junk | Spam
+
+WARNING: anysievefolder, takes precedence over autosievefolders . Which means that if 
+anysievefolder is set to "yes", cyrus will create any INBOX subfolder requested, no-matter what the value of autosievefolders is.
+
+
+Things to be done
+=================
+
+1. Support cyrus wildcards in the autosievefolders option. 
+
+
+For more information and updates please visit http://email.uoa.gr/projects/cyrus/autosievefolder
+
diff -Naur cyrus-imapd-2.3.1/imap/lmtp_sieve.c cyrus-imapd-2.3.1-autosieve/imap/lmtp_sieve.c
--- cyrus-imapd-2.3.1/imap/lmtp_sieve.c	2005-11-21 18:26:54 +0200
+++ cyrus-imapd-2.3.1-autosieve/imap/lmtp_sieve.c	2006-01-19 03:29:13 +0200
@@ -86,6 +86,9 @@
     struct auth_state *authstate;
 } script_data_t;
 
+static int autosieve_subfolder(char *userid, struct auth_state *auth_state,
+                               char *subfolder, struct namespace *namespace);
+
 static char *make_sieve_db(const char *user)
 {
     static char buf[MAX_MAILBOX_PATH+1];
@@ -487,7 +490,20 @@
 			      sd->username, mdata->notifyheader,
 			      namebuf, quotaoverride, 0);
     }
-
+    
+    if (ret == IMAP_MAILBOX_NONEXISTENT) {
+        /* if "plus" folder under INBOX, then try to create it */
+        ret = autosieve_subfolder((char *) sd->username, sd->authstate, namebuf, mdata->namespace);
+
+	/* Try to deliver the mail again. */
+        if (!ret)
+            ret = deliver_mailbox(md->f, mdata->content, mdata->stage, md->size,
+                                  fc->imapflags->flag, fc->imapflags->nflags,
+                                  (char *) sd->username, sd->authstate, md->id,
+                                  sd->username, mdata->notifyheader,
+                                  namebuf, quotaoverride, 0);
+    }
+    
     if (!ret) {
 	snmp_increment(SIEVE_FILEINTO, 1);
 	return SIEVE_OK;
@@ -939,3 +955,80 @@
        we'll do normal delivery */
     return r;
 }
+
+
+#define SEP '|'
+
+static int autosieve_subfolder(char *userid, struct auth_state *auth_state,
+                               char *subfolder, struct namespace *namespace)
+{
+     char option_name_external[MAX_MAILBOX_NAME + 1];
+     char option_name_internal[MAX_MAILBOX_NAME + 1];
+     const char *subf ;
+     char *p, *q, *next_subf;
+     int len, r = 0;
+     int createsievefolder = 0;
+
+    /* Check if subfolder or userid are NULL */
+    if(userid == NULL || subfolder == NULL)
+         return IMAP_MAILBOX_NONEXISTENT;
+
+    syslog(LOG_DEBUG, "autosievefolder: autosieve_subfolder() was called for user %s, folder %s", 
+		    userid, subfolder);
+
+    if (config_getswitch(IMAPOPT_ANYSIEVEFOLDER)) {
+         createsievefolder = 1;
+    } else if ((subf = config_getstring(IMAPOPT_AUTOSIEVEFOLDERS)) != NULL) {
+         /* Roll through subf */
+         next_subf = (char *) subf;
+         while (*next_subf) {
+              for (p = next_subf ; isspace((int) *p) || *p == SEP ; p++);
+              for (next_subf = p ; *next_subf && *next_subf != SEP ; next_subf++);
+              for (q = next_subf ; q > p && (isspace((int) *q) || *q == SEP || !*q); q--);
+
+              if (!*p) continue;
+                    
+              len = q - p + 1;
+             /*
+              * This is a preliminary length check based on the assumption
+              * that the *final* internal format will be something
+              * like user.userid.subfolder(s).
+              */
+              if (len > sizeof(option_name_external) - strlen(userid) - 5)
+                   return IMAP_MAILBOX_BADNAME;
+
+              strlcpy(option_name_external, namespace->prefix[NAMESPACE_INBOX], sizeof(option_name_external));
+	      strncat(option_name_external, p, len);
+                    
+              /* 
+               * Transform the option folder name to internal namespace and compare it
+	       * with what must be created.
+               */
+              r = namespace->mboxname_tointernal(namespace, option_name_external, userid, option_name_internal);
+              if (r) continue;
+
+              if (!strcmp(option_name_internal, subfolder)) {
+                  createsievefolder = 1;
+                  break;
+              }
+         }
+    }
+
+    if (createsievefolder) {
+        /* Folder is already in internal namespace format */
+        r = mboxlist_createmailbox(subfolder, MAILBOX_FORMAT_NORMAL, NULL,
+                                           1, userid, auth_state, 0, 0, 0);
+        if (!r) {
+            mboxlist_changesub(subfolder, userid, auth_state, 1, 1);
+            syslog(LOG_DEBUG, "autosievefolder: User %s, folder %s creation succeeded",
+                                                   userid, subfolder);
+            return 0;
+        } else {
+            syslog(LOG_ERR, "autosievefolder: User %s, folder %s creation failed. %s",
+                                                  userid, subfolder,error_message(r));
+            return r;
+        }
+    } else
+        return IMAP_MAILBOX_NONEXISTENT;
+}
+
diff -Naur cyrus-imapd-2.3.1/lib/imapoptions cyrus-imapd-2.3.1-autosieve/lib/imapoptions
--- cyrus-imapd-2.3.1/lib/imapoptions	2005-12-13 21:36:11 +0200
+++ cyrus-imapd-2.3.1-autosieve/lib/imapoptions	2006-01-19 03:29:15 +0200
@@ -856,6 +856,15 @@
 /* If enabled, lmtpd will look for Sieve scripts in user's home
    directories: ~user/.sieve. */
 
+{ "anysievefolder", 0, SWITCH }
+/* It must be "yes" in order to permit the autocreation of any INBOX subfolder 
+   requested by a sieve filter, through the "fileinto" action. (default = no) */
+
+{ "autosievefolders", NULL, STRING }
+/* It is a "|" separated list of subfolders of INBOX that will be automatically created, 
+   if requested by a sieve filter, through the "fileinto" action. (default = null)
+   i.e. autosievefolders: Junk | Spam */
+
 { "singleinstancestore", 1, SWITCH }
 /* If enabled, imapd, lmtpd and nntpd attempt to only write one copy
    of a message per partition and create hard links, resulting in a

cyrus-imapd-2.3.1-backend_sigsegv.patch:

--- NEW FILE cyrus-imapd-2.3.1-backend_sigsegv.patch ---
diff -Naur cyrus-imapd-2.3.1.orig/imap/backend.c cyrus-imapd-2.3.1/imap/backend.c
--- cyrus-imapd-2.3.1.orig/imap/backend.c	2005-02-25 07:46:14.000000000 +0100
+++ cyrus-imapd-2.3.1/imap/backend.c	2006-01-25 08:10:20.000000000 +0100
@@ -274,7 +274,7 @@
     /* need to (re)establish connection to server or create one */
     int sock = -1;
     int r;
-    int err;
+    int err = -1;
     struct addrinfo hints, *res0 = NULL, *res1 = NULL, *res;
     struct sockaddr_un sunsock;
     char buf[2048], *mechlist = NULL;

cyrus-imapd-2.3.1-config_defaults.patch:

--- NEW FILE cyrus-imapd-2.3.1-config_defaults.patch ---
diff -Naur cyrus-imapd-2.3.1.orig/lib/imapoptions cyrus-imapd-2.3.1/lib/imapoptions
--- cyrus-imapd-2.3.1.orig/lib/imapoptions	2005-12-13 20:36:11.000000000 +0100
+++ cyrus-imapd-2.3.1/lib/imapoptions	2006-01-13 10:17:26.000000000 +0100
@@ -198,9 +198,12 @@
    grant the user the ability to delete a mailbox.  If a user has this
    right, they will automatically be given the new 'x' right. */
 
-{ "duplicate_db", "berkeley-nosync", STRINGLIST("berkeley", "berkeley-nosync", "skiplist") }
+{ "duplicate_db", "skiplist", STRINGLIST("berkeley", "berkeley-nosync", "skiplist") }
 /* The cyrusdb backend to use for the duplicate delivery suppression
-   and sieve. */
+   and sieve.
+.PP
+   Note: This Invoca RPM build uses \fIskiplist\fR by default instead of
+   \fIberkeley-nosync\fR for \fBduplicate_db\fR. */
 
 { "duplicatesuppression", 1, SWITCH }
 /* If enabled, lmtpd will suppress delivery of a message to a mailbox if
@@ -220,12 +223,15 @@
    result in greater responsiveness for the client, especially when
    expunging a large number of messages. */
 
-{ "flushseenstate", 0, SWITCH }
+{ "flushseenstate", 1, SWITCH }
 /* If enabled, changes to the seen state will be flushed to disk
    immediately, otherwise changes will be cached and flushed when the
    mailbox is closed.  This option may be used to fix the problem of
    previously read messages being marked as unread in Microsoft
-   Outlook, at the expense of a loss of performance/scalability. */
+   Outlook, at the expense of a loss of performance/scalability.
+.PP
+   Note: This Invoca RPM build uses \fI1\fR by default instead of
+   \fI0\fR for \fBflushseenstate\fR. */
 
 { "foolstupidclients", 0, SWITCH }
 /* If enabled, only list the personal namespace when a LIST "*" is performed.
@@ -735,8 +741,11 @@
 /* Unix domain socket that ptloader listens on.
    (defaults to configdir/ptclient/ptsock) */
 
-{ "ptscache_db", "berkeley", STRINGLIST("berkeley", "skiplist") }
-/* The cyrusdb backend to use for the pts cache. */
+{ "ptscache_db", "skiplist", STRINGLIST("berkeley", "skiplist") }
+/* The cyrusdb backend to use for the pts cache.
+.PP
+   Note: This Invoca RPM build uses \fIskiplist\fR by default instead of
+   \fIberkeley\fR for \fBptscache_db\fR. */
 
 { "ptscache_timeout", 10800, INT }
 /* The timeout (in seconds) for the PTS cache database when using the
@@ -813,9 +822,12 @@
 { "seenstate_db", "skiplist", STRINGLIST("flat", "berkeley", "skiplist") }
 /* The cyrusdb backend to use for the seen state. */
 
-{ "sendmail", "/usr/lib/sendmail", STRING }
+{ "sendmail", "/usr/sbin/sendmail", STRING }
 /* The pathname of the sendmail executable.  Sieve invokes sendmail
-   for sending rejections, redirects and vacation responses. */
+   for sending rejections, redirects and vacation responses.
+.PP
+   Note: This Invoca RPM build uses \fI/usr/sbin/sendmail\fR by default
+   instead of \fI/usr/lib/sendmail\fR for \fBsendmail\fR. */
 
 { "servername", NULL, STRING }
 /* This is the hostname visible in the greeting messages of the POP,
@@ -842,9 +854,12 @@
 /* Maximum number of sieve scripts any user may have, enforced at
    submission by timsieved(8). */
    
-{ "sievedir", "/usr/sieve", STRING }
+{ "sievedir", "/var/lib/imap/sieve", STRING }
 /* If sieveusehomedir is false, this directory is searched for Sieve
-   scripts. */
+   scripts.
+.PP
+   Note: This Invoca RPM build uses \fI/var/lib/imap/sieve\fR by default
+   instead of \fI/usr/sieve\fR for \fBsievedir\fR. */
 
 { "sievenotifier", NULL, STRING }
 /* Notifyd(8) method to use for "SIEVE" notifications.  If not set, "SIEVE"
@@ -934,8 +949,11 @@
    have filenames with the hashed value of the certificate (see
    openssl(XXX)). */
 
-{ "tlscache_db", "berkeley-nosync", STRINGLIST("berkeley", "berkeley-nosync", "skiplist") }
-/* The cyrusdb backend to use for the TLS cache. */
+{ "tlscache_db", "skiplist", STRINGLIST("berkeley", "berkeley-nosync", "skiplist") }
+/* The cyrusdb backend to use for the TLS cache.
+.PP
+   Note: This Invoca RPM build uses \fIskiplist\fR by default instead of
+   \fIberkeley-nosync\fR for \fBtlscache_db\fR. */
 
 { "tls_cert_file", NULL, STRING }
 /* File containing the certificate presented for server authentication

cyrus-imapd-2.3.1-make_md5.patch:

--- NEW FILE cyrus-imapd-2.3.1-make_md5.patch ---
diff -Naur cyrus-imapd-2.3.1.orig/imap/make_md5.c cyrus-imapd-2.3.1/imap/make_md5.c
--- cyrus-imapd-2.3.1.orig/imap/make_md5.c	2005-12-13 16:31:08.000000000 +0100
+++ cyrus-imapd-2.3.1/imap/make_md5.c	2006-01-18 20:21:14.000000000 +0100
@@ -391,7 +391,13 @@
     FILE *file;
     int i;
 
-    if ((file=fopen(name, "w")) == NULL)
+    file = fopen(name, "w");
+    if (file == NULL && errno == ENOENT) {
+        if (cyrus_mkdir(name, 0750) == 0) {
+            file = fopen(name, "w");
+        }
+    }
+    if (file == NULL)
         return(IMAP_IOERROR);
 
     for (mailbox = list->head ; mailbox ; mailbox = mailbox->next) {

cyrus-imapd-2.3.1-make_md5_defaults.patch:

--- NEW FILE cyrus-imapd-2.3.1-make_md5_defaults.patch ---
diff -Naur cyrus-imapd-2.3.1.orig/imap/make_md5.c cyrus-imapd-2.3.1/imap/make_md5.c
--- cyrus-imapd-2.3.1.orig/imap/make_md5.c	2005-12-13 16:31:08.000000000 +0100
+++ cyrus-imapd-2.3.1/imap/make_md5.c	2006-01-16 11:27:29.000000000 +0100
@@ -811,7 +811,7 @@
     if (!md5_dir) md5_dir = config_getstring(IMAPOPT_MD5_DIR);
 
     if (!md5_dir)
-        md5_dir = xstrdup("/var/imap/md5");
+        md5_dir = xstrdup("/var/lib/imap/md5");
 
     if (((uid_file = config_getstring(IMAPOPT_MD5_USER_MAP)) != NULL) &&
         ((uid_fd=open(uid_file, O_RDONLY)) < 0)) {
diff -Naur cyrus-imapd-2.3.1.orig/lib/imapoptions cyrus-imapd-2.3.1/lib/imapoptions
--- cyrus-imapd-2.3.1.orig/lib/imapoptions	2005-12-13 20:36:11.000000000 +0100
+++ cyrus-imapd-2.3.1/lib/imapoptions	2006-01-16 11:26:54.000000000 +0100
@@ -527,10 +527,14 @@
    mailspool, but each have their own "replicated" copy of
    mailboxes.db. */
 
-{ "md5_dir", NULL, STRING }
+{ "md5_dir", "/var/lib/imap/md5", STRING }
 /* Top level directory for MD5 store manipulated by make_md5. File
    structure within this directory is one file for each user on the system,
-   hashed on the first letter of the userid (e.g: /var/imap/md5/d/dpc22). */
+   hashed on the first letter of the
+   userid (e.g: /var/lib/imap/md5/d/dpc22).
+.PP
+   Note: This Invoca RPM build uses \fI/var/lib/imap/md5\fR by default
+   instead of \fI/var/imap/md5\fR for \fBmd5_dir\fR. */
 
 { "md5_user_map", NULL, STRING }
 /* Map file (cdb) to allow partial make_md5 runs. Maps username to UID */

cyrus-imapd-2.3.1-replication_policycheck.patch:

--- NEW FILE cyrus-imapd-2.3.1-replication_policycheck.patch ---
diff -Naur cyrus-imapd-2.3.1.orig/imap/sync_commit.c cyrus-imapd-2.3.1/imap/sync_commit.c
--- cyrus-imapd-2.3.1.orig/imap/sync_commit.c	2005-12-13 16:31:10.000000000 +0100
+++ cyrus-imapd-2.3.1/imap/sync_commit.c	2006-01-25 10:18:50.000000000 +0100
@@ -834,9 +834,15 @@
     /* Must be atleast MAX_PARTITION_LEN + 30 for partition, need
      * MAX_PARTITION_LEN + HOSTNAME_SIZE + 2 for mupdate location */
     char buf[MAX_PARTITION_LEN + HOSTNAME_SIZE + 2];
+    char *mbox = name;
+    char *p;
 
     /* Need an extra sanity check here as normal ACL logic is bypassed */
-    r = mboxname_policycheck(name);
+    if (config_virtdomains && (p = strchr(name, '!'))) {
+        /* pointer to mailbox w/o domain prefix */
+        mbox = p + 1;
+    }
+    r = mboxname_policycheck(mbox);
     if (r) return r;
 
     if (!uniqueid) {

cyrus-imapd-2.3.1-rmquota+deletemailbox-0.2-1.diff:

--- NEW FILE cyrus-imapd-2.3.1-rmquota+deletemailbox-0.2-1.diff ---
diff -Naur cyrus-imapd-2.3.1.orig/imap/ctl_cyrusdb.c cyrus-imapd-2.3.1/imap/ctl_cyrusdb.c
--- cyrus-imapd-2.3.1.orig/imap/ctl_cyrusdb.c	2005-02-16 22:06:18.000000000 +0100
+++ cyrus-imapd-2.3.1/imap/ctl_cyrusdb.c	2006-01-16 11:10:56.000000000 +0100
@@ -133,7 +133,7 @@
     /* if it is MBTYPE_RESERVED, unset it & call mboxlist_delete */
     if(!r && (mbtype & MBTYPE_RESERVE)) {
 	if(!r) {
-	    r = mboxlist_deletemailbox(name, 1, NULL, NULL, 0, 0, 1);
+	    r = mboxlist_deletemailbox(name, 1, NULL, NULL, 0, 0, 1, 1);
 	    if(r) {
 		/* log the error */
 		syslog(LOG_ERR,
diff -Naur cyrus-imapd-2.3.1.orig/imap/ctl_mboxlist.c cyrus-imapd-2.3.1/imap/ctl_mboxlist.c
--- cyrus-imapd-2.3.1.orig/imap/ctl_mboxlist.c	2005-11-23 14:41:24.000000000 +0100
+++ cyrus-imapd-2.3.1/imap/ctl_mboxlist.c	2006-01-16 11:10:56.000000000 +0100
@@ -457,7 +457,7 @@
 	    
 	    wipe_head = wipe_head->next;
 	    
-	    ret = mboxlist_deletemailbox(me->mailbox, 1, "", NULL, 0, 1, 1);
+	    ret = mboxlist_deletemailbox(me->mailbox, 1, "", NULL, 0, 1, 1, 1);
 	    if(ret) {
 		fprintf(stderr, "couldn't delete defunct mailbox %s\n",
 			me->mailbox);
diff -Naur cyrus-imapd-2.3.1.orig/imap/imapd.c cyrus-imapd-2.3.1/imap/imapd.c
--- cyrus-imapd-2.3.1.orig/imap/imapd.c	2005-12-13 20:35:50.000000000 +0100
+++ cyrus-imapd-2.3.1/imap/imapd.c	2006-01-16 11:10:56.000000000 +0100
@@ -4707,7 +4707,7 @@
 
     r = mboxlist_deletemailbox(name, imapd_userisadmin,
 			       imapd_userid, imapd_authstate,
-			       0, 0, 0);
+			       0, 0, 0, 1);
     
     if (!r) sync_log_mailbox(name);
 
@@ -4731,6 +4731,12 @@
     char *p;
     int domainlen = 0;
     int sync_lockfd = (-1);
+    int keepQuota = 1;
+
+    if(name && *name == '+') {
+	keepQuota = 0;
+	name++;
+    }
 
     r = (*imapd_namespace.mboxname_tointernal)(&imapd_namespace, name,
 					       imapd_userid, mailboxname);
@@ -4789,7 +4795,7 @@
 
 	r = mboxlist_deletemailbox(mailboxname, imapd_userisadmin,
 				   imapd_userid, imapd_authstate, 1-force,
-				   localonly, 0);
+				   localonly, 0, keepQuota);
     }
 
     /* was it a top-level user mailbox? */
@@ -6149,6 +6155,7 @@
 {
     int newquota = -1;
     int badresource = 0;
+    int rmquota = 0;
     int c;
     int force = 0;
     static struct buf arg;
@@ -6165,7 +6172,8 @@
     if (c != ')' || arg.s[0] != '\0') {
 	for (;;) {
 	    if (c != ' ') goto badlist;
-	    if (strcasecmp(arg.s, "storage") != 0) badresource = 1;
+	    if (strcasecmp(arg.s, "remove") == 0) rmquota = 1;
+	    else if (strcasecmp(arg.s, "storage") != 0) badresource = 1;
 	    c = getword(imapd_in, &arg);
 	    if (c != ' ' && c != ')') goto badlist;
 	    if (arg.s[0] == '\0') goto badlist;
@@ -6234,7 +6242,10 @@
 	    quotaroot++;
 	}
 	
-	r = mboxlist_setquota(mailboxname, newquota, force);
+	if(!rmquota)
+	    r = mboxlist_setquota(mailboxname, newquota, force);
+	else
+	    r = mboxlist_unsetquota(mailboxname);
     }
 
     imapd_check(NULL, 0, 0);
@@ -7931,7 +7942,7 @@
 	/* note also that we need to remember to let proxyadmins do this */
 	r = mboxlist_deletemailbox(mailboxname,
 				   imapd_userisadmin || imapd_userisproxyadmin,
-				   imapd_userid, imapd_authstate, 0, 1, 0);
+				   imapd_userid, imapd_authstate, 0, 1, 0, 1);
 	if(r) syslog(LOG_ERR,
 		     "Could not delete local mailbox during move of %s",
 		     mailboxname);
diff -Naur cyrus-imapd-2.3.1.orig/imap/mailbox.c cyrus-imapd-2.3.1/imap/mailbox.c
--- cyrus-imapd-2.3.1.orig/imap/mailbox.c	2005-11-10 07:04:55.000000000 +0100
+++ cyrus-imapd-2.3.1/imap/mailbox.c	2006-01-16 11:10:56.000000000 +0100
@@ -2622,27 +2622,7 @@
 
     seen_delete_mailbox(mailbox);
 
-    if (delete_quota_root && !rquota) {
-	quota_delete(&mailbox->quota, &tid);
-	free(mailbox->quota.root);
-	mailbox->quota.root = NULL;
-    } else if (!rquota) {
-	/* Free any quota being used by this mailbox */
-	if (mailbox->quota.used >= mailbox->quota_mailbox_used) {
-	    mailbox->quota.used -= mailbox->quota_mailbox_used;
-	}
-	else {
-	    mailbox->quota.used = 0;
-	}
-	r = quota_write(&mailbox->quota, &tid);
-	if (r) {
-	    syslog(LOG_ERR,
-		   "LOSTQUOTA: unable to record free of " UQUOTA_T_FMT " bytes in quota %s",
-		   mailbox->quota_mailbox_used, mailbox->quota.root);
-	}
-	else
-	    quota_commit(&tid);
-    }
+    mailbox_updatequota(mailbox,NULL);
 
     /* remove data (message file) directory */
     path = mailbox->path;
@@ -3263,3 +3243,49 @@
 	if (*p == '.') *p = '/';
     }
 }
+
+
+/* This function is used to update the quota. Can be used to replace
+ * identical parts of the code, and can be quite handy some times 
+ * The tid is used in order to make possible to make the quota update
+ * being a part of a bigger transaction to the quota db */
+int mailbox_updatequota(struct mailbox *mailbox, struct txn **tid)
+{
+    int r = 0, havetid = 0;
+    struct txn **ltid = NULL;
+
+    if(tid) {
+        ltid = tid;
+        havetid = 1;
+    }
+    /* Ensure that we are locked */
+    if(!mailbox->header_lock_count) return IMAP_INTERNAL;
+
+
+    if(mailbox->quota.root) {
+        r = quota_read(&mailbox->quota, ltid, 1);
+        if( r == 0 ) {
+            if (mailbox->quota.used >= mailbox->quota_mailbox_used) {
+                mailbox->quota.used -= mailbox->quota_mailbox_used;
+            }
+            else {
+                mailbox->quota.used = 0;
+            }
+            r = quota_write(&mailbox->quota, ltid);
+            if (r) {
+                syslog(LOG_ERR,
+                   "LOSTQUOTA: unable to record free of %lu bytes in quota %s",
+                   mailbox->quota_mailbox_used, mailbox->quota.root);
+            }
+            else if(!havetid)
+                quota_commit(tid);
+        }
+        /* It is not a big mistake not to have quota .. just remove from the mailbox */
+        else if ( r == IMAP_QUOTAROOT_NONEXISTENT) {
+                free(mailbox->quota.root);
+                r = 0;
+        }
+    }
+    return r;
+}
+
diff -Naur cyrus-imapd-2.3.1.orig/imap/mailbox.h cyrus-imapd-2.3.1/imap/mailbox.h
--- cyrus-imapd-2.3.1.orig/imap/mailbox.h	2005-05-27 19:40:54.000000000 +0200
+++ cyrus-imapd-2.3.1/imap/mailbox.h	2006-01-16 11:10:56.000000000 +0100
@@ -329,6 +329,8 @@
 			  struct mailbox *mailboxp);
 extern int mailbox_delete(struct mailbox *mailbox, int delete_quota_root);
 
+extern int mailbox_updatequota(struct mailbox *mailbox, struct txn **tid);
+
 extern int mailbox_rename_copy(struct mailbox *oldmailbox, 
 			       const char *newname, char *newpartition,
 			       bit32 *olduidvalidityp, bit32 *newuidvalidityp,
diff -Naur cyrus-imapd-2.3.1.orig/imap/mboxlist.c cyrus-imapd-2.3.1/imap/mboxlist.c
--- cyrus-imapd-2.3.1.orig/imap/mboxlist.c	2005-12-13 20:36:03.000000000 +0100
+++ cyrus-imapd-2.3.1/imap/mboxlist.c	2006-01-16 11:10:56.000000000 +0100
@@ -93,6 +93,11 @@
 static int mboxlist_opensubs();
 static void mboxlist_closesubs();
 
+static int child_cb(char *name,
+                    int matchlen __attribute__((unused)),
+                    int maycreate __attribute__((unused)),
+                    void *rock);
+
 static int mboxlist_rmquota(const char *name, int matchlen, int maycreate,
 			    void *rock);
 static int mboxlist_changequota(const char *name, int matchlen, int maycreate,
@@ -100,6 +105,7 @@
 
 struct change_rock {
     struct quota *quota;
+    struct quota *oldquota;
     struct txn **tid;
 };
 
@@ -891,9 +897,9 @@
  */
 int mboxlist_deletemailbox(const char *name, int isadmin, char *userid, 
 			   struct auth_state *auth_state, int checkacl,
-			   int local_only, int force)
+			   int local_only, int force, int keepQuota)
 {
-    int r;
+    int r, has_children = 0;
     char *acl;
     long access;
     struct mailbox mailbox;
@@ -904,6 +910,7 @@
     int mbtype;
     const char *p;
     mupdate_handle *mupdate_h = NULL;
+    char *quotaroot = NULL;
 
     if(!isadmin && force) return IMAP_PERMISSION_DENIED;
 
@@ -1016,13 +1023,44 @@
 
     if ((r && !force) || isremote) goto done;
 
-    if (!r || force) r = mailbox_delete(&mailbox, deletequotaroot);
+    if (!r || force) {
+        /* first we have to keep the previous quota root in order to delete it */
+        if(mailbox.quota.root)
+                quotaroot = xstrdup(mailbox.quota.root);
+	r = mailbox_delete(&mailbox, deletequotaroot);
+    }
 
     /*
      * See if we have to remove mailbox's quota root
      */
-    if (!r && mailbox.quota.root != NULL) {
+    if (!r && quotaroot != NULL) {
 	/* xxx look for any other mailboxes in this quotaroot */
+        /* If we have not asked to remove the quota (default behaviour), we check 
+         * whether there are any subfolders beneeth the quota root. If there aren't
+         * any subfolders the reasonable thing is to delete the quota */
+        if(keepQuota) {
+            char pattern[MAX_MAILBOX_PATH+1];
+            strlcpy(pattern, quotaroot, sizeof(pattern));
+            if (config_virtdomains && name[strlen(name)-1] == '!') {
+                strlcat(pattern, "*", sizeof(pattern));
+            }
+            else {
+                strlcat(pattern, ".*", sizeof(pattern));
+            }
+		/* find if there are subfolders. Then we want to 
+		 * keep the existing quota */
+            mboxlist_findall(NULL, pattern, isadmin, userid,
+                    auth_state, child_cb, (void *) &has_children);
+
+	    if(!has_children)
+                if(!mboxlist_mylookup(quotaroot, NULL, NULL, NULL, NULL, NULL, NULL, 0 ))
+		    has_children = 1;
+        }
+        /* If we want to remove the quota explicitely or the quota root folder has no subfolders
+         * we execute the rmquota patch */
+        if(!keepQuota || !has_children )
+            mboxlist_unsetquota(quotaroot);
+        free(quotaroot);
     }
 
  done:
@@ -2478,6 +2516,7 @@
     if (r) return r;
 
     crock.quota = &quota;
+    crock.oldquota = NULL;
     crock.tid = &tid;
     /* top level mailbox */
     if(have_mailbox)
@@ -2496,17 +2535,21 @@
  */
 int mboxlist_unsetquota(const char *root)
 {
+    char newquota[MAX_MAILBOX_PATH+1];
     char pattern[MAX_MAILBOX_PATH+1];
     struct quota quota;
-    int r=0;
+    struct change_rock crock;
+    int r=0, k=0;
 
     if (!root[0] || root[0] == '.' || strchr(root, '/')
 	|| strchr(root, '*') || strchr(root, '%') || strchr(root, '?')) {
 	return IMAP_MAILBOX_BADNAME;
     }
+	
+    crock.tid=NULL;
     
     quota.root = (char *) root;
-    r = quota_read(&quota, NULL, 0);
+    r = quota_read(&quota, crock.tid, 0);
     if (r == IMAP_QUOTAROOT_NONEXISTENT) {
 	/* already unset */
 	return 0;
@@ -2523,13 +2566,45 @@
     }
     else
 	strlcat(pattern, ".*", sizeof(pattern));
-    
-    /* top level mailbox */
-    mboxlist_rmquota(root, 0, 0, (void *)root);
-    /* submailboxes - we're using internal names here */
-    mboxlist_findall(NULL, pattern, 1, 0, 0, mboxlist_rmquota, (void *)root);
 
-    r = quota_delete(&quota, NULL);
+    r = quota_delete(&quota, crock.tid);
+
+    /* If we cannot delete the quota then abort the operation */
+    if(!r) {
+       /* quota_findroot performs several checks that we can
+        * assume that are already done, and don't have to perform
+        * them again. One of them is that it returns 1 only if
+        * quotaroot exists.
+        */
+        if(quota_findroot(newquota, sizeof(newquota), root)) {
+            struct quota rootquota;
+            rootquota.root = newquota;
+            k = quota_read(&rootquota, crock.tid, 0);
+            if (!k) {
+                crock.quota = &rootquota;
+                crock.oldquota = &quota;
+                /* top level mailbox */
+                k = mboxlist_changequota(root, 0, 0, &crock);
+            }
+            /* submailboxes - we're using internal names here */
+            if (!k)
+                k = mboxlist_findall(NULL, pattern, 1, 0, 0, mboxlist_changequota, &crock);
+            if(!k)
+                k = quota_write(&rootquota, crock.tid);
+
+         }
+         else {
+           /* top level mailbox */
+           mboxlist_rmquota(root, 0, 0, (void *)root);
+           /* submailboxes - we're using internal names here */
+           mboxlist_findall(NULL, pattern, 1, 0, 0, mboxlist_rmquota, (void *)root);
+       }
+    }
+
+    if(!r && !k)
+        quota_commit(crock.tid);
+    else
+        quota_abort(crock.tid);
 
     return r;
 }
@@ -2627,6 +2702,7 @@
     struct mailbox mailbox;
     struct change_rock *crock = (struct change_rock *) rock;
     struct quota *mboxlist_newquota = crock->quota;
+    struct quota *mboxlist_oldquota = crock->oldquota;
     struct txn **tid = crock->tid;
 
     assert(rock != NULL);
@@ -2644,27 +2720,24 @@
     if (r) goto error;
 
     if (mailbox.quota.root) {
-	if (strlen(mailbox.quota.root) >= strlen(mboxlist_newquota->root)) {
-	    /* Part of a child quota root */
-	    mailbox_close(&mailbox);
-	    return 0;
-	}
-
-	r = quota_read(&mailbox.quota, tid, 1);
-	if (r) goto error;
-	if (mailbox.quota.used >= mailbox.quota_mailbox_used) {
-	    mailbox.quota.used -= mailbox.quota_mailbox_used;
+	if(mboxlist_oldquota) {
+	    if (strlen(mailbox.quota.root) > strlen(mboxlist_oldquota->root)) {
+		/* Part of a child quota root */
+		mailbox_close(&mailbox);
+		return 0;
+	    }
 	}
 	else {
-	    mailbox.quota.used = 0;
-	}
-	r = quota_write(&mailbox.quota, tid);
-	if (r) {
-	    syslog(LOG_ERR,
-		   "LOSTQUOTA: unable to record free of " UQUOTA_T_FMT " bytes in quota %s",
-		   mailbox.quota_mailbox_used, mailbox.quota.root);
+	    if (strlen(mailbox.quota.root) >= strlen(mboxlist_newquota->root)) {
+		/* Part of a child quota root */
+		mailbox_close(&mailbox);
+		return 0;
+	    }
 	}
-	free(mailbox.quota.root);
+
+	r = mailbox_updatequota(&mailbox,tid);
+	if (r)
+	    goto error;
     }
 
     mailbox.quota.root = xstrdup(mboxlist_newquota->root);
@@ -2674,18 +2747,24 @@
     mboxlist_newquota->used += mailbox.quota_mailbox_used;
     mailbox_close(&mailbox);
     return 0;
-
+ 
  error:
     mailbox_close(&mailbox);
+    syslog(LOG_ERR, "LOSTQUOTA: unable to change quota root for %s to %s: %s. \
+                        Command aborted. Run reconstruct to make sure mailboxes \
+                         are in consistent state",
+           name, mboxlist_newquota->root, error_message(r));
+    return 1;
  error_noclose:
     syslog(LOG_ERR, "LOSTQUOTA: unable to change quota root for %s to %s: %s",
-	   name, mboxlist_newquota->root, error_message(r));
+           name, mboxlist_newquota->root, error_message(r));
 
     /* Note, we're a callback, and it's not a huge tragedy if we
      * fail, so we don't ever return a failure */
     return 0;
 }
 
+
 /* must be called after cyrus_init */
 void mboxlist_init(int myflags)
 {
diff -Naur cyrus-imapd-2.3.1.orig/imap/mboxlist.h cyrus-imapd-2.3.1/imap/mboxlist.h
--- cyrus-imapd-2.3.1.orig/imap/mboxlist.h	2005-02-21 20:25:40.000000000 +0100
+++ cyrus-imapd-2.3.1/imap/mboxlist.h	2006-01-16 11:10:56.000000000 +0100
@@ -125,7 +125,7 @@
  * the planet */
 int mboxlist_deletemailbox(const char *name, int isadmin, char *userid, 
 			   struct auth_state *auth_state, int checkacl,
-			   int local_only, int force);
+			   int local_only, int force, int keepQuota);
 
 /* Rename/move a mailbox (hierarchical) */
 int mboxlist_renamemailbox(char *oldname, char *newname, char *partition, 
diff -Naur cyrus-imapd-2.3.1.orig/imap/mupdate.c cyrus-imapd-2.3.1/imap/mupdate.c
--- cyrus-imapd-2.3.1.orig/imap/mupdate.c	2005-11-04 14:34:23.000000000 +0100
+++ cyrus-imapd-2.3.1/imap/mupdate.c	2006-01-16 11:10:56.000000000 +0100
@@ -2297,7 +2297,7 @@
 	    remote_boxes.head = r->next;
 	} else if (ret < 0) {
 	    /* Local without corresponding remote, delete it */
-	    mboxlist_deletemailbox(l->mailbox, 1, "", NULL, 0, 0, 0);
+	    mboxlist_deletemailbox(l->mailbox, 1, "", NULL, 0, 0, 0, 1);
 	    local_boxes.head = l->next;
 	} else /* (ret > 0) */ {
 	    /* Remote without corresponding local, insert it */
@@ -2312,7 +2312,7 @@
     if(l && !r) {
 	/* we have more deletes to do */
 	while(l) {
-	    mboxlist_deletemailbox(l->mailbox, 1, "", NULL, 0, 0, 0);
+	    mboxlist_deletemailbox(l->mailbox, 1, "", NULL, 0, 0, 0, 1);
 	    local_boxes.head = l->next;
 	    l = local_boxes.head;
 	}
diff -Naur cyrus-imapd-2.3.1.orig/imap/nntpd.c cyrus-imapd-2.3.1/imap/nntpd.c
--- cyrus-imapd-2.3.1.orig/imap/nntpd.c	2005-12-13 20:36:06.000000000 +0100
+++ cyrus-imapd-2.3.1/imap/nntpd.c	2006-01-16 11:10:56.000000000 +0100
@@ -3342,7 +3342,7 @@
     /* XXX should we delete right away, or wait until empty? */
 
     r = mboxlist_deletemailbox(mailboxname, 0,
-			       newsmaster, newsmaster_authstate, 1, 0, 0);
+			       newsmaster, newsmaster_authstate, 1, 0, 0, 1);
 
     if (!r) sync_log_mailbox(mailboxname);
 
diff -Naur cyrus-imapd-2.3.1.orig/imap/sync_reset.c cyrus-imapd-2.3.1/imap/sync_reset.c
--- cyrus-imapd-2.3.1.orig/imap/sync_reset.c	2005-12-13 16:31:10.000000000 +0100
+++ cyrus-imapd-2.3.1/imap/sync_reset.c	2006-01-16 11:12:34.000000000 +0100
@@ -254,7 +254,7 @@
     if (r) goto fail;
 
     for (item = list->head ; item ; item = item->next) {
-        r=mboxlist_deletemailbox(item->name, 1, NULL, sync_authstate, 1, 0, 0);
+        r=mboxlist_deletemailbox(item->name, 1, NULL, sync_authstate, 1, 0, 0, 1);
 
         if (r) goto fail;
     }
@@ -270,7 +270,7 @@
     if (r) goto fail;
 
     for (item = list->head ; item ; item = item->next) {
-        r=mboxlist_deletemailbox(item->name, 1, NULL, sync_authstate, 1, 0, 0);
+        r=mboxlist_deletemailbox(item->name, 1, NULL, sync_authstate, 1, 0, 0, 1);
 
         if (r) goto fail;
     }
@@ -278,7 +278,7 @@
 
     /* Nuke inbox (recursive nuke possible?) */
     snprintf(buf, sizeof(buf)-1, "user.%s", user);
-    r = mboxlist_deletemailbox(buf, 1, "cyrus", sync_authstate, 1, 0, 0);
+    r = mboxlist_deletemailbox(buf, 1, "cyrus", sync_authstate, 1, 0, 0, 1);
     if (r && (r != IMAP_MAILBOX_NONEXISTENT)) goto fail;
 
     if ((r=user_deletedata(user, sync_userid, sync_authstate, 1)))
diff -Naur cyrus-imapd-2.3.1.orig/imap/sync_server.c cyrus-imapd-2.3.1/imap/sync_server.c
--- cyrus-imapd-2.3.1.orig/imap/sync_server.c	2005-12-20 16:54:43.000000000 +0100
+++ cyrus-imapd-2.3.1/imap/sync_server.c	2006-01-16 11:13:02.000000000 +0100
@@ -1569,7 +1569,7 @@
 
     for (item = list->head ; item ; item = item->next) {
         r=mboxlist_deletemailbox(item->name, sync_userisadmin, sync_userid,
-				 sync_authstate, 0, 0, 1);
+				 sync_authstate, 0, 0, 1, 1);
 
         if (r) goto fail;
     }
@@ -1579,7 +1579,7 @@
     (sync_namespacep->mboxname_tointernal)(sync_namespacep, "INBOX",
 					   user, buf);
     r = mboxlist_deletemailbox(buf, sync_userisadmin, sync_userid,
-			       sync_authstate, 0, 0, 1);
+			       sync_authstate, 0, 0, 1, 1);
     if (r && (r != IMAP_MAILBOX_NONEXISTENT)) goto fail;
 
     if ((r=user_deletedata(user, sync_userid, sync_authstate, 1)))
@@ -2501,7 +2501,7 @@
 
     /* Delete with admin priveleges */
     r = mboxlist_deletemailbox(name, sync_userisadmin, sync_userid,
-			       sync_authstate, 0, 0, 1);
+			       sync_authstate, 0, 0, 1, 1);
 
     if (r)
         prot_printf(sync_out, "NO Failed to delete %s: %s\r\n",


--- NEW FILE cyrus-imapd-2.3.1.tar.gz.sig ---
ˆ?

--- NEW FILE cyrus-imapd-README.skiplist_recovery ---
>From http://article.gmane.org/gmane.mail.imap.cyrus/18840

We have also seen skiplist corruption in seen databases.  I don't have a 
recovery tool, but I have been able to manually recover seen db's to the 
point of corruption so that at least most of the users mails are in the 
correct 'read' state.  Typically, you will see errors like:

DBERROR: skiplist recovery /usr/local/imap/user/k/kdelaney.seen: 0D2C 
should be ADD or DELETE

If you truncate the file at this point, it should fix the problem, and 
the users mail read state will be valid upto the point of corruption. 
To do this, convert the hex to decimal (above would be 1372) and use the 
dd command:

dd if=kdelaney.seen of=kdelaney.seen.fixed bs=1 count=1372

replace the corrupted .seen file with the fixed one and have user log in 
and should be ok.

Seems to work on the couple I have tried it on.


--- NEW FILE cyrus-imapd.imap-2.3.x-conf ---
configdirectory: /var/lib/imap
partition-default: /var/spool/imap
admins: cyrus
sievedir: /var/lib/imap/sieve
sendmail: /usr/sbin/sendmail
hashimapspool: true
sasl_pwcheck_method: saslauthd
sasl_mech_list: PLAIN
tls_cert_file: /usr/share/ssl/certs/cyrus-imapd.pem
tls_key_file: /usr/share/ssl/certs/cyrus-imapd.pem
tls_ca_file: /usr/share/ssl/certs/ca-bundle.crt


--- NEW FILE skiplist.py ---
#!/usr/bin/env python
# -*- Mode: Python; tab-width: 4 -*-
#
# Cyrus Imapd Skiplist db recovery tool
#
# Copyright (C) 2004 Gianluigi Tiesi <sherpya at netfarm.it>
# Copyright (C) 2004 NetFarm S.r.l.  [http://www.netfarm.it]
#
# 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, 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 MERCHANTIBILITY
# or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
# for more details.
# ======================================================================

__version__= '0.1'
__doc__="""Cyrus skiplist db recover"""

from sys import argv,exit,stdout,stderr
from struct import unpack
from time import localtime, strftime

### User Conf
debug = 0
###

TIMEFMT ='%a, %d %b %Y %H:%M:%S %z'
PADDING = '\xff' * 4
INORDER = 1
ADD     = 2
DELETE  = 4
COMMIT  = 255
DUMMY   = 257
HEADER  = -1
MAIN    = -2

types = {
    1:   'INORDER',
    2:   'ADD',
    4:   'DELETE',
    255: 'COMMIT',
    257: 'DUMMY',
    -1:  'HEADER',
    -2:  '*'
    }

def log(rtype, text):
    global debug
    if debug:
        out = '[%s] %s\n' % (types[rtype], text)
        stdout.write(out)
        stdout.flush()

def roundto4(value):
    if value % 4:
        return ((value / 4) + 1) * 4
    return value

def get_header(fp):
    #### Magic ??
    fp.seek(4)
    
    sign = fp.read(16)
    log(HEADER, sign[:-3])

    version = unpack('>I', fp.read(4))[0]
    version_minor = unpack('>I', fp.read(4))[0]

    log(HEADER, 'Version %d,%d' % (version, version_minor))

    maxlevel = unpack('>I', fp.read(4))[0]
    curlevel = unpack('>I', fp.read(4))[0]

    log(HEADER, 'Level %d/%d' % (curlevel, maxlevel))

    listsize = unpack('>I', fp.read(4))[0]
    log(HEADER, 'List size %d' % listsize)

    logstart = unpack('>I', fp.read(4))[0]
    log(HEADER, 'Offset %d' % logstart)
    
    lastrecovery = localtime(unpack('>I', fp.read(4))[0])
    lastrecovery = strftime(TIMEFMT, lastrecovery)

    log(HEADER, 'Last Recovery %s' % lastrecovery)

    return { 'version'    : [version, version_minor],
             'level'      : [curlevel, maxlevel],
             'listsize'   : listsize,
             'logstart'   : logstart,
             'lastrecover': lastrecovery
             }

def getkeys(fp):
    values = []
    keys = {}
    keystring = ''
    datastring = ''

    while 1:
        log(MAIN, '-'*78)

        stype = fp.read(4)

        ### EOF
        if len(stype) != 4:
            break

        rtype = unpack('>I', stype)[0]
        if not types.has_key(rtype):
            log(MAIN, 'Invalid type %d' % rtype)
            continue
        
        log(rtype, 'Record type %s' % types[rtype])

        if rtype == DELETE:
            ptr = unpack('>I', fp.read(4))[0]
            log(rtype, 'DELETE %d (0x%x)' % (ptr, ptr))
            continue

        if rtype == COMMIT:
            continue
        
        ksize = unpack('>I', fp.read(4))[0]
        log(rtype, 'Key size %d (%d)' % (ksize, roundto4(ksize)))

        if ksize:
            keystring = fp.read(roundto4(ksize))[:ksize]
            log(rtype, 'Key String %s' % keystring)

        datasize = unpack('>I', fp.read(4))[0]
        log(rtype, 'Data size %d (%d)' % (datasize, roundto4(datasize)))
                
        if datasize:
            datastring = fp.read(roundto4(datasize))[:datasize]
            log(rtype, 'Data String %s' % datastring)

        n = 0
        while 1:
            str_p = fp.read(4)
            if str_p == PADDING:
                break
            spointer = unpack('>I', str_p)[0]
            n = n +1
            if spointer: log(rtype, 'Skip pointer %d' % spointer)
            
        log(rtype, 'Total Skip pointers: %d' % n)

        if rtype != DUMMY:
            if keystring not in values:
                values.append(keystring)
            keys[keystring] = datastring

    return values, keys

if __name__ == '__main__':
    if len(argv) != 2:
        print 'Usage: %s skiplist.file' % argv[0]
        exit()

    fp = open(argv[1], 'rb')
    header = get_header(fp)
    values, keys = getkeys(fp)
    fp.close()

    if debug: exit()
    for v in values:
        print '%s\t%s' % (v, keys[v])


Index: .cvsignore
===================================================================
RCS file: /cvs/extras/rpms/cyrus-imapd/devel/.cvsignore,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- .cvsignore	15 Apr 2005 20:24:15 -0000	1.2
+++ .cvsignore	28 Feb 2006 20:04:01 -0000	1.3
@@ -1,3 +1,2 @@
-cyrus-imapd-2.2.12.tar.gz
-cyrus-imapd-README.HOWTO-recover-mailboxes.db
+cyrus-imapd-2.3.1.tar.gz
 cyrus_sharedbackup-0.1.tar.gz


Index: cyrus-imapd-README.RPM
===================================================================
RCS file: /cvs/extras/rpms/cyrus-imapd/devel/cyrus-imapd-README.RPM,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- cyrus-imapd-README.RPM	15 Apr 2005 20:24:15 -0000	1.1
+++ cyrus-imapd-README.RPM	28 Feb 2006 20:04:01 -0000	1.2
@@ -7,7 +7,7 @@
 The following steps should lead you to a running Cyrus IMAP server:
 
 1)  Install on a distribution which is supported by this RPM. Don't install
-    on a dirty system, where you have previously tried to install from source.
+    on a dirty system, where you have previously installed from source.
 2)  Don't install if you have a previous Cyrus IMAPd installation <=2.1.x on
     your box. Upgrading any Invoca rpm based installation should be fine.
 3)  Make sure you understand that this RPM installs in FHS compliant
@@ -17,7 +17,8 @@
     needed and do 'chkconfig saslauthd on ; service saslauthd start'
 6)  Install the cyrus-imapd RPMs.
 7)  If it's your first install of Cyrus IMAPd, then set a password for the
-    cyrus user in whatever database you are using to authenticate.
+    cyrus user in whatever database you are using to authenticate. When
+    using a local account, this should be 'passwd cyrus'.
 8)  Make sure your MTA delivers to Cyrus IMAPd, I recommend LMTP for this.
 9)  Start Cyrus IMAPd with 'service cyrus-imapd start'
 10) Run cyradm and create a user. Usually it's something like this:
@@ -30,4 +31,7 @@
     info priority with something like 'mail.info    /var/log/maillog' in
     /etc/syslog.conf.
 
+Read the file "README.buildoptions" in this directory to find out which
+build time options have been used to build this package.
+
 Enjoy!


Index: cyrus-imapd.cvt_cyrusdb_all
===================================================================
RCS file: /cvs/extras/rpms/cyrus-imapd/devel/cyrus-imapd.cvt_cyrusdb_all,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- cyrus-imapd.cvt_cyrusdb_all	15 Apr 2005 20:24:15 -0000	1.1
+++ cyrus-imapd.cvt_cyrusdb_all	28 Feb 2006 20:04:01 -0000	1.2
@@ -70,6 +70,35 @@
 #
 # v1.0.12, Dec 16 2004 Simon Matter <simon.matter at invoca.ch>
 # - use runuser instead of su if available
+#
+# v1.0.13, Jul 15 2005 Simon Matter <simon.matter at invoca.ch>
+# - don't use flat in the two step conversion, use skiplist instead
+#
+# v1.0.14, Jul 18 2005 Simon Matter <simon.matter at invoca.ch>
+# - replace the order of the magic files in the file call to make
+#   sure skiplist is detected correctly.
+#
+# v1.0.15, Aug 17 2005 Simon Matter <simon.matter at invoca.ch>
+# - add functionality to export all berkeley db files to skiplist
+#
+# v1.1.0, Aug 18 2005 Simon Matter <simon.matter at invoca.ch>
+# - fix export functionality, try to recover Berkeley databases
+#   as much as possible before any conversion.
+#
+# v1.1.1, Dec 05 2005 Simon Matter <simon.matter at invoca.ch>
+# - run db_checkpoint in background with a timeout to prevent
+#   that cyrus-imapd doesn't start at all if it hangs.
+#
+# v1.1.2, Dec 06 2005 Simon Matter <simon.matter at invoca.ch>
+# - make handling of db_checkpoint more robust
+#
+# v1.2.0, Jan 12 2006 Simon Matter <simon.matter at invoca.ch>
+# - adopt for cyrus-imapd-2.3
+#
+# v1.2.1, Jan 13 2006 Simon Matter <simon.matter at invoca.ch>
+# - code cleanup
+
+VERSION=1.2.1
 
 if [ -n "$(/sbin/pidof cyrus-master)" ]; then
   echo "ERROR: cyrus-master is running, unable to convert mailboxes!"
@@ -90,12 +119,18 @@
 
 # force cyrus user for security reasons
 if [ ! $(whoami) = "cyrus" ]; then
-  exec $RUNUSER - cyrus -c "cd $PWD < /dev/null ; $0"
+  exec $RUNUSER - cyrus -c "cd $PWD < /dev/null ; $0 $*"
 fi
 
+# special function for migration
+EXPORT=$1
+
 # files get mode 0600
 umask 166
 
+# show version info in log files
+echo "cvt_cyrusdb_all version: $VERSION"
+
 # get_config [config default]
 # extracts config option from config file
 get_config() {
@@ -107,13 +142,16 @@
 }
 
 # where to find files and directories
+data_dir=/usr/share/cyrus-imapd/rpm
+lib_dir=/usr/lib/cyrus-imapd
 system_magic=$(file --version | awk '/magic file/ {print $4}')
-cyrus_magic=/usr/share/cyrus-imapd/rpm/magic
-cvt_cyrusdb=/usr/lib/cyrus-imapd/cvt_cyrusdb
-sievec=/usr/lib/cyrus-imapd/sievec
+cyrus_magic=${data_dir}/magic
+cvt_cyrusdb=${lib_dir}/cvt_cyrusdb
+sievec=${lib_dir}/sievec
+masssievec=${lib_dir}/masssievec
 imap_prefix=$(get_config configdirectory /var/lib/imap)
 sieve_dir=$(get_config sievedir /var/lib/imap/sieve)
-db_cfg=/usr/share/cyrus-imapd/rpm/db.cfg
+db_cfg=${data_dir}/db.cfg
 db_current=${imap_prefix}/rpm/db.cfg.current
 db_cache=${imap_prefix}/rpm/db.cfg.cache
 
@@ -121,27 +159,33 @@
 . $db_cfg
 
 # get configured db backend config
-CONFIG_DB_DUPLICATE=$(get_config duplicate_db $CONFIG_DB_DUPLICATE)
-CONFIG_DB_MBOX=$(get_config mboxlist_db $CONFIG_DB_MBOX)
-CONFIG_DB_SEEN=$(get_config seenstate_db $CONFIG_DB_SEEN)
-CONFIG_DB_SUBS=$(get_config subscription_db $CONFIG_DB_SUBS)
-CONFIG_DB_TLS=$(get_config tlscache_db $CONFIG_DB_TLS)
-CONFIG_DB_ANNOTATION=$(get_config annotation_db $CONFIG_DB_ANNOTATION)
+duplicate_db=$(get_config duplicate_db $duplicate_db)
+mboxlist_db=$(get_config mboxlist_db $mboxlist_db)
+seenstate_db=$(get_config seenstate_db $seenstate_db)
+subscription_db=$(get_config subscription_db $subscription_db)
+tlscache_db=$(get_config tlscache_db $tlscache_db)
+annotation_db=$(get_config annotation_db $annotation_db)
+mboxkey_db=$(get_config mboxkey_db $mboxkey_db)
+ptscache_db=$(get_config ptscache_db $ptscache_db)
+quota_db=$(get_config quota_db $quota_db)
 
 # remember current db backend config
 {
-echo "CONFIG_DB_DUPLICATE=$CONFIG_DB_DUPLICATE"
-echo "CONFIG_DB_MBOX=$CONFIG_DB_MBOX"
-echo "CONFIG_DB_SEEN=$CONFIG_DB_SEEN"
-echo "CONFIG_DB_SUBS=$CONFIG_DB_SUBS"
-echo "CONFIG_DB_TLS=$CONFIG_DB_TLS"
-echo "CONFIG_DB_ANNOTATION=$CONFIG_DB_ANNOTATION"
-echo "CONFIG_DB_SIEVE=$CONFIG_DB_SIEVE"
-} > $db_current
+echo "duplicate_db=$duplicate_db"
+echo "mboxlist_db=$mboxlist_db"
+echo "seenstate_db=$seenstate_db"
+echo "subscription_db=$subscription_db"
+echo "tlscache_db=$tlscache_db"
+echo "annotation_db=$annotation_db"
+echo "mboxkey_db=$mboxkey_db"
+echo "ptscache_db=$ptscache_db"
+echo "quota_db=$quota_db"
+echo "sieve_version=$sieve_version"
+} | sort > $db_current
 
 # file_type [file]
 file_type() {
-  this_type=$(file -b -m "$system_magic:$cyrus_magic" "$1" 2> /dev/null)
+  this_type=$(file -b -m "$cyrus_magic:$system_magic" "$1" 2> /dev/null)
   if echo "$this_type" | grep -qi skip > /dev/null 2>&1; then
     echo skiplist
   elif echo "$this_type" | grep -qi text > /dev/null 2>&1; then
@@ -160,32 +204,32 @@
     if [ ! "$old_db" = "$new_db" ]; then
       # The two-step conversion is paranoia against the filenames being encoded
       # inside the database or logfiles (berkeley does this, for example).
-      rm -f "${target}.flat"
-      if [ "$old_db" = "flat" ]; then
-        cp -a "$target" "${target}.flat"
+      rm -f "${target}.skiplist"
+      if [ "$old_db" = "skiplist" ]; then
+        cp -a "$target" "${target}.skiplist"
       else
-        $cvt_cyrusdb "$target" "$old_db" "${target}.flat" flat
+        $cvt_cyrusdb "$target" "$old_db" "${target}.skiplist" skiplist
       fi
       RETVAL=$?
       ERRVAL=$[ $ERRVAL + $RETVAL ]
       if [ $RETVAL -eq 0 ]; then
         rm -f "$target"
-        if [ -s "${target}.flat" ]; then
-          if [ "$new_db" = "flat" ]; then
-            cp -a "${target}.flat" "$target"
+        if [ -s "${target}.skiplist" ]; then
+          if [ "$new_db" = "skiplist" ]; then
+            cp -a "${target}.skiplist" "$target"
           else
-            $cvt_cyrusdb "${target}.flat" flat "$target" "$new_db"
+            $cvt_cyrusdb "${target}.skiplist" skiplist "$target" "$new_db"
           fi
         fi
         RETVAL=$?
         ERRVAL=$[ $ERRVAL + $RETVAL ]
         if [ $RETVAL -eq 0 ]; then
-          rm -f "${target}.flat"
+          rm -f "${target}.skiplist"
         else
-          echo "ERROR: unable to convert ${target}.flat from flat to $new_db"
+          echo "ERROR: unable to convert ${target}.skiplist from skiplist to $new_db"
         fi
       else
-        echo "ERROR: unable to convert $target from $old_db to flat"
+        echo "ERROR: unable to convert $target from $old_db to skiplist"
       fi
     fi
   fi
@@ -211,27 +255,77 @@
 
 ERRVAL=0
 
-# do we need to convert databases ?
-if ! cmp -s $db_current $db_cache; then
-  # we treat sieve scripts the same way like db files
-  find ${sieve_dir}/ -name "*.script" -type f | while read db_file trash; do
-    cvt_to_utf8 "$db_file"
-  done
-  /usr/lib/cyrus-imapd/masssievec /usr/lib/cyrus-imapd/sievec
-  # convert all db files
-  cvt_file $imap_prefix/deliver.db           "$CONFIG_DB_DUPLICATE"
-  cvt_file $imap_prefix/mailboxes.db         "$CONFIG_DB_MBOX"
-  cvt_file $imap_prefix/tls_sessions.db      "$CONFIG_DB_TLS"
-  cvt_file $imap_prefix/annotations.db       "$CONFIG_DB_ANNOTATION"
-  find ${imap_prefix}/user/ -name "*.seen" -type f | while read db_file trash; do
-    cvt_file "$db_file" "$CONFIG_DB_SEEN"
-  done
-  find ${imap_prefix}/user/ -name "*.sub" -type f | while read db_file trash; do
-    cvt_file "$db_file" "$CONFIG_DB_SUBS"
-  done
+# make sure our Berkeley databases are in a sane state
+# wait for db_checkpoint to end successfully or kill it after a timeout
+db_checkpoint -v -1 -h $imap_prefix/db &
+DB_CHECK_PID=$!
+CNT=0
+while [ $CNT -lt 60 ]; do
+  if ! kill -0 $DB_CHECK_PID > /dev/null 2>&1; then
+    break
+  fi
+  sleep 1
+  let CNT+=1
+done
+if kill -0 $DB_CHECK_PID > /dev/null 2>&1; then
+  kill -USR1 $DB_CHECK_PID > /dev/null 2>&1
+  sleep 1
+  kill -KILL $DB_CHECK_PID > /dev/null 2>&1
+  wait $DB_CHECK_PID > /dev/null 2>&1
+fi
+
+# do a normal recovery
+db_recover -v -h $imap_prefix/db
+RETVAL=$?
+if [ $RETVAL -ne 0 ]; then
+  # try a catastrophic recovery instead of normal recovery
+  db_recover -v -c -h $imap_prefix/db
+  RETVAL=$?
+  ERRVAL=$[ $ERRVAL + $RETVAL ]
+  if [ $RETVAL -ne 0 ]; then
+    echo "ERROR: catastrophic recovery of Berkeley databases failed"
+  fi
+fi
+
+if [ "$EXPORT" = "export" ]; then
+  # convert all db files to skiplist for migration
+  # TODO: quota_db, we don't touch it for now
+  cvt_file $imap_prefix/deliver.db           "skiplist"
+  cvt_file $imap_prefix/mailboxes.db         "skiplist"
+  cvt_file $imap_prefix/tls_sessions.db      "skiplist"
+  cvt_file $imap_prefix/annotations.db       "skiplist"
+  cvt_file $imap_prefix/ptclient/ptscache.db "skiplist"
+  rm -vf $imap_prefix/db/log.*
+  rm -vf $imap_prefix/db/__db.*
+else
+  # always convert db files which have been converted to skiplist
+  # TODO: quota_db, we don't touch it for now
+  cvt_file $imap_prefix/deliver.db           "$duplicate_db"
+  cvt_file $imap_prefix/mailboxes.db         "$mboxlist_db"
+  cvt_file $imap_prefix/tls_sessions.db      "$tlscache_db"
+  cvt_file $imap_prefix/annotations.db       "$annotation_db"
+  cvt_file $imap_prefix/ptclient/ptscache.db "$ptscache_db"
+  # do we have to convert all databases?
+  if ! cmp -s $db_current $db_cache; then
+    # we treat sieve scripts the same way like db files
+    find ${sieve_dir}/ -name "*.script" -type f | while read db_file trash; do
+      cvt_to_utf8 "$db_file"
+    done
+    $masssievec $sievec
+    # convert all db files left
+    find ${imap_prefix}/user/ -name "*.seen" -type f | while read db_file trash; do
+      cvt_file "$db_file" "$seenstate_db"
+    done
+    find ${imap_prefix}/user/ -name "*.sub" -type f | while read db_file trash; do
+      cvt_file "$db_file" "$subscription_db"
+    done
+    find ${imap_prefix}/user/ -name "*.mboxkey" -type f | while read db_file trash; do
+      cvt_file "$db_file" "$mboxkey_db"
+    done
+  fi
 fi
 
-# copy the current config file so we can check whether something has changed
+# update the config cache file so we can check whether something has changed
 if [ $ERRVAL -eq 0 ]; then
   mv -f $db_current $db_cache
 else


Index: cyrus-imapd.init
===================================================================
RCS file: /cvs/extras/rpms/cyrus-imapd/devel/cyrus-imapd.init,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- cyrus-imapd.init	15 Apr 2005 20:24:15 -0000	1.1
+++ cyrus-imapd.init	28 Feb 2006 20:04:01 -0000	1.2
@@ -7,22 +7,9 @@
 # config: /etc/imapd.conf
 # pidfile: /var/run/cyrus-master.pid
 
-# author:       Simon Matter, Invoca Systems <simon.matter at invoca.ch>
-# version:	2005010600
-# changed:	2002020200 chkconfig modified
-#               2002042500 rewrote start function
-#               2002091800 added auto db converting functionality
-#		2003020400 modified to use builtin daemon mode
-#		2003050200 modified exec path
-#		2003050900 return RETVAL from rhstatus(), did some cleanup
-#		2003060700 added umask for cvt_cyrusdb_all log
-#		2004012300 modified auto db converting functionality for 2.2
-#		2004012700 fixed startup procedure
-#		2004022400 change su within init script to get input from
-#			   /dev/null, this prevents hang when running in SELinux
-#		2004052000 don't enable cyrus-imapd per default
-#		2004111900 use runuser instead of su if available
-#		2005010600 removed LIB placeholder
+# author:	Simon Matter, Invoca Systems <simon.matter at invoca.ch>
+# version:	2005111100
+# changed:	add quickstart/stop option to init script to bypass db import/export
 
 # Source function library
 if [ -f /etc/init.d/functions ]; then
@@ -50,48 +37,67 @@
   BASENAME=$(basename $BASENAME)
 fi
 
-# fallback to su if runuser not available
-if [ -x /sbin/runuser ]; then
-  RUNUSER=runuser
+# Source service configuration.
+if [ -f /etc/sysconfig/$BASENAME ]; then
+  . /etc/sysconfig/$BASENAME
 else
-  RUNUSER=su
+  echo "$BASENAME: configfile /etc/sysconfig/$BASENAME does NOT exist !"
+  exit 1
 fi
 
+# get_config [config default]
+# extracts config option from config file
+get_config() {
+  if config=$(grep "^$1" /etc/imapd.conf); then
+    echo $config | cut -d: -f2
+  else
+    echo $2
+  fi
+}
+
+# where to find files and directories
+CONFIGDIRECTORY=$(get_config configdirectory /var/lib/imap)
 CYRUSMASTER=/usr/lib/cyrus-imapd/cyrus-master
 CYRUS_PROC_NAME=$(basename $CYRUSMASTER)
 ALWAYS_CONVERT=1
 
-# Source service configuration.
-if [ -f /etc/sysconfig/$BASENAME ]; then
-  . /etc/sysconfig/$BASENAME
+# fallback to su if runuser not available
+if [ -x /sbin/runuser ]; then
+  RUNUSER=runuser
 else
-  echo "$BASENAME: configfile /etc/sysconfig/$BASENAME does NOT exist !"
-  exit 1
+  RUNUSER=su
 fi
 
 RETVAL=0
+RETVAL2=1
+QUICK=0
 
 start() {
-  echo -n $"Starting $BASENAME: "
   if [ $(/sbin/pidof -s $CYRUSMASTER) ]; then
     echo -n $"$BASENAME already running."
     false
+    echo
   else
-    echo -n $"preparing databases... "
-    $RUNUSER - cyrus -c "umask 166 ; /usr/lib/cyrus-imapd/cvt_cyrusdb_all > /var/lib/imap/rpm/cvt_cyrusdb_all.log 2>&1" < /dev/null
-    RETVAL=$?
+    if [ $QUICK -eq 0 ]; then
+      echo -n $"Importing $BASENAME databases: "
+      cd $CONFIGDIRECTORY
+      $RUNUSER - cyrus -c "umask 166 ; /usr/lib/cyrus-imapd/cvt_cyrusdb_all > ${CONFIGDIRECTORY}/rpm/db_import.log 2>&1" < /dev/null
+      RETVAL=$?
+      if [ $RETVAL -eq 0 ]; then
+        success $"$BASENAME importing databases"
+      else
+        failure $"$BASENAME error importing databases, check ${CONFIGDIRECTORY}/rpm/db_import.log"
+      fi
+      echo
+    fi
     if [ $RETVAL -eq 0 ]; then
-      echo -n $"done. "
+      echo -n $"Starting $BASENAME: "
       daemon $CYRUSMASTER -d $CYRUSOPTIONS
-    else
-      echo -n $"error! "
-      initlog -n $BASENAME -s "error converting databases, check /var/lib/imap/rpm/cvt_cyrusdb_all.log"
-      failure $"$BASENAME startup"
+      RETVAL2=$?
+      echo
     fi
   fi
-  RETVAL=$?
-  echo
-  [ $RETVAL -eq 0 ] && touch /var/lock/subsys/$BASENAME
+  [ $RETVAL -eq 0 -a $RETVAL2 -eq 0 ] && touch /var/lock/subsys/$BASENAME
   return $RETVAL
 }
 
@@ -99,8 +105,22 @@
   echo -n $"Shutting down $BASENAME: "
   killproc $CYRUSMASTER
   RETVAL=$?
-  [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$BASENAME
+  if [ $QUICK -eq 0 ]; then
+    if [ ! $(/sbin/pidof -s $CYRUSMASTER) ]; then
+      echo
+      echo -n $"Exporting $BASENAME databases: "
+      cd $CONFIGDIRECTORY
+      $RUNUSER - cyrus -c "umask 166 ; /usr/lib/cyrus-imapd/cvt_cyrusdb_all export > ${CONFIGDIRECTORY}/rpm/db_export.log 2>&1" < /dev/null
+      RETVAL2=$?
+      if [ $RETVAL2 -eq 0 ]; then
+        success $"$BASENAME exporting databases"
+      else
+        failure $"$BASENAME error exporting databases, check ${CONFIGDIRECTORY}/rpm/db_export.log"
+      fi
+    fi
+  fi
   echo
+  [ $RETVAL -eq 0 -a $RETVAL2 -eq 0 ] && rm -f /var/lock/subsys/$BASENAME
   return $RETVAL
 }
 
@@ -146,8 +166,16 @@
   status)
     rhstatus
     ;;
+  quickstart)
+    QUICK=1
+    start
+    ;;
+  quickstop)
+    QUICK=1
+    stop
+    ;;
   *)
-    echo $"Usage: $BASENAME {start|stop|restart|reload|condrestart|status}"
+    echo $"Usage: $BASENAME {start|stop|restart|reload|condrestart|status|quickstart|quickstop}"
     RETVAL=1
 esac
 


Index: cyrus-imapd.rpm_set_permissions
===================================================================
RCS file: /cvs/extras/rpms/cyrus-imapd/devel/cyrus-imapd.rpm_set_permissions,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- cyrus-imapd.rpm_set_permissions	15 Apr 2005 20:24:15 -0000	1.1
+++ cyrus-imapd.rpm_set_permissions	28 Feb 2006 20:04:01 -0000	1.2
@@ -8,18 +8,18 @@
 fi
 
 find $CONFDIR -type d ! -name "lost+found" -exec chmod 700 {} \; -exec chown cyrus:mail {} \;
-grep -se "^partition-.*:" $IMAPCONF | cut -d":" -f2 | while read SPOOLDIR; do
+grep -sE "^(meta|)partition-.*:" $IMAPCONF | cut -d":" -f2 | while read SPOOLDIR; do
   if [ "x$SPOOLDIR" = "x" ]; then
-    echo "$0 warning: invalid partition configuration in /etc/imapd.conf found!"
+    echo "$0 warning: invalid (meta)partition configuration in /etc/imapd.conf found!"
   else
     find $SPOOLDIR -type d ! -name "lost+found" -exec chmod 700 {} \; -exec chown cyrus:mail {} \;
   fi
 done
 
 find $CONFDIR -type f ! -name "lost+found" -exec chmod 600 {} \; -exec chown cyrus:mail {} \;
-grep -se "^partition-.*:" $IMAPCONF | cut -d":" -f2 | while read SPOOLDIR; do
+grep -sE "^(meta|)partition-.*:" $IMAPCONF | cut -d":" -f2 | while read SPOOLDIR; do
   if [ "x$SPOOLDIR" = "x" ]; then
-    echo "$0 warning: invalid partition configuration in /etc/imapd.conf found!"
+    echo "$0 warning: invalid (meta)partition configuration in /etc/imapd.conf found!"
   else
     find $SPOOLDIR -type f ! -name "lost+found" -exec chmod 600 {} \; -exec chown cyrus:mail {} \;
   fi


Index: cyrus-imapd.spec
===================================================================
RCS file: /cvs/extras/rpms/cyrus-imapd/devel/cyrus-imapd.spec,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- cyrus-imapd.spec	28 Feb 2006 18:36:40 -0000	1.6
+++ cyrus-imapd.spec	28 Feb 2006 20:04:01 -0000	1.7
@@ -1,6 +1,6 @@
-Name:			cyrus-imapd
-Version:		2.2.12
-Release:		1.fc5
+Name: cyrus-imapd
+Version: 2.3.1
+Release: 2.fc5
 
 # ********************** BUILD TIME OPTIONS START **********************
 
@@ -8,140 +8,151 @@
 # rpm --rebuild --define='SEEN_DB skiplist' cyrus-imapd-2.x.x-x.src.rpm
 
 # use saslauth group
-%{!?SASLGROUP:		%define		SASLGROUP 0}
-
+%{!?SASLGROUP: %define SASLGROUP 0}
 # include deliver-wrapper
-%{!?DEL_WRAP:		%define		DEL_WRAP 0}
-
+%{!?DEL_WRAP: %define DEL_WRAP 0}
 # use preforking cyrus.conf
-%{!?PREFORK:		%define		PREFORK 1}
-
+%{!?PREFORK: %define PREFORK 1}
 # enable Netscape hack (recommended)
-%{!?NETSCAPEHACK:	%define		NETSCAPEHACK 1}
-
+%{!?NETSCAPEHACK: %define NETSCAPEHACK 1}
 # enable IMAP4 LIST extensions
-%{!?LISTEXT:		%define		LISTEXT 1}
-
+%{!?LISTEXT: %define LISTEXT 1}
 # enable IDLED support
-%{!?IDLED:		%define		IDLED 1}
-
+%{!?IDLED: %define IDLED 1}
+# enable SNMP support
+%{!?SNMP: %define SNMP 0}
 # force syncronous updates on ext3
-%{!?FORCESYNCEXT3:	%define		FORCESYNCEXT3 0}
-
+%{!?FORCESYNCEXT3: %define FORCESYNCEXT3 0}
 # include autocreate feature
-%{!?AUTOCREATE:		%define		AUTOCREATE 1}
-
+%{!?AUTOCREATE: %define AUTOCREATE 1}
 # include groupcache feature
-%{!?GROUPCACHE:		%define		GROUPCACHE 1}
-
+%{!?GROUPCACHE: %define GROUPCACHE 1}
 # don't check for RFC compliant line termination (bare newlines)
-%{!?NO_BARE_NL:		%define		NO_BARE_NL 0}
-
+%{!?NO_BARE_NL: %define NO_BARE_NL 0}
 # used syslog facility for logging
-%{!?SYSLOGFACILITY:	%define		SYSLOGFACILITY MAIL}
-
+%{!?SYSLOGFACILITY: %define SYSLOGFACILITY MAIL}
 # use -fpie for linking
-%{!?USEPIE:		%define		USEPIE 0}
-
-# OutlookExpress seenstate patch
-%{!?OE_SEEN_ST:		%define		OE_SEEN_ST 1}
-
-# use authorization module METHOD [unix|krb5]
-%{!?AUTH_METHOD:	%define		AUTH_METHOD unix}
+%{!?USEPIE: %define USEPIE 0}
 
 # ********************** BUILD TIME OPTIONS END ************************
 
-%define			_use_internal_dependency_generator 0
-%define			_rhver %(eval rpm -q --queryformat '%{VERSION}' $(rpm -qf /etc/redhat-release))
-%define			_rhrelease %(eval %{__cat} /etc/redhat-release)
-%define			_dbver db4
-%define			_dbrpmver %(eval "rpm -q %{_dbver}")
+%define _acversion 2.59
+%define _use_internal_dependency_generator 0
+%define _rhver %(eval rpm -q --queryformat '%{VERSION}' $(rpm -qf /etc/redhat-release))
+%define _rhrelease %(eval %{__cat} /etc/redhat-release)
+%define _dbver db4
+%define _dbrpmver %(eval "rpm -q %{_dbver}")
 # Do we need the perl install hack for RedHat > 7.3 ?
-%define			_perlhack %(eval [ %{_rhver} = "6.2" -o %{_rhver} = "7.0" -o %{_rhver} = "7.1" -o %{_rhver} = "7.2" -o %{_rhver} = "7.3" -o %{_rhver} = "2.1AS" -o %{_rhver} = "2.1ES" ] && echo 0 || echo 1)
-%define			_perl_man3dir %(eval "$(perl -V:man3dir)"; echo $man3dir)
+%define _perlhack %(eval [ %{_rhver} = "6.2" -o %{_rhver} = "7.0" -o %{_rhver} = "7.1" -o %{_rhver} = "7.2" -o %{_rhver} = "7.3" -o %{_rhver} = "2.1AS" -o %{_rhver} = "2.1ES" ] && echo 0 || echo 1)
+%define _perl_man3dir %(eval "$(perl -V:man3dir)"; echo $man3dir)
+%define _withldap %(eval "rpm -q --requires openldap | grep -q ^libsasl2 && echo 1 || echo 0")
+%define _snmpver %(eval "rpm -q --quiet ucd-snmp && echo ucd || echo net")
 # Disable -debuginfo package generation
-#define debug_package	%{nil}
+#define debug_package %{nil}
+# Do we have filesystem >= 2.3.2 (new pki location) ?
+%define use_etc_pki %(eval [ $(rpm -q --queryformat '%{VERSION}' filesystem \| sed -e "s/\\.//g") -ge 232 ] && echo 1 || echo 0 )
+%if %{use_etc_pki}
+%define certs_dir %{_sysconfdir}/pki/tls/certs
 %define pki_dir %{_sysconfdir}/pki/%{name}
+%else
+%define certs_dir %{_datadir}/ssl/certs
+%define pki_dir %{_datadir}/ssl/certs
+%endif
 %define ssl_pem_file %{pki_dir}/%{name}.pem
-
-Summary:		A high-performance mail server with IMAP, POP3, NNTP and SIEVE support.
-License:		BSD
-Group:			System Environment/Daemons
-URL:			http://asg.web.cmu.edu/cyrus/imapd/
-#Packager:		Simon Matter <simon.matter at invoca.ch>
-#Vendor:		Invoca Systems
-#Distribution:		Invoca Linux Server
-Source0:		ftp://ftp.andrew.cmu.edu/pub/cyrus/%{name}-%{version}.tar.gz
-Source1:		ftp://ftp.andrew.cmu.edu/pub/cyrus/%{name}-%{version}.tar.gz.sig
-Source2:		cyrus-procmailrc
-Source3:		cyrus-deliver-wrapper.c
-Source4:		cyrus-user-procmailrc.template
-Source5:		cyrus-imapd.logrotate
-Source6:		cyrus-imapd.imap-2.2.x-conf
-Source7:		cyrus-imapd.pam-config
-Source8:		http://email.uoa.gr/projects/cyrus/autocreate/README.autocreate-cyrus-2.2
-Source9:		http://email.uoa.gr/projects/cyrus/autosievefolder/README.autosievefolder
-Source10:		cyrus-imapd-db.cfg
-Source11:		cyrus-imapd.init
-Source12:		cyrus-imapd.sysconfig
-Source13:		cyrus-imapd.cvt_cyrusdb_all
-Source14:		cyrus-imapd.magic
-Source15:      		http://clement.hermann.free.fr/scripts/Cyrus/imapcreate.pl
-Source16:		http://eu.dl.sourceforge.net/cyrus-utils/cyrus_ldap_quota.pl
-Source17:		ftp://kalamazoolinux.org/pub/projects/awilliam/cyrus/batchreconstruct
-Source18:		ftp://kalamazoolinux.org/pub/projects/awilliam/cyrus/bsd2cyrus
-Source19:		ftp://kalamazoolinux.org/pub/projects/awilliam/cyrus/cpmsg
-Source20:		ftp://kalamazoolinux.org/pub/projects/awilliam/cyrus/folderxfer
-Source21:		ftp://kalamazoolinux.org/pub/projects/awilliam/cyrus/inboxfer
-Source22:		http://email.uoa.gr/download/cyrus/cyrus_sharedbackup/cyrus_sharedbackup-0.1.tar.gz
-Source23:		cyrus-imapd-README.RPM
-Source24:		cyrus-imapd-README.HOWTO-recover-mailboxes.db
-Source25:		cyrus-imapd.cron-daily
-Source27:		cyrus-imapd-procmail+cyrus.mc
-Source28:		cyrus-imapd.rpm_set_permissions
-Source29:		cyrus-imapd-sendmail-8.12.9-cyrusv2.m4
-Source30:		cyrus-imapd-README.contrib
-Source31:		cyrus-imapd-README.groupcache
-Source32:		cyrus-imapd.upd_groupcache
-Patch0:			cyrus-imapd-2.1.9-fdatasync.patch
-Patch1:			http://email.uoa.gr/download/cyrus/cyrus-imapd-2.2.12/cyrus-imapd-2.2.12-autocreate-0.9.2.diff
-Patch2:			http://email.uoa.gr/download/cyrus/cyrus-imapd-2.2.12/cyrus-imapd-2.2.12-autosievefolder-0.6.diff
-Patch3:			http://email.uoa.gr/download/cyrus/cyrus-imapd-2.2.10/cyrus-imapd-2.2.10-rmquota+deletemailbox-0.1.diff
-Patch4:			http://servercc.oakton.edu/~jwade/cyrus/cyrus-imapd-2.1.3/cyrus-imapd-2.1.3-flock.patch
-Patch5:			cyrus-imapd-2.2.4-munge8bit.patch
-Patch6:			cyrus-imapd-2.1.16-getrlimit.patch
-Patch7:			cyrus-imapd-2.1.15-nobarenewlinescheck.patch
-Patch8:			cyrus-imapd-2.2.10-groupcache.patch
-Patch9:			cyrus-imapd-2.2.4-OE-seenstate.patch
-Patch10:		cyrus-imapd-acceptinvalidfrom.patch
-Patch50:		cyrus-imapd-gcc4.patch
-# Patches >= 100 are fixed in CVS
-BuildRoot:		%{_tmppath}/%{name}-%{version}-root
-Prereq:			e2fsprogs, diffutils, /sbin/chkconfig, /sbin/service
-Requires:		cyrus-sasl >= 2.1.15, file >= 3.35-1
-Requires:		filesystem >= 2.3.2-1
-Requires:		openssl >= 0.9.7f-4
-BuildPrereq:		cyrus-sasl-devel >= 2.1.15-1, perl, tcp_wrappers, %{_dbver}-devel, openssl-devel
-BuildPrereq:		flex, bison, groff >= 1.15-8, autoconf
-
-%define			uid 76
+%define uid 76
 %if %{SASLGROUP}
-%define			gid 76
-%define			_saslgroup saslauth
+%define gid 76
+%define _saslgroup saslauth
 %endif
-%define			_cyrususer cyrus
-%define			_cyrusgroup mail
-%define			_vardata %{_var}/lib/imap
-%define			_spooldata %{_var}/spool/imap
-%define			_cyrexecdir %{_exec_prefix}/lib/%{name}
-%define			_confdir master/conf
-%define			_contribdir doc/contrib
+%define _cyrususer cyrus
+%define _cyrusgroup mail
+%define _vardata %{_var}/lib/imap
+%define _spooldata %{_var}/spool/imap
+%define _cyrexecdir %{_exec_prefix}/lib/%{name}
+%define _confdir master/conf
+%define _contribdir doc/contrib
 %if %{PREFORK}
-%define			_cyrusconf %{_confdir}/prefork.conf
+%define _cyrusconf %{_confdir}/prefork.conf
 %else
-%define			_cyrusconf %{_confdir}/normal.conf
+%define _cyrusconf %{_confdir}/normal.conf
 %endif
 
+Summary: A high-performance mail server with IMAP, POP3, NNTP and SIEVE support.
+License: BSD
+Group: System Environment/Daemons
+URL: http://asg.web.cmu.edu/cyrus/imapd/
+#Packager: Simon Matter <simon.matter at invoca.ch>
+#Vendor: Invoca Systems
+#Distribution: Invoca Linux Server
+Source0: ftp://ftp.andrew.cmu.edu/pub/cyrus/%{name}-%{version}.tar.gz
+Source1: ftp://ftp.andrew.cmu.edu/pub/cyrus/%{name}-%{version}.tar.gz.sig
+Source2: http://ftp.gnu.org/gnu/autoconf/autoconf-%{_acversion}.tar.gz
+Source3: cyrus-deliver-wrapper.c
+Source4: cyrus-user-procmailrc.template
+Source5: cyrus-imapd.logrotate
+Source6: cyrus-imapd.imap-2.3.x-conf
+Source7: cyrus-imapd.pam-config
+Source8: http://email.uoa.gr/projects/cyrus/autocreate/README.autocreate-cyrus-2.3
+Source9: http://email.uoa.gr/projects/cyrus/autosievefolder/README.autosievefolder
+Source10: http://oss.netfarm.it/download/skiplist.py
+Source11: cyrus-imapd.init
+Source12: cyrus-imapd.sysconfig
+Source13: cyrus-imapd.cvt_cyrusdb_all
+Source14: cyrus-imapd.magic
+Source15: http://clement.hermann.free.fr/scripts/Cyrus/imapcreate.pl
+Source16: http://eu.dl.sourceforge.net/cyrus-utils/cyrus_ldap_quota.pl
+Source17: ftp://kalamazoolinux.org/pub/projects/awilliam/cyrus/batchreconstruct
+Source18: ftp://kalamazoolinux.org/pub/projects/awilliam/cyrus/bsd2cyrus
+Source19: ftp://kalamazoolinux.org/pub/projects/awilliam/cyrus/cpmsg
+Source20: ftp://kalamazoolinux.org/pub/projects/awilliam/cyrus/folderxfer
+Source21: ftp://kalamazoolinux.org/pub/projects/awilliam/cyrus/inboxfer
+Source22: http://email.uoa.gr/download/cyrus/cyrus_sharedbackup/cyrus_sharedbackup-0.1.tar.gz
+Source23: cyrus-imapd-README.RPM
+Source24: cyrus-imapd-README.HOWTO-recover-mailboxes.db
+Source25: cyrus-imapd.cron-daily
+Source26: cyrus-procmailrc
+Source27: cyrus-imapd-procmail+cyrus.mc
+Source28: cyrus-imapd.rpm_set_permissions
+Source29: cyrus-imapd-sendmail-8.12.9-cyrusv2.m4
+Source30: cyrus-imapd-README.contrib
+Source31: cyrus-imapd-README.groupcache
+Source32: cyrus-imapd.upd_groupcache
+Source33: cyrus-imapd-README.skiplist_recovery
+Patch0: cyrus-imapd-2.2.12-no_transfig.patch
+Patch1: http://email.uoa.gr/download/cyrus/cyrus-imapd-2.3.1/cyrus-imapd-2.3.1-autocreate-0.10-0.diff
+Patch2: http://email.uoa.gr/download/cyrus/cyrus-imapd-2.3.1/cyrus-imapd-2.3.1-autosievefolder-0.6-0.diff
+Patch3: http://email.uoa.gr/download/cyrus/cyrus-imapd-2.3.1/cyrus-imapd-2.3.1-rmquota+deletemailbox-0.2-1.diff
+Patch4: http://servercc.oakton.edu/~jwade/cyrus/cyrus-imapd-2.1.3/cyrus-imapd-2.1.3-flock.patch
+Patch5: cyrus-imapd-2.2.12-munge8bit.patch
+Patch6: cyrus-imapd-2.1.16-getrlimit.patch
+Patch7: cyrus-imapd-2.1.15-nobarenewlinescheck.patch
+Patch8: cyrus-imapd-2.2.10-groupcache.patch
+Patch9: cyrus-imapd-2.3.1-config_defaults.patch
+Patch10: cyrus-imapd-acceptinvalidfrom.patch
+Patch11: cyrus-imapd-2.2.12-dam_invalid_id-christos.patch
+Patch12: cyrus-imapd-2.2.12-notify_sms.patch
+Patch13: allow_auth_plain_proxying.patch
+Patch14: cyrus-imapd-2.3.1-authid_normalize.patch
+Patch15: cyrus-imapd-2.3.1-make_md5_defaults.patch
+# Patches >= 100 are / will be fixed in CVS
+Patch100: cyrus-imapd-2.3.1-make_md5.patch
+Patch101: cyrus-imapd-2.3.1-backend_sigsegv.patch
+Patch102: cyrus-imapd-2.3.1-replication_policycheck.patch
+BuildRoot: %{_tmppath}/%{name}-%{version}-root
+BuildPrereq: cyrus-sasl-devel >= 2.1.15-1, perl, tcp_wrappers
+BuildPrereq: %{_dbver}-devel, openssl-devel, pkgconfig
+BuildPrereq: flex, bison, groff >= 1.15-8, automake
+%if %{_withldap}
+BuildPrereq: openldap-devel
+%endif
+%if %{SNMP}
+BuildPrereq: %{_snmpver}-snmp-devel, lm_sensors-devel
+%endif
+Prereq: e2fsprogs, /sbin/chkconfig, /sbin/service
+Prereq: %{name}-utils = %{version}-%{release}
+Requires: cyrus-sasl >= 2.1.15, file >= 3.35-1, %{_dbver}-utils
+Obsoletes: %{name}-murder, %{name}-nntp
+
 %description
 The %{name} package contains the core of the Cyrus IMAP server.
 It is a scaleable enterprise mail system designed for use from
@@ -151,33 +162,24 @@
 A full Cyrus IMAP implementation allows a seamless mail and bulletin
 board environment to be set up across multiple servers. It differs from
 other IMAP server implementations in that it is run on "sealed"
-servers, where users are not normally permitted to log in. The mailbox
-database is stored in parts of the filesystem that are private to the
-Cyrus IMAP server. All user access to mail is through software using
-the IMAP, POP3, or KPOP protocols. TLSv1 and SSL are supported for
-security.
-
-%package murder
-Group: System Environment/Daemons
-Summary: Cyrus IMAP server murder aggregator system files.
-Requires: %{name} = %{version}-%{release}
-
-%description murder
-The %{name}-murder package contains the Cyrus murder aggregator system,
-i.e. IMAP, POP3 and LMTP proxies, and the mupdate mailbox master daemon.
-It allows for cluster setups where there are many backend Cyrus spools
-and frontend proxy servers.
-
-%package nntp
-Group: System Environment/Daemons
-Summary: Cyrus IMAP server NNTP system files.
-Requires: %{name} = %{version}-%{release}
- 
-%description nntp
-The %{name}-nntp package contains the Cyrus NNTP server component.
-Cyrus has the ability to export Usenet via IMAP and/or export shared IMAP
-mailboxes via NNTP. This is made possible by a new NNTP daemon which is
-included with Cyrus.
+servers, where users are not normally permitted to log in and have no
+system account on the server. The mailbox database is stored in parts
+of the filesystem that are private to the Cyrus IMAP server. All user
+access to mail is through software using the IMAP, POP3 or KPOP
+protocols. It also includes support for virtual domains, NNTP,
+mailbox annotations, and much more. The private mailbox database design
+gives the server large advantages in efficiency, scalability and
+administratability. Multiple concurrent read/write connections to the
+same mailbox are permitted. The server supports access control lists on
+mailboxes and storage quotas on mailbox hierarchies.
+
+The Cyrus IMAP server supports the IMAP4rev1 protocol described
+in RFC 3501. IMAP4rev1 has been approved as a proposed standard.
+It supports any authentication mechanism available from the SASL
+library, imaps/pop3s/nntps (IMAP/POP3/NNTP encrypted using SSL and
+TLSv1) can be used for security. The server supports single instance
+store where possible when an email message is addressed to multiple
+recipients, SIEVE provides server side email filtering.
 
 %package devel
 Group: Development/Libraries
@@ -199,6 +201,7 @@
 %package utils
 Group: Applications/System
 Summary: Cyrus IMAP server administration utilities.
+Prereq: diffutils, findutils, grep, sed
 Requires: perl-Cyrus = %{version}-%{release}
 
 %description utils
@@ -207,8 +210,8 @@
 one running the server.
 
 %prep
-%setup -q
-%patch0 -p0 -b .fdatasync
+%setup -q -a 2
+%patch0 -p1 -b .no_transfig
 %if %{AUTOCREATE}
 %patch1 -p1 -b .autocreate
 %patch2 -p1 -b .autosievefolder
@@ -223,18 +226,37 @@
 %if %{GROUPCACHE}
 %patch8 -p1 -b .groupcache
 %endif
-%if %{OE_SEEN_ST}
-%patch9 -p1 -b .oeseenstate
-%endif
+%patch9 -p1 -b .config_defaults
 %patch10 -p1 -b .acceptinvalidfrom
-%patch50 -p1
+%patch11 -p1 -b .dam_invalid_id
+%patch12 -p1 -b .notify_sms
+%patch13 -p0 -b .allow_auth_plain
+%patch14 -p1 -b .authid_normalize
+%patch15 -p1 -b .make_md5_defaults
+%patch100 -p1 -b .make_md5
+%patch101 -p1 -b .backend_sigsegv
+%patch102 -p1 -b .replication_policycheck
+
+# build and run private autoconf
+autodir=$(pwd)/auto-instroot
+pushd autoconf-%{_acversion}
+./configure --prefix=$autodir
+make all install
+popd
+PATH=${autodir}/bin:${PATH}
+aclocal -I cmulocal
+autoheader
+autoconf -f
 
 %build
-# kerberos include is needed (because of openssl-0.9.7 ?)
-CPPFLAGS="-I%{_includedir}/et -I%{_prefix}/kerberos/include"; export CPPFLAGS
+CPPFLAGS="-I%{_includedir}/et"; export CPPFLAGS
 CFLAGS="$RPM_OPT_FLAGS -fPIC"; export CFLAGS
+if pkg-config openssl; then
+  CPPFLAGS="$(pkg-config --cflags-only-I openssl) $CPPFLAGS"; export CPPFLAGS
+  CFLAGS="$(pkg-config --cflags openssl) $CFLAGS"; export CFLAGS
+  LDFLAGS="$(pkg-config --libs-only-L openssl) $LDFLAGS"; export LDFLAGS
+fi
 CCDLFLAGS="-rdynamic"; export CCDLFLAGS
-LDFLAGS="-L%{_prefix}/kerberos/%{_lib}"; export LDFLAGS
 %if %{USEPIE}
 %ifnarch ppc ppc64
 LDFLAGS="$LDFLAGS -pie"; export LDFLAGS
@@ -249,20 +271,30 @@
   --enable-listext \
 %endif
 %if %{IDLED}
-  --with-idle=idled \
+  --enable-idled \
+%endif
+%if %{_withldap}
+  --with-ldap \
+%endif
+%if %{SNMP}
+  --with-snmp \
+%else
+  --without-snmp \
 %endif
   --enable-murder \
+  --enable-replication \
   --enable-nntp \
-  --without-snmp \
   --with-perl=%{__perl} \
   --with-cyrus-prefix=%{_cyrexecdir} \
   --with-service-path=%{_cyrexecdir} \
-  --with-auth=%{AUTH_METHOD} \
   --with-bdb-incdir=%{_includedir}/%{_dbver} \
   --with-extraident="Invoca-RPM-%{version}-%{release}" \
   --with-syslogfacility=%{SYSLOGFACILITY}
 
+%{__make} -C man -f Makefile.dist
+%{__make} -C doc -f Makefile.dist
 %{__make}
+%{__make} -C notifyd notifytest
 %if %{DEL_WRAP}
 %{__cc} $CFLAGS -DLIBEXECDIR=\"%{_cyrexecdir}\" -Wall -o deliver-wrapper %{SOURCE3}
 %endif
@@ -286,15 +318,15 @@
 
 # Cleanup of doc dir
 find doc perl -name CVS -type d | xargs -r %{__rm} -fr
+find doc perl -name .cvsignore -type f | xargs -r %{__rm} -f
 find doc -name "*~" -type f | xargs -r %{__rm} -f
-%{__rm} -f doc/Makefile.dist
+find doc -name "*.html.*" -type f | xargs -r %{__rm} -f
+%{__rm} -f doc/Makefile.dist*
 %{__rm} -f doc/text/htmlstrip.c
 
 # Create README.buildoptions
 %{__cat} << EOF >> doc/README.buildoptions
-This RPM has been compiled on %{_rhrelease} using
-Berkeley DB version %{_dbrpmver} with the following source
-RPM build options:
+This RPM has been built on %{_rhrelease} using the following options:
 
 use saslauth group
 SASLGROUP       : %{SASLGROUP}
@@ -314,6 +346,9 @@
 enable IDLED support
 IDLED           : %{IDLED}
 
+enable SNMP support
+SNMP            : %{SNMP}
+
 force syncronous updates on ext3
 FORCESYNCEXT3   : %{FORCESYNCEXT3}
 
@@ -332,11 +367,11 @@
 used -fpie for linking
 USEPIE          : %{USEPIE}
 
-include OutlookExpress seenstate patch
-OE_SEEN_ST      : %{OE_SEEN_ST}
+enable LDAP support
+(autodetected)  : %{_withldap}
 
-use authorization module METHOD [unix|krb5]
-AUTH_METHOD     : %{AUTH_METHOD}
+Berkeley DB version
+(autodetected)  : %{_dbrpmver}
 
 
 To modify parameters, edit the .spec file or build like this:
@@ -348,12 +383,13 @@
 %if %{GROUPCACHE}
 %{__install} -m 644 %{SOURCE31}	doc/README.groupcache
 %endif
+%{__install} -m 644 %{SOURCE33} doc/README.skiplist_recovery
 %if %{AUTOCREATE}
 %{__install} -m 644 %{SOURCE8}  doc/README.autocreate
 %{__install} -m 644 %{SOURCE9}  doc/README.autosievefolder
 %endif
 %{__install} -d doc/m4
-%{__install} -m 644 %{SOURCE2}	doc/m4/cyrus-procmailrc
+%{__install} -m 644 %{SOURCE26}	doc/m4/cyrus-procmailrc
 %{__install} -m 644 %{SOURCE4}	doc/m4/cyrus-user-procmailrc.template
 %{__install} -m 644 %{SOURCE27}	doc/m4/%{name}-procmail+cyrus.mc
 %{__install} -m 644 %{SOURCE29}	doc/m4/%{name}-sendmail-8.12.9-cyrusv2.m4
@@ -389,10 +425,11 @@
 %endif
 
 %if %{DEL_WRAP}
-%{__install} -m 2755 deliver-wrapper	%{buildroot}%{_cyrexecdir}/
+%{__install} -m 2755 deliver-wrapper    %{buildroot}%{_cyrexecdir}/
 %endif
-%{__install} -m 755 imtest/imtest	%{buildroot}%{_cyrexecdir}/
-%{__install} -m 755 perl/imap/cyradm	%{buildroot}%{_cyrexecdir}/
+%{__install} -m 755 imtest/imtest       %{buildroot}%{_bindir}/
+%{__install} -m 755 notifyd/notifytest  %{buildroot}%{_bindir}/
+%{__install} -m 755 perl/imap/cyradm    %{buildroot}%{_bindir}/
 
 # Install tools
 for tool in tools/* ; do
@@ -403,9 +440,11 @@
 %{__install} -d \
   %{buildroot}%{_sysconfdir}/{rc.d/init.d,logrotate.d,pam.d,sysconfig,cron.daily} \
   %{buildroot}%{_libdir}/sasl \
-  %{buildroot}%{_bindir} \
   %{buildroot}%{_spooldata} \
-  %{buildroot}%{_vardata}/{user,quota,proc,log,msg,socket,db,sieve,rpm,backup} \
+  %{buildroot}%{_vardata}/{user,quota,proc,log,msg,socket,db,sieve,sync,md5,rpm,backup} \
+%if %{_withldap}
+  %{buildroot}%{_vardata}/ptclient \
+%endif
   %{buildroot}%{_datadir}/%{name}/rpm \
   %{buildroot}%{pki_dir} \
   %{_contribdir}
@@ -417,7 +456,7 @@
 %endif
 %{__install} -m 755 %{SOURCE28}   %{buildroot}%{_cyrexecdir}/rpm_set_permissions
 %{__install} -m 644 %{SOURCE14}   %{buildroot}%{_datadir}/%{name}/rpm/magic
-%{__install} -m 644 %{SOURCE10}   %{buildroot}%{_datadir}/%{name}/rpm/db.cfg
+%{__install} -m 644 %{SOURCE10}   %{_contribdir}/
 %{__install} -m 644 %{SOURCE15}   %{_contribdir}/imapcreate
 %{__install} -m 644 %{SOURCE16}   %{_contribdir}/cyrus_ldap_quota
 %{__install} -m 644 %{SOURCE17}   %{_contribdir}/batchreconstruct
@@ -437,6 +476,7 @@
 %{__install} -m 644 %{SOURCE7}    %{buildroot}%{_sysconfdir}/pam.d/mupdate
 %{__install} -m 644 %{SOURCE7}    %{buildroot}%{_sysconfdir}/pam.d/lmtp
 %{__install} -m 644 %{SOURCE7}    %{buildroot}%{_sysconfdir}/pam.d/nntp
+%{__install} -m 644 %{SOURCE7}    %{buildroot}%{_sysconfdir}/pam.d/csync
 %{__install} -m 644 %{SOURCE12}   %{buildroot}%{_sysconfdir}/sysconfig/%{name}
 %{__install} -m 644 %{SOURCE5}    %{buildroot}%{_sysconfdir}/logrotate.d/%{name}
 %{__install} -m 755 %{SOURCE25}   %{buildroot}%{_sysconfdir}/cron.daily/%{name}
@@ -446,14 +486,20 @@
 %{__install} -m 755 -d doc/conf
 %{__install} -m 644 %{_confdir}/*.conf doc/conf/
 
+# Generate db config file
+( grep '^{' lib/imapoptions | grep _db | cut -d'"' -f 2,4 | \
+  sed -e 's/^ *//' -e 's/-nosync//' -e 's/ *$//' -e 's/"/=/'
+  echo sieve_version=2.2.3 ) | sort > %{buildroot}%{_datadir}/%{name}/rpm/db.cfg
+
 # create the ghost pem file
 touch %{buildroot}%{ssl_pem_file}
+%if %{use_etc_pki}
 # change config file so ssl certificates are under /etc rather than /usr/share
 %{__perl} -pi -e \
-'s@/usr/share/ssl/certs/cyrus-imapd.pem@%{ssl_pem_file}@g; \
+'s@/usr/share/ssl/certs/%{name}.pem@%{ssl_pem_file}@g; \
  s@/usr/share/ssl/certs/ca-bundle.crt@/etc/pki/tls/certs/ca-bundle.crt@' \
  %{buildroot}%{_sysconfdir}/imapd.conf
-
+%endif
 
 # Rename 'master' binary and manpage to avoid crash with postfix
 %{__mv} -f %{buildroot}%{_cyrexecdir}/master         %{buildroot}%{_cyrexecdir}/cyrus-master
@@ -477,10 +523,6 @@
 %{__perl} -pi -e 's/Fetchnews/Cyrfetchnews/g'        doc/man/cyrfetchnews.8.html
 %{__perl} -pi -e 's/FETCHNEWS/CYRFETCHNEWS/g'        doc/man/cyrfetchnews.8.html
 
-# Create symlinks
-%{__ln_s} -f %{_exec_prefix}/lib/%{name}/cyradm %{buildroot}%{_bindir}/
-%{__ln_s} -f %{_exec_prefix}/lib/%{name}/imtest %{buildroot}%{_bindir}/
-
 # Create filelist for perl package, compress manpages before
 [ -x /usr/lib/rpm/brp-compress ] && /usr/lib/rpm/brp-compress
 find %{buildroot}%{perl_sitearch}/Cyrus %{buildroot}%{perl_sitearch}/auto/Cyrus -type f -print |
@@ -499,7 +541,7 @@
 
 # Remove installed but not packaged files
 %{__rm} -f %{buildroot}%{_cyrexecdir}/not-mkdep
-%{__rm} -f %{buildroot}%{_cyrexecdir}/config2header
+%{__rm} -f %{buildroot}%{_cyrexecdir}/config2header*
 %{__rm} -f %{buildroot}%{_cyrexecdir}/config2man
 %{__rm} -f %{buildroot}%{_cyrexecdir}/pop3proxyd
 find %{buildroot} -name "perllocal.pod" -exec %{__rm} -f {} \;
@@ -508,6 +550,9 @@
 %{__rm} -f %{buildroot}%{_mandir}/man8/idled.8*
 %{__rm} -f doc/man/idled.8.html
 %endif
+%{__rm} -f doc/text/Makefile
+%{__rm} -f %{buildroot}%{_mandir}/man8/syncnews.8*
+%{__rm} -f doc/man/syncnews.8.html
 
 # On RedHat 7.3, this file is created here
 %{__rm} -f /perllocal.pod
@@ -516,15 +561,6 @@
 [ "%{buildroot}" != "/" ] && %{__rm} -rf %{buildroot}
 
 %pre
-# Create 'cyrus' user on target host
-%if %{SASLGROUP}
-/usr/sbin/groupadd -g %{gid} -r %{_saslgroup} 2> /dev/null || :
-/usr/sbin/useradd -c "Cyrus IMAP Server" -d %{_vardata} -g %{_cyrusgroup} \
-  -G %{_saslgroup} -s /bin/bash -u %{uid} -r %{_cyrususer} 2> /dev/null || :
-%else
-/usr/sbin/useradd -c "Cyrus IMAP Server" -d %{_vardata} -g %{_cyrusgroup} \
-  -s /bin/bash -u %{uid} -r %{_cyrususer} 2> /dev/null || :
-%endif
 # Let postun know whether cyrus-imapd was running
 if [ -e /var/lock/subsys/cyrus-imapd ]; then
   /sbin/service %{name} stop >/dev/null 2>&1 || :
@@ -534,30 +570,6 @@
 %post
 /sbin/chkconfig --add %{name}
 
-# Create SSL certificates
-exec > /dev/null 2> /dev/null
-# if the certificate is only in the old location, move it to the new location
-if [ -f %{_datadir}/ssl/certs/%{name}.pem -a ! %{ssl_pem_file} ]; then
-mv %{_datadir}/ssl/certs/%{name}.pem %{ssl_pem_file}
-fi
-if [ ! -f %{ssl_pem_file} ]; then
-pushd /etc/pki/tls/certs
-umask 077
-%{__cat} << EOF | make %{name}.pem
---
-SomeState
-SomeCity
-SomeOrganization
-SomeOrganizationalUnit
-localhost.localdomain
-root at localhost.localdomain
-EOF
-%{__chown} root.%{_cyrusgroup} %{name}.pem
-%{__chmod} 640 %{name}.pem
-mv %{name}.pem %{ssl_pem_file}
-popd
-fi
-
 # Force synchronous updates, usually only on ext2 filesystems
 for i in %{_vardata}/{user,quota} %{_spooldata}
 do
@@ -586,14 +598,104 @@
   fi
 %endif
 
+%if %{use_etc_pki}
+# change existing config so ssl certificates are under /etc rather than /usr/share
+%{__perl} -pi -e \
+'s@/usr/share/ssl/certs/%{name}.pem@%{ssl_pem_file}@g; \
+ s@/usr/share/ssl/certs/ca-bundle.crt@/etc/pki/tls/certs/ca-bundle.crt@' \
+ %{_sysconfdir}/imapd.conf
+%endif
+
 %preun
 if [ $1 = 0 ]; then
   /sbin/service %{name} stop >/dev/null 2>&1 || :
   /sbin/chkconfig --del %{name}
-  %{__rm} -f %{_vardata}/socket/lmtp 2> /dev/null
+  %{__rm} -f %{_vardata}/socket/* 2> /dev/null
+  %{__rm} -f %{_vardata}/proc/* 2> /dev/null
+%if %{_withldap}
+  %{__rm} -f %{_vardata}/ptclient/ptsock 2> /dev/null
+%endif
 fi
 
 %postun
+if [ $1 != 0 ]; then
+  /sbin/service %{name} condrestart >/dev/null 2>&1 || :
+fi
+
+%pre utils
+# Create 'cyrus' user on target host
+%if %{SASLGROUP}
+/usr/sbin/groupadd -g %{gid} -r %{_saslgroup} 2> /dev/null || :
+/usr/sbin/useradd -c "Cyrus IMAP Server" -d %{_vardata} -g %{_cyrusgroup} \
+  -G %{_saslgroup} -s /bin/bash -u %{uid} -r %{_cyrususer} 2> /dev/null || :
+%else
+/usr/sbin/useradd -c "Cyrus IMAP Server" -d %{_vardata} -g %{_cyrusgroup} \
+  -s /bin/bash -u %{uid} -r %{_cyrususer} 2> /dev/null || :
+%endif
+
+%post utils
+# Create SSL certificates
+exec > /dev/null 2> /dev/null
+%if %{use_etc_pki}
+# if the certificate is only in the old location, move it to the new location
+if [ -f %{_datadir}/ssl/certs/%{name}.pem -a ! -f %{ssl_pem_file} ]; then
+mv %{_datadir}/ssl/certs/%{name}.pem %{ssl_pem_file}
+fi
+%endif
+if [ ! -f %{ssl_pem_file} ]; then
+pushd %{certs_dir}
+umask 077
+%{__cat} << EOF | make %{name}.pem
+--
+SomeState
+SomeCity
+SomeOrganization
+SomeOrganizationalUnit
+localhost.localdomain
+root at localhost.localdomain
+EOF
+%{__chown} root.%{_cyrusgroup} %{name}.pem
+%{__chmod} 640 %{name}.pem
+%if %{use_etc_pki}
+mv %{name}.pem %{ssl_pem_file}
+%endif
+popd
+fi
+
+# Add service entries if necessary
+if ! %{__grep} -q ^lmtp %{_sysconfdir}/services; then
+  echo -e 'lmtp\t\t24/tcp\t\t\t\t# LMTP Mail Delivery over TCP' >> %{_sysconfdir}/services
+  echo -e 'lmtp\t\t24/udp\t\t\t\t# LMTP Mail Delivery over TCP' >> %{_sysconfdir}/services
+fi
+if ! %{__grep} -q ^nntps %{_sysconfdir}/services; then
+  echo -e 'nntps\t\t563/tcp\t\t\t\t# NNTP over SSL' >> %{_sysconfdir}/services
+  echo -e 'nntps\t\t563/udp\t\t\t\t# NNTP over SSL' >> %{_sysconfdir}/services
+fi
+if ! %{__grep} -q ^pop3s %{_sysconfdir}/services; then
+  echo -e 'pop3s\t\t995/tcp\t\t\t\t# POP-3 over SSL' >> %{_sysconfdir}/services
+  echo -e 'pop3s\t\t995/udp\t\t\t\t# POP-3 over SSL' >> %{_sysconfdir}/services
+fi
+if ! %{__grep} -q ^imaps %{_sysconfdir}/services; then
+  echo -e 'imaps\t\t993/tcp\t\t\t\t# IMAP over SSL' >> %{_sysconfdir}/services
+  echo -e 'imaps\t\t993/udp\t\t\t\t# IMAP over SSL' >> %{_sysconfdir}/services
+fi
+if ! %{__grep} -q ^sieve %{_sysconfdir}/services; then
+  echo -e 'sieve\t\t2000/tcp\t\t\t# Sieve Mail Filter Daemon' >> %{_sysconfdir}/services
+  echo -e 'sieve\t\t2000/udp\t\t\t# Sieve Mail Filter Daemon' >> %{_sysconfdir}/services
+fi
+if ! %{__grep} -q ^csync %{_sysconfdir}/services; then
+  echo -e 'csync\t\t2005/tcp\t\t\t# Cyrus IMAP Replication Daemon' >> %{_sysconfdir}/services
+  echo -e 'csync\t\t2005/udp\t\t\t# Cyrus IMAP Replication Daemon' >> %{_sysconfdir}/services
+fi
+if ! %{__grep} -q ^mupdate %{_sysconfdir}/services; then
+  echo -e 'mupdate\t\t3905/tcp\t\t\t# Cyrus IMAP Mupdate Daemon' >> %{_sysconfdir}/services
+  echo -e 'mupdate\t\t3905/udp\t\t\t# Cyrus IMAP Mupdate Daemon' >> %{_sysconfdir}/services
+fi
+if ! %{__grep} -q ^fud %{_sysconfdir}/services; then
+  echo -e 'fud\t\t4201/udp\t\t\t# Cyrus IMAP FUD Daemon' >> %{_sysconfdir}/services
+fi
+
+%postun utils
 if [ $1 = 0 ]; then
   /usr/sbin/userdel %{_cyrususer} 2> /dev/null || :
 %if %{SASLGROUP}
@@ -601,8 +703,6 @@
     /usr/sbin/groupdel %{_saslgroup} 2> /dev/null || :
   fi
 %endif
-else
-  /sbin/service %{name} condrestart >/dev/null 2>&1 || :
 fi
 
 %files
@@ -616,6 +716,9 @@
 %config(noreplace) %{_sysconfdir}/pam.d/imap
 %config(noreplace) %{_sysconfdir}/pam.d/sieve
 %config(noreplace) %{_sysconfdir}/pam.d/lmtp
+%config(noreplace) %{_sysconfdir}/pam.d/mupdate
+%config(noreplace) %{_sysconfdir}/pam.d/csync
+%config(noreplace) %{_sysconfdir}/pam.d/nntp
 %attr(0755,root,root) %config %{_sysconfdir}/cron.daily/%{name}
 %dir %{_cyrexecdir}
 %attr(0755,root,root) %{_cyrexecdir}/arbitron
@@ -638,6 +741,7 @@
 %attr(0755,root,root) %{_cyrexecdir}/masssievec
 %attr(0755,root,root) %{_cyrexecdir}/mbexamine
 %attr(0755,root,root) %{_cyrexecdir}/mbpath
+%attr(0755,root,root) %{_cyrexecdir}/migrate-metadata
 %attr(0755,root,root) %{_cyrexecdir}/mkimap
 %attr(0755,root,root) %{_cyrexecdir}/mknewsgroups
 %attr(0755,root,root) %{_cyrexecdir}/notifyd
@@ -652,6 +756,7 @@
 %attr(0755,root,root) %{_cyrexecdir}/tls_prune
 %attr(0755,root,root) %{_cyrexecdir}/translatesieve
 %attr(0755,root,root) %{_cyrexecdir}/undohash
+%attr(0755,root,root) %{_cyrexecdir}/unexpunge
 %attr(0755,root,root) %{_cyrexecdir}/upgradesieve
 %attr(0755,root,root) %{_cyrexecdir}/cvt_cyrusdb_all
 %if %{GROUPCACHE}
@@ -664,6 +769,20 @@
 %if %{AUTOCREATE}
 %attr(0755,root,root) %{_cyrexecdir}/compile_sieve
 %endif
+%attr(0755,root,root) %{_cyrexecdir}/mupdate
+%attr(0755,root,root) %{_cyrexecdir}/mupdate-loadgen.pl
+%attr(0755,root,root) %{_cyrexecdir}/proxyd
+%attr(0755,root,root) %{_cyrexecdir}/make_md5
+%attr(0755,root,root) %{_cyrexecdir}/sync_client
+%attr(0755,root,root) %{_cyrexecdir}/sync_reset
+%attr(0755,root,root) %{_cyrexecdir}/sync_server
+%attr(0755,root,root) %{_cyrexecdir}/cyrfetchnews
+%attr(0755,root,root) %{_cyrexecdir}/nntpd
+%if %{_withldap}
+%attr(0755,root,root) %{_cyrexecdir}/ptdump
+%attr(0755,root,root) %{_cyrexecdir}/ptexpire
+%attr(0755,root,root) %{_cyrexecdir}/ptloader
+%endif
 %if %{DEL_WRAP}
 %attr(2755,%{_cyrususer},%{_cyrusgroup}) %{_cyrexecdir}/deliver-wrapper
 %endif
@@ -676,8 +795,13 @@
 %attr(0700,%{_cyrususer},%{_cyrusgroup}) %dir %{_vardata}/msg
 %attr(0700,%{_cyrususer},%{_cyrusgroup}) %dir %{_vardata}/db
 %attr(0700,%{_cyrususer},%{_cyrusgroup}) %dir %{_vardata}/sieve
+%attr(0700,%{_cyrususer},%{_cyrusgroup}) %dir %{_vardata}/sync
+%attr(0700,%{_cyrususer},%{_cyrusgroup}) %dir %{_vardata}/md5
 %attr(0700,%{_cyrususer},%{_cyrusgroup}) %dir %{_vardata}/rpm
 %attr(0700,%{_cyrususer},%{_cyrusgroup}) %dir %{_vardata}/backup
+%if %{_withldap}
+%attr(0700,%{_cyrususer},%{_cyrusgroup}) %dir %{_vardata}/ptclient
+%endif
 %attr(0700,%{_cyrususer},%{_cyrusgroup}) %dir %{_spooldata}
 %dir %{_datadir}/%{name}
 %dir %{_datadir}/%{name}/rpm
@@ -686,22 +810,11 @@
 %{_mandir}/man8/*
 %doc COPYRIGHT README
 %doc doc/*
+%if %{use_etc_pki}
 %dir %{pki_dir}
+%endif
 %attr(0640,root,%{_cyrusgroup}) %ghost %config(missingok,noreplace) %verify(not md5 size mtime) %{ssl_pem_file}
 
-%files murder
-%defattr(0644,root,root,0755)
-%config(noreplace) %{_sysconfdir}/pam.d/mupdate
-%attr(0755,root,root) %{_cyrexecdir}/lmtpproxyd
-%attr(0755,root,root) %{_cyrexecdir}/mupdate
-%attr(0755,root,root) %{_cyrexecdir}/proxyd
-
-%files nntp
-%defattr(0644,root,root,0755)
-%config(noreplace) %{_sysconfdir}/pam.d/nntp
-%attr(0755,root,root) %{_cyrexecdir}/cyrfetchnews
-%attr(0755,root,root) %{_cyrexecdir}/nntpd
-
 %files devel
 %defattr(0644,root,root,0755)
 %{_includedir}/cyrus
@@ -716,13 +829,158 @@
 
 %files utils
 %defattr(0644,root,root,0755)
-%attr(0755,root,root) %{_cyrexecdir}/cyradm
-%attr(0755,root,root) %{_cyrexecdir}/imtest
-%attr(0755,root,root) %{_cyrexecdir}/mupdate-loadgen.pl
 %attr(0755,root,root) %{_bindir}/*
 %{_mandir}/man1/*
 
 %changelog
+* Wed Jan 25 2006 Simon Matter <simon.matter at invoca.ch> 2.3.1-2
+- add backend_sigsegv patch
+- add replication_policycheck patch
+
+* Mon Jan 23 2006 Simon Matter <simon.matter at invoca.ch> 2.3.1-1
+- update to official autocreate and autosievefolder patches
+
+* Thu Jan 19 2006 Simon Matter <simon.matter at invoca.ch> 2.3.1-0.18
+- update rpm_set_permissions script
+- add snmp support as build time option, disabled by default
+  because it doesn't build on older distributions
+
+* Wed Jan 18 2006 Simon Matter <simon.matter at invoca.ch> 2.3.1-0.15
+- add make_md5 patch
+
+* Mon Jan 16 2006 Simon Matter <simon.matter at invoca.ch> 2.3.1-0.13
+- add autosievefolder patch
+- add rmquota+deletemailbox patch
+- change default path for make_md5, add md5 directory
+
+* Fri Jan 13 2006 Simon Matter <simon.matter at invoca.ch> 2.3.1-0.10
+- spec file cleanup
+- add more cvt_cyrusdb_all fixes
+- fix pre/post scripts
+- fix requirements
+- add patch to set Invoca RPM config defaults
+- add sync directory used for replication
+- add autocreate patch
+
+* Thu Jan 12 2006 Simon Matter <simon.matter at invoca.ch> 2.3.1-0.8
+- update cvt_cyrusdb_all script
+- build db.cfg on the fly
+
+* Thu Jan 05 2006 Simon Matter <simon.matter at invoca.ch> 2.3.1-0.5
+- create ptclient directory if ldap enabled
+
+* Wed Jan 04 2006 Simon Matter <simon.matter at invoca.ch> 2.3.1-0.4
+- build without ldap support if openldap is linked against SASLv1
+
+* Tue Jan 03 2006 Simon Matter <simon.matter at invoca.ch> 2.3.1-0.3
+- fix ldap support
+
+* Mon Jan 02 2006 Simon Matter <simon.matter at invoca.ch> 2.3.1-0.2
+- add openldap-devel to buildprereq, build with ldap support
+
+* Wed Dec 21 2005 Simon Matter <simon.matter at invoca.ch> 2.3.1-0.1
+- update to 2.3.1, officially called BETA-quality release
+
+* Fri Dec 16 2005 Simon Matter <simon.matter at invoca.ch> 2.3.0-0.4
+- add skiplist.py to contrib/
+- port authid_normalize patch
+
+* Thu Dec 15 2005 Simon Matter <simon.matter at invoca.ch> 2.3.0-0.3
+- reintroduce subpackage utils, fix requirements
+- move some utils to %{_bindir}/
+
+* Wed Dec 14 2005 Simon Matter <simon.matter at invoca.ch> 2.3.0-0.2
+- integrate subpackages murder, nntp, replication, utils
+
+* Tue Dec 13 2005 Simon Matter <simon.matter at invoca.ch> 2.3.0-0.1
+- update to 2.3.0, officially called BETA-quality release
+- add replication subpackage
+
+* Fri Dec 09 2005 Simon Matter <simon.matter at invoca.ch> 2.2.12-15.1
+- add missing automake to buildprereq
+- change package description
+
+* Tue Dec 06 2005 Simon Matter <simon.matter at invoca.ch> 2.2.12-15
+- update cvt_cyrusdb_all script
+- update autocreate patches
+
+* Mon Dec 05 2005 Simon Matter <simon.matter at invoca.ch> 2.2.12-14
+- update cvt_cyrusdb_all script
+
+* Mon Nov 14 2005 Simon Matter <simon.matter at invoca.ch> 2.2.12-13
+- add 64bit quota support backported from 2.3
+
+* Fri Nov 11 2005 Simon Matter <simon.matter at invoca.ch> 2.2.12-12
+- add quickstart/stop option to init script to bypass db import/export
+- add authid_normalize patch
+- add allow_auth_plain_proxying patch
+- update gcc4 patch
+- remove useless fdatasync patch
+- add private autoconf used for build, remove autoconf dependency
+- generate correct docs including man pages
+- remove unneeded files from doc directory
+
+* Fri Nov 04 2005 Simon Matter <simon.matter at invoca.ch> 2.2.12-11
+- add mupdate thread-safe patch
+
+* Mon Oct 24 2005 Simon Matter <simon.matter at invoca.ch> 2.2.12-9.4
+- add spool patch, which is already fixed in CVS
+
+* Tue Aug 30 2005 Simon Matter <simon.matter at invoca.ch> 2.2.12-9.2
+- pull in CPPFLAGS and LDFLAGS from openssl's pkg-config data, if it exists
+
+* Wed Aug 24 2005 Simon Matter <simon.matter at invoca.ch> 2.2.12-9.1
+- add timsieved_reset_sasl_conn patch
+
+* Mon Aug 22 2005 Simon Matter <simon.matter at invoca.ch> 2.2.12-9
+- cosmetic changes in pre and post scripts
+
+* Fri Aug 19 2005 Simon Matter <simon.matter at invoca.ch> 2.2.12-8
+- add more pki dir fixes for inplace upgrades
+
+* Thu Aug 18 2005 Simon Matter <simon.matter at invoca.ch> 2.2.12-7
+- include requirement for Berkeley DB utils
+
+* Thu Aug 18 2005 Simon Matter <simon.matter at invoca.ch> 2.2.12-6
+- fix recovery problems with db4, which do not exist with db3
+- fix logic for handling ssl certs
+- remove initlog from init script
+
+* Wed Aug 17 2005 Simon Matter <simon.matter at invoca.ch> 2.2.12-5
+- add notifytest to the distribution
+- add functionality to convert all berkeley databases to skiplist
+  on shutdown and convert them back as needed on startup. This should
+  solve the upgrade problems with Berkeley databases.
+
+* Tue Aug 16 2005 Simon Matter <simon.matter at invoca.ch> 2.2.12-4.14
+- add gcc4 patch
+- determine and handle pki directory for openssl correctly
+- add skiplist recovery docs
+- add notify_sms patch
+
+* Mon Jul 18 2005 Simon Matter <simon.matter at invoca.ch> 2.2.12-4.10
+- update cvt_cyrusdb_all script
+- update autocreate patches
+
+* Fri Jul 15 2005 Simon Matter <simon.matter at invoca.ch> 2.2.12-4.9
+- add patch to remove ACLs with invalid identifier
+- update cvt_cyrusdb_all script
+
+* Sat Jun 18 2005 Simon Matter <simon.matter at invoca.ch> 2.2.12-4.1
+- update munge8bit patch
+
+* Wed Jun 08 2005 Simon Matter <simon.matter at invoca.ch> 2.2.12-4
+- updated seenstate patch
+
+* Thu Jun 02 2005 Simon Matter <simon.matter at invoca.ch>
+- removed nolinkimapspool patch, added singleinstancestore patch instead
+
+* Thu Jun 02 2005 Simon Matter <simon.matter at invoca.ch>
+- added nolinkimapspool patch
+- fix debug_package macro, it was still being expanded,
+  comments don't hide macro expansion
+- change license field to BSD, its not exact BSD, but BSD is the closest
+
 * Fri Apr 22 2005 John Dennis <jdennis at redhat.com> - 2.2.12-6.fc4
 - the openssl package moved all its certs, CA, Makefile, etc. to /etc/pki
   now we are consistent with the openssl directory changes.
@@ -748,6 +1006,9 @@
 * Mon Apr  4 2005 John Dennis <jdennis at redhat.com> - 2.2.12-1.1.fc4
 - bring up to 2.2.12, includes security fix for CAN-2005-0546
 
+* Mon Mar 07 2005 Simon Matter <simon.matter at invoca.ch>
+- updated rmquota+deletemailbox patches
+
 * Fri Mar  4 2005 John Dennis <jdennis at redhat.com> - 2.2.10-11.4.fc4
 - fix gcc4 build problems
 
@@ -830,7 +1091,7 @@
   fixes bug #139382, 
   security advisories: CAN-2004-1011 CAN-2004-1012 CAN-2004-1013 CAN-2004-1015
 
-* Tue Nov 24 2004 Simon Matter <simon.matter at invoca.ch>
+* Wed Nov 24 2004 Simon Matter <simon.matter at invoca.ch>
 - updated to 2.2.10
 
 * Tue Nov 23 2004 Simon Matter <simon.matter at invoca.ch>


Index: sources
===================================================================
RCS file: /cvs/extras/rpms/cyrus-imapd/devel/sources,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- sources	18 Apr 2005 22:52:24 -0000	1.3
+++ sources	28 Feb 2006 20:04:01 -0000	1.4
@@ -1,2 +1,2 @@
-70b3bba526a8d36d3bb23a87d37e9188  cyrus-imapd-2.2.12.tar.gz
+cde15876d5c953bba9ad9f7811aff695  cyrus-imapd-2.3.1.tar.gz
 8f7a26b0556369827bb5c8084a3e3ea1  cyrus_sharedbackup-0.1.tar.gz


--- README.autocreate-cyrus-2.2 DELETED ---


--- cyrus-imapd-2.1.9-fdatasync.patch DELETED ---


--- cyrus-imapd-2.2.10-rmquota+deletemailbox-0.1.diff DELETED ---


--- cyrus-imapd-2.2.12-autocreate-0.9.2.diff DELETED ---


--- cyrus-imapd-2.2.12-autosievefolder-0.6.diff DELETED ---


--- cyrus-imapd-2.2.12.tar.gz.sig DELETED ---


--- cyrus-imapd-2.2.4-OE-seenstate.patch DELETED ---


--- cyrus-imapd-2.2.4-munge8bit.patch DELETED ---


--- cyrus-imapd-db.cfg DELETED ---


--- cyrus-imapd-gcc4.patch DELETED ---


--- cyrus-imapd.imap-2.2.x-conf DELETED ---




More information about the scm-commits mailing list