[SVN] r771 - in /branches/cyrus23/cyrus-imapd-2.3-development: ./ contrib/ debian/ debian/patches/ doc/ imap/ imtest/ lib/ perl/sieve/lib/ perl/sieve/managesieve/ sieve/ timsieved/

debian at incase.de debian at incase.de
Thu Apr 23 17:56:51 UTC 2009


Author: duncan
Date: Thu Apr 23 19:56:51 2009
New Revision: 771

URL: https://mail.incase.de/viewcvs?rev=771&root=cyrus22&view=rev
Log:
New upstream release 2.3.14

Modified:
    branches/cyrus23/cyrus-imapd-2.3-development/Makefile.in
    branches/cyrus23/cyrus-imapd-2.3-development/config.h.in
    branches/cyrus23/cyrus-imapd-2.3-development/contrib/drac_auth.patch
    branches/cyrus23/cyrus-imapd-2.3-development/debian/changelog
    branches/cyrus23/cyrus-imapd-2.3-development/debian/patches/10-fix_potential_overflows.dpatch
    branches/cyrus23/cyrus-imapd-2.3-development/doc/changes.html
    branches/cyrus23/cyrus-imapd-2.3-development/imap/annotate.c
    branches/cyrus23/cyrus-imapd-2.3-development/imap/annotate.h
    branches/cyrus23/cyrus-imapd-2.3-development/imap/append.c
    branches/cyrus23/cyrus-imapd-2.3-development/imap/append.h
    branches/cyrus23/cyrus-imapd-2.3-development/imap/arbitron.c
    branches/cyrus23/cyrus-imapd-2.3-development/imap/backend.c
    branches/cyrus23/cyrus-imapd-2.3-development/imap/ctl_mboxlist.c
    branches/cyrus23/cyrus-imapd-2.3-development/imap/cvt_cyrusdb.c
    branches/cyrus23/cyrus-imapd-2.3-development/imap/cyr_expire.c
    branches/cyrus23/cyrus-imapd-2.3-development/imap/cyr_synclog.c
    branches/cyrus23/cyrus-imapd-2.3-development/imap/cyr_virusscan.c
    branches/cyrus23/cyrus-imapd-2.3-development/imap/cyrdump.c
    branches/cyrus23/cyrus-imapd-2.3-development/imap/fud.c
    branches/cyrus23/cyrus-imapd-2.3-development/imap/global.c
    branches/cyrus23/cyrus-imapd-2.3-development/imap/idle.c
    branches/cyrus23/cyrus-imapd-2.3-development/imap/idled.h
    branches/cyrus23/cyrus-imapd-2.3-development/imap/imap_proxy.c
    branches/cyrus23/cyrus-imapd-2.3-development/imap/imapd.c
    branches/cyrus23/cyrus-imapd-2.3-development/imap/index.c
    branches/cyrus23/cyrus-imapd-2.3-development/imap/ipurge.c
    branches/cyrus23/cyrus-imapd-2.3-development/imap/lmtp_sieve.c
    branches/cyrus23/cyrus-imapd-2.3-development/imap/lmtpd.c
    branches/cyrus23/cyrus-imapd-2.3-development/imap/lmtpengine.h
    branches/cyrus23/cyrus-imapd-2.3-development/imap/mailbox.c
    branches/cyrus23/cyrus-imapd-2.3-development/imap/mailbox.h
    branches/cyrus23/cyrus-imapd-2.3-development/imap/make_md5.c
    branches/cyrus23/cyrus-imapd-2.3-development/imap/make_sha1.c
    branches/cyrus23/cyrus-imapd-2.3-development/imap/mbdump.c
    branches/cyrus23/cyrus-imapd-2.3-development/imap/mboxlist.c
    branches/cyrus23/cyrus-imapd-2.3-development/imap/mboxlist.h
    branches/cyrus23/cyrus-imapd-2.3-development/imap/mboxname.c
    branches/cyrus23/cyrus-imapd-2.3-development/imap/message.c
    branches/cyrus23/cyrus-imapd-2.3-development/imap/mupdate.c
    branches/cyrus23/cyrus-imapd-2.3-development/imap/mupdate.h
    branches/cyrus23/cyrus-imapd-2.3-development/imap/nntpd.c
    branches/cyrus23/cyrus-imapd-2.3-development/imap/pop3d.c
    branches/cyrus23/cyrus-imapd-2.3-development/imap/proxy.h
    branches/cyrus23/cyrus-imapd-2.3-development/imap/quota.c
    branches/cyrus23/cyrus-imapd-2.3-development/imap/quota_db.c
    branches/cyrus23/cyrus-imapd-2.3-development/imap/reconstruct.c
    branches/cyrus23/cyrus-imapd-2.3-development/imap/smmapd.c
    branches/cyrus23/cyrus-imapd-2.3-development/imap/squatter.c
    branches/cyrus23/cyrus-imapd-2.3-development/imap/statuscache_db.c
    branches/cyrus23/cyrus-imapd-2.3-development/imap/sync_client.c
    branches/cyrus23/cyrus-imapd-2.3-development/imap/sync_log.c
    branches/cyrus23/cyrus-imapd-2.3-development/imap/sync_log.h
    branches/cyrus23/cyrus-imapd-2.3-development/imap/sync_reset.c
    branches/cyrus23/cyrus-imapd-2.3-development/imap/sync_server.c
    branches/cyrus23/cyrus-imapd-2.3-development/imap/tls.c
    branches/cyrus23/cyrus-imapd-2.3-development/imap/user.c
    branches/cyrus23/cyrus-imapd-2.3-development/imap/version.h
    branches/cyrus23/cyrus-imapd-2.3-development/imtest/imtest.c
    branches/cyrus23/cyrus-imapd-2.3-development/lib/cyrusdb_berkeley.c
    branches/cyrus23/cyrus-imapd-2.3-development/lib/cyrusdb_quotalegacy.c
    branches/cyrus23/cyrus-imapd-2.3-development/lib/imapoptions
    branches/cyrus23/cyrus-imapd-2.3-development/lib/imapopts.c
    branches/cyrus23/cyrus-imapd-2.3-development/lib/imapopts.h
    branches/cyrus23/cyrus-imapd-2.3-development/lib/prot.c
    branches/cyrus23/cyrus-imapd-2.3-development/perl/sieve/lib/isieve.c
    branches/cyrus23/cyrus-imapd-2.3-development/perl/sieve/lib/isieve.h
    branches/cyrus23/cyrus-imapd-2.3-development/perl/sieve/managesieve/managesieve.xs
    branches/cyrus23/cyrus-imapd-2.3-development/sieve/comparator.c
    branches/cyrus23/cyrus-imapd-2.3-development/timsieved/actions.c
    branches/cyrus23/cyrus-imapd-2.3-development/timsieved/actions.h
    branches/cyrus23/cyrus-imapd-2.3-development/timsieved/parser.c
    branches/cyrus23/cyrus-imapd-2.3-development/timsieved/timsieved.c

Modified: branches/cyrus23/cyrus-imapd-2.3-development/Makefile.in
URL: https://mail.incase.de/viewcvs/branches/cyrus23/cyrus-imapd-2.3-development/Makefile.in?rev=771&root=cyrus22&r1=770&r2=771&view=diff
==============================================================================
--- branches/cyrus23/cyrus-imapd-2.3-development/Makefile.in (original)
+++ branches/cyrus23/cyrus-imapd-2.3-development/Makefile.in Thu Apr 23 19:56:51 2009
@@ -40,7 +40,7 @@
 # AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
 # OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 # 
-# $Id: Makefile.in,v 1.101 2008/10/14 14:40:50 murch Exp $
+# $Id: Makefile.in,v 1.103 2009/03/25 10:41:00 murch Exp $
 
 SUBDIRS = man @PRE_SUBDIRS@ lib @SIEVE_SUBDIRS@ @SERVER_SUBDIRS@ \
 	imtest @SNMP_SUBDIRS@ @EXTRA_SUBDIRS@
@@ -64,7 +64,7 @@
 LEX = @LEX@
 COMPILE_ET = @COMPILE_ET@
 
-VERSION = 2.3.13
+VERSION = 2.3.14
 
 all:: 
 	@for d in  $(SUBDIRS); \

Modified: branches/cyrus23/cyrus-imapd-2.3-development/config.h.in
URL: https://mail.incase.de/viewcvs/branches/cyrus23/cyrus-imapd-2.3-development/config.h.in?rev=771&root=cyrus22&r1=770&r2=771&view=diff
==============================================================================
--- branches/cyrus23/cyrus-imapd-2.3-development/config.h.in (original)
+++ branches/cyrus23/cyrus-imapd-2.3-development/config.h.in Thu Apr 23 19:56:51 2009
@@ -48,6 +48,9 @@
 #define _CYRUS_IMAPD_CONFIG_H_
 
 
+/* Define if building universal (internal helper macro) */
+#undef AC_APPLE_UNIVERSAL_BUILD
+
 /* Should the AFS PTS plugin use krb5? */
 #undef AFSPTS_USE_KRB5
 
@@ -376,23 +379,56 @@
 /* Build in Sieve support? */
 #undef USE_SIEVE
 
+/* Enable extensions on AIX 3, Interix.  */
+#ifndef _ALL_SOURCE
+# undef _ALL_SOURCE
+#endif
+/* Enable GNU extensions on systems that have them.  */
+#ifndef _GNU_SOURCE
+# undef _GNU_SOURCE
+#endif
+/* Enable threading extensions on Solaris.  */
+#ifndef _POSIX_PTHREAD_SEMANTICS
+# undef _POSIX_PTHREAD_SEMANTICS
+#endif
+/* Enable extensions on HP NonStop.  */
+#ifndef _TANDEM_SOURCE
+# undef _TANDEM_SOURCE
+#endif
+/* Enable general extensions on Solaris.  */
+#ifndef __EXTENSIONS__
+# undef __EXTENSIONS__
+#endif
+
+
 /* Build in PTS support? */
 #undef WITH_PTS
 
-/* Define to 1 if your processor stores words with the most significant byte
-   first (like Motorola and SPARC, unlike Intel and VAX). */
-#undef WORDS_BIGENDIAN
+/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
+   significant byte first (like Motorola and SPARC, unlike Intel). */
+#if defined AC_APPLE_UNIVERSAL_BUILD
+# if defined __BIG_ENDIAN__
+#  define WORDS_BIGENDIAN 1
+# endif
+#else
+# ifndef WORDS_BIGENDIAN
+#  undef WORDS_BIGENDIAN
+# endif
+#endif
 
 /* Define to 1 if `lex' declares `yytext' as a `char *' by default, not a
    `char[]'. */
 #undef YYTEXT_POINTER
 
-/* Define to 1 if on AIX 3.
-   System headers sometimes define this.
-   We just want to avoid a redefinition error message.  */
-#ifndef _ALL_SOURCE
-# undef _ALL_SOURCE
-#endif
+/* Define to 1 if on MINIX. */
+#undef _MINIX
+
+/* Define to 2 if the system does not provide POSIX.1 features except with
+   this defined. */
+#undef _POSIX_1_SOURCE
+
+/* Define to 1 if you need to in order for `stat' and other things to work. */
+#undef _POSIX_SOURCE
 
 /* Define to empty if `const' does not conform to ANSI C. */
 #undef const

Modified: branches/cyrus23/cyrus-imapd-2.3-development/contrib/drac_auth.patch
URL: https://mail.incase.de/viewcvs/branches/cyrus23/cyrus-imapd-2.3-development/contrib/drac_auth.patch?rev=771&root=cyrus22&r1=770&r2=
3D771&view=diff
==============================================================================
--- branches/cyrus23/cyrus-imapd-2.3-development/contrib/drac_auth.patch (original)
+++ branches/cyrus23/cyrus-imapd-2.3-development/contrib/drac_auth.patch Thu Apr 23 19:56:51 2009
@@ -1,4 +1,4 @@
-$Id: drac_auth.patch,v 1.27 2008/09/25 11:24:48 murch Exp $
+$Id: drac_auth.patch,v 1.28 2009/03/13 12:16:24 murch Exp $
 
 Patch to add support for Dynamic Relay Authorization Control
 
@@ -67,11 +67,11 @@
 Index: configure.in
 ===============3D====================================================
 RCS file: /afs/andrew/system/cvs/src/cyrus/configure.in,v
-retrieving revision 1.306
-diff -u -r1.306 configure.in
---- configure.in	30 Jul 2008 16:03:36 -0000	1.306
-+++ configure.in	25 Sep 2008 11:15:28 -0000
-@@ -1215,6 +1215,19 @@
+retrieving revision 1.308
+diff -u -r1.308 configure.in
+--- configure.in	8 Oct 2008 23:28:58 -0000	1.308
++++ configure.in	13 Mar 2009 12:12:52 -0000
+@@ -1219,6 +1219,19 @@
  SNMP_SUBDIRS=""
  AC_SUBST(SNMP_SUBDIRS)
  
@@ -97,7 +97,7 @@
 retrieving revision 1.196
 diff -u -r1.196 Makefile.in
 --- imap/Makefile.in	23 Sep 2008 16:17:09 -0000	1.196
-+++ imap/Makefile.in	25 Sep 2008 11:15:28 -0000
++++ imap/Makefile.in	13 Mar 2009 12:12:53 -0000
 @@ -66,6 +66,7 @@
  SIEVE_LIBS = @SIEVE_LIBS@
  IMAP_COM_ERR_LIBS = @IMAP_COM_ERR_LIBS@
@@ -139,10 +139,10 @@
 Index: imap/imapd.c
 ===============3D====================================================
 RCS file: /afs/andrew/system/cvs/src/cyrus/imap/imapd.c,v
-retrieving revision 1.551
-diff -u -r1.551 imapd.c
---- imap/imapd.c	5 Sep 2008 15:56:21 -0000	1.551
-+++ imap/imapd.c	25 Sep 2008 11:15:29 -0000
+retrieving revision 1.557
+diff -u -r1.557 imapd.c
+--- imap/imapd.c	9 Feb 2009 05:05:48 -0000	1.557
++++ imap/imapd.c	13 Mar 2009 12:12:54 -0000
 @@ -188,6 +188,18 @@
      1, 1, &imapd_authstate, &imapd_userisadmin, &imapd_userisproxyadmin
  };
@@ -289,10 +289,10 @@
 Index: imap/pop3d.c
 ===============3D====================================================
 RCS file: /afs/andrew/system/cvs/src/cyrus/imap/pop3d.c,v
-retrieving revision 1.189
-diff -u -r1.189 pop3d.c
---- imap/pop3d.c	22 Apr 2008 13:11:18 -0000	1.189
-+++ imap/pop3d.c	25 Sep 2008 11:15:29 -0000
+retrieving revision 1.191
+diff -u -r1.191 pop3d.c
+--- imap/pop3d.c	9 Feb 2009 05:01:58 -0000	1.191
++++ imap/pop3d.c	13 Mar 2009 12:12:54 -0000
 @@ -105,6 +105,10 @@
  extern int opterr;
  
@@ -368,7 +368,7 @@
 retrieving revision 1.22
 diff -u -r1.22 version.c
 --- imap/version.c	24 Mar 2008 17:09:20 -0000	1.22
-+++ imap/version.c	25 Sep 2008 11:15:29 -0000
++++ imap/version.c	13 Mar 2009 12:12:54 -0000
 @@ -153,6 +153,10 @@
      snprintf(env_buf + strlen(env_buf), MAXIDVALUELEN - strlen(env_buf),
  	     "; %s", SIEVE_VERSION);
@@ -383,10 +383,10 @@
 Index: lib/imapoptions
 ===============3D====================================================
 RCS file: /afs/andrew/system/cvs/src/cyrus/lib/imapoptions,v
-retrieving revision 1.57
-diff -u -r1.57 imapoptions
---- lib/imapoptions	24 Sep 2008 11:56:41 -0000	1.57
-+++ lib/imapoptions	25 Sep 2008 11:15:29 -0000
+retrieving revision 1.62
+diff -u -r1.62 imapoptions
+--- lib/imapoptions	6 Mar 2009 03:52:55 -0000	1.62
++++ lib/imapoptions	13 Mar 2009 12:12:55 -0000
 @@ -236,6 +236,14 @@
     grant the user the ability to delete a mailbox.  If a user has this
     right, they will automatically be given the new 'x' right. */

Modified: branches/cyrus23/cyrus-imapd-2.3-development/debian/changelog
URL: https://mail.incase.de/viewcvs/branches/cyrus23/cyrus-imapd-2.3-development/debian/changelog?rev=771&root=cyrus22&r1=770&r2=771&view=diff
==============================================================================
--- branches/cyrus23/cyrus-imapd-2.3-development/debian/changelog (original)
+++ branches/cyrus23/cyrus-imapd-2.3-development/debian/changelog Thu Apr 23 19:56:51 2009
@@ -1,3 +1,11 @@
+cyrus-imapd-2.3 (2009:2.3.14-1) experimental; urgency=low
+
+  * New upstream release.
+  * Remove the sections of Sven's 10-fix_potential_overflows.dpatch
+    superceded by upstream fixes by Bron.
+
+ -- Duncan Gibb <Duncan.Gibb at siriusit.co.uk>  Thu, 23 Apr 2009 18:54:37 +0100
+
 cyrus-imapd-2.3 (2.3.13-1) experimental; urgency=low
 
   * New upstream release (via conservative branch from Sirius in-house).

Modified: branches/cyrus23/cyrus-imapd-2.3-development/debian/patches/10-fix_potential_overflows.dpatch
URL: https://mail.incase.de/viewcvs/branches/cyrus23/cyrus-imapd-2.3-development/debian/patches/10-fix_potential_overflows.dpatch?rev=771&root=3Dcyrus22&r1=770&r2=771&view=diff
==============================================================================
--- branches/cyrus23/cyrus-imapd-2.3-development/debian/patches/10-fix_potential_overflows.dpatch (original)
+++ branches/cyrus23/cyrus-imapd-2.3-development/debian/patches/10-fix_potential_overflows.dpatch Thu Apr 23 19:56:51 2009
@@ -3,48 +3,11 @@
 ##
 ## All lines beginning with `## DP:' are a description of the patch.
 ## DP: fix potential buffer overflows
+## DP: Revised for 2.3.14 by Duncan Gibb <duncan.gibb at siriusit.co.uk>
+## DP: Many of the problems Sven's original patch fixed have since
+## DP: been resolved upsteam (thanks mainly to Bron Gondwana).
 
 @DPATCH@
-diff -urNad cyrus-imapd-2.3.7~/imap/ctl_mboxlist.c cyrus-imapd-2.3.7/imap/ctl_mboxlist.c
---- cyrus-imapd-2.3.7~/imap/ctl_mboxlist.c	2006-04-06 17:42:10.000000000 +0200
-+++ cyrus-imapd-2.3.7/imap/ctl_mboxlist.c	2006-08-11 11:54:55.000000000 +0200
-@@ -480,7 +480,7 @@
-     int r = 0;
-     char buf[16384];
-     int line = 0;
--    char last_commit[MAX_MAILBOX_NAME];
-+    char last_commit[MAX_MAILBOX_NAME+1];
-     char *key=NULL, *data=NULL;
-     int keylen, datalen;
-     int untilCommit = PER_COMMIT;
-diff -urNad cyrus-imapd-2.3.7~/imap/fud.c cyrus-imapd-2.3.7/imap/fud.c
---- cyrus-imapd-2.3.7~/imap/fud.c	2006-08-11 11:54:55.000000000 +0200
-+++ cyrus-imapd-2.3.7/imap/fud.c	2006-08-11 11:54:55.000000000 +0200
-@@ -119,9 +119,9 @@
- 
-         while(1) {
-             /* For safety */
--            memset(username,'\0',MAXLOGNAME + MAXDOMNAME);	
--            memset(mbox,'\0',MAX_MAILBOX_NAME+1);
--            memset(buf, '\0', MAXLOGNAME + MAX_MAILBOX_NAME + 1);
-+            memset(username,'\0', sizeof(username));	
-+            memset(mbox,'\0', sizeof(mbox));
-+            memset(buf, '\0', sizeof(buf));
- 
- 	    if (signals_poll() == SIGHUP) {
- 		/* caught a SIGHUP, return */
-diff -urNad cyrus-imapd-2.3.7~/imap/global.c cyrus-imapd-2.3.7/imap/global.c
---- cyrus-imapd-2.3.7~/imap/global.c	2005-12-13 20:35:50.000000000 +0100
-+++ cyrus-imapd-2.3.7/imap/global.c	2006-08-11 11:54:55.000000000 +0200
-@@ -473,7 +473,7 @@
- {
-     struct namespace namespace;
-     char *acl;
--    char bufuser[MAX_MAILBOX_NAME], inboxname[MAX_MAILBOX_NAME];
-+    char bufuser[MAX_MAILBOX_NAME+1], inboxname[MAX_MAILBOX_NAME+1];
-     int r;
- 
-     /* Set namespace */
 diff -urNad cyrus-imapd-2.3.7~/imap/index.c cyrus-imapd-2.3.7/imap/index.c
 --- cyrus-imapd-2.3.7~/imap/index.c	2006-07-05 21:51:30.000000000 +0200
 +++ cyrus-imapd-2.3.7/imap/index.c	2006-08-11 11:54:55.000000000 +0200
@@ -69,18 +32,6 @@
  		cur->xsubj_hash = strhash(cur->xsubj);
  		break;
  	    case SORT_TO:
-diff -urNad cyrus-imapd-2.3.7~/imap/mboxlist.h cyrus-imapd-2.3.7/imap/mboxlist.h
---- cyrus-imapd-2.3.7~/imap/mboxlist.h	2005-02-21 20:25:40.000000000 +0100
-+++ cyrus-imapd-2.3.7/imap/mboxlist.h	2006-08-11 11:54:55.000000000 +0200
-@@ -73,7 +73,7 @@
- 
- /* each mailbox has the following data */
- struct mbox_entry {
--    char name[MAX_MAILBOX_NAME];
-+    char name[MAX_MAILBOX_NAME+1];
-     int mbtype;
-     char partition[MAX_PARTITION_LEN];
- 				/* holds remote machine for REMOTE mailboxes */
 diff -urNad cyrus-imapd-2.3.7~/imap/message.c cyrus-imapd-2.3.7/imap/message.c
 --- cyrus-imapd-2.3.7~/imap/message.c	2006-05-26 18:27:18.000000000 +0200
 +++ cyrus-imapd-2.3.7/imap/message.c	2006-08-11 11:54:55.000000000 +0200
@@ -93,20 +44,6 @@
      ibuf->end += len;
      *(ibuf->end)++ = '\r';
      *(ibuf->end)++ = '\n';
-diff -urNad cyrus-imapd-2.3.7~/imap/mupdate.h cyrus-imapd-2.3.7/imap/mupdate.h
---- cyrus-imapd-2.3.7~/imap/mupdate.h	2006-03-15 19:56:32.000000000 +0100
-+++ cyrus-imapd-2.3.7/imap/mupdate.h	2006-08-11 11:54:55.000000000 +0200
-@@ -68,8 +68,8 @@
-     struct buf tag, cmd, arg1, arg2, arg3;
- 
-     /* For client side mupdate_find calls */
--    char mailbox_buf[MAX_MAILBOX_NAME];
--    char server_buf[MAX_MAILBOX_NAME];
-+    char mailbox_buf[MAX_MAILBOX_NAME+1];
-+    char server_buf[MAX_MAILBOX_NAME+1];
-     char *acl_buf;
-     size_t acl_buf_len;
-     struct mupdate_mailboxdata mailboxdata_buf;
 diff -urNad cyrus-imapd-2.3.7~/imtest/imtest.c cyrus-imapd-2.3.7/imtest/imtest.c
 --- cyrus-imapd-2.3.7~/imtest/imtest.c	2006-05-25 17:21:49.000000000 +0200
 +++ cyrus-imapd-2.3.7/imtest/imtest.c	2006-08-11 11:54:55.000000000 +0200

Modified: branches/cyrus23/cyrus-imapd-2.3-development/doc/changes.html
URL: https://mail.incase.de/viewcvs/branches/cyrus23/cyrus-imapd-2.3-development/doc/changes.html?rev=771&root=cyrus22&r1=770&r2=771&view=diff
==============================================================================
--- branches/cyrus23/cyrus-imapd-2.3-development/doc/changes.html (original)
+++ branches/cyrus23/cyrus-imapd-2.3-development/doc/changes.html Thu Apr 23 19:56:51 2009
@@ -1,12 +1,48 @@
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<!-- $Id: changes.html,v 1.164 2008/10/09 14:40:20 murch Exp $ -->
+<!-- $Id: changes.html,v 1.166 2009/03/13 12:08:01 murch Exp $ -->
 <html xmlns="http://www.w3.org/1999/xhtml">
 <head>
 <meta name="generator" content="HTML Tidy, see www.w3.org" />
 <title>Changes to the Cyrus IMAP Server</title>
 </head>
 <body>
+
+<h1>Changes to the Cyrus IMAP Server since 2.3.13</h1>
+<ul>
+<li>Fixed incompatibility between older ManageSieve clients and newer
+  servers that issue an auto-capability response after AUTH with a
+  SASL security layer.</li>
+<li>Fixed quota calculation to ignore files not mentioned in the
+  index</li>
+<li>Correct cache truncation after an aborted append (was leaving
+  empty holes in the cache file>)</li>
+<li>Fixed ACLs copying when renaming users</li>
+<li>Fixed TLS session reuse</li>
+<li>Log more detail about changes done by a reconstruct (indicating
+  that there were problems with the mailbox before hand - mainly
+  as a debugging aid)</li>
+<li>Ensured that the longest possible named mailbox can still be
+  deleted when delayed delete is enabled by increasing buffer sizes</li>
+<li>Add configuration option mailbox_default_options allowing
+  (for example) modsequences to be turned on for all new mailboxes</li>
+<li>Replication:
+<ul>
+  <li>added -R option to sync_client to do rolling replication in the
+   foreground (to run under supervise or similar)</li>
+ <li>made cyr_synclog run as cyrus user if started as root</li>
+ <li>Changed ADDSUB/DELSUB replication to replicate current state
+   rather than log explicit changes, avoiding a bug where if multiple
+   subscription changes happened in one sync run, the replica could
+   be incorrect</li>
+ <li>Changed replication logging related to user creation and mailboxes
+   to ensure correct replication of delayed delete of entire users</li>
+ <li>Always overwrite the seen DB on the replica with the full DB from
+   the master on "setseen_all" to guarantee consistency</li>
+ <li>Sync all mailbox annotations, not just condstore, ensuring
+   mailbox is consistent on both ends (solves POP3_NEW_UIDL bug)</li>
+</ul></li>
+</ul>
 
 <h1>Changes to the Cyrus IMAP Server since 2.3.12</h1>
 <ul>
@@ -2361,7 +2397,7 @@
 </ul>
 
 <hr />
-last modified: $Date: 2008/10/09 14:40:20 $ <br />
+last modified: $Date: 2009/03/13 12:08:01 $ <br />
 <a href="index.html">Return</a> to the Cyrus IMAP Server Home Page
 </body>
 </html>

Modified: branches/cyrus23/cyrus-imapd-2.3-development/imap/annotate.c
URL: https://mail.incase.de/viewcvs/branches/cyrus23/cyrus-imapd-2.3-development/imap/annotate.c?rev=771&root=cyrus22&r1=770&r2=771&view=diff
==============================================================================
--- branches/cyrus23/cyrus-imapd-2.3-development/imap/annotate.c (original)
+++ branches/cyrus23/cyrus-imapd-2.3-development/imap/annotate.c Thu Apr 23 19:56:51 2009
@@ -39,7 +39,7 @@
  * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
  * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  *
- * $Id: annotate.c,v 1.42 2008/10/08 15:47:06 murch Exp $
+ * $Id: annotate.c,v 1.44 2009/02/09 05:08:20 brong Exp $
  */
 
 #include <config.h>
@@ -422,6 +422,19 @@
     char *server, *partition, *acl, *path, *mpath;
 };
 
+const struct annotate_info_t annotate_mailbox_flags[] =
+{
+    { "/vendor/cmu/cyrus-imapd/pop3newuidl",
+      OPT_POP3_NEW_UIDL },
+    { "/vendor/cmu/cyrus-imapd/duplicatedeliver",
+      OPT_IMAP_DUPDELIVER },
+    { "/vendor/cmu/cyrus-imapd/sharedseen",
+      OPT_IMAP_SHAREDSEEN },
+    { "/vendor/cmu/cyrus-imapd/condstore",
+      OPT_IMAP_CONDSTORE },
+    { NULL, 0 }
+};
+
 /* To free values in the mailbox_annotation_rock as needed */
 static void cleanup_mbrock(struct mailbox_annotation_rock *mbrock __attribute__((unused))) 
 {
@@ -506,9 +519,9 @@
 			    struct fetchdata *fdata)
 {
     static struct attvaluelist *attvalues = NULL;
-    static char lastname[MAX_MAILBOX_NAME+1];
-    static char lastentry[MAX_MAILBOX_NAME+1];
-    char key[MAX_MAILBOX_PATH+1]; /* XXX MAX_MAILBOX_NAME + entry + userid */
+    static char lastname[MAX_MAILBOX_BUFFER];
+    static char lastentry[MAX_MAILBOX_BUFFER];
+    char key[MAX_MAILBOX_BUFFER]; /* XXX MAX_MAILBOX_NAME + entry + userid */
     char buf[100];
 
     /* We have to reset before each GETANNOTATION command.
@@ -611,7 +624,7 @@
 				    void *rock)
 {
     const char *filename = (const char *) rock;
-    char path[1024], buf[1024], *p;
+    char path[MAX_MAILBOX_PATH+1], buf[MAX_MAILBOX_PATH+1], *p;
     FILE *f;
     struct stat statbuf;
     struct annotation_data attrib;
@@ -878,7 +891,7 @@
 				     void *rock __attribute__((unused)))
 { 
     struct mailbox mailbox;
-    int flag, r = 0;
+    int flag = 0, r = 0, i;
     char value[40];
     struct annotation_data attrib;
   
@@ -891,16 +904,14 @@
     /* Make sure its a local mailbox */
     if (mbrock->server) return;
 
-    /* Check entry */
-    if (!strcmp(entry, "/vendor/cmu/cyrus-imapd/condstore")) {
-	flag = OPT_IMAP_CONDSTORE;
-    } else if (!strcmp(entry, "/vendor/cmu/cyrus-imapd/sharedseen")) {
-	flag = OPT_IMAP_SHAREDSEEN;
-    } else if (!strcmp(entry, "/vendor/cmu/cyrus-imapd/duplicatedeliver")) {
-	flag = OPT_IMAP_DUPDELIVER;
-    } else {
-	return;
-    }
+    /* check that this is a mailboxopt annotation */
+    for (i = 0; annotate_mailbox_flags[i].name; i++) {
+	if (!strcmp(entry, annotate_mailbox_flags[i].name)) {
+	    flag = annotate_mailbox_flags[i].flag;
+	    break;
+	}
+    }
+    if (!flag) return;
   
     /* Check ACL */
     if(!fdata->isadmin &&
@@ -1028,6 +1039,8 @@
       annotation_get_lastupdate, NULL },
     { "/vendor/cmu/cyrus-imapd/lastpop", BACKEND_ONLY,
       annotation_get_lastpop, NULL },
+    { "/vendor/cmu/cyrus-imapd/pop3newuidl", BACKEND_ONLY,
+      annotation_get_mailboxopt, NULL },
     { "/vendor/cmu/cyrus-imapd/condstore", BACKEND_ONLY,
       annotation_get_mailboxopt, NULL },
     { "/vendor/cmu/cyrus-imapd/sharedseen", BACKEND_ONLY,
@@ -1080,10 +1093,10 @@
 {
     struct fetchdata *fdata = (struct fetchdata *) rock;
     struct annotate_f_entry_list *entries_ptr;
-    static char lastname[MAX_MAILBOX_PATH+1];
+    static char lastname[MAX_MAILBOX_BUFFER];
     static int sawuser = 0;
     int c;
-    char int_mboxname[MAX_MAILBOX_PATH+1], ext_mboxname[MAX_MAILBOX_PATH+1];
+    char int_mboxname[MAX_MAILBOX_BUFFER], ext_mboxname[MAX_MAILBOX_BUFFER];
     struct mailbox_annotation_rock mbrock;
 
     /* We have to reset the sawuser flag before each fetch command.
@@ -1298,7 +1311,7 @@
 	/* mailbox annotation(s) */
 
 	if (fdata.entry_list || proxy_fetch_func) {
-	    char mboxpat[MAX_MAILBOX_NAME+1];
+	    char mboxpat[MAX_MAILBOX_BUFFER];
 
 	    /* Reset state in fetch_cb */
 	    fetch_cb(NULL, 0, 0, 0);
@@ -1537,7 +1550,7 @@
     struct annotate_st_entry_list *entries_ptr;
     static char lastname[MAX_MAILBOX_PATH+1];
     static int sawuser = 0;
-    char int_mboxname[MAX_MAILBOX_PATH+1];
+    char int_mboxname[MAX_MAILBOX_BUFFER];
     struct mailbox_annotation_rock mbrock;
     int r = 0;
 
@@ -1621,7 +1634,7 @@
 				 void *rock)
 {
     const char *filename = (const char *) rock;
-    char path[1024];
+    char path[MAX_MAILBOX_PATH+1];
     FILE *f;
 
     /* Check ACL */
@@ -1717,20 +1730,16 @@
 				    void *rock __attribute__((unused)))
 {
     struct mailbox mailbox;
-    int flag, r = 0;
+    int flag = 0, r = 0, i;
 
     /* Check entry */
-    if (!strcmp(entry->entry->name, "/vendor/cmu/cyrus-imapd/condstore")) {
-	flag = OPT_IMAP_CONDSTORE;
-    } else if (!strcmp(entry->entry->name,
-		       "/vendor/cmu/cyrus-imapd/sharedseen")) {
-	flag = OPT_IMAP_SHAREDSEEN;
-    } else if (!strcmp(entry->entry->name,
-		       "/vendor/cmu/cyrus-imapd/duplicatedeliver")) {
-	flag = OPT_IMAP_DUPDELIVER;
-    } else {
-	return IMAP_PERMISSION_DENIED;
-    }
+    for (i = 0; annotate_mailbox_flags[i].name; i++) {
+	if (!strcmp(entry->entry->name, annotate_mailbox_flags[i].name)) {
+	    flag = annotate_mailbox_flags[i].flag;
+	    break;
+	}
+    }
+    if (!flag) return IMAP_PERMISSION_DENIED;
   
     /* Check ACL */
     if(!sdata->isadmin &&
@@ -1820,6 +1829,9 @@
     { "/vendor/cmu/cyrus-imapd/sieve", ATTRIB_TYPE_STRING, BACKEND_ONLY,
       ATTRIB_VALUE_SHARED | ATTRIB_CONTENTTYPE_SHARED,
       ACL_ADMIN, annotation_set_todb, NULL },
+    { "/vendor/cmu/cyrus-imapd/pop3newuidl", ATTRIB_TYPE_BOOLEAN, BACKEND_ONLY,
+      ATTRIB_VALUE_SHARED | ATTRIB_CONTENTTYPE_SHARED,
+      ACL_ADMIN, annotation_set_mailboxopt, NULL },
     { "/vendor/cmu/cyrus-imapd/condstore", ATTRIB_TYPE_BOOLEAN, BACKEND_ONLY,
       ATTRIB_VALUE_SHARED | ATTRIB_CONTENTTYPE_SHARED,
       ACL_ADMIN, annotation_set_mailboxopt, NULL },
@@ -1982,7 +1994,7 @@
     else {
 	/* mailbox annotations */
 
-	char mboxpat[MAX_MAILBOX_NAME+1];
+	char mboxpat[MAX_MAILBOX_BUFFER];
 
 	/* Reset state in store_cb */
 	store_cb(NULL, 0, 0, 0);

Modified: branches/cyrus23/cyrus-imapd-2.3-development/imap/annotate.h
URL: https://mail.incase.de/viewcvs/branches/cyrus23/cyrus-imapd-2.3-development/imap/annotate.h?rev=771&root=cyrus22&r1=770&r2=771&view=diff
==============================================================================
--- branches/cyrus23/cyrus-imapd-2.3-development/imap/annotate.h (original)
+++ branches/cyrus23/cyrus-imapd-2.3-development/imap/annotate.h Thu Apr 23 19:56:51 2009
@@ -39,7 +39,7 @@
  * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
  * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  *
- * $Id: annotate.h,v 1.11 2008/03/24 17:09:16 murch Exp $
+ * $Id: annotate.h,v 1.12 2009/02/09 05:08:21 brong Exp $
  */
 
 #ifndef ANNOTATE_H
@@ -119,6 +119,14 @@
     const char *contenttype;
 };
 
+struct annotate_info_t
+{
+    const char *name;
+    int flag;
+};
+
+extern const struct annotate_info_t annotate_mailbox_flags[];
+
 /* lookup a single annotation and return result */
 int annotatemore_lookup(const char *mboxname, const char *entry,
 			const char *userid, struct annotation_data *attrib);

Modified: branches/cyrus23/cyrus-imapd-2.3-development/imap/append.c
URL: https://mail.incase.de/viewcvs/branches/cyrus23/cyrus-imapd-2.3-development/imap/append.c?rev=771&root=cyrus22&r1=770&r2=771&view=diff
==============================================================================
--- branches/cyrus23/cyrus-imapd-2.3-development/imap/append.c (original)
+++ branches/cyrus23/cyrus-imapd-2.3-development/imap/append.c Thu Apr 23 19:56:51 2009
@@ -39,7 +39,7 @@
  * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
  * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  *
- * $Id: append.c,v 1.115 2008/09/23 16:19:42 murch Exp $
+ * $Id: append.c,v 1.118 2009/03/16 00:17:14 brong Exp $
  */
 
 #include <config.h>
@@ -107,7 +107,7 @@
  */
 int append_check(const char *name, int format, 
 		 struct auth_state *auth_state,
-		 long aclcheck, long quotacheck)
+		 long aclcheck, quota_t quotacheck)
 {
     struct mailbox m;
     int r;
@@ -173,7 +173,7 @@
 int append_setup(struct appendstate *as, const char *name,
 		 int format, 
 		 const char *userid, struct auth_state *auth_state,
-		 long aclcheck, long quotacheck)
+		 long aclcheck, quota_t quotacheck)
 {
     int r;
 
@@ -217,7 +217,6 @@
 	    as->m.quota.used + quotacheck > 
 	    ((uquota_t) as->m.quota.limit * QUOTA_UNITS)) {
 	    quota_abort(&as->tid);
-	    mailbox_close(&as->m);
 	    r = IMAP_QUOTA_EXCEEDED;
 	}
     }
@@ -234,8 +233,10 @@
 	as->userid[0] = '\0';
     }
 
+    /* store original size to truncate if append is aborted */
+    as->orig_cache_size = as->m.cache_size;
+
     /* zero out metadata */
-    as->orig_cache_len = as->m.cache_len;
     as->nummsg = as->numanswered = 
 	as->numdeleted = as->numflagged = 0;
     as->quota_used = 0;
@@ -251,7 +252,7 @@
 /* may return non-zero, indicating that the entire append has failed
  and the mailbox is probably in an inconsistent state. */
 int append_commit(struct appendstate *as, 
-		  long quotacheck __attribute__((unused)),
+		  quota_t quotacheck __attribute__((unused)),
 		  unsigned long *uidvalidity, 
 		  unsigned long *start,
 		  unsigned long *num)
@@ -369,7 +370,7 @@
     }
 
     /* truncate the cache */
-    ftruncate(as->m.cache_fd, as->orig_cache_len);
+    ftruncate(as->m.cache_fd, as->orig_cache_size);
 
     /* unlock mailbox */
     mailbox_unlock_index(&as->m);

Modified: branches/cyrus23/cyrus-imapd-2.3-development/imap/append.h
URL: https://mail.incase.de/viewcvs/branches/cyrus23/cyrus-imapd-2.3-development/imap/append.h?rev=771&root=cyrus22&r1=770&r2=771&view=diff
==============================================================================
--- branches/cyrus23/cyrus-imapd-2.3-development/imap/append.h (original)
+++ branches/cyrus23/cyrus-imapd-2.3-development/imap/append.h Thu Apr 23 19:56:51 2009
@@ -39,7 +39,7 @@
  * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
  * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  *
- * $Id: append.h,v 1.30 2008/03/24 17:09:16 murch Exp $
+ * $Id: append.h,v 1.33 2009/03/16 00:17:14 brong Exp $
  */
 
 #ifndef INCLUDED_APPEND_H
@@ -70,13 +70,13 @@
 struct appendstate {
     /* mailbox we're appending to */
     struct mailbox m;
-    char userid[MAX_MAILBOX_NAME+1];
+    char userid[MAX_MAILBOX_BUFFER];
 
     enum { APPEND_READY, APPEND_DONE } s;
 				/* current state of append */
 
     /* if we abort, where should we truncate the cache file? */
-    unsigned long orig_cache_len;
+    unsigned long orig_cache_size;
 
     int writeheader;		/* did we change the mailbox header? */
 
@@ -91,7 +91,7 @@
     int seen_alloced;
 
     /* the amount of quota we've used so far in this append */
-    int quota_used;
+    uquota_t quota_used;
 
     /* txn for updating quota */
     struct txn *tid;
@@ -103,16 +103,16 @@
 
 extern int append_check(const char *name, int format, 
 			struct auth_state *auth_state,
-			long aclcheck, long quotacheck);
+			long aclcheck, quota_t quotacheck);
 
 /* appendstate must be allocated by client */
 extern int append_setup(struct appendstate *mailbox, const char *name,
 			int format, 
 			const char *userid, struct auth_state *auth_state,
-			long aclcheck, long quotacheck);
+			long aclcheck, quota_t quotacheck);
 
 extern int append_commit(struct appendstate *mailbox,
-			 long quotacheck,
+			 quota_t quotacheck,
 			 unsigned long *uidvalidity, 
 			 unsigned long *startuid, 
 			 unsigned long *num);

Modified: branches/cyrus23/cyrus-imapd-2.3-development/imap/arbitron.c
URL: https://mail.incase.de/viewcvs/branches/cyrus23/cyrus-imapd-2.3-development/imap/arbitron.c?rev=771&root=cyrus22&r1=770&r2=771&view=diff
==============================================================================
--- branches/cyrus23/cyrus-imapd-2.3-development/imap/arbitron.c (original)
+++ branches/cyrus23/cyrus-imapd-2.3-development/imap/arbitron.c Thu Apr 23 19:56:51 2009
@@ -39,7 +39,7 @@
  * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
  * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  *
- * $Id: arbitron.c,v 1.46 2008/03/24 17:09:16 murch Exp $
+ * $Id: arbitron.c,v 1.47 2009/02/09 05:01:56 brong Exp $
  */
 
 #include <config.h>
@@ -121,7 +121,7 @@
     int opt, r;
     int report_days = 30;
     int prune_months = 0;
-    char pattern[MAX_MAILBOX_NAME+1];
+    char pattern[MAX_MAILBOX_BUFFER];
     char *alt_config = NULL;
     time_t now = time(0);
 
@@ -446,7 +446,7 @@
 			  int tmpdatalen __attribute__((unused))) 
 {
     struct arb_mailbox_data *mbox;
-    char buf[MAX_MAILBOX_NAME+1];
+    char buf[MAX_MAILBOX_BUFFER];
     const char *user = (const char *) rockp;
 
     memcpy(buf, key, keylen);

Modified: branches/cyrus23/cyrus-imapd-2.3-development/imap/backend.c
URL: https://mail.incase.de/viewcvs/branches/cyrus23/cyrus-imapd-2.3-development/imap/backend.c?rev=771&root=cyrus22&r1=770&r2=771&view=diff
==============================================================================
--- branches/cyrus23/cyrus-imapd-2.3-development/imap/backend.c (original)
+++ branches/cyrus23/cyrus-imapd-2.3-development/imap/backend.c Thu Apr 23 19:56:51 2009
@@ -39,7 +39,7 @@
  * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
  * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  *
- * $Id: backend.c,v 1.57 2008/10/08 13:12:41 wescraig Exp $
+ * $Id: backend.c,v 1.59 2009/02/04 16:42:02 murch Exp $
  */
 
 #include <config.h>
@@ -95,7 +95,10 @@
     
     resp = (automatic == AUTO_BANNER) ? prot->banner.resp : prot->capa_cmd.resp;
 
-    if (!automatic && prot->capa_cmd.cmd) {
+    if (!automatic) {
+	/* no capability command */
+	if (!prot->capa_cmd.cmd) return NULL;
+	
 	/* request capabilities of server */
 	prot_printf(pout, "%s", prot->capa_cmd.cmd);
 	if (prot->capa_cmd.arg) prot_printf(pout, " %s", prot->capa_cmd.arg);
@@ -270,16 +273,8 @@
     if (local_cb) free_callbacks(cb);
 
     if (r == SASL_OK) {
-	const void *ssf;
-
 	prot_setsasl(s->in, s->saslconn);
 	prot_setsasl(s->out, s->saslconn);
-
-	sasl_getprop(s->saslconn, SASL_SSF, &ssf);
-	if (*((sasl_ssf_t *) ssf) && prot->sasl_cmd.auto_capa) {
-	    free(*mechlist);
-	    *mechlist = ask_capability(s->out, s->in, prot, &s->capability, 1);
-	}
     }
 
     /* r == SASL_OK on success */
@@ -431,7 +426,9 @@
     if ((server[0] != '/') ||
 	(strcmp(prot->sasl_service, "lmtp") &&
 	 strcmp(prot->sasl_service, "csync"))) {
-	if ((r = backend_authenticate(ret, prot, &mechlist, userid,
+	char *mlist = xstrdup(mechlist); /* backend_auth is destructive */
+
+	if ((r = backend_authenticate(ret, prot, &mlist, userid,
 				      cb, auth_status))) {
 	    syslog(LOG_ERR, "couldn't authenticate to backend server: %s",
 		   sasl_errstring(r, NULL, NULL));
@@ -439,6 +436,50 @@
 	    close(sock);
 	    ret = NULL;
 	}
+	else {
+	    const void *ssf;
+
+	    sasl_getprop(ret->saslconn, SASL_SSF, &ssf);
+	    if (*((sasl_ssf_t *) ssf)) {
+		/* if we have a SASL security layer, compare SASL mech lists
+		   to check for a MITM attack */
+		char *new_mechlist;
+		int auto_capa = prot->sasl_cmd.auto_capa;
+
+		if (!strcmp(prot->service, "sieve")) {
+		    /* XXX  Hack to handle ManageSieve servers.
+		     * No way to tell from protocol if server will
+		     * automatically send capabilities, so we treat it
+		     * as optional.
+		     */
+		    char ch;
+
+		    /* wait and probe for possible auto-capability response */
+		    usleep(250000);
+		    prot_NONBLOCK(ret->in);
+		    if ((ch = prot_getc(ret->in)) != EOF) {
+			prot_ungetc(ch, ret->in);
+		    } else {
+			auto_capa = AUTO_NO;
+		    }
+		    prot_BLOCK(ret->in);
+		}
+
+		new_mechlist = ask_capability(ret->out, ret->in, prot,
+					      &ret->capability, auto_capa);
+		if (new_mechlist && strcmp(new_mechlist, mechlist)) {
+		    syslog(LOG_ERR, "possible MITM attack:"
+			   "list of available SASL mechanisms changed");
+		    if (!ret_backend) free(ret);
+		    close(sock);
+		    ret = NULL;
+		}
+
+		free(new_mechlist);
+	    }
+	}
+
+	if (mlist) free(mlist);
     }
 
     if (mechlist) free(mechlist);

Modified: branches/cyrus23/cyrus-imapd-2.3-development/imap/ctl_mboxlist.c
URL: https://mail.incase.de/viewcvs/branches/cyrus23/cyrus-imapd-2.3-development/imap/ctl_mboxlist.c?rev=771&root=cyrus22&r1=770&r2=771&view=diff
==============================================================================
--- branches/cyrus23/cyrus-imapd-2.3-development/imap/ctl_mboxlist.c (original)
+++ branches/cyrus23/cyrus-imapd-2.3-development/imap/ctl_mboxlist.c Thu Apr 23 19:56:51 2009
@@ -39,7 +39,7 @@
  * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
  * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  *
- * $Id: ctl_mboxlist.c,v 1.63 2008/09/24 11:45:50 murch Exp $
+ * $Id: ctl_mboxlist.c,v 1.64 2009/02/09 05:01:56 brong Exp $
  */
 
 /* currently doesn't catch signals; probably SHOULD */
@@ -116,8 +116,8 @@
 
 struct mb_node 
 {
-    char mailbox[MAX_MAILBOX_NAME+1];
-    char server[MAX_MAILBOX_NAME+1];
+    char mailbox[MAX_MAILBOX_BUFFER];
+    char server[MAX_MAILBOX_BUFFER];
     char *acl;
     struct mb_node *next;
 };
@@ -556,7 +556,7 @@
     int r = 0;
     char buf[16384];
     int line = 0;
-    char last_commit[MAX_MAILBOX_NAME];
+    char last_commit[MAX_MAILBOX_BUFFER];
     char *key=NULL, *data=NULL;
     int keylen, datalen;
     int untilCommit = PER_COMMIT;
@@ -596,7 +596,7 @@
 	for (; *p && *p != '\r' && *p != '\n'; p++) ;
 	*p++ = '\0';
 
-	if (strlen(name) > MAX_MAILBOX_NAME) {
+	if (strlen(name) >= MAX_MAILBOX_BUFFER) {
 	    fprintf(stderr, "line %d: mailbox name too long\n", line);
 	    continue;
 	}
@@ -666,8 +666,8 @@
 
 struct found_data {
     int type;
-    char mboxname[MAX_MAILBOX_NAME+1];
-    char partition[MAX_MAILBOX_NAME+1];
+    char mboxname[MAX_MAILBOX_BUFFER];
+    char partition[MAX_MAILBOX_BUFFER];
     char path[MAX_MAILBOX_PATH+1];
 };
 
@@ -825,8 +825,8 @@
     for (i = 0; i < found.size; i++) {
 	DIR *dirp;
 	struct dirent *dirent;
-	char name[MAX_MAILBOX_NAME+1];
-	char part[MAX_MAILBOX_NAME+1]; 
+	char name[MAX_MAILBOX_BUFFER];
+	char part[MAX_MAILBOX_BUFFER]; 
 	char path[MAX_MAILBOX_PATH+1];
 	int type;
 

Modified: branches/cyrus23/cyrus-imapd-2.3-development/imap/cvt_cyrusdb.c
URL: https://mail.incase.de/viewcvs/branches/cyrus23/cyrus-imapd-2.3-development/imap/cvt_cyrusdb.c?rev=771&root=cyrus22&r1=770&r2=771&view=diff
==============================================================================
--- branches/cyrus23/cyrus-imapd-2.3-development/imap/cvt_cyrusdb.c (original)
+++ branches/cyrus23/cyrus-imapd-2.3-development/imap/cvt_cyrusdb.c Thu Apr 23 19:56:51 2009
@@ -39,7 +39,7 @@
  * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
  * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  *
- * $Id: cvt_cyrusdb.c,v 1.18 2008/03/24 17:09:16 murch Exp $
+ * $Id: cvt_cyrusdb.c,v 1.19 2009/02/11 19:11:32 murch Exp $
  */
 
 #include <config.h>
@@ -107,8 +107,13 @@
 	fprintf(stderr, "Usage: %s [-C altconfig] <old db> <old db backend> <new db> <new db backend>\n", argv[0]);
 	fprintf(stderr, "Usable Backends:  ");
 
+	/* The following is commented out because its an over-paranoid
+	   check (cyrusdb_backends[] is statically defined to be non-empty)
+	   and causes a compiler warning
+
 	if(!cyrusdb_backends || !cyrusdb_backends[0])
 	    fatal("we don't seem to have any db backends available", EC_OSERR);
+	*/
 	
 	fprintf(stderr, "%s", cyrusdb_backends[0]->name);
 	for(i=1; cyrusdb_backends[i]; i++)

Modified: branches/cyrus23/cyrus-imapd-2.3-development/imap/cyr_expire.c
URL: https://mail.incase.de/viewcvs/branches/cyrus23/cyrus-imapd-2.3-development/imap/cyr_expire.c?rev=771&root=cyrus22&r1=770&r2=771&view=diff
==============================================================================
--- branches/cyrus23/cyrus-imapd-2.3-development/imap/cyr_expire.c (original)
+++ branches/cyrus23/cyrus-imapd-2.3-development/imap/cyr_expire.c Thu Apr 23 19:56:51 2009
@@ -39,7 +39,7 @@
  * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
  * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  *
- * $Id: cyr_expire.c,v 1.20 2008/10/06 15:24:03 murch Exp $
+ * $Id: cyr_expire.c,v 1.21 2009/02/09 05:01:56 brong Exp $
  */
 
 #include <config.h>
@@ -149,7 +149,7 @@
 	   void *rock)
 {
     struct expire_rock *erock = (struct expire_rock *) rock;
-    char buf[MAX_MAILBOX_NAME+1] = "", *p;
+    char buf[MAX_MAILBOX_BUFFER] = "", *p;
     struct annotation_data attrib;
     int r, domainlen = 0;
 

Modified: branches/cyrus23/cyrus-imapd-2.3-development/imap/cyr_synclog.c
URL: https://mail.incase.de/viewcvs/branches/cyrus23/cyrus-imapd-2.3-development/imap/cyr_synclog.c?rev=771&root=cyrus22&r1=770&r2=771&view=diff
==============================================================================
--- branches/cyrus23/cyrus-imapd-2.3-development/imap/cyr_synclog.c (original)
+++ branches/cyrus23/cyrus-imapd-2.3-development/imap/cyr_synclog.c Thu Apr 23 19:56:51 2009
@@ -39,7 +39,7 @@
  * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
  * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  *
- * $Id: cyr_synclog.c,v 1.2 2008/03/24 17:09:16 murch Exp $
+ * $Id: cyr_synclog.c,v 1.5 2009/02/11 19:11:32 murch Exp $
  *
  * Originally written by Bron Gondwana <brong at fastmail.fm>
  */
@@ -54,6 +54,8 @@
 
 #include "global.h"
 #include "sync_log.h"
+#include "util.h"
+#include "xmalloc.h"
 
 /* config.c stuff */
 const int config_need_data = 0;
@@ -63,6 +65,10 @@
     char *alt_config = NULL;
     char cmd = '\0';
     char opt;
+
+    if ((geteuid()) == 0 && (become_cyrus() != 0)) {
+	fatal("must run as the Cyrus user", EC_USAGE);
+    }
 
     while ((opt = getopt(argc, argv, "C:uvmacqnsb")) != EOF) {
 	switch (opt) {
@@ -149,7 +155,7 @@
 	    sync_log_seen(argv[optind], argv[optind+1]);
 	    break;
 	case 'b': /* suBscription */
-	    sync_log_subscribe(argv[optind], argv[optind+1], argv[optind+2]);
+	    sync_log_subscribe(argv[optind], argv[optind+1]);
 	    break;
         default:
             /* just as is! */

Modified: branches/cyrus23/cyrus-imapd-2.3-development/imap/cyr_virusscan.c
URL: https://mail.incase.de/viewcvs/branches/cyrus23/cyrus-imapd-2.3-development/imap/cyr_virusscan.c?rev=771&root=cyrus22&r1=770&r2=771&view=diff
==============================================================================
--- branches/cyrus23/cyrus-imapd-2.3-development/imap/cyr_virusscan.c (original)
+++ branches/cyrus23/cyrus-imapd-2.3-development/imap/cyr_virusscan.c Thu Apr 23 19:56:51 2009
@@ -39,7 +39,7 @@
  * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
  * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  *
- * $Id: cyr_virusscan.c,v 1.5 2008/09/23 16:17:09 murch Exp $
+ * $Id: cyr_virusscan.c,v 1.6 2009/02/09 05:01:56 brong Exp $
  */
 
 #include <config.h>
@@ -296,7 +296,7 @@
 					   scan_me, NULL);
     } else {
 	for (; optind < argc; optind++) {
-	    strncpy(buf, argv[optind], MAX_MAILBOX_NAME);
+	    strncpy(buf, argv[optind], MAX_MAILBOX_BUFFER);
 	    /* Translate any separators in mailboxname */
 	    mboxname_hiersep_tointernal(&scan_namespace, buf,
 					config_virtdomains ?
@@ -342,7 +342,7 @@
     struct infected_mbox *i_mbox = NULL;
 
     if (verbose) {
-	char mboxname[MAX_MAILBOX_NAME+1];
+	char mboxname[MAX_MAILBOX_BUFFER];
 
 	/* Convert internal name to external */
 	(*scan_namespace.mboxname_toexternal)(&scan_namespace, name,

Modified: branches/cyrus23/cyrus-imapd-2.3-development/imap/cyrdump.c
URL: https://mail.incase.de/viewcvs/branches/cyrus23/cyrus-imapd-2.3-development/imap/cyrdump.c?rev=771&root=cyrus22&r1=770&r2=771&view=diff
==============================================================================
--- branches/cyrus23/cyrus-imapd-2.3-development/imap/cyrdump.c (original)
+++ branches/cyrus23/cyrus-imapd-2.3-development/imap/cyrdump.c Thu Apr 23 19:56:51 2009
@@ -38,7 +38,7 @@
  * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
  * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  *
- * $Id: cyrdump.c,v 1.21 2008/03/24 17:09:16 murch Exp $
+ * $Id: cyrdump.c,v 1.22 2009/02/09 05:01:56 brong Exp $
  */
 
 #include <config.h>
@@ -178,7 +178,7 @@
     struct mailbox m;
     char boundary[128];
     struct imapurl url;
-    char imapurl[MAX_MAILBOX_PATH];
+    char imapurl[MAX_MAILBOX_PATH+1];
     struct incremental_record *irec = (struct incremental_record *) rock;
     struct searchargs searchargs;
     unsigned *uids;

Modified: branches/cyrus23/cyrus-imapd-2.3-development/imap/fud.c
URL: https://mail.incase.de/viewcvs/branches/cyrus23/cyrus-imapd-2.3-development/imap/fud.c?rev=771&root=cyrus22&r1=770&r2=771&view=
3Ddiff
==============================================================================
--- branches/cyrus23/cyrus-imapd-2.3-development/imap/fud.c (original)
+++ branches/cyrus23/cyrus-imapd-2.3-development/imap/fud.c Thu Apr 23 19:56:51 2009
@@ -39,7 +39,7 @@
  * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
  * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  *
- * $Id: fud.c,v 1.56 2008/03/24 17:09:16 murch Exp $
+ * $Id: fud.c,v 1.57 2009/02/09 05:01:56 brong Exp $
  */
 
 #include <config.h>
@@ -112,18 +112,21 @@
         struct sockaddr_storage sfrom;
         socklen_t sfromsiz = sizeof(sfrom);
         int r;
-        char    buf[MAXLOGNAME + MAXDOMNAME+ MAX_MAILBOX_NAME + 1];
+        char    buf[MAXLOGNAME + MAXDOMNAME + MAX_MAILBOX_BUFFER];
         char    username[MAXLOGNAME + MAXDOMNAME];
-        char    mbox[MAX_MAILBOX_NAME+1];
+        char    mbox[MAX_MAILBOX_BUFFER];
         char    *q;
         int     off;
-	int     maxuserlen = MAXLOGNAME + config_virtdomains ? MAXDOMNAME : 0;
+	int     maxuserlen = MAXLOGNAME;
+
+	if (config_virtdomains) 
+	    maxuserlen += MAXDOMNAME + 1; /* @ + DOM */
 
         while(1) {
             /* For safety */
-            memset(username,'\0',MAXLOGNAME + MAXDOMNAME);	
-            memset(mbox,'\0',MAX_MAILBOX_NAME+1);
-            memset(buf, '\0', MAXLOGNAME + MAX_MAILBOX_NAME + 1);
+            memset(buf, 0, sizeof(buf));
+            memset(username, 0, sizeof(username));
+            memset(mbox, 0, sizeof(mbox));
 
 	    if (signals_poll() == SIGHUP) {
 		/* caught a SIGHUP, return */
@@ -354,7 +357,7 @@
     unsigned recentuid;
     char *seenuids;
     unsigned numrecent;
-    char mboxname[MAX_MAILBOX_NAME+1];
+    char mboxname[MAX_MAILBOX_BUFFER];
     char *location, *acl;
     int mbflag;
 

Modified: branches/cyrus23/cyrus-imapd-2.3-development/imap/global.c
URL: https://mail.incase.de/viewcvs/branches/cyrus23/cyrus-imapd-2.3-development/imap/global.c?rev=771&root=cyrus22&r1=770&r2=771&view=diff
==============================================================================
--- branches/cyrus23/cyrus-imapd-2.3-development/imap/global.c (original)
+++ branches/cyrus23/cyrus-imapd-2.3-development/imap/global.c Thu Apr 23 19:56:51 2009
@@ -39,7 +39,7 @@
  * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
  * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  *
- * $Id: global.c,v 1.28 2008/07/30 16:03:37 murch Exp $
+ * $Id: global.c,v 1.29 2009/02/09 05:01:56 brong Exp $
  */
 
 #include <config.h>
@@ -496,7 +496,7 @@
 {
     struct namespace namespace;
     char *acl;
-    char bufuser[MAX_MAILBOX_NAME], inboxname[MAX_MAILBOX_NAME];
+    char bufuser[MAX_MAILBOX_BUFFER], inboxname[MAX_MAILBOX_BUFFER];
     int r;
 
     /* Set namespace */

Modified: branches/cyrus23/cyrus-imapd-2.3-development/imap/idle.c
URL: https://mail.incase.de/viewcvs/branches/cyrus23/cyrus-imapd-2.3-development/imap/idle.c?rev=771&root=cyrus22&r1=770&r2=771&view=diff
==============================================================================
--- branches/cyrus23/cyrus-imapd-2.3-development/imap/idle.c (original)
+++ branches/cyrus23/cyrus-imapd-2.3-development/imap/idle.c Thu Apr 23 19:56:51 2009
@@ -38,7 +38,7 @@
  * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
  * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  *
- * $Id: idle.c,v 1.5 2008/03/24 17:09:16 murch Exp $
+ * $Id: idle.c,v 1.6 2009/02/06 13:46:18 brong Exp $
  */
 
 #include <config.h>
@@ -85,7 +85,7 @@
     /* fill the structure */
     idledata.msg = msg;
     idledata.pid = getpid();
-    strcpy(idledata.mboxname, mboxname ? mboxname : ".");
+    strncpy(idledata.mboxname, mboxname ? mboxname : ".", sizeof(idledata.mboxname));
 
     /* send */
     if (sendto(notify_sock, (void *) &idledata,

Modified: branches/cyrus23/cyrus-imapd-2.3-development/imap/idled.h
URL: https://mail.incase.de/viewcvs/branches/cyrus23/cyrus-imapd-2.3-development/imap/idled.h?rev=771&root=cyrus22&r1=770&r2=771&view=diff
==============================================================================
--- branches/cyrus23/cyrus-imapd-2.3-development/imap/idled.h (original)
+++ branches/cyrus23/cyrus-imapd-2.3-development/imap/idled.h Thu Apr 23 19:56:51 2009
@@ -39,7 +39,7 @@
  * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
  * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  *
- * $Id: idled.h,v 1.7 2008/03/24 17:09:16 murch Exp $
+ * $Id: idled.h,v 1.8 2009/02/09 05:01:56 brong Exp $
  */
 
 #ifndef IDLED_H
@@ -55,7 +55,7 @@
     unsigned long pid;
 
     /* 1 for null. leave at end of structure for alignment */
-    char mboxname[MAX_MAILBOX_NAME+1];
+    char mboxname[MAX_MAILBOX_BUFFER];
 } idle_data_t;
 
 #define IDLEDATA_BASE_SIZE	(2 * (int) sizeof(unsigned long))

Modified: branches/cyrus23/cyrus-imapd-2.3-development/imap/imap_proxy.c
URL: https://mail.incase.de/viewcvs/branches/cyrus23/cyrus-imapd-2.3-development/imap/imap_proxy.c?rev=771&root=cyrus22&r1=770&r2=771&view=diff
==============================================================================
--- branches/cyrus23/cyrus-imapd-2.3-development/imap/imap_proxy.c (original)
+++ branches/cyrus23/cyrus-imapd-2.3-development/imap/imap_proxy.c Thu Apr 23 19:56:51 2009
@@ -39,7 +39,7 @@
  * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
  * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  *
- * $Id: imap_proxy.c,v 1.11 2008/10/08 15:47:06 murch Exp $
+ * $Id: imap_proxy.c,v 1.12 2009/02/09 05:01:56 brong Exp $
  */
 
 #include <config.h>
@@ -129,7 +129,7 @@
 
 struct backend *proxy_findinboxserver(void)
 {
-    char inbox[MAX_MAILBOX_NAME+1];
+    char inbox[MAX_MAILBOX_BUFFER];
     int r, mbtype;
     char *server = NULL;
     struct backend *s = NULL;
@@ -468,7 +468,7 @@
     int c;
     int r = PROXY_OK;
     int exist_r;
-    char mailboxname[MAX_MAILBOX_PATH + 1];
+    char mailboxname[MAX_MAILBOX_BUFFER];
     static struct buf tagb, cmd, sep, name;
     int cur_flags_size = 64;
     char *flags = xmalloc(cur_flags_size);

Modified: branches/cyrus23/cyrus-imapd-2.3-development/imap/imapd.c
URL: https://mail.incase.de/viewcvs/branches/cyrus23/cyrus-imapd-2.3-development/imap/imapd.c?rev=771&root=cyrus22&r1=770&r2=771&view=diff
==============================================================================
--- branches/cyrus23/cyrus-imapd-2.3-development/imap/imapd.c (original)
+++ branches/cyrus23/cyrus-imapd-2.3-development/imap/imapd.c Thu Apr 23 19:56:51 2009
@@ -38,7 +38,7 @@
  * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
  * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  *
- * $Id: imapd.c,v 1.553 2008/10/08 15:47:06 murch Exp $
+ * $Id: imapd.c,v 1.558 2009/03/16 00:17:14 brong Exp $
  */
 
 #include <config.h>
@@ -117,7 +117,7 @@
 /* global state */
 const int config_need_data = CONFIG_NEED_PARTITION_DATA;
 
-static char shutdownfilename[1024];
+static char shutdownfilename[MAX_MAILBOX_PATH+1];
 static int imaps = 0;
 static sasl_ssf_t extprops_ssf = 0;
 static int nosaslpasswdcheck = 0;
@@ -335,7 +335,7 @@
 			    unsigned flags, const char *user_realm,
 			    char *out, unsigned out_max, unsigned *out_ulen)
 {
-    char userbuf[MAX_MAILBOX_NAME+1], *p;
+    char userbuf[MAX_MAILBOX_BUFFER], *p;
     size_t n;
     int r;
 
@@ -343,7 +343,7 @@
 
     if (config_getswitch(IMAPOPT_IMAPMAGICPLUS)) {
 	/* make a working copy of the auth[z]id */
-	if (ulen > MAX_MAILBOX_NAME) {
+	if (ulen >= MAX_MAILBOX_BUFFER) {
 	    sasl_seterror(conn, 0, "buffer overflow while canonicalizing");
 	    return SASL_BUFOVER;
 	}
@@ -400,12 +400,12 @@
 			      struct propctx *propctx)
 {
     if (config_getswitch(IMAPOPT_IMAPMAGICPLUS)) {
-	char userbuf[MAX_MAILBOX_NAME+1], *p;
+	char userbuf[MAX_MAILBOX_BUFFER], *p;
 	size_t n;
 
 	/* make a working copy of the authzid */
 	if (!rlen) rlen = strlen(requested_user);
-	if (rlen > MAX_MAILBOX_NAME) {
+	if (rlen >= MAX_MAILBOX_BUFFER) {
 	    sasl_seterror(conn, 0, "buffer overflow while proxying");
 	    return SASL_BUFOVER;
 	}
@@ -828,7 +828,7 @@
 int fd;
 {
     struct protstream *motd_in;
-    char buf[1024];
+    char buf[MAX_MAILBOX_PATH+1];
     char *p;
 
     motd_in = prot_new(fd, 0);
@@ -973,12 +973,12 @@
 void cmdloop()
 {
     int fd;
-    char motdfilename[1024];
+    char motdfilename[MAX_MAILBOX_PATH+1];
     int c;
     int ret;
     int usinguid, havepartition, havenamespace, recursive;
     static struct buf tag, cmd, arg1, arg2, arg3, arg4;
-    char *p, shut[1024];
+    char *p, shut[MAX_MAILBOX_PATH+1];
     const char *err;
 
     prot_printf(imapd_out, "* OK [CAPABILITY ");
@@ -1979,7 +1979,7 @@
  */
 void cmd_login(char *tag, char *user)
 {
-    char userbuf[MAX_MAILBOX_NAME+1];
+    char userbuf[MAX_MAILBOX_BUFFER];
     unsigned userlen;
     const char *canon_user = userbuf;
     const void *val;
@@ -2231,7 +2231,7 @@
     /* If we're proxying, the authzid may contain a magic plus,
        so re-canonify it */
     if (config_getswitch(IMAPOPT_IMAPMAGICPLUS) && strchr(canon_user, '+')) {
-	char userbuf[MAX_MAILBOX_NAME+1];
+	char userbuf[MAX_MAILBOX_BUFFER];
 	unsigned userlen;
 
 	sasl_result = imapd_canon_user(imapd_saslconn, NULL, canon_user, 0,
@@ -2622,7 +2622,7 @@
 	index_check(imapd_mailbox, 0, 1);
 
     if (flags & IDLE_ALERT) {
-	char shut[1024];
+	char shut[MAX_MAILBOX_PATH+1];
 	if (! imapd_userisadmin && shutdown_file(shut, sizeof(shut))) {
 	    char *p;
 	    for (p = shut; *p == '['; p++); /* can't have [ be first char */
@@ -2834,7 +2834,7 @@
 			unsigned *totalsize, const char **parseerr)
 {
     struct imapurl url;
-    char mailboxname[MAX_MAILBOX_NAME+1];
+    char mailboxname[MAX_MAILBOX_BUFFER];
     struct mailbox mboxstruct, *mailbox;
     unsigned msgno;
     int r = 0, doclose = 0;
@@ -3032,11 +3032,12 @@
     int c;
     static struct buf arg;
     time_t now = time(NULL);
-    unsigned size, totalsize = 0;
+    uquota_t totalsize = 0;
+    unsigned size;
     int sync_seen = 0;
     int r;
     unsigned i;
-    char mailboxname[MAX_MAILBOX_NAME+1];
+    char mailboxname[MAX_MAILBOX_BUFFER];
     struct appendstate mailbox;
     unsigned long uidvalidity;
     unsigned long firstuid, num;
@@ -3341,7 +3342,7 @@
 {
     int c;
     struct mailbox mailbox;
-    char mailboxname[MAX_MAILBOX_NAME+1];
+    char mailboxname[MAX_MAILBOX_BUFFER];
     int r = 0;
     double usage;
     int doclose = 0;
@@ -4734,7 +4735,7 @@
 void cmd_copy(char *tag, char *sequence, char *name, int usinguid)
 {
     int r, myrights;
-    char mailboxname[MAX_MAILBOX_NAME+1];
+    char mailboxname[MAX_MAILBOX_BUFFER];
     int mbtype;
     char *server, *acl;
     char *copyuid;
@@ -4928,7 +4929,7 @@
 void cmd_create(char *tag, char *name, char *partition, int localonly)
 {
     int r = 0;
-    char mailboxname[MAX_MAILBOX_NAME+1];
+    char mailboxname[MAX_MAILBOX_BUFFER];
     int autocreatequota;
 
     if (partition && !imapd_userisadmin) {
@@ -5071,10 +5072,9 @@
 		    error_message(IMAP_OK_COMPLETED));
 
 	if ( !localonly ) {
+	    sync_log_mailbox(mailboxname);
 	if (mboxname_isusermailbox(mailboxname, 1))
 		sync_log_user(mboxname_inbox_touserid(mailboxname));
-	else
-	    sync_log_mailbox(mailboxname);
     }
     }
 }	
@@ -5117,7 +5117,7 @@
 void cmd_delete(char *tag, char *name, int localonly, int force)
 {
     int r;
-    char mailboxname[MAX_MAILBOX_NAME+1];
+    char mailboxname[MAX_MAILBOX_BUFFER];
     int mbtype;
     char *server;
     char *p;
@@ -5201,7 +5201,7 @@
 	!strchr(mailboxname+domainlen+5, '.')) {
  	size_t mailboxname_len = strlen(mailboxname);
 
- 	/* If we aren't too close to MAX_MAILBOX_NAME, append .* */
+ 	/* If we aren't too close to MAX_MAILBOX_BUFFER, append .* */
  	p = mailboxname + mailboxname_len; /* end of mailboxname */
  	if (mailboxname_len < sizeof(mailboxname) - 3) {
  	    strcpy(p, ".*");
@@ -5264,12 +5264,12 @@
 		   int maycreate __attribute__((unused)),
 		   void *rock)
 {
-    char oldextname[MAX_MAILBOX_NAME+1];
-    char newextname[MAX_MAILBOX_NAME+1];
+    char oldextname[MAX_MAILBOX_BUFFER];
+    char newextname[MAX_MAILBOX_BUFFER];
     struct renrock *text = (struct renrock *)rock;
     int r;
 
-    if((text->nl + strlen(name + text->ol)) > MAX_MAILBOX_NAME)
+    if((text->nl + strlen(name + text->ol)) >= MAX_MAILBOX_BUFFER)
 	return 0;
 
     strcpy(text->newmailboxname + text->nl, name + text->ol);
@@ -5306,6 +5306,14 @@
 		    oldextname, newextname);
 
         sync_log_mailbox_double(name, text->newmailboxname);
+
+	if (text->rename_user) {
+	    /* allow the replica to get the correct new quotaroot 
+	     * and acls copied across */
+	    sync_log_user(text->newuser);
+	    /* allow the replica to clean up the old meta files */
+	    sync_log_user(text->olduser);
+	}
     }
 
     prot_flush(imapd_out);
@@ -5319,12 +5327,12 @@
 void cmd_rename(char *tag, char *oldname, char *newname, char *partition)
 {
     int r = 0;
-    char oldmailboxname[MAX_MAILBOX_NAME+3];
-    char newmailboxname[MAX_MAILBOX_NAME+2];
-    char oldmailboxname2[MAX_MAILBOX_NAME+1];
-    char newmailboxname2[MAX_MAILBOX_NAME+1];
-    char oldextname[MAX_MAILBOX_NAME+1];
-    char newextname[MAX_MAILBOX_NAME+1];
+    char oldmailboxname[MAX_MAILBOX_BUFFER];
+    char newmailboxname[MAX_MAILBOX_BUFFER];
+    char oldmailboxname2[MAX_MAILBOX_BUFFER];
+    char newmailboxname2[MAX_MAILBOX_BUFFER];
+    char oldextname[MAX_MAILBOX_BUFFER];
+    char newextname[MAX_MAILBOX_BUFFER];
     int omlen, nmlen;
     int recursive_rename = 1;
     int rename_user = 0;
@@ -5381,7 +5389,7 @@
 
 	    destpart = strchr(partition,'!');
 	    if (destpart) {
-		char newserver[MAX_MAILBOX_NAME+1];	    
+		char newserver[MAX_MAILBOX_BUFFER];	    
 		if (strlen(partition) >= sizeof(newserver)) {
 		    prot_printf(imapd_out,
 				"%s NO Partition name too long\r\n", tag);
@@ -5636,8 +5644,8 @@
 void cmd_reconstruct(const char *tag, const char *name, int recursive)
 {
     int r = 0;
-    char mailboxname[MAX_MAILBOX_NAME+1];
-    char quotaroot[MAX_MAILBOX_NAME+1];
+    char mailboxname[MAX_MAILBOX_BUFFER];
+    char quotaroot[MAX_MAILBOX_BUFFER];
     int mbtype;
     char *server;
     struct mailbox mailbox;
@@ -5990,7 +5998,7 @@
 {
     const char *cmd = add ? "Subscribe" : "Unsubscribe";
     int r = 0;
-    char mailboxname[MAX_MAILBOX_NAME+1];
+    char mailboxname[MAX_MAILBOX_BUFFER];
     int force = config_getswitch(IMAPOPT_ALLOWALLSUBSCRIBE);
 
     if (backend_inbox || (backend_inbox = proxy_findinboxserver())) {
@@ -6065,7 +6073,7 @@
     else {
 	prot_printf(imapd_out, "%s OK %s\r\n", tag,
 		    error_message(IMAP_OK_COMPLETED));
-        sync_log_subscribe(imapd_userid, mailboxname, add);
+        sync_log_subscribe(imapd_userid, mailboxname);
     }
 }
 
@@ -6074,7 +6082,7 @@
  */
 void cmd_getacl(const char *tag, const char *name)
 {
-    char mailboxname[MAX_MAILBOX_NAME+1];
+    char mailboxname[MAX_MAILBOX_BUFFER];
     int r, access;
     char *acl;
     char *rights, *nextid;
@@ -6137,7 +6145,7 @@
 char *name;
 char *identifier;
 {
-    char mailboxname[MAX_MAILBOX_NAME+1];
+    char mailboxname[MAX_MAILBOX_BUFFER];
     int r, rights;
     char *acl;
 
@@ -6232,7 +6240,7 @@
  */
 void cmd_myrights(const char *tag, const char *name)
 {
-    char mailboxname[MAX_MAILBOX_NAME+1];
+    char mailboxname[MAX_MAILBOX_BUFFER];
     int r, rights = 0;
     char *acl;
     char str[ACL_MAXSTR];
@@ -6283,7 +6291,7 @@
 		const char *identifier, const char *rights)
 {
     int r;
-    char mailboxname[MAX_MAILBOX_NAME+1];
+    char mailboxname[MAX_MAILBOX_BUFFER];
     char *server;
     int mbtype;
 
@@ -6400,8 +6408,8 @@
 {
     int r;
     struct quota quota;
-    char quotarootbuf[MAX_MAILBOX_PATH+3];
-    char mailboxname[MAX_MAILBOX_NAME+1];
+    char quotarootbuf[MAX_MAILBOX_BUFFER];
+    char mailboxname[MAX_MAILBOX_BUFFER];
     int mbtype;
     char *server_rock = NULL, *server_rock_tmp = NULL;
 
@@ -6471,7 +6479,7 @@
  */
 void cmd_getquotaroot(const char *tag, const char *name)
 {
-    char mailboxname[MAX_MAILBOX_NAME+1];
+    char mailboxname[MAX_MAILBOX_BUFFER];
     char *server;
     int mbtype;
     struct mailbox mailbox;
@@ -6581,7 +6589,7 @@
     static struct buf arg;
     char *p;
     int r;
-    char mailboxname[MAX_MAILBOX_NAME+1];
+    char mailboxname[MAX_MAILBOX_BUFFER];
     int mbtype;
     char *server_rock_tmp = NULL;
 
@@ -6636,7 +6644,7 @@
 
     if (!r && (mbtype & MBTYPE_REMOTE)) {
 	/* remote mailbox */
-	char quotarootbuf[MAX_MAILBOX_NAME + 3];
+	char quotarootbuf[MAX_MAILBOX_BUFFER];
 	char *server_rock = xstrdup(server_rock_tmp);
 
 	snprintf(quotarootbuf, sizeof(quotarootbuf), "%s.*", mailboxname);
@@ -6796,7 +6804,7 @@
     int c;
     unsigned statusitems = 0;
     static struct buf arg;
-    char mailboxname[MAX_MAILBOX_NAME+1];
+    char mailboxname[MAX_MAILBOX_BUFFER];
     int mbtype;
     char *server, *acl;
     int r = 0;
@@ -6998,9 +7006,9 @@
     char* pattern;
 
     if (SLEEZY_NAMESPACE) {
-	char inboxname[MAX_MAILBOX_NAME+1];
-
-	if (strlen(imapd_userid) + 5 > MAX_MAILBOX_NAME)
+	char inboxname[MAX_MAILBOX_BUFFER];
+
+	if (strlen(imapd_userid) + 5 >= MAX_MAILBOX_BUFFER)
 	    sawone[NAMESPACE_INBOX] = 0;
 	else {
 	    (*imapd_namespace.mboxname_tointernal)(&imapd_namespace, "INBOX",
@@ -7897,7 +7905,7 @@
 void cmd_dump(char *tag, char *name, int uid_start) 
 {
     int r = 0;
-    char mailboxname[MAX_MAILBOX_NAME+1];
+    char mailboxname[MAX_MAILBOX_BUFFER];
     char *path, *mpath, *acl;
 
     /* administrators only please */
@@ -7932,7 +7940,7 @@
 void cmd_undump(char *tag, char *name) 
 {
     int r = 0;
-    char mailboxname[MAX_MAILBOX_NAME+1];
+    char mailboxname[MAX_MAILBOX_BUFFER];
     char *path, *mpath, *acl;
 
     /* administrators only please */
@@ -8461,7 +8469,7 @@
     char *toserver = ((struct xfer_user_rock *)rock)->toserver;
     char *topart = ((struct xfer_user_rock *)rock)->topart;
     struct backend *be = ((struct xfer_user_rock *)rock)->be;
-    char externalname[MAX_MAILBOX_NAME+1];
+    char externalname[MAX_MAILBOX_BUFFER];
     int mbflags;
     int r = 0;
     char *inpath, *inmpath, *inpart, *inacl;
@@ -8510,7 +8518,7 @@
 {
     int r = 0;
     char buf[MAX_PARTITION_LEN+HOSTNAME_SIZE+2];
-    char mailboxname[MAX_MAILBOX_NAME+1];
+    char mailboxname[MAX_MAILBOX_BUFFER];
     int mbflags;
     int moving_user = 0;
     int backout_mupdate = 0;
@@ -9331,7 +9339,7 @@
 		       int maycreate __attribute__((unused)),
 		       void *rock __attribute__((unused)))
 {
-    char mboxname[MAX_MAILBOX_PATH+1];
+    char mboxname[MAX_MAILBOX_BUFFER];
 
     (*imapd_namespace.mboxname_toexternal)(&imapd_namespace, name,
 					   imapd_userid, mboxname);
@@ -9352,7 +9360,7 @@
     static int sawuser = 0;
     int lastnamehassub = 0;
     int c, mbtype;
-    char mboxname[MAX_MAILBOX_PATH+1];
+    char mboxname[MAX_MAILBOX_BUFFER];
 
     /* We have to reset the sawuser flag before each list command.
      * Handle it as a dirty hack.
@@ -9489,7 +9497,7 @@
     
     if (name && listargs->scan) {
 	/* SCAN mailbox for content */
-	char mailboxname[MAX_MAILBOX_NAME+1];
+	char mailboxname[MAX_MAILBOX_BUFFER];
 	int r = 0;
 	int mbtype;
 	char *server;
@@ -9620,7 +9628,7 @@
 void cmd_mupdatepush(char *tag, char *name)
 {
     int r = 0;
-    char mailboxname[MAX_MAILBOX_NAME+1];
+    char mailboxname[MAX_MAILBOX_BUFFER];
     char *part, *acl;
     mupdate_handle *mupdate_h = NULL;
     char buf[MAX_PARTITION_LEN + HOSTNAME_SIZE + 2];
@@ -9698,7 +9706,7 @@
     int c, r, doclose;
     static struct buf arg;
     struct imapurl url;
-    char mailboxname[MAX_MAILBOX_NAME+1];
+    char mailboxname[MAX_MAILBOX_BUFFER];
     struct mailbox mboxstruct, *mailbox = NULL;
     unsigned msgno;
     unsigned int token_len;
@@ -9916,7 +9924,7 @@
     int c, r;
     static struct buf arg1, arg2;
     struct imapurl url;
-    char mailboxname[MAX_MAILBOX_NAME+1], *urlauth = NULL;
+    char mailboxname[MAX_MAILBOX_BUFFER], *urlauth = NULL;
     char newkey[MBOX_KEY_LEN];
     const char *key;
     size_t keylen;
@@ -10062,7 +10070,7 @@
 
     if (mailbox) {
 	/* delete key for specified mailbox */
-	char mailboxname[MAX_MAILBOX_NAME+1], *newserver;
+	char mailboxname[MAX_MAILBOX_BUFFER], *newserver;
 	int mbtype;
 	struct mboxkey *mboxkey_db;
 

Modified: branches/cyrus23/cyrus-imapd-2.3-development/imap/index.c
URL: https://mail.incase.de/viewcvs/branches/cyrus23/cyrus-imapd-2.3-development/imap/index.c?rev=771&root=cyrus22&r1=770&r2=771&view=diff
==============================================================================
--- branches/cyrus23/cyrus-imapd-2.3-development/imap/index.c (original)
+++ branches/cyrus23/cyrus-imapd-2.3-development/imap/index.c Thu Apr 23 19:56:51 2009
@@ -39,7 +39,7 @@
  * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
  * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  *
- * $Id: index.c,v 1.246 2008/10/09 13:59:53 murch Exp $
+ * $Id: index.c,v 1.247 2009/03/16 00:17:16 brong Exp $
  */
 
 #include <config.h>
@@ -1389,7 +1389,7 @@
 {
     static struct copyargs copyargs;
     int i;
-    unsigned long totalsize = 0;
+    uquota_t totalsize = 0;
     int r;
     struct appendstate append_mailbox;
     char *copyuid;

Modified: branches/cyrus23/cyrus-imapd-2.3-development/imap/ipurge.c
URL: https://mail.incase.de/viewcvs/branches/cyrus23/cyrus-imapd-2.3-development/imap/ipurge.c?rev=771&root=cyrus22&r1=770&r2=771&view=diff
==============================================================================
--- branches/cyrus23/cyrus-imapd-2.3-development/imap/ipurge.c (original)
+++ branches/cyrus23/cyrus-imapd-2.3-development/imap/ipurge.c Thu Apr 23 19:56:51 2009
@@ -42,7 +42,7 @@
  * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
  * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  *
- * $Id: ipurge.c,v 1.31 2008/03/24 17:09:17 murch Exp $
+ * $Id: ipurge.c,v 1.32 2009/02/09 05:01:57 brong Exp $
  */
 
 #include <config.h>
@@ -192,7 +192,7 @@
 					purge_me, NULL);
   } else {
     for (; optind < argc; optind++) {
-      strncpy(buf, argv[optind], MAX_MAILBOX_NAME);
+      strncpy(buf, argv[optind], MAX_MAILBOX_BUFFER);
       /* Translate any separators in mailboxname */
       mboxname_hiersep_tointernal(&purge_namespace, buf,
 				  config_virtdomains ?
@@ -241,7 +241,7 @@
   memset(&stats, '\0', sizeof(mbox_stats_t));
 
   if (verbose) {
-      char mboxname[MAX_MAILBOX_NAME+1];
+      char mboxname[MAX_MAILBOX_BUFFER];
 
       /* Convert internal name to external */
       (*purge_namespace.mboxname_toexternal)(&purge_namespace, name,

Modified: branches/cyrus23/cyrus-imapd-2.3-development/imap/lmtp_sieve.c
URL: https://mail.incase.de/viewcvs/branches/cyrus23/cyrus-imapd-2.3-development/imap/lmtp_sieve.c?rev=771&root=cyrus22&r1=770&r2=771&view=diff
==============================================================================
--- branches/cyrus23/cyrus-imapd-2.3-development/imap/lmtp_sieve.c (original)
+++ branches/cyrus23/cyrus-imapd-2.3-development/imap/lmtp_sieve.c Thu Apr 23 19:56:51 2009
@@ -39,7 +39,7 @@
  * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
  * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  *
- * $Id: lmtp_sieve.c,v 1.17 2008/03/24 17:09:17 murch Exp $
+ * $Id: lmtp_sieve.c,v 1.18 2009/02/09 05:01:57 brong Exp $
  */
 
 #include <config.h>
@@ -179,7 +179,7 @@
 		      char *fname, size_t size)
 {
     script_data_t *sdata = (script_data_t *) sc;
-    char userbuf[MAX_MAILBOX_NAME+1], *user, *domain = NULL;
+    char userbuf[MAX_MAILBOX_BUFFER], *user, *domain = NULL;
     struct stat sbuf;
     int r;
 
@@ -471,7 +471,7 @@
     deliver_data_t *mdata = (deliver_data_t *) mc;
     message_data_t *md = mdata->m;
     int quotaoverride = msg_getrcpt_ignorequota(md, mdata->cur_rcpt);
-    char namebuf[MAX_MAILBOX_NAME+1];
+    char namebuf[MAX_MAILBOX_BUFFER];
     int ret;
 
     ret = (*mdata->namespace->mboxname_tointernal)(mdata->namespace,
@@ -858,14 +858,14 @@
 int run_sieve(const char *user, const char *domain, const char *mailbox,
 	      sieve_interp_t *interp, deliver_data_t *msgdata)
 {
-    char namebuf[MAX_MAILBOX_NAME+1] = "";
+    char namebuf[MAX_MAILBOX_BUFFER] = "";
     struct annotation_data attrib;
     const char *script = NULL;
     char fname[MAX_MAILBOX_PATH+1];
     sieve_execute_t *bc = NULL;
     script_data_t sdata;
-    char userbuf[MAX_MAILBOX_NAME+1] = "";
-    char authuserbuf[MAX_MAILBOX_NAME+1];
+    char userbuf[MAX_MAILBOX_BUFFER] = "";
+    char authuserbuf[MAX_MAILBOX_BUFFER];
     int r = 0;
 
     if (!user) {

Modified: branches/cyrus23/cyrus-imapd-2.3-development/imap/lmtpd.c
URL: https://mail.incase.de/viewcvs/branches/cyrus23/cyrus-imapd-2.3-development/imap/lmtpd.c?rev=771&root=cyrus22&r1=770&r2=771&view=diff
==============================================================================
--- branches/cyrus23/cyrus-imapd-2.3-development/imap/lmtpd.c (original)
+++ branches/cyrus23/cyrus-imapd-2.3-development/imap/lmtpd.c Thu Apr 23 19:56:51 2009
@@ -39,7 +39,7 @@
  * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
  * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  *
- * $Id: lmtpd.c,v 1.161 2008/04/22 13:11:18 murch Exp $
+ * $Id: lmtpd.c,v 1.163 2009/03/16 00:17:16 brong Exp $
  */
 
 #include <config.h>
@@ -109,7 +109,7 @@
 static int deliver(message_data_t *msgdata, char *authuser,
 		   struct auth_state *authstate);
 static int verify_user(const char *user, const char *domain, char *mailbox,
-		       long quotacheck, struct auth_state *authstate);
+		       quota_t quotacheck, struct auth_state *authstate);
 static char *generate_notify(message_data_t *m);
 
 void shut_down(int code);
@@ -377,7 +377,7 @@
 
 int fuzzy_match(char *mboxname)
 {
-    char name[MAX_MAILBOX_NAME+1], prefix[MAX_MAILBOX_NAME+1], *p = NULL;
+    char name[MAX_MAILBOX_BUFFER], prefix[MAX_MAILBOX_BUFFER], *p = NULL;
     size_t prefixlen;
     struct fuzz_rock frock;
 
@@ -557,9 +557,9 @@
     }
 
     if (!r && user && (notifier = config_getstring(IMAPOPT_MAILNOTIFIER))) {
-	char inbox[MAX_MAILBOX_NAME+1];
-	char namebuf[MAX_MAILBOX_NAME+1];
-	char userbuf[MAX_MAILBOX_NAME+1];
+	char inbox[MAX_MAILBOX_BUFFER];
+	char namebuf[MAX_MAILBOX_BUFFER];
+	char userbuf[MAX_MAILBOX_BUFFER];
 	const char *notify_mailbox = mailboxname;
 	int r2;
 
@@ -683,7 +683,7 @@
 int deliver_local(deliver_data_t *mydata, char **flag, int nflags,
 		  const char *username, const char *mailboxname)
 {
-    char namebuf[MAX_MAILBOX_NAME+1] = "", *tail;
+    char namebuf[MAX_MAILBOX_BUFFER] = "", *tail;
     message_data_t *md = mydata->m;
     int quotaoverride = msg_getrcpt_ignorequota(md, mydata->cur_rcpt);
     int ret;
@@ -778,8 +778,8 @@
     
     /* loop through each recipient, attempting delivery for each */
     for (n = 0; n < nrcpts; n++) {
-	char namebuf[MAX_MAILBOX_NAME+1] = "", *server;
-	char userbuf[MAX_MAILBOX_NAME+1];
+	char namebuf[MAX_MAILBOX_BUFFER] = "", *server;
+	char userbuf[MAX_MAILBOX_BUFFER];
 	const char *rcpt, *user, *domain, *mailbox;
 	int r = 0;
 
@@ -977,9 +977,9 @@
 }
 
 static int verify_user(const char *user, const char *domain, char *mailbox,
-		       long quotacheck, struct auth_state *authstate)
-{
-    char namebuf[MAX_MAILBOX_NAME+1] = "";
+		       quota_t quotacheck, struct auth_state *authstate)
+{
+    char namebuf[MAX_MAILBOX_BUFFER] = "";
     int r = 0;
 
     if ((!user && !mailbox) ||
@@ -1103,7 +1103,7 @@
        (don't bother if we're only a proxy) */
     n = mhandle ? 0 : msg_getnumrcpt(msgdata);
     for (i = 0; !f && (i < n); i++) {
-	char namebuf[MAX_MAILBOX_NAME+1] = "", *server;
+	char namebuf[MAX_MAILBOX_BUFFER] = "", *server;
 	const char *user, *domain, *mailbox;
 	int r;
 

Modified: branches/cyrus23/cyrus-imapd-2.3-development/imap/lmtpengine.h
URL: https://mail.incase.de/viewcvs/branches/cyrus23/cyrus-imapd-2.3-development/imap/lmtpengine.h?rev=771&root=cyrus22&r1=770&r2=771&view=diff
==============================================================================
--- branches/cyrus23/cyrus-imapd-2.3-development/imap/lmtpengine.h (original)
+++ branches/cyrus23/cyrus-imapd-2.3-development/imap/lmtpengine.h Thu Apr 23 19:56:51 2009
@@ -39,7 +39,7 @@
  * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
  * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  *
- * $Id: lmtpengine.h,v 1.25 2008/04/03 21:09:52 murch Exp $
+ * $Id: lmtpengine.h,v 1.26 2009/03/16 00:17:16 brong Exp $
  */
 
 #ifndef LMTPENGINE_H
@@ -49,6 +49,7 @@
 
 #include "spool.h"
 #include "mboxname.h"
+#include "quota.h"
 
 typedef struct message_data message_data_t;
 typedef struct address_data address_data_t;
@@ -109,7 +110,7 @@
     int (*deliver)(message_data_t *m, 
 		   char *authuser, struct auth_state *authstate);
     int (*verify_user)(const char *user, const char *domain, char *mailbox,
-		       long quotacheck, /* user must have this much quota left
+		       quota_t quotacheck, /* user must have this much quota left
 					   (-1 means don't care about quota) */
 		       struct auth_state *authstate);
     void (*shutdown)(int code);

Modified: branches/cyrus23/cyrus-imapd-2.3-development/imap/mailbox.c
URL: https://mail.incase.de/viewcvs/branches/cyrus23/cyrus-imapd-2.3-development/imap/mailbox.c?rev=771&root=cyrus22&r1=770&r2=771&view=diff
==============================================================================
--- branches/cyrus23/cyrus-imapd-2.3-development/imap/mailbox.c (original)
+++ branches/cyrus23/cyrus-imapd-2.3-development/imap/mailbox.c Thu Apr 23 19:56:51 2009
@@ -39,7 +39,7 @@
  * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
  * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  *
- * $Id: mailbox.c,v 1.184 2008/10/15 17:40:37 wescraig Exp $
+ * $Id: mailbox.c,v 1.189 2009/02/09 05:25:20 brong Exp $
  */
 
 #include <config.h>
@@ -959,7 +959,8 @@
 	ntohl(*((bit32 *)(mailbox->index_base+OFFSET_HIGHESTMODSEQ)));
 #endif
 
-    if (!mailbox->exists) mailbox->options |= OPT_POP3_NEW_UIDL;
+    if (!mailbox->exists) 
+	mailbox->options |= OPT_POP3_NEW_UIDL;
 
     if (!mailbox_doing_reconstruct &&
 	(mailbox->minor_version < MAILBOX_MINOR_VERSION)) {
@@ -1555,8 +1556,11 @@
     unsigned long exists;
     unsigned msgno;
     bit32 oldstart_offset, oldrecord_size;
-    indexbuffer_t ibuf;
-    unsigned char *buf = ibuf.buf, *bufp;
+    indexbuffer_t rbuf;
+    indexbuffer_t hbuf;
+    unsigned char *bufp;
+    unsigned char *recordbuf = rbuf.buf;
+    unsigned char *headerbuf = hbuf.buf;
     int quota_offset = 0;
     int calculate_flagcounts = 0;
     bit32 numansweredflag = 0;
@@ -1565,48 +1569,48 @@
     int old_minor_version = 0;
 
     /* Copy existing header so we can upgrade it */ 
-    memcpy(buf, index_base, INDEX_HEADER_SIZE);
-
-    exists = ntohl(*((bit32 *)(buf+OFFSET_EXISTS)));
-
-    old_minor_version = ntohl(*((bit32 *)(buf+OFFSET_MINOR_VERSION)));
+    memcpy(headerbuf, index_base, INDEX_HEADER_SIZE);
+
+    exists = ntohl(*((bit32 *)(headerbuf+OFFSET_EXISTS)));
+
+    old_minor_version = ntohl(*((bit32 *)(headerbuf+OFFSET_MINOR_VERSION)));
 
     /* QUOTA_MAILBOX_USED64 added with minor version 6 */
     if (old_minor_version < 6) {
 	quota_offset = sizeof(bit32);
 	/* upgrade quota to 64-bits (bump existing fields) */
-	memmove(buf+OFFSET_QUOTA_MAILBOX_USED, buf+OFFSET_QUOTA_MAILBOX_USED64,
+	memmove(headerbuf+OFFSET_QUOTA_MAILBOX_USED, headerbuf+OFFSET_QUOTA_MAILBOX_USED64,
 		INDEX_HEADER_SIZE - OFFSET_QUOTA_MAILBOX_USED64 - quota_offset);
 	/* zero the unused 32-bits */
-	*((bit32 *)(buf+OFFSET_QUOTA_MAILBOX_USED64)) = htonl(0);
+	*((bit32 *)(headerbuf+OFFSET_QUOTA_MAILBOX_USED64)) = htonl(0);
     }
 
     /* HIGHESTMODSEQ[_64] added with minor version 8 */
     if (old_minor_version < 8) {
 	/* Set the initial highestmodseq to 1 */
 #ifdef HAVE_LONG_LONG_INT
-	align_htonll(buf+OFFSET_HIGHESTMODSEQ_64, 1);
+	align_htonll(headerbuf+OFFSET_HIGHESTMODSEQ_64, 1);
 #else
-	*((bit32 *)(buf+OFFSET_HIGHESTMODSEQ_64)) = htonl(0);
-	*((bit32 *)(buf+OFFSET_HIGHESTMODSEQ)) = htonl(1);
+	*((bit32 *)(headerbuf+OFFSET_HIGHESTMODSEQ_64)) = htonl(0);
+	*((bit32 *)(headerbuf+OFFSET_HIGHESTMODSEQ)) = htonl(1);
 #endif
     }
 
     /* change version number */
-    *((bit32 *)(buf+OFFSET_MINOR_VERSION)) = htonl(MAILBOX_MINOR_VERSION);
+    *((bit32 *)(headerbuf+OFFSET_MINOR_VERSION)) = htonl(MAILBOX_MINOR_VERSION);
 
     /* save old start_offset; change start_offset */
-    oldstart_offset = ntohl(*((bit32 *)(buf+OFFSET_START_OFFSET)));
-    *((bit32 *)(buf+OFFSET_START_OFFSET)) = htonl(INDEX_HEADER_SIZE);
+    oldstart_offset = ntohl(*((bit32 *)(headerbuf+OFFSET_START_OFFSET)));
+    *((bit32 *)(headerbuf+OFFSET_START_OFFSET)) = htonl(INDEX_HEADER_SIZE);
 
     /* save old record_size; change record_size */
-    oldrecord_size = ntohl(*((bit32 *)(buf+OFFSET_RECORD_SIZE)));
-    *((bit32 *)(buf+OFFSET_RECORD_SIZE)) = htonl(INDEX_RECORD_SIZE);
+    oldrecord_size = ntohl(*((bit32 *)(headerbuf+OFFSET_RECORD_SIZE)));
+    *((bit32 *)(headerbuf+OFFSET_RECORD_SIZE)) = htonl(INDEX_RECORD_SIZE);
 
     /* sanity check the record size */
     if (oldrecord_size > INDEX_RECORD_SIZE) {
-        char *err = xmalloc(MAX_MAILBOX_NAME+128);
-        snprintf(err, MAX_MAILBOX_NAME+128,
+        char *err = xmalloc(MAX_MAILBOX_BUFFER);
+        snprintf(err, MAX_MAILBOX_BUFFER,
                  "Mailbox %s needs reconstruct: Record size %d > %d",
                  mailbox->name, (int) oldrecord_size, INDEX_RECORD_SIZE);
         fatal(err, EC_SOFTWARE);
@@ -1617,10 +1621,10 @@
      * minor version wasn't updated religiously in the early days,
      * so we need to use the old offset instead */
     if (oldstart_offset < OFFSET_POP3_LAST_LOGIN-quota_offset+sizeof(bit32)) {
-	*((bit32 *)(buf+OFFSET_POP3_LAST_LOGIN)) = htonl(0);
+	*((bit32 *)(headerbuf+OFFSET_POP3_LAST_LOGIN)) = htonl(0);
     }
     if (oldstart_offset < OFFSET_UIDVALIDITY-quota_offset+sizeof(bit32)) {
-	*((bit32 *)(buf+OFFSET_UIDVALIDITY)) = htonl(1);
+	*((bit32 *)(headerbuf+OFFSET_UIDVALIDITY)) = htonl(1);
     }
     if (oldstart_offset < OFFSET_FLAGGED-quota_offset+sizeof(bit32)) {
 	struct stat sbuf;
@@ -1637,18 +1641,19 @@
 	calculate_flagcounts = 1;
     }
     if (oldstart_offset < OFFSET_MAILBOX_OPTIONS-quota_offset+sizeof(bit32)) {
-	unsigned long options = !exists ? OPT_POP3_NEW_UIDL : 0;
-	*((bit32 *)(buf+OFFSET_MAILBOX_OPTIONS)) = htonl(options);
-    }
-
-    *((bit32 *)(buf+OFFSET_SPARE0)) = htonl(0); /* RESERVED */
-    *((bit32 *)(buf+OFFSET_SPARE1)) = htonl(0); /* RESERVED */
-    *((bit32 *)(buf+OFFSET_SPARE2)) = htonl(0); /* RESERVED */
-    *((bit32 *)(buf+OFFSET_SPARE3)) = htonl(0); /* RESERVED */
-    *((bit32 *)(buf+OFFSET_SPARE4)) = htonl(0); /* RESERVED */
+	unsigned long options = config_getint(IMAPOPT_MAILBOX_DEFAULT_OPTIONS);
+	if (!exists) options |= OPT_POP3_NEW_UIDL;
+	*((bit32 *)(headerbuf+OFFSET_MAILBOX_OPTIONS)) = htonl(options);
+    }
+
+    *((bit32 *)(headerbuf+OFFSET_SPARE0)) = htonl(0); /* RESERVED */
+    *((bit32 *)(headerbuf+OFFSET_SPARE1)) = htonl(0); /* RESERVED */
+    *((bit32 *)(headerbuf+OFFSET_SPARE2)) = htonl(0); /* RESERVED */
+    *((bit32 *)(headerbuf+OFFSET_SPARE3)) = htonl(0); /* RESERVED */
+    *((bit32 *)(headerbuf+OFFSET_SPARE4)) = htonl(0); /* RESERVED */
 
     /* Write new header */
-    fwrite(buf, 1, INDEX_HEADER_SIZE, newindex);
+    fwrite(headerbuf, 1, INDEX_HEADER_SIZE, newindex);
 
     /* Write the rest of new index */
     for (msgno = 1; msgno <= exists; msgno++) {
@@ -1670,77 +1675,75 @@
         }
 
 	    /* We need to upgrade the index record to include new fields. */
-        memset(buf, 0, INDEX_RECORD_SIZE);
-        memcpy(buf, bufp, oldrecord_size);
+        memset(recordbuf, 0, INDEX_RECORD_SIZE);
+        memcpy(recordbuf, bufp, oldrecord_size);
 
         /* CONTENT_LINES added with minor version 5 */
         if (old_minor_version < 5) {
 	    /* Set the initial content lines to BIT32_MAX rather than 0,
 	     * since a message body can be empty.
 	     * We'll calculate the actual value on demand. */
-		*((bit32 *)(buf+OFFSET_CONTENT_LINES)) = htonl(BIT32_MAX);
+            *((bit32 *)(recordbuf+OFFSET_CONTENT_LINES)) = htonl(BIT32_MAX);
 	    }
 
         /* CACHE_VERSION added with minor version 6 */
         if (old_minor_version < 6) {
 	    /* Set the initial cache version to 0, that is, with the old
 	     * format of the cached headers */
-		*((bit32 *)(buf+OFFSET_CACHE_VERSION)) = htonl(0);
+            *((bit32 *)(recordbuf+OFFSET_CACHE_VERSION)) = htonl(0);
 	    }
 
         if (old_minor_version < 7) {
             /* 12-byte GUIDs added with minor version 7.
 	     * Set to NIL GUID */
-            memset(buf+OFFSET_MESSAGE_GUID, 0, MESSAGE_GUID_SIZE);
+            memset(recordbuf+OFFSET_MESSAGE_GUID, 0, MESSAGE_GUID_SIZE);
         } else if (old_minor_version < 10) {
             /* GUIDs extended from 12 to 20 bytes with minor version 10 */
-            void *src = (buf+OFFSET_MESSAGE_GUID)+12;
-            void *dst = (buf+OFFSET_MESSAGE_GUID)+20;
+            void *src = (recordbuf+OFFSET_MESSAGE_GUID)+12;
+            void *dst = (recordbuf+OFFSET_MESSAGE_GUID)+20;
             size_t len = INDEX_RECORD_SIZE - (OFFSET_MESSAGE_GUID+20);
                          
             /* Bump everything after MESSAGE_GUID down by 8 bytes */
             memmove(dst, src, len);
 
             /* Pad existing GUID with zeros */
-            memset(buf+OFFSET_MESSAGE_GUID+12, 0, 8);
+            memset(recordbuf+OFFSET_MESSAGE_GUID+12, 0, 8);
         }
 
         /* MODSEQ added with minor version 8 */
         if (old_minor_version < 8) {
 	    /* Set the initial modseq to 1 */
 #ifdef HAVE_LONG_LONG_INT
-		*((bit64 *)(buf+OFFSET_MODSEQ_64)) = htonll(1);
+	    *((bit64 *)(recordbuf+OFFSET_MODSEQ_64)) = htonll(1);
 #else
-		*((bit32 *)(buf+OFFSET_MODSEQ_64)) = htonl(0);
-		*((bit32 *)(buf+OFFSET_MODSEQ)) = htonl(1);
+	    *((bit32 *)(recordbuf+OFFSET_MODSEQ_64)) = htonl(0);
+	    *((bit32 *)(recordbuf+OFFSET_MODSEQ)) = htonl(1);
 #endif
 	} else {
 	    /* Older versions may have incorrectly allowed modseq to be 0 */
 #ifdef HAVE_LONG_LONG_INT
-	    if ( *((bit64 *)(buf+OFFSET_MODSEQ_64)) == 0 ) {
-		*((bit64 *)(buf+OFFSET_MODSEQ_64)) = htonll(1);
+	    if ( *((bit64 *)(recordbuf+OFFSET_MODSEQ_64)) == 0 ) {
+		*((bit64 *)(recordbuf+OFFSET_MODSEQ_64)) = htonll(1);
 	    }
 #else
-	    if ( *((bit32 *)(buf+OFFSET_MODSEQ)) == 0 ) {
-		*((bit32 *)(buf+OFFSET_MODSEQ_64)) = htonl(0);
-		*((bit32 *)(buf+OFFSET_MODSEQ)) = htonl(1);
+	    if ( *((bit32 *)(recordbuf+OFFSET_MODSEQ)) == 0 ) {
+		*((bit32 *)(recordbuf+OFFSET_MODSEQ_64)) = htonl(0);
+		*((bit32 *)(recordbuf+OFFSET_MODSEQ)) = htonl(1);
 	}
 #endif
 	}
 
-        fwrite(buf, INDEX_RECORD_SIZE, 1, newindex);
+        fwrite(recordbuf, INDEX_RECORD_SIZE, 1, newindex);
     }
 
     if (calculate_flagcounts) {
 	/* go back and add flag counts to header */
-	memset(buf, 0, INDEX_RECORD_SIZE);
-	*((bit32 *)(buf+OFFSET_DELETED)) = htonl(numdeletedflag);
-	*((bit32 *)(buf+OFFSET_ANSWERED)) = htonl(numansweredflag);
-	*((bit32 *)(buf+OFFSET_FLAGGED)) = htonl(numflaggedflag);
-
-	fseek(newindex, OFFSET_DELETED, SEEK_SET);
-	fwrite(buf+OFFSET_DELETED,
-	       OFFSET_FLAGGED+sizeof(bit32)-OFFSET_DELETED, 1, newindex);
+	*((bit32 *)(headerbuf+OFFSET_DELETED)) = htonl(numdeletedflag);
+	*((bit32 *)(headerbuf+OFFSET_ANSWERED)) = htonl(numansweredflag);
+	*((bit32 *)(headerbuf+OFFSET_FLAGGED)) = htonl(numflaggedflag);
+
+	rewind(newindex);
+	fwrite(headerbuf, INDEX_HEADER_SIZE, 1, newindex);
     }
 }
 
@@ -1935,7 +1938,7 @@
     time_t now = time(NULL);
     unsigned n;
 
-    /* Copy over records for nondeleted messages */
+    /* Copy over records for all messages */
     for (msgno = 1; msgno <= exists; msgno++) {
 	/* Copy index record for this message */
 	memcpy(buf,
@@ -2004,10 +2007,11 @@
             if (cache_offset >= mailbox->cache_size) {
 		syslog(LOG_ERR,
 		       "IOERROR: reading cache record for %s:"
-		       " got bogus offset %d for %u/%lu; try reconstruct",
+		       " initial bogus offset %d of %d for %u/%lu; mailbox needs a reconstruct",
 		       mailbox->name,
-		       (int) (cacheitem - (mailbox->cache_base + cache_offset)),
-		       msgno, mailbox->exists);
+		       (int) (cacheitem - mailbox->cache_base),
+		       (int) mailbox->cache_size,
+		       msgno, exists);
 		return IMAP_IOERROR;
             }
 	    for (cache_ent = 0; cache_ent < NUM_CACHE_FIELDS; cache_ent++) {
@@ -2016,10 +2020,12 @@
 		    (cacheitem > (mailbox->cache_base + mailbox->cache_size))) {
 		    syslog(LOG_ERR,
 			   "IOERROR: reading cache record for %s:"
-			   " got bogus offset %d for %u/%lu; try reconstruct",
+			   " item %d has bogus offset %d of %d for %u/%lu; mailbox needs a reconstruct",
 			   mailbox->name,
-			   (int) (cacheitem - (mailbox->cache_base + cache_offset)),
-			   msgno, mailbox->exists);
+			   cache_ent+1,
+			   (int) (cacheitem - mailbox->cache_base),
+			   (int) mailbox->cache_size,
+			   msgno, exists);
 		    return IMAP_IOERROR;
 		}
 	    }
@@ -2592,7 +2598,7 @@
 		   struct mailbox *mailboxp)
 {
     int r;
-    char quota_root[MAX_MAILBOX_PATH+1];
+    char quota_root[MAX_MAILBOX_BUFFER];
     int hasquota;
     char *path, *mpath;
     struct fnamepath fpath;
@@ -2730,7 +2736,7 @@
     mailbox.deleted = 0;
     mailbox.answered = 0;
     mailbox.flagged = 0;
-    mailbox.options = OPT_POP3_NEW_UIDL;
+    mailbox.options = config_getint(IMAPOPT_MAILBOX_DEFAULT_OPTIONS) | OPT_POP3_NEW_UIDL;
     mailbox.leaked_cache_records = 0;
     mailbox.highestmodseq = 1;
 
@@ -2826,7 +2832,7 @@
 int mailbox_delete(struct mailbox *mailbox, int delete_quota_root)
 {
     int r, rquota = 0;
-    char nbuf[MAX_MAILBOX_NAME+1];
+    char nbuf[MAX_MAILBOX_BUFFER];
     char pbuf[MAX_MAILBOX_PATH+1], mbuf[MAX_MAILBOX_PATH+1];
     char *ntail, *ptail, *mtail = NULL;
     struct txn *tid = NULL;

Modified: branches/cyrus23/cyrus-imapd-2.3-development/imap/mailbox.h
URL: https://mail.incase.de/viewcvs/branches/cyrus23/cyrus-imapd-2.3-development/imap/mailbox.h?rev=771&root=cyrus22&r1=770&r2=771&view=diff
==============================================================================
--- branches/cyrus23/cyrus-imapd-2.3-development/imap/mailbox.h (original)
+++ branches/cyrus23/cyrus-imapd-2.3-development/imap/mailbox.h Thu Apr 23 19:56:51 2009
@@ -39,7 +39,7 @@
  * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
  * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  *
- * $Id: mailbox.h,v 1.91 2008/03/24 17:09:17 murch Exp $
+ * $Id: mailbox.h,v 1.93 2009/02/09 05:08:21 brong Exp $
  */
 
 #ifndef INCLUDED_MAILBOX_H
@@ -78,6 +78,7 @@
 #endif
 
 #define MAX_MAILBOX_NAME 490
+#define MAX_MAILBOX_BUFFER 1024   /* enough space for all possible rewrites and DELETED.* and stuff */
 #define MAX_MAILBOX_PATH 4096
 
 #define MAX_USER_FLAGS (16*8)
@@ -257,10 +258,11 @@
 #define FLAG_DRAFT (1<<3)
 
 #define OPT_POP3_NEW_UIDL (1<<0)	/* added for Outlook stupidity */
+/* these three are annotations, if you add more, update annotate.c
+ * struct annotate_mailbox_flags */
 #define OPT_IMAP_CONDSTORE (1<<1)	/* added for CONDSTORE extension */
 #define OPT_IMAP_SHAREDSEEN (1<<2)	/* added for shared \Seen flag */
 #define OPT_IMAP_DUPDELIVER (1<<3)	/* added to allow duplicate delivery */
-
 
 struct mailbox_header_cache {
     const char *name; /* Name of header */

Modified: branches/cyrus23/cyrus-imapd-2.3-development/imap/make_md5.c
URL: https://mail.incase.de/viewcvs/branches/cyrus23/cyrus-imapd-2.3-development/imap/make_md5.c?rev=771&root=cyrus22&r1=770&r2=771&view=diff
==============================================================================
--- branches/cyrus23/cyrus-imapd-2.3-development/imap/make_md5.c (original)
+++ branches/cyrus23/cyrus-imapd-2.3-development/imap/make_md5.c Thu Apr 23 19:56:51 2009
@@ -38,7 +38,7 @@
  * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
  * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  *
- * $Id: make_md5.c,v 1.8 2008/10/02 14:05:44 murch Exp $
+ * $Id: make_md5.c,v 1.9 2009/02/09 05:01:58 brong Exp $
  */
 
 #include <config.h>
@@ -378,7 +378,7 @@
 {
     struct md5_mailbox *current = NULL;
     FILE *file;
-    char buf[MAX_MAILBOX_NAME+18]; /* mboxname + uniqueid(16) + SP + CR */
+    char buf[MAX_MAILBOX_BUFFER]; /* mboxname + uniqueid(16) + SP + CR */
     unsigned char md5_msg[16];
     unsigned char md5_cache[16];
     int len;

Modified: branches/cyrus23/cyrus-imapd-2.3-development/imap/make_sha1.c
URL: https://mail.incase.de/viewcvs/branches/cyrus23/cyrus-imapd-2.3-development/imap/make_sha1.c?rev=771&root=cyrus22&r1=770&r2=771&view=diff
==============================================================================
--- branches/cyrus23/cyrus-imapd-2.3-development/imap/make_sha1.c (original)
+++ branches/cyrus23/cyrus-imapd-2.3-development/imap/make_sha1.c Thu Apr 23 19:56:51 2009
@@ -38,7 +38,7 @@
  * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
  * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  *
- * $Id: make_sha1.c,v 1.4 2008/10/02 14:05:44 murch Exp $
+ * $Id: make_sha1.c,v 1.5 2009/02/09 05:01:58 brong Exp $
  */
 
 #include <config.h>
@@ -381,7 +381,7 @@
 {
     struct sha1_mailbox *current = NULL;
     FILE *file;
-    char buf[MAX_MAILBOX_NAME+18]; /* mboxname + uniqueid(16) + SP + CR */
+    char buf[MAX_MAILBOX_BUFFER]; /* mboxname + uniqueid(16) + SP + CR */
     unsigned char sha1_msg[20];
     unsigned char sha1_cache[20];
     int len;

Modified: branches/cyrus23/cyrus-imapd-2.3-development/imap/mbdump.c
URL: https://mail.incase.de/viewcvs/branches/cyrus23/cyrus-imapd-2.3-development/imap/mbdump.c?rev=771&root=cyrus22&r1=770&r2=771&view=diff
==============================================================================
--- branches/cyrus23/cyrus-imapd-2.3-development/imap/mbdump.c (original)
+++ branches/cyrus23/cyrus-imapd-2.3-development/imap/mbdump.c Thu Apr 23 19:56:51 2009
@@ -39,7 +39,7 @@
  * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
  * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  *
- * $Id: mbdump.c,v 1.41 2008/10/08 15:47:08 murch Exp $
+ * $Id: mbdump.c,v 1.43 2009/02/09 05:01:58 brong Exp $
  */
 
 #include <config.h>
@@ -757,11 +757,6 @@
 		r = IMAP_PROTOCOL_ERROR;
 		goto done;
 	    }
-	    if(strncmp(file.s, "cyrus.", 6)) {
-		/* it doesn't match cyrus.*, so its a message file.
-		 * charge it against the quota */
-		quotaused += size;
-	    }
 	}	
 
 	/* if we haven't opened it, do so */
@@ -825,31 +820,6 @@
 	}
     }
     
-    if(!r && quotaused) {
-	struct quota quota;
-	char quota_root[MAX_MAILBOX_PATH+1];
-	struct txn *tid = NULL;
-	
-	if (quota_findroot(quota_root, sizeof(quota_root), mbname)) {
-	    /* update the quota file */
-	    memset(&quota, 0, sizeof(quota));
-	    quota.root = quota_root;
-	    r = quota_read(&quota, &tid, 1);
-	    if(!r) {
-		quota.used += quotaused;
-		r = quota_write(&quota, &tid);
-		if (!r) quota_commit(&tid);
-	    } else {
-		syslog(LOG_ERR, "could not lock quota file for %s (%s)",
-		       quota_root, error_message(r));
-	    }
-	    if(r) {
-		syslog(LOG_ERR, "failed writing quota file for %s (%s)",
-		       quota_root, error_message(r));
-	    }
-	}
-    }
-
  done:
     /* eat the rest of the line, we have atleast a \r\n coming */
     eatline(pin, c);
@@ -859,7 +829,7 @@
     if(curfile >= 0) close(curfile);
     mailbox_close(&mb);
     
-    if ( r || quotaused == 0 ) {
+    if ( r ) {
 	return r;
     }
 
@@ -885,6 +855,12 @@
 	record_size = mb.record_size;
 
 	for ( i = 1; i <= mb.exists; i++ ) {
+	    /*
+	     * We calculate the usage here to avoid counting expunged
+	     * messages that may have been included in the undump.
+	     */
+	    quotaused += SIZE( i );
+
 	    mailbox_message_get_fname( &mb, UID(i),
 		    fname + offset, sizeof( fname ) - offset);
 	    times[ 0 ].tv_sec = INTERNALDATE( i );
@@ -894,6 +870,32 @@
 	    (void)utimes( fname, times );
 	}
     }
+
+    if(!r && quotaused) {
+	struct quota quota;
+	char quota_root[MAX_MAILBOX_BUFFER];
+	struct txn *tid = NULL;
+	
+	if (quota_findroot(quota_root, sizeof(quota_root), mbname)) {
+	    /* update the quota file */
+	    memset(&quota, 0, sizeof(quota));
+	    quota.root = quota_root;
+	    r = quota_read(&quota, &tid, 1);
+	    if(!r) {
+		quota.used += quotaused;
+		r = quota_write(&quota, &tid);
+		if (!r) quota_commit(&tid);
+	    } else {
+		syslog(LOG_ERR, "could not lock quota file for %s (%s)",
+		       quota_root, error_message(r));
+	    }
+	    if(r) {
+		syslog(LOG_ERR, "failed writing quota file for %s (%s)",
+		       quota_root, error_message(r));
+	    }
+	}
+    }
+
     mailbox_close( &mb );
     
     return r;

Modified: branches/cyrus23/cyrus-imapd-2.3-development/imap/mboxlist.c
URL: https://mail.incase.de/viewcvs/branches/cyrus23/cyrus-imapd-2.3-development/imap/mboxlist.c?rev=771&root=cyrus22&r1=770&r2=771&view=diff
==============================================================================
--- branches/cyrus23/cyrus-imapd-2.3-development/imap/mboxlist.c (original)
+++ branches/cyrus23/cyrus-imapd-2.3-development/imap/mboxlist.c Thu Apr 23 19:56:51 2009
@@ -39,7 +39,7 @@
  * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
  * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  *
- * $Id: mboxlist.c,v 1.260 2008/10/08 15:47:08 murch Exp $
+ * $Id: mboxlist.c,v 1.263 2009/02/09 05:04:38 brong Exp $
  */
 
 #include <config.h>
@@ -239,7 +239,7 @@
 	break;
 
     default:
-	syslog(LOG_ERR, "DBERROR: error fetching %s: %s",
+	syslog(LOG_ERR, "DBERROR: error fetching mboxlist %s: %s",
 	       name, cyrusdb_strerror(r));
 	return IMAP_IOERROR;
 	break;
@@ -362,7 +362,7 @@
     char *p;
     char *acl;
     char *defaultacl, *identifier, *rights;
-    char parent[MAX_MAILBOX_NAME+1];
+    char parent[MAX_MAILBOX_BUFFER];
     unsigned long parentlen;
     char *parentname = NULL;
     char *parentpartition = NULL;
@@ -885,7 +885,7 @@
                                int local_only __attribute__((unused)),
 			       int force)
 {
-    char newname[MAX_MAILBOX_PATH+1];
+    char newname[MAX_MAILBOX_BUFFER];
     char *path, *mpath;
     char *acl;
     char *partition;
@@ -1925,7 +1925,7 @@
 
     minmatch = 0;
     if (rock->inboxoffset) {
-	char namebuf[MAX_MAILBOX_NAME+1];
+	char namebuf[MAX_MAILBOX_BUFFER];
 
 	if(keylen >= (int) sizeof(namebuf)) {
 	    syslog(LOG_ERR, "oversize keylen in mboxlist.c:find_p()");
@@ -1971,7 +1971,7 @@
 
     /* Suppress deleted hierarchy unless admin: overrides ACL_LOOKUP test */
     if (!rock->isadmin) {
-	char namebuf[MAX_MAILBOX_NAME+1];
+	char namebuf[MAX_MAILBOX_BUFFER];
 
 	memcpy(namebuf, key, keylen);
 	namebuf[keylen] = '\0';
@@ -2026,7 +2026,7 @@
 		   const char *data __attribute__((unused)),
 		   int datalen __attribute__((unused)))
 {
-    char namebuf[MAX_MAILBOX_NAME+1];
+    char namebuf[MAX_MAILBOX_BUFFER];
     struct find_rock *rock = (struct find_rock *) rockp;
     int r = 0;
     long minmatch;
@@ -2129,7 +2129,7 @@
 		     struct auth_state *auth_state, int (*proc)(), void *rock)
 {
     struct find_rock cbrock;
-    char usermboxname[MAX_MAILBOX_NAME+1];
+    char usermboxname[MAX_MAILBOX_BUFFER];
     int usermboxnamelen = 0;
     const char *data;
     int datalen;
@@ -2137,7 +2137,7 @@
     char *p;
     int prefixlen;
     int userlen = userid ? strlen(userid) : 0, domainlen = 0;
-    char domainpat[MAX_MAILBOX_NAME+1] = ""; /* do intra-domain fetches only */
+    char domainpat[MAX_MAILBOX_BUFFER] = ""; /* do intra-domain fetches only */
     char *pat = NULL;
 
     if (config_virtdomains) {
@@ -2192,7 +2192,7 @@
 
     /* Build usermboxname */
     if (userid && (!(p = strchr(userid, '.')) || ((p - userid) > userlen)) &&
-	strlen(userid)+5 < MAX_MAILBOX_NAME) {
+	strlen(userid)+5 < MAX_MAILBOX_BUFFER) {
 	if (domainlen)
 	    snprintf(usermboxname, sizeof(usermboxname),
 		     "%s!", userid+userlen+1);
@@ -2306,7 +2306,7 @@
 			 void *rock)
 {
     struct find_rock cbrock;
-    char usermboxname[MAX_MAILBOX_NAME+1], patbuf[MAX_MAILBOX_NAME+1];
+    char usermboxname[MAX_MAILBOX_BUFFER], patbuf[MAX_MAILBOX_BUFFER];
     int usermboxnamelen = 0;
     const char *data;
     int datalen;
@@ -2314,7 +2314,7 @@
     char *p;
     int prefixlen, len;
     int userlen = userid ? strlen(userid) : 0, domainlen = 0;
-    char domainpat[MAX_MAILBOX_NAME+1]; /* do intra-domain fetches only */
+    char domainpat[MAX_MAILBOX_BUFFER]; /* do intra-domain fetches only */
     char *pat = NULL;
 
     if (config_virtdomains && userid && (p = strchr(userid, '@'))) {
@@ -2338,7 +2338,7 @@
 
     /* Build usermboxname */
     if (userid && (!(p = strchr(userid, '.')) || ((p - userid) > userlen)) &&
-	strlen(userid)+5 < MAX_MAILBOX_NAME) {
+	strlen(userid)+5 < MAX_MAILBOX_BUFFER) {
 	if (domainlen)
 	    snprintf(usermboxname, sizeof(usermboxname),
 		     "%s!", userid+userlen+1);
@@ -2946,7 +2946,7 @@
 {
     struct db *subs = NULL;
     struct find_rock cbrock;
-    char usermboxname[MAX_MAILBOX_NAME+1];
+    char usermboxname[MAX_MAILBOX_BUFFER];
     int usermboxnamelen = 0;
     const char *data;
     int datalen;
@@ -2954,7 +2954,7 @@
     char *p;
     int prefixlen;
     int userlen = userid ? strlen(userid) : 0, domainlen = 0;
-    char domainpat[MAX_MAILBOX_NAME+1]; /* do intra-domain fetches only */
+    char domainpat[MAX_MAILBOX_BUFFER]; /* do intra-domain fetches only */
     char *pat = NULL;
 
     if (config_virtdomains && userid && (p = strchr(userid, '@'))) {
@@ -2984,7 +2984,7 @@
 
     /* Build usermboxname */
     if (userid && (!(p = strchr(userid, '.')) || ((p - userid) > userlen)) &&
-	strlen(userid)+5 < MAX_MAILBOX_NAME) {
+	strlen(userid)+5 < MAX_MAILBOX_BUFFER) {
 	if (domainlen)
 	    snprintf(usermboxname, sizeof(usermboxname),
 		     "%s!", userid+userlen+1);
@@ -3097,7 +3097,7 @@
 {
     struct db *subs = NULL;
     struct find_rock cbrock;
-    char usermboxname[MAX_MAILBOX_NAME+1], patbuf[MAX_MAILBOX_NAME+1];
+    char usermboxname[MAX_MAILBOX_BUFFER], patbuf[MAX_MAILBOX_BUFFER];
     int usermboxnamelen = 0;
     const char *data;
     int datalen;
@@ -3105,7 +3105,7 @@
     char *p;
     int prefixlen, len;
     int userlen = userid ? strlen(userid) : 0, domainlen = 0;
-    char domainpat[MAX_MAILBOX_NAME+1]; /* do intra-domain fetches only */
+    char domainpat[MAX_MAILBOX_BUFFER]; /* do intra-domain fetches only */
     char *pat = NULL;
 
     if (config_virtdomains && userid && (p = strchr(userid, '@'))) {
@@ -3135,7 +3135,7 @@
 
     /* Build usermboxname */
     if (userid && (!(p = strchr(userid, '.')) || ((p - userid) > userlen)) &&
-	strlen(userid)+5 < MAX_MAILBOX_NAME) {
+	strlen(userid)+5 < MAX_MAILBOX_BUFFER) {
 	if (domainlen)
 	    snprintf(usermboxname, sizeof(usermboxname),
 		     "%s!", userid+userlen+1);
@@ -3311,6 +3311,22 @@
     return r;
 }
 
+/* returns CYRUSDB_NOTFOUND if the folder doesn't exist, and 0 if it does! */
+int mboxlist_checksub(const char *name, const char *userid)
+{
+    int r;
+    struct db *subs;
+    const char *val;
+    int vallen;
+
+    r = mboxlist_opensubs(userid, &subs);
+
+    if (!r) r = SUBDB->fetch(subs, name, strlen(name), &val, &vallen, NULL);
+
+    mboxlist_closesubs(subs);
+    return r;
+}
+
 /*
  * Change 'user's subscription status for mailbox 'name'.
  * Subscribes if 'add' is nonzero, unsubscribes otherwise.

Modified: branches/cyrus23/cyrus-imapd-2.3-development/imap/mboxlist.h
URL: https://mail.incase.de/viewcvs/branches/cyrus23/cyrus-imapd-2.3-development/imap/mboxlist.h?rev=771&root=cyrus22&r1=770&r2=771&view=diff
==============================================================================
--- branches/cyrus23/cyrus-imapd-2.3-development/imap/mboxlist.h (original)
+++ branches/cyrus23/cyrus-imapd-2.3-development/imap/mboxlist.h Thu Apr 23 19:56:51 2009
@@ -39,7 +39,7 @@
  * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
  * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  * 
- * $Id: mboxlist.h,v 1.43 2008/03/24 17:09:18 murch Exp $
+ * $Id: mboxlist.h,v 1.45 2009/02/09 05:01:58 brong Exp $
  */
 
 #ifndef INCLUDED_MBOXLIST_H
@@ -74,7 +74,7 @@
 
 /* each mailbox has the following data */
 struct mbox_entry {
-    char name[MAX_MAILBOX_NAME];
+    char name[MAX_MAILBOX_BUFFER];
     int mbtype;
     char partition[MAX_PARTITION_LEN];
 				/* holds remote machine for REMOTE mailboxes */
@@ -179,6 +179,9 @@
    'stagedir' should be MAX_MAILBOX_PATH. */
 int mboxlist_findstage(const char *name, char *stagedir, size_t sd_len);
 
+/* Check 'user's subscription status for mailbox 'name' */
+int mboxlist_checksub(const char *name, const char *userid);
+
 /* Change 'user's subscription status for mailbox 'name'. */
 int mboxlist_changesub(const char *name, const char *userid, 
 		       struct auth_state *auth_state, int add, int force);

Modified: branches/cyrus23/cyrus-imapd-2.3-development/imap/mboxname.c
URL: https://mail.incase.de/viewcvs/branches/cyrus23/cyrus-imapd-2.3-development/imap/mboxname.c?rev=771&root=cyrus22&r1=770&r2=771&view=diff
==============================================================================
--- branches/cyrus23/cyrus-imapd-2.3-development/imap/mboxname.c (original)
+++ branches/cyrus23/cyrus-imapd-2.3-development/imap/mboxname.c Thu Apr 23 19:56:51 2009
@@ -39,7 +39,7 @@
  * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
  * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  *
- * $Id: mboxname.c,v 1.45 2008/10/08 15:47:08 murch Exp $
+ * $Id: mboxname.c,v 1.46 2009/02/09 05:01:58 brong Exp $
  */
 
 #include <config.h>
@@ -101,7 +101,9 @@
  * Convert the external mailbox 'name' to an internal name.
  * If 'userid' is non-null, it is the name of the current user.
  * On success, results are placed in the buffer pointed to by
- * 'result', the buffer must be of size MAX_MAILBOX_NAME+1.
+ * 'result', the buffer must be of size MAX_MAILBOX_BUFFER to
+ * allow space for DELETED mailboxes and moving the domain from
+ * one end to the other and such.  Yay flexibility.
  */
 
 /* Handle conversion from the standard namespace to the internal namespace */
@@ -326,7 +328,7 @@
     if (domainlen+resultlen+6+namelen > MAX_MAILBOX_NAME) {
 	return IMAP_MAILBOX_BADNAME;
     }
-    snprintf(result+resultlen, MAX_MAILBOX_NAME+1-resultlen, ".%.*s", 
+    snprintf(result+resultlen, MAX_MAILBOX_BUFFER-resultlen, ".%.*s", 
 	     namelen, name);
 
     /* Translate any separators in mailboxname */
@@ -338,7 +340,7 @@
  * Convert the internal mailbox 'name' to an external name.
  * If 'userid' is non-null, it is the name of the current user.
  * On success, results are placed in the buffer pointed to by
- * 'result', the buffer must be of size MAX_MAILBOX_NAME+1.
+ * 'result', the buffer must be of size MAX_MAILBOX_BUFFER.
  */
 
 /* Handle conversion from the internal namespace to the standard namespace */
@@ -376,7 +378,7 @@
 	if(resultlen+domainlen+1 > MAX_MAILBOX_NAME) 
 	    return IMAP_MAILBOX_BADNAME;
 
-	snprintf(result+resultlen, MAX_MAILBOX_NAME+1-resultlen, 
+	snprintf(result+resultlen, MAX_MAILBOX_BUFFER-resultlen, 
 		 "@%.*s", (int) domainlen, domain);
     }
 
@@ -583,7 +585,7 @@
 {
     struct namespace internal = { '.', 0, 0, { "INBOX.", "user.", "" },
 				  NULL, NULL, NULL, NULL };
-    char inboxname[MAX_MAILBOX_NAME+1];
+    char inboxname[MAX_MAILBOX_BUFFER];
 
     if (!mboxname_tointernal(&internal, "INBOX", userid, inboxname) &&
 	!strncmp(name, inboxname, strlen(inboxname)) &&
@@ -646,7 +648,7 @@
  */
 char *mboxname_inbox_touserid(const char *inboxname)
 {
-    static char userid[MAX_MAILBOX_NAME+1];
+    static char userid[MAX_MAILBOX_BUFFER];
     const char *domain = NULL, *cp;
     int domainlen = 0;
 

Modified: branches/cyrus23/cyrus-imapd-2.3-development/imap/message.c
URL: https://mail.incase.de/viewcvs/branches/cyrus23/cyrus-imapd-2.3-development/imap/message.c?rev=771&root=cyrus22&r1=770&r2=771&view=diff
==============================================================================
--- branches/cyrus23/cyrus-imapd-2.3-development/imap/message.c (original)
+++ branches/cyrus23/cyrus-imapd-2.3-development/imap/message.c Thu Apr 23 19:56:51 2009
@@ -39,7 +39,7 @@
  * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
  * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  *
- * $Id: message.c,v 1.112 2008/10/08 15:47:08 murch Exp $
+ * $Id: message.c,v 1.113 2009/03/06 03:52:55 brong Exp $
  */
 
 #include <config.h>
@@ -645,6 +645,8 @@
     int left, len;
     char *next;
     int sawboundary = 0;
+    int maxlines = config_getint(IMAPOPT_MAXHEADERLINES);
+    int have_max = 0;
 
     body->header_offset = msg->offset;
 
@@ -700,6 +702,17 @@
     for (next = headers; *next; next++) {
 	if (*next == '\n') {
 	    body->header_lines++;
+
+	    /* if we're skipping, skip now */
+	    if (have_max) continue;
+
+	    /* check if we've hit a limit and flag it */
+	    if (maxlines && body->header_lines > maxlines) {
+		syslog(LOG_ERR, "ERROR: message has more than %d header lines, not caching any more",
+		       maxlines);
+		have_max = 1;
+		continue;
+	    }
 
 	    /* Check for headers in generic cache */
 	    if (body->cacheheaders.start &&

Modified: branches/cyrus23/cyrus-imapd-2.3-development/imap/mupdate.c
URL: https://mail.incase.de/viewcvs/branches/cyrus23/cyrus-imapd-2.3-development/imap/mupdate.c?rev=771&root=cyrus22&r1=770&r2=771&view=diff
==============================================================================
--- branches/cyrus23/cyrus-imapd-2.3-development/imap/mupdate.c (original)
+++ branches/cyrus23/cyrus-imapd-2.3-development/imap/mupdate.c Thu Apr 23 19:56:51 2009
@@ -39,7 +39,7 @@
  * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
  * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  *
- * $Id: mupdate.c,v 1.106 2008/10/08 15:47:08 murch Exp $
+ * $Id: mupdate.c,v 1.107 2009/02/09 05:01:58 brong Exp $
  */
 
 #include <config.h>
@@ -112,7 +112,7 @@
 struct pending {
     struct pending *next;
 
-    char mailbox[MAX_MAILBOX_NAME+1];
+    char mailbox[MAX_MAILBOX_BUFFER];
 };
 
 struct stringlist 

Modified: branches/cyrus23/cyrus-imapd-2.3-development/imap/mupdate.h
URL: https://mail.incase.de/viewcvs/branches/cyrus23/cyrus-imapd-2.3-development/imap/mupdate.h?rev=771&root=cyrus22&r1=770&r2=771&view=diff
==============================================================================
--- branches/cyrus23/cyrus-imapd-2.3-development/imap/mupdate.h (original)
+++ branches/cyrus23/cyrus-imapd-2.3-development/imap/mupdate.h Thu Apr 23 19:56:51 2009
@@ -39,7 +39,7 @@
  * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
  * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  *
- * $Id: mupdate.h,v 1.18 2008/03/24 17:09:18 murch Exp $
+ * $Id: mupdate.h,v 1.19 2009/02/09 05:01:58 brong Exp $
  */
 
 #ifndef INCLUDED_MUPDATE_H
@@ -70,8 +70,8 @@
     struct buf tag, cmd, arg1, arg2, arg3;
 
     /* For client side mupdate_find calls */
-    char mailbox_buf[MAX_MAILBOX_NAME];
-    char server_buf[MAX_MAILBOX_NAME];
+    char mailbox_buf[MAX_MAILBOX_BUFFER];
+    char server_buf[MAX_MAILBOX_BUFFER];
     char *acl_buf;
     size_t acl_buf_len;
     struct mupdate_mailboxdata mailboxdata_buf;

Modified: branches/cyrus23/cyrus-imapd-2.3-development/imap/nntpd.c
URL: https://mail.incase.de/viewcvs/branches/cyrus23/cyrus-imapd-2.3-development/imap/nntpd.c?rev=771&root=cyrus22&r1=770&r2=771&view=diff
==============================================================================
--- branches/cyrus23/cyrus-imapd-2.3-development/imap/nntpd.c (original)
+++ branches/cyrus23/cyrus-imapd-2.3-development/imap/nntpd.c Thu Apr 23 19:56:51 2009
@@ -39,7 +39,7 @@
  * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
  * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  *
- * $Id: nntpd.c,v 1.69 2008/10/08 15:47:08 murch Exp $
+ * $Id: nntpd.c,v 1.70 2009/02/09 05:01:58 brong Exp $
  */
 
 /*
@@ -899,7 +899,7 @@
 	    else if (!(nntp_capa & MODE_READ)) goto noperm;
 	    else if (!nntp_userid && !allowanonymous) goto nologin;
 	    else if (!strcmp(cmd.s, "Article")) {
-		char curgroup[MAX_MAILBOX_NAME+1], *msgid;
+		char curgroup[MAX_MAILBOX_BUFFER], *msgid;
 
 		mode = ARTICLE_ALL;
 
@@ -1055,7 +1055,7 @@
 	    else if (!(nntp_capa & MODE_READ)) goto noperm;
 	    else if (!nntp_userid && !allowanonymous) goto nologin;
 	    else if (!strcmp(cmd.s, "Hdr")) {
-		char curgroup[MAX_MAILBOX_NAME+1], *msgid;
+		char curgroup[MAX_MAILBOX_BUFFER], *msgid;
 
 	      hdr:
 		if (arg2.s) *arg2.s = 0;
@@ -1331,7 +1331,7 @@
 
 	case 'O':
 	    if (!strcmp(cmd.s, "Over")) {
-		char curgroup[MAX_MAILBOX_NAME+1], *msgid;
+		char curgroup[MAX_MAILBOX_BUFFER], *msgid;
 
 	      over:
 		if (arg1.s) *arg1.s = 0;
@@ -1437,7 +1437,7 @@
 		goto over;
 	    }
 	    else if (!strcmp(cmd.s, "Xpat")) {
-		char curgroup[MAX_MAILBOX_NAME+1], *msgid;
+		char curgroup[MAX_MAILBOX_BUFFER], *msgid;
 
 		if (c != ' ') goto missingargs;
 		c = getword(nntp_in, &arg1); /* header */
@@ -1745,7 +1745,7 @@
 static int open_group(char *name, int has_prefix, struct backend **ret,
 		      int *postable /* used for LIST ACTIVE only */)
 {
-    char mailboxname[MAX_MAILBOX_NAME+1];
+    char mailboxname[MAX_MAILBOX_BUFFER];
     int r = 0;
     char *acl, *newserver;
     struct backend *backend_next = NULL;
@@ -2400,7 +2400,7 @@
 int list_cb(char *name, int matchlen, int maycreate __attribute__((unused)),
 	    void *rock)
 {
-    static char lastname[MAX_MAILBOX_NAME+1];
+    static char lastname[MAX_MAILBOX_BUFFER];
     struct list_rock *lrock = (struct list_rock *) rock;
     struct wildmat *wild;
 
@@ -2567,7 +2567,7 @@
 	lcase(arg1);
 
     if (!strcmp(arg1, "active")) {
-	char pattern[MAX_MAILBOX_NAME+1];
+	char pattern[MAX_MAILBOX_BUFFER];
 	struct list_rock lrock;
 	struct enum_rock erock;
 
@@ -2628,7 +2628,7 @@
 	prot_printf(nntp_out, ".\r\n");
     }
     else if (!strcmp(arg1, "newsgroups")) {
-	char pattern[MAX_MAILBOX_NAME+1];
+	char pattern[MAX_MAILBOX_BUFFER];
 	struct list_rock lrock;
 	struct enum_rock erock;
 
@@ -3355,7 +3355,7 @@
 {
     int r;
     char *group;
-    char mailboxname[MAX_MAILBOX_NAME+1];
+    char mailboxname[MAX_MAILBOX_BUFFER];
 
     /* isolate newsgroup */
     group = msg->control + 8; /* skip "newgroup" */
@@ -3378,7 +3378,7 @@
 {
     int r;
     char *group;
-    char mailboxname[MAX_MAILBOX_NAME+1];
+    char mailboxname[MAX_MAILBOX_BUFFER];
 
     /* isolate newsgroup */
     group = msg->control + 7; /* skip "rmgroup" */
@@ -3402,8 +3402,8 @@
     int r;
     size_t len;
     char *group;
-    char oldmailboxname[MAX_MAILBOX_NAME+1];
-    char newmailboxname[MAX_MAILBOX_NAME+1];
+    char oldmailboxname[MAX_MAILBOX_BUFFER];
+    char newmailboxname[MAX_MAILBOX_BUFFER];
 
     /* isolate old newsgroup */
     group = msg->control + 7; /* skip "mvgroup" */
@@ -4115,7 +4115,7 @@
 static struct wildmat *split_wildmats(char *str)
 {
     const char *prefix;
-    char pattern[MAX_MAILBOX_NAME+1] = "", *p, *c;
+    char pattern[MAX_MAILBOX_BUFFER] = "", *p, *c;
     struct wildmat *wild = NULL;
     int n = 0;
 

Modified: branches/cyrus23/cyrus-imapd-2.3-development/imap/pop3d.c
URL: https://mail.incase.de/viewcvs/branches/cyrus23/cyrus-imapd-2.3-development/imap/pop3d.c?rev=771&root=cyrus22&r1=770&r2=771&view=diff
==============================================================================
--- branches/cyrus23/cyrus-imapd-2.3-development/imap/pop3d.c (original)
+++ branches/cyrus23/cyrus-imapd-2.3-development/imap/pop3d.c Thu Apr 23 19:56:51 2009
@@ -39,7 +39,7 @@
  * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
  * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  *
- * $Id: pop3d.c,v 1.189 2008/04/22 13:11:18 murch Exp $
+ * $Id: pop3d.c,v 1.191 2009/02/09 05:01:58 brong Exp $
  */
 
 #include <config.h>
@@ -213,7 +213,7 @@
 			   unsigned flags, const char *user_realm,
 			   char *out, unsigned out_max, unsigned *out_ulen)
 {
-    char userbuf[MAX_MAILBOX_NAME+1], *p;
+    char userbuf[MAX_MAILBOX_BUFFER], *p;
     size_t n;
     int r;
 
@@ -221,7 +221,7 @@
 
     if (config_getswitch(IMAPOPT_POPSUBFOLDERS)) {
 	/* make a working copy of the auth[z]id */
-	if (ulen > MAX_MAILBOX_NAME) {
+	if (ulen >= MAX_MAILBOX_BUFFER) {
 	    sasl_seterror(conn, 0, "buffer overflow while canonicalizing");
 	    return SASL_BUFOVER;
 	}
@@ -277,12 +277,12 @@
 			     struct propctx *propctx)
 {
     if (config_getswitch(IMAPOPT_POPSUBFOLDERS)) {
-	char userbuf[MAX_MAILBOX_NAME+1], *p;
+	char userbuf[MAX_MAILBOX_BUFFER], *p;
 	size_t n;
 
 	/* make a working copy of the authzid */
 	if (!rlen) rlen = strlen(requested_user);
-	if (rlen > MAX_MAILBOX_NAME) {
+	if (rlen >= MAX_MAILBOX_BUFFER) {
 	    sasl_seterror(conn, 0, "buffer overflow while proxying");
 	    return SASL_BUFOVER;
 	}
@@ -551,13 +551,13 @@
 	syslog(LOG_WARNING, "APOP disabled: can't create challenge");
     }
 
-    prot_printf(popd_out, "+OK %s", popd_apop_chal);
+    prot_printf(popd_out, "+OK");
     if (config_serverinfo) prot_printf(popd_out, " %s", config_servername);
     if (config_serverinfo == IMAP_ENUM_SERVERINFO_ON) {
 	prot_printf(popd_out, " Cyrus POP3%s %s",
 		    config_mupdate_server ? " Murder" : "", CYRUS_VERSION);
     }
-    prot_printf(popd_out, " server ready\r\n");
+    prot_printf(popd_out, " server ready %s\r\n", popd_apop_chal);
 
     cmdloop();
 
@@ -1212,7 +1212,7 @@
 
 void cmd_user(char *user)
 {
-    char userbuf[MAX_MAILBOX_NAME+1], *dot, *domain;
+    char userbuf[MAX_MAILBOX_BUFFER], *dot, *domain;
     unsigned userlen;
 
     /* possibly disallow USER */
@@ -1235,7 +1235,7 @@
 	     (popd_namespace.hier_sep == '.' && (dot = strchr(userbuf, '.')) &&
 	      !(config_virtdomains &&  /* allow '.' in dom.ain */
 		(domain = strchr(userbuf, '@')) && (dot > domain))) ||
-	     strlen(userbuf) + 6 > MAX_MAILBOX_NAME) {
+	     strlen(userbuf) + 6 >= MAX_MAILBOX_BUFFER) {
 	prot_printf(popd_out, "-ERR [AUTH] Invalid user\r\n");
 	syslog(LOG_NOTICE,
 	       "badlogin: %s plaintext %s invalid user",
@@ -1514,7 +1514,7 @@
     /* If we're proxying, the authzid may contain a subfolder,
        so re-canonify it */
     if (config_getswitch(IMAPOPT_POPSUBFOLDERS) && strchr(canon_user, '+')) {
-	char userbuf[MAX_MAILBOX_NAME+1];
+	char userbuf[MAX_MAILBOX_BUFFER];
 	unsigned userlen;
 
 	sasl_result = popd_canon_user(popd_saslconn, NULL, canon_user, 0,
@@ -1552,8 +1552,8 @@
  */
 int openinbox(void)
 {
-    char userid[MAX_MAILBOX_NAME+1], inboxname[MAX_MAILBOX_PATH+1];
-    char extname[MAX_MAILBOX_NAME+1] = "INBOX";
+    char userid[MAX_MAILBOX_BUFFER], inboxname[MAX_MAILBOX_BUFFER];
+    char extname[MAX_MAILBOX_BUFFER] = "INBOX";
     int type, myrights = 0;
     char *server = NULL, *acl;
     int r, log_level = LOG_ERR;

Modified: branches/cyrus23/cyrus-imapd-2.3-development/imap/proxy.h
URL: https://mail.incase.de/viewcvs/branches/cyrus23/cyrus-imapd-2.3-development/imap/proxy.h?rev=771&root=cyrus22&r1=770&r2=771&view=diff
==============================================================================
--- branches/cyrus23/cyrus-imapd-2.3-development/imap/proxy.h (original)
+++ branches/cyrus23/cyrus-imapd-2.3-development/imap/proxy.h Thu Apr 23 19:56:51 2009
@@ -39,7 +39,7 @@
  * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
  * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  *
- * $Id: proxy.h,v 1.3 2008/03/24 17:09:19 murch Exp $
+ * $Id: proxy.h,v 1.4 2009/02/09 05:01:58 brong Exp $
  */
 
 #ifndef _PROXY_H
@@ -53,14 +53,14 @@
 
 /* a final destination for a message */
 struct rcpt {
-    char rcpt[MAX_MAILBOX_NAME+1]; /* where? */
+    char rcpt[MAX_MAILBOX_BUFFER]; /* where? */
     int rcpt_num;		    /* credit this to who? */
     struct rcpt *next;
 };
 
 struct dest {
-    char server[MAX_MAILBOX_NAME+1];  /* where? */
-    char authas[MAX_MAILBOX_NAME+1];  /* as who? */
+    char server[MAX_MAILBOX_BUFFER];  /* where? */
+    char authas[MAX_MAILBOX_BUFFER];  /* as who? */
     int rnum;			      /* number of rcpts */
     struct rcpt *to;
     struct dest *next;

Modified: branches/cyrus23/cyrus-imapd-2.3-development/imap/quota.c
URL: https://mail.incase.de/viewcvs/branches/cyrus23/cyrus-imapd-2.3-development/imap/quota.c?rev=771&root=cyrus22&r1=770&r2=771&view=diff
==============================================================================
--- branches/cyrus23/cyrus-imapd-2.3-development/imap/quota.c (original)
+++ branches/cyrus23/cyrus-imapd-2.3-development/imap/quota.c Thu Apr 23 19:56:51 2009
@@ -39,7 +39,7 @@
  * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
  * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  *
- * $Id: quota.c,v 1.70 2008/03/24 17:09:19 murch Exp $
+ * $Id: quota.c,v 1.71 2009/02/09 05:01:58 brong Exp $
  */
 
 #include <config.h>
@@ -285,7 +285,7 @@
 		   struct fix_rock *frock)
 {
     int i, r;
-    char buf[MAX_MAILBOX_NAME+1], *tail;
+    char buf[MAX_MAILBOX_BUFFER], *tail;
     size_t domainlen = 0;
 
     buf[0] = '\0';

Modified: branches/cyrus23/cyrus-imapd-2.3-development/imap/quota_db.c
URL: https://mail.incase.de/viewcvs/branches/cyrus23/cyrus-imapd-2.3-development/imap/quota_db.c?rev=771&root=cyrus22&r1=770&r2=771&view=diff
==============================================================================
--- branches/cyrus23/cyrus-imapd-2.3-development/imap/quota_db.c (original)
+++ branches/cyrus23/cyrus-imapd-2.3-development/imap/quota_db.c Thu Apr 23 19:56:51 2009
@@ -39,7 +39,7 @@
  * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
  * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  *
- * $Id: quota_db.c,v 1.8 2008/03/24 17:09:19 murch Exp $
+ * $Id: quota_db.c,v 1.10 2009/02/09 05:04:38 brong Exp $
  */
 
 #include <config.h>
@@ -94,6 +94,10 @@
 	if (!data ||
 	    sscanf(data, UQUOTA_T_FMT " %d",
 		   &quota->used, &quota->limit) != 2) {
+            char *buf = xstrndup(data, datalen);
+            syslog(LOG_ERR, "DBERROR: parsed bogus quota data <%s> for %s",
+               buf, quota->root);
+            free(buf);
 	    r = CYRUSDB_IOERROR;
 	}
 	break;
@@ -108,7 +112,7 @@
     }
 
     if (r) {
-	syslog(LOG_ERR, "DBERROR: error fetching %s: %s",
+	syslog(LOG_ERR, "DBERROR: error fetching quota %s: %s",
 	       quota->root, cyrusdb_strerror(r));
 	return IMAP_IOERROR;
     }
@@ -197,7 +201,7 @@
 
 /*
  * Find the mailbox 'name' 's quotaroot, and return it in 'ret'.
- * 'ret' must be at least MAX_MAILBOX_PATH. 
+ * 'ret' must be at least MAX_MAILBOX_NAME.
  *
  * returns true if a quotaroot is found, 0 otherwise. 
 */

Modified: branches/cyrus23/cyrus-imapd-2.3-development/imap/reconstruct.c
URL: https://mail.incase.de/viewcvs/branches/cyrus23/cyrus-imapd-2.3-development/imap/reconstruct.c?rev=771&root=cyrus22&r1=770&r2=771&view=diff
==============================================================================
--- branches/cyrus23/cyrus-imapd-2.3-development/imap/reconstruct.c (original)
+++ branches/cyrus23/cyrus-imapd-2.3-development/imap/reconstruct.c Thu Apr 23 19:56:51 2009
@@ -39,7 +39,7 @@
  * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
  * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  *
- * $Id: reconstruct.c,v 1.106 2008/04/10 14:19:51 murch Exp $
+ * $Id: reconstruct.c,v 1.109 2009/02/11 18:53:04 murch Exp $
  */
 
 #include <config.h>
@@ -769,7 +769,7 @@
 {
     indexbuffer_t ibuf;
     unsigned char *buf = ibuf.buf;
-    char quota_root[MAX_MAILBOX_PATH+1];
+    char quota_root[MAX_MAILBOX_BUFFER];
     bit32 valid_user_flags[MAX_USER_FLAGS/32];
 
     struct mailbox mailbox;
@@ -814,6 +814,9 @@
     
     int expunge_found, index_found;
     char unique_buf[32];
+
+    time_t now = time(0);
+    modseq_t highestmodseq = 0;
 
     /* Start by looking up current data in mailbox list */
     r = mboxlist_detail(name, &mytype, &mypath, &mympath,
@@ -903,7 +906,7 @@
 	mailbox.exists = 0;
 	mailbox.last_uid = 0;
 	mailbox.last_appenddate = 0;
-	mailbox.uidvalidity = time(0);
+	mailbox.uidvalidity = now;
 	/* If we can't read the index, assume new UIDL so that stupid clients
 	   will retrieve all of the messages in the mailbox. */
 	mailbox.options = OPT_POP3_NEW_UIDL;
@@ -1127,8 +1130,8 @@
 	    message_index.modseq = 1;
 	}
 
-	if (message_index.modseq > mailbox.highestmodseq) {
-	    mailbox.highestmodseq = message_index.modseq;
+        if (message_index.modseq > highestmodseq) {
+            highestmodseq = message_index.modseq;
 	}
 	
 	/* Force rebuild from message_create_record() */
@@ -1166,12 +1169,37 @@
     }
 
     /* Write out new index and expunge file headers */
-    if (uid_num && mailbox.last_uid < uid[uid_num-1])
+    if (uid_num && mailbox.last_uid < uid[uid_num-1]) {
+	syslog (LOG_ERR, "Updating last_uid for %s: %lu => %lu",
+		mailbox.name, mailbox.last_uid, uid[uid_num-1] + 100);
 	mailbox.last_uid = uid[uid_num-1] + 100;
-    if (mailbox.last_appenddate == 0 || mailbox.last_appenddate > time(0))
-	mailbox.last_appenddate = time(0);
-    if (mailbox.uidvalidity == 0 || mailbox.uidvalidity > (unsigned) time(0))
-	mailbox.uidvalidity = time(0);
+    }
+
+    if (mailbox.last_appenddate == 0 || mailbox.last_appenddate > now) {
+	syslog (LOG_ERR, "Updating last_appenddate for %s: %lu => %lu",
+		mailbox.name, mailbox.last_appenddate, now);
+	mailbox.last_appenddate = now;
+    }
+
+    if (mailbox.uidvalidity == 0 || mailbox.uidvalidity > (unsigned)now) {
+	syslog (LOG_ERR, "Updating uidvalidity for %s: %lu => %lu",
+		mailbox.name, mailbox.uidvalidity, now);
+	mailbox.uidvalidity = (unsigned)now;
+    }
+
+    if (mailbox.highestmodseq < highestmodseq) {
+	syslog (LOG_ERR, "Updating highestmodseq for %s: "
+		MODSEQ_FMT " => " MODSEQ_FMT,
+		mailbox.name, mailbox.highestmodseq, highestmodseq);
+	mailbox.highestmodseq = highestmodseq;
+    }
+
+    if (mailbox.quota_mailbox_used != index_counts.newquota_used) {
+	syslog (LOG_ERR, "Updating quota_mailbox_used for %s: "
+                QUOTA_T_FMT " => " QUOTA_T_FMT,
+		mailbox.name, mailbox.quota_mailbox_used, index_counts.newquota_used);
+	/* updated by the counts_tobuf below, different in each file */
+    }
 
     rewind(newindex);
     reconstruct_counts_tobuf(buf, &mailbox, &index_counts);

Modified: branches/cyrus23/cyrus-imapd-2.3-development/imap/smmapd.c
URL: https://mail.incase.de/viewcvs/branches/cyrus23/cyrus-imapd-2.3-development/imap/smmapd.c?rev=771&root=cyrus22&r1=770&r2=771&view=diff
==============================================================================
--- branches/cyrus23/cyrus-imapd-2.3-development/imap/smmapd.c (original)
+++ branches/cyrus23/cyrus-imapd-2.3-development/imap/smmapd.c Thu Apr 23 19:56:51 2009
@@ -38,7 +38,7 @@
  * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
  * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  *
- * $Id: smmapd.c,v 1.21 2008/10/08 15:47:08 murch Exp $
+ * $Id: smmapd.c,v 1.22 2009/02/09 05:01:59 brong Exp $
  *
  * smmapd.c -- sendmail socket map daemon
  *
@@ -225,7 +225,7 @@
 int verify_user(const char *key, long quotacheck,
 		struct auth_state *authstate)
 {
-    char rcpt[MAX_MAILBOX_NAME+1], namebuf[MAX_MAILBOX_NAME+1] = "";
+    char rcpt[MAX_MAILBOX_BUFFER], namebuf[MAX_MAILBOX_BUFFER] = "";
     char *user = rcpt, *domain = NULL, *mailbox = NULL;
     int r = 0;
 

Modified: branches/cyrus23/cyrus-imapd-2.3-development/imap/squatter.c
URL: https://mail.incase.de/viewcvs/branches/cyrus23/cyrus-imapd-2.3-development/imap/squatter.c?rev=771&root=cyrus22&r1=770&r2=771&view=diff
==============================================================================
--- branches/cyrus23/cyrus-imapd-2.3-development/imap/squatter.c (original)
+++ branches/cyrus23/cyrus-imapd-2.3-development/imap/squatter.c Thu Apr 23 19:56:51 2009
@@ -39,7 +39,7 @@
  * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
  * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  *
- * $Id: squatter.c,v 1.22 2008/04/04 13:58:59 murch Exp $
+ * $Id: squatter.c,v 1.23 2009/02/09 05:01:59 brong Exp $
  */
 
 /*
@@ -574,7 +574,7 @@
     char squat_file_name[MAX_MAILBOX_PATH+1], *path;
     struct stat squat_file_info;
     struct stat index_file_info;
-    char extname[MAX_MAILBOX_NAME+1];
+    char extname[MAX_MAILBOX_BUFFER];
     int use_annot = *((int *) rock);
     int mbtype;
 
@@ -596,7 +596,7 @@
     /* make sure the mailbox (or an ancestor) has
        /vendor/cmu/cyrus-imapd/squat set to "true" */
     if (use_annot) {
-	char buf[MAX_MAILBOX_NAME+1] = "", *p;
+	char buf[MAX_MAILBOX_BUFFER] = "", *p;
 	struct annotation_data attrib;
 	int domainlen = 0;
 

Modified: branches/cyrus23/cyrus-imapd-2.3-development/imap/statuscache_db.c
URL: https://mail.incase.de/viewcvs/branches/cyrus23/cyrus-imapd-2.3-development/imap/statuscache_db.c?rev=771&root=cyrus22&r1=770&r2=771&view=diff
==============================================================================
--- branches/cyrus23/cyrus-imapd-2.3-development/imap/statuscache_db.c (original)
+++ branches/cyrus23/cyrus-imapd-2.3-development/imap/statuscache_db.c Thu Apr 23 19:56:51 2009
@@ -39,7 +39,7 @@
  * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
  * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  *
- * $Id: statuscache_db.c,v 1.4 2008/10/08 23:28:58 murch Exp $
+ * $Id: statuscache_db.c,v 1.5 2009/02/09 05:01:59 brong Exp $
  */
 
 #include <config.h>
@@ -145,7 +145,7 @@
 static char *statuscache_buildkey(const char *mailboxname, const char *userid,
 				  int *keylen)
 {
-    static char key[MAX_MAILBOX_NAME*2+2];
+    static char key[MAX_MAILBOX_BUFFER];
 
     /* Build statuscache key */
     *keylen = strlcpy(key, mailboxname, sizeof(key)) + 1;

Modified: branches/cyrus23/cyrus-imapd-2.3-development/imap/sync_client.c
URL: https://mail.incase.de/viewcvs/branches/cyrus23/cyrus-imapd-2.3-development/imap/sync_client.c?rev=771&root=cyrus22&r1=770&r2=771&view=diff
==============================================================================
--- branches/cyrus23/cyrus-imapd-2.3-development/imap/sync_client.c (original)
+++ branches/cyrus23/cyrus-imapd-2.3-development/imap/sync_client.c Thu Apr 23 19:56:51 2009
@@ -39,7 +39,7 @@
  * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
  * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  *
- * $Id: sync_client.c,v 1.35 2008/04/22 13:11:18 murch Exp $
+ * $Id: sync_client.c,v 1.43 2009/02/11 19:11:32 murch Exp $
  *
  * Original version written by David Carter <dpc22 at cam.ac.uk>
  * Rewritten and integrated into Cyrus by Ken Murchison <ken at oceana.com>
@@ -88,6 +88,8 @@
 #include "backend.h"
 #include "xstrlcat.h"
 #include "xstrlcpy.h"
+#include "signals.h"
+#include "cyrusdb.h"
 
 /* signal to config.c */
 const int config_need_data = 0;  /* YYY */
@@ -129,6 +131,7 @@
 static int verbose         = 0;
 static int verbose_logging = 0;
 static int connect_once    = 0;
+static int foreground      = 0;
 
 static struct protocol_t csync_protocol =
 { "csync", "csync",
@@ -696,40 +699,41 @@
     return(sync_parse_code("DELETE", fromserver, SYNC_PARSE_EAT_OKLINE, NULL));
 }
 
-static int user_addsub(char *user, char *name)
-{
+static int set_sub(char *user, char *name, int add)
+{
+    char *cmd = add ? "ADDSUB" : "DELSUB";
+
     if (verbose) 
-        printf("ADDSUB %s %s\n", user, name);
+        printf("%s %s %s\n", cmd, user, name);
 
     if (verbose_logging)
-        syslog(LOG_INFO, "ADDSUB %s %s", user, name);
-
-    prot_printf(toserver, "ADDSUB ");
+        syslog(LOG_INFO, "%s %s %s", cmd, user, name);
+
+    sync_printastring(toserver, cmd);
+    prot_printf(toserver, " ");
     sync_printastring(toserver, user);
     prot_printf(toserver, " ");
     sync_printastring(toserver, name);
     prot_printf(toserver, "\r\n");
     prot_flush(toserver);
 
-    return(sync_parse_code("ADDSUB", fromserver, SYNC_PARSE_EAT_OKLINE, NULL));
-}
-
-static int user_delsub(char *user, char *name)
-{
-    if (verbose) 
-        printf("DELSUB %s %s\n", user, name);
-
-    if (verbose_logging)
-        syslog(LOG_INFO, "DELSUB %s %s", user, name);
-
-    prot_printf(toserver, "DELSUB ");
-    sync_printastring(toserver, user);
-    prot_printf(toserver, " ");
-    sync_printastring(toserver, name);
-    prot_printf(toserver, "\r\n");
-    prot_flush(toserver);
-
-    return(sync_parse_code("DELSUB", fromserver, SYNC_PARSE_EAT_OKLINE, NULL));
+    return(sync_parse_code(cmd, fromserver, SYNC_PARSE_EAT_OKLINE, NULL));
+}
+
+static int user_sub(char *user, char *name)
+{
+    int r;
+
+    r = mboxlist_checksub(name, user);
+
+    switch (r) {
+    case CYRUSDB_OK:
+	return set_sub(user, name, 1);
+    case CYRUSDB_NOTFOUND:
+	return set_sub(user, name, 0);
+    default:
+	return r;
+    }
 }
 
 static int folder_setacl(char *name, char *acl)
@@ -744,7 +748,7 @@
     return(sync_parse_code("SETACL", fromserver, SYNC_PARSE_EAT_OKLINE, NULL));
 }
 
-static int folder_setannotation(char *name, char *entry, char *userid,
+static int folder_setannotation(char *name, const char *entry, char *userid,
 				char *value)
 {
     prot_printf(toserver, "SETANNOTATION "); 
@@ -1827,7 +1831,7 @@
 	       int doing_user)
 {
     struct mailbox m;
-    int r = 0, mailbox_open = 0;
+    int r = 0, mailbox_open = 0, i;
     struct sync_rename_list *rename_list = sync_rename_list_create();
     struct sync_folder   *folder, *folder2;
 
@@ -1977,13 +1981,14 @@
                 if (!r && (m.uidvalidity != folder2->uidvalidity))
                     r = folder_setuidvalidity(folder->name, m.uidvalidity);
 
-                if (!r &&
-                    (folder2->options ^ m.options) & OPT_IMAP_CONDSTORE) {
+		for (i = 0; !r && annotate_mailbox_flags[i].name; i++) {
+		    if ((folder2->options ^ m.options) & annotate_mailbox_flags[i].flag) {
                     r = folder_setannotation(m.name,
-					     "/vendor/cmu/cyrus-imapd/condstore",
+					     annotate_mailbox_flags[i].name,
 					     "",
-					     (m.options & OPT_IMAP_CONDSTORE) ?
+					     (m.options & annotate_mailbox_flags[i].flag) ?
 					     "true" : "false");
+		}
 		}
 
 		if (!r && m.quota.root && !strcmp(m.name, m.quota.root))
@@ -2264,7 +2269,7 @@
 
 int do_user_preload(char *user)
 {
-    char buf[MAX_MAILBOX_NAME+1];
+    char buf[MAX_MAILBOX_BUFFER];
     int r = 0;
     struct sync_folder_list *client_list = sync_folder_list_create();
     struct sync_folder *folder;
@@ -2298,7 +2303,7 @@
 int do_user_main(char *user, struct sync_folder_list *server_list,
 		 int *vanishedp)
 {
-    char buf[MAX_MAILBOX_NAME+1];
+    char buf[MAX_MAILBOX_BUFFER];
     int r = 0;
     struct sync_folder_list *client_list = sync_folder_list_create();
 
@@ -2326,7 +2331,7 @@
     struct sync_folder_list *client_list = sync_folder_list_create();
     struct sync_folder *c, *s;
     int n;
-    char buf[MAX_MAILBOX_NAME+1];
+    char buf[MAX_MAILBOX_BUFFER];
 
     /* Includes subsiduary nodes automatically */
     r = (sync_namespace.mboxlist_findsub)(&sync_namespace, "*", 1,
@@ -2352,7 +2357,7 @@
 	    do {
 		(sync_namespace.mboxname_tointernal)(&sync_namespace, s->name,
 						     user, buf);
-		if ((r = user_delsub(user, buf))) goto bail;
+		if ((r = set_sub(user, buf, 0))) goto bail;
 		s = s->next;
 		if (!s) n = -1;		/* end of server list, we're done */
 		else if (!c) n = 1;	/* remove all server subscriptions */
@@ -2366,7 +2371,7 @@
 	}
 	else if (c && n < 0) {
 	    /* add the current client subscription */
-	    if ((r = user_addsub(user, c->name))) goto bail;
+	    if ((r = set_sub(user, c->name, 1))) goto bail;
 	}
     }
 
@@ -2638,7 +2643,7 @@
 
 int do_user_work(char *user, int *vanishedp)
 {
-    char buf[MAX_MAILBOX_NAME+1];
+    char buf[MAX_MAILBOX_BUFFER];
     int r = 0, mailbox_open = 0;
     struct sync_folder_list *server_list      = sync_folder_list_create();
     struct sync_folder_list *server_sub_list  = sync_folder_list_create();
@@ -2924,7 +2929,6 @@
     struct sync_action_list *annot_list  = sync_action_list_create();
     struct sync_action_list *seen_list   = sync_action_list_create();
     struct sync_action_list *sub_list    = sync_action_list_create();
-    struct sync_action_list *unsub_list  = sync_action_list_create();
     struct sync_folder_list *folder_list = sync_folder_list_create();
     static struct buf type, arg1, arg2;
     char *arg1s, *arg2s;
@@ -3005,7 +3009,7 @@
         else if (!strcmp(type.s, "SUB"))
             sync_action_list_add(sub_list, arg2s, arg1s);
         else if (!strcmp(type.s, "UNSUB"))
-            sync_action_list_add(unsub_list, arg2s, arg1s);
+            sync_action_list_add(sub_list, arg2s, arg1s);
         else
             syslog(LOG_ERR, "Unknown action type: %s", type.s);
     }
@@ -3013,14 +3017,16 @@
     /* Optimise out redundant clauses */
 
     for (action = user_list->head ; action ; action = action->next) {
-	char inboxname[MAX_MAILBOX_NAME+1];
+	char inboxname[MAX_MAILBOX_BUFFER];
 
 	/* USER action overrides any MAILBOX, APPEND, ACL, QUOTA, ANNOTATION action on
 	   any of the user's mailboxes or any META, SIEVE, SEEN, SUB, UNSUB
 	   action for same user */
 	(sync_namespace.mboxname_tointernal)(&sync_namespace, "INBOX",
 					      action->user, inboxname);
-        remove_folder(inboxname, mailbox_list, 1);
+        /* breaks DELETED namespace renames
+        * remove_folder(inboxname, mailbox_list, 1);
+        */
         remove_folder(inboxname, append_list, 1);
         remove_folder(inboxname, acl_list, 1);
         remove_folder(inboxname, quota_list, 1);
@@ -3029,7 +3035,6 @@
         remove_meta(action->user, sieve_list);
         remove_meta(action->user, seen_list);
         remove_meta(action->user, sub_list);
-        remove_meta(action->user, unsub_list);
     }
     
     for (action = meta_list->head ; action ; action = action->next) {
@@ -3038,7 +3043,6 @@
         remove_meta(action->user, sieve_list);
         remove_meta(action->user, seen_list);
         remove_meta(action->user, sub_list);
-        remove_meta(action->user, unsub_list);
     }
 
     for (action = mailbox_list->head ; action ; action = action->next) {
@@ -3155,7 +3159,7 @@
     }
 
     for (action = sub_list->head ; action ; action = action->next) {
-        if (action->active && user_addsub(action->user, action->name)) {
+        if (action->active && user_sub(action->user, action->name)) {
             sync_action_list_add(meta_list, NULL, action->user);
             if (verbose) {
                 printf("  Promoting: SUB %s %s -> META %s\n",
@@ -3168,19 +3172,6 @@
         }
     }
 
-    for (action = unsub_list->head ; action ; action = action->next) {
-        if (action->active && user_delsub(action->user, action->name)) {
-            sync_action_list_add(meta_list, NULL, action->user);
-            if (verbose) {
-                printf("  Promoting: UNSUB %s %s -> META %s\n",
-                       action->user, action->name, action->user);
-            }
-            if (verbose_logging) {
-                syslog(LOG_INFO, "  Promoting: UNSUB %s %s -> META %s",
-                       action->user, action->name, action->name);
-            }
-        }
-    }
     for (action = mailbox_list->head ; action ; action = action->next) {
         if (!action->active)
             continue;
@@ -3196,12 +3187,12 @@
 	    if (r) {
 		/* promote failed personal mailboxes to USER */
 		struct sync_folder *folder;
-		char *userid, *p;
+		char *userid, *p, *useridp;
 
 		for (folder = folder_list->head; folder && folder->mark;
 		     folder = folder->next);
-		if (folder &&
-		    (userid = xstrdup(mboxname_isusermailbox(folder->name, 0)))) {
+		if (folder && (useridp = mboxname_isusermailbox(folder->name, 0))) {
+		    userid = xstrdup(useridp);
 		    if ((p = strchr(userid, '.'))) *p = '\0';
 		    folder->mark = 1;
 		    if (--folder_list->count == 0) r = 0;
@@ -3271,7 +3262,6 @@
     sync_action_list_free(&annot_list);
     sync_action_list_free(&seen_list);
     sync_action_list_free(&sub_list);
-    sync_action_list_free(&unsub_list);
     sync_folder_list_free(&folder_list);
 
     prot_free(input);
@@ -3446,6 +3436,7 @@
     int status;
     int restart;
 
+    if (!foreground) {
     /* fork a child so we can release from master */
     if ((pid=fork()) < 0) fatal("fork failed", EC_SOFTWARE);
 
@@ -3454,8 +3445,9 @@
 	exit(0);
     }
     /* child */
-
-    if (timeout == 0) {
+    }
+
+    if (foreground || timeout == 0) {
         do_daemon_work(sync_log_file, sync_shutdown_file,
                        timeout, min_delta, &restart);
         return;
@@ -3566,7 +3558,7 @@
 
     setbuf(stdout, NULL);
 
-    while ((opt = getopt(argc, argv, "C:vlS:F:f:w:t:d:rumso")) != EOF) {
+    while ((opt = getopt(argc, argv, "C:vlS:F:f:w:t:d:rRumso")) != EOF) {
         switch (opt) {
         case 'C': /* alt config file */
             alt_config = optarg;
@@ -3609,6 +3601,8 @@
             min_delta = atoi(optarg);
             break;
 
+        case 'R':
+	    foreground = 1;
         case 'r':
 	    if (mode != MODE_UNKNOWN)
 		fatal("Mutually exclusive options defined", EC_USAGE);
@@ -3762,7 +3756,7 @@
     case MODE_MAILBOX:
     {
 	struct sync_folder_list *folder_list = sync_folder_list_create();
-	char mailboxname[MAX_MAILBOX_NAME+1];
+	char mailboxname[MAX_MAILBOX_BUFFER];
 
 	if (input_filename) {
 	    if ((file=fopen(input_filename, "r")) == NULL) {

Modified: branches/cyrus23/cyrus-imapd-2.3-development/imap/sync_log.c
URL: https://mail.incase.de/viewcvs/branches/cyrus23/cyrus-imapd-2.3-development/imap/sync_log.c?rev=771&root=cyrus22&r1=770&r2=771&view=diff
==============================================================================
--- branches/cyrus23/cyrus-imapd-2.3-development/imap/sync_log.c (original)
+++ branches/cyrus23/cyrus-imapd-2.3-development/imap/sync_log.c Thu Apr 23 19:56:51 2009
@@ -39,7 +39,7 @@
  * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
  * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  *
- * $Id: sync_log.c,v 1.4 2008/03/24 17:09:20 murch Exp $
+ * $Id: sync_log.c,v 1.5 2009/02/09 05:01:59 brong Exp $
  *
  * Original version written by David Carter <dpc22 at cam.ac.uk>
  * Rewritten and integrated into Cyrus by Ken Murchison <ken at oceana.com>
@@ -142,7 +142,7 @@
 
 static const char *sync_quote_name(const char *name)
 {
-    static char buf[(2*MAX_MAILBOX_NAME)+3];
+    static char buf[MAX_MAILBOX_BUFFER]; /* 2 * MAX_MAILBOX_NAME + 3 */
     const char *s;
     char *p = buf;
     char c;
@@ -159,7 +159,7 @@
             fatal("Illegal line break in folder name", EC_IOERR);
     }
 
-    if ((s-name) > MAX_MAILBOX_NAME+64)
+    if ((s-name) > MAX_MAILBOX_NAME+64) /* XXX: hope that's safe! */
         fatal("word too long", EC_IOERR);
 
     if (!need_quote) return(name);

Modified: branches/cyrus23/cyrus-imapd-2.3-development/imap/sync_log.h
URL: https://mail.incase.de/viewcvs/branches/cyrus23/cyrus-imapd-2.3-development/imap/sync_log.h?rev=771&root=cyrus22&r1=770&r2=771&view=diff
==============================================================================
--- branches/cyrus23/cyrus-imapd-2.3-development/imap/sync_log.h (original)
+++ branches/cyrus23/cyrus-imapd-2.3-development/imap/sync_log.h Thu Apr 23 19:56:51 2009
@@ -39,7 +39,7 @@
  * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
  * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  *
- * $Id: sync_log.h,v 1.3 2008/03/24 17:09:20 murch Exp $
+ * $Id: sync_log.h,v 1.4 2009/01/30 10:54:13 brong Exp $
  *
  * Original version written by David Carter <dpc22 at cam.ac.uk>
  * Rewritten and integrated into Cyrus by Ken Murchison <ken at oceana.com>
@@ -81,8 +81,7 @@
 #define sync_log_seen(user, name) \
     sync_log("SEEN %s %s\n", user, name)
 
-#define sync_log_subscribe(user, name, add) \
-    if (add) sync_log("SUB %s %s\n", user, name); \
-    else sync_log("UNSUB %s %s\n", user, name)
+#define sync_log_subscribe(user, name) \
+    sync_log("SUB %s %s\n", user, name)
 
 #endif /* INCLUDED_SYNC_LOG_H */

Modified: branches/cyrus23/cyrus-imapd-2.3-development/imap/sync_reset.c
URL: https://mail.incase.de/viewcvs/branches/cyrus23/cyrus-imapd-2.3-development/imap/sync_reset.c?rev=771&root=cyrus22&r1=770&r2=771&view=diff
==============================================================================
--- branches/cyrus23/cyrus-imapd-2.3-development/imap/sync_reset.c (original)
+++ branches/cyrus23/cyrus-imapd-2.3-development/imap/sync_reset.c Thu Apr 23 19:56:51 2009
@@ -39,7 +39,7 @@
  * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
  * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  *
- * $Id: sync_reset.c,v 1.6 2008/03/24 17:09:20 murch Exp $
+ * $Id: sync_reset.c,v 1.7 2009/02/09 05:01:59 brong Exp $
  *
  * Original version written by David Carter <dpc22 at cam.ac.uk>
  * Rewritten and integrated into Cyrus by Ken Murchison <ken at oceana.com>
@@ -207,7 +207,7 @@
 {
     struct sync_folder_list *list = NULL;
     struct sync_folder *item;
-    char buf[MAX_MAILBOX_NAME+1];
+    char buf[MAX_MAILBOX_BUFFER];
     int r = 0;
     static int md5_dir_set     = 0;
     static const char *md5_dir = NULL;

Modified: branches/cyrus23/cyrus-imapd-2.3-development/imap/sync_server.c
URL: https://mail.incase.de/viewcvs/branches/cyrus23/cyrus-imapd-2.3-development/imap/sync_server.c?rev=771&root=cyrus22&r1=770&r2=771&view=diff
==============================================================================
--- branches/cyrus23/cyrus-imapd-2.3-development/imap/sync_server.c (original)
+++ branches/cyrus23/cyrus-imapd-2.3-development/imap/sync_server.c Thu Apr 23 19:56:51 2009
@@ -39,7 +39,7 @@
  * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
  * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  *
- * $Id: sync_server.c,v 1.26 2008/09/23 16:28:15 murch Exp $
+ * $Id: sync_server.c,v 1.28 2009/02/09 05:02:54 brong Exp $
  *
  * Original version written by David Carter <dpc22 at cam.ac.uk>
  * Rewritten and integrated into Cyrus by Ken Murchison <ken at oceana.com>
@@ -1618,7 +1618,7 @@
 {
     struct sync_folder_list *list = NULL;
     struct sync_folder *item;
-    char buf[MAX_MAILBOX_NAME+1];
+    char buf[MAX_MAILBOX_BUFFER];
     int r = 0;
     
     /* Nuke subscriptions */
@@ -2204,17 +2204,19 @@
 	r = IMAP_IOERROR;
     }
 
-    if (!r && write(filefd, data->s, data->len) == -1) {
+    if (!r && retry_write(filefd, data->s, data->len) == -1) {
 	syslog(LOG_ERR, "IOERROR: writing %s: %m", fnamebuf);
 	r = IMAP_IOERROR;
     }
 
-    /* we were operating on the seen state, so merge it and cleanup */
-    if (!r) seen_merge(fnamebuf, seen_file);
+    /* new seen file from the master is in place */
+    if (filefd != -1) close(filefd);
+
+    /* overwrite the old seen file */
+    if (!r) rename(fnamebuf, seen_file);
+    else unlink(fnamebuf);
 
     free(seen_file);
-    unlink(fnamebuf);
-    if (filefd != -1) close(filefd);
 
     if (r)
         prot_printf(sync_out, "NO Setseen_all Failed on %s: %s\r\n",

Modified: branches/cyrus23/cyrus-imapd-2.3-development/imap/tls.c
URL: https://mail.incase.de/viewcvs/branches/cyrus23/cyrus-imapd-2.3-development/imap/tls.c?rev=771&root=cyrus22&r1=770&r2=771&view=
3Ddiff
==============================================================================
--- branches/cyrus23/cyrus-imapd-2.3-development/imap/tls.c (original)
+++ branches/cyrus23/cyrus-imapd-2.3-development/imap/tls.c Thu Apr 23 19:56:51 2009
@@ -43,7 +43,7 @@
  * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
  * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  *
- * $Id: tls.c,v 1.65 2008/04/15 17:58:08 murch Exp $
+ * $Id: tls.c,v 1.66 2008/11/14 22:24:38 wescraig Exp $
  */
 
 /*
@@ -1135,7 +1135,7 @@
     strlcpy(dbdir, config_dir, sizeof(dbdir));
     strlcat(dbdir, FNAME_TLSSESSIONS, sizeof(dbdir));
 
-    ret = (DB->open)(dbdir, CYRUSDB_CREATE, &sessdb);
+    ret = (DB->open)(dbdir, 0, &sessdb);
     if (ret != CYRUSDB_OK) {
 	syslog(LOG_ERR, "DBERROR: opening %s: %s",
 	       dbdir, cyrusdb_strerror(ret));

Modified: branches/cyrus23/cyrus-imapd-2.3-development/imap/user.c
URL: https://mail.incase.de/viewcvs/branches/cyrus23/cyrus-imapd-2.3-development/imap/user.c?rev=771&root=cyrus22&r1=770&r2=771&view=diff
==============================================================================
--- branches/cyrus23/cyrus-imapd-2.3-development/imap/user.c (original)
+++ branches/cyrus23/cyrus-imapd-2.3-development/imap/user.c Thu Apr 23 19:56:51 2009
@@ -39,7 +39,7 @@
  * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
  * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  *
- * $Id: user.c,v 1.24 2008/03/24 17:09:20 murch Exp $
+ * $Id: user.c,v 1.26 2009/02/09 05:01:59 brong Exp $
  */
 
 #include <config.h>
@@ -91,8 +91,12 @@
     int r;
     char *acl;
     char *rights, *nextid;
-
-    r = mboxlist_lookup(name, &acl, NULL);
+    char *origacl, *aclalloc;
+
+    r = mboxlist_lookup(name, &origacl, NULL);
+
+    /* setacl re-calls mboxlist_lookup and will stomp on us */
+    aclalloc = acl = xstrdup(origacl);
 
     while (!r && acl) {
 	rights = strchr(acl, '\t');
@@ -111,6 +115,9 @@
 
 	acl = nextid;
     }
+
+    free(aclalloc);
+
     return 0;
 }
 #endif
@@ -214,7 +221,7 @@
 			  int maycreate __attribute__((unused)), void* rock)
 {
     struct rename_rock *rrock = (struct rename_rock *) rock;
-    char newname[MAX_MAILBOX_NAME+1];
+    char newname[MAX_MAILBOX_BUFFER];
 
     if (!strncasecmp(name, "INBOX", 5) &&
 	(name[5] == '\0' || name[5] == '.')) {
@@ -312,10 +319,10 @@
 		    struct auth_state *authstate)
 {
     struct namespace namespace;
-    char oldinbox[MAX_MAILBOX_NAME+1], newinbox[MAX_MAILBOX_NAME+1];
+    char oldinbox[MAX_MAILBOX_BUFFER], newinbox[MAX_MAILBOX_BUFFER];
     char *olddomain, *newdomain;
     struct rename_rock rrock;
-    char pat[MAX_MAILBOX_NAME+1];
+    char pat[MAX_MAILBOX_BUFFER];
     int r;
 
     /* set namespace */
@@ -370,8 +377,12 @@
     int r = 0;
     char *acl;
     char *rights, *nextid;
-
-    r = mboxlist_lookup(name, &acl, NULL);
+    char *origacl, *aclalloc;
+
+    r = mboxlist_lookup(name, &origacl, NULL);
+
+    /* setacl re-calls mboxlist_lookup and will stomp on us */
+    aclalloc = acl = xstrdup(origacl);
 
     while (!r && acl) {
 	rights = strchr(acl, '\t');
@@ -393,6 +404,8 @@
 	acl = nextid;
     }
 
+    free(aclalloc);
+
     return r;
 }
 
@@ -443,7 +456,7 @@
 int user_deletequotaroots(const char *user)
 {
     struct namespace namespace;
-    char buf[MAX_MAILBOX_NAME+1], *inboxname = buf;
+    char buf[MAX_MAILBOX_BUFFER], *inboxname = buf;
     struct txn *tid = NULL;
     int r;
 

Modified: branches/cyrus23/cyrus-imapd-2.3-development/imap/version.h
URL: https://mail.incase.de/viewcvs/branches/cyrus23/cyrus-imapd-2.3-development/imap/version.h?rev=771&root=cyrus22&r1=770&r2=771&view=diff
==============================================================================
--- branches/cyrus23/cyrus-imapd-2.3-development/imap/version.h (original)
+++ branches/cyrus23/cyrus-imapd-2.3-development/imap/version.h Thu Apr 23 19:56:51 2009
@@ -39,10 +39,10 @@
  * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
  * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  *
- * $Id: version.h,v 1.158 2008/10/14 14:40:51 murch Exp $
+ * $Id: version.h,v 1.160 2009/03/25 10:41:00 murch Exp $
  */
 
-#define _CYRUS_VERSION "v2.3.13"
+#define _CYRUS_VERSION "v2.3.14"
 
 /* EXTRA_IDENT is a hack to add some version information for which compile
  * was used to build this version (at CMU, but we don't care what you do with

Modified: branches/cyrus23/cyrus-imapd-2.3-development/imtest/imtest.c
URL: https://mail.incase.de/viewcvs/branches/cyrus23/cyrus-imapd-2.3-development/imtest/imtest.c?rev=771&root=cyrus22&r1=770&r2=771&view=diff
==============================================================================
--- branches/cyrus23/cyrus-imapd-2.3-development/imtest/imtest.c (original)
+++ branches/cyrus23/cyrus-imapd-2.3-development/imtest/imtest.c Thu Apr 23 19:56:51 2009
@@ -41,7 +41,7 @@
  * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
  * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  *
- * $Id: imtest.c,v 1.120 2008/10/08 15:47:08 murch Exp $
+ * $Id: imtest.c,v 1.124 2009/01/14 15:50:47 murch Exp $
  */
 
 #include "config.h"
@@ -1867,7 +1867,7 @@
     char *chal = NULL;
     
     /* look for APOP challenge in banner '<... at ...>' */
-    cp = str+4;
+    cp = str+3;
     while (cp && (start = strchr(cp, '<'))) {
 	cp = start + 1;
 	while (*cp && *cp != '@' && *cp != '<' && *cp != '>') cp++;
@@ -1905,7 +1905,7 @@
     
     printf("S: %s", str);
     
-    if (strncasecmp(str, "+OK ", 4)) return IMTEST_FAIL;
+    if (strncasecmp(str, "+OK", 3)) return IMTEST_FAIL;
     
     interaction(SASL_CB_PASS, NULL, "Please enter your password",
 		&pass, &passlen);
@@ -1920,7 +1920,7 @@
     
     printf("S: %s", str);
     
-    if (!strncasecmp(str, "+OK ", 4)) {
+    if (!strncasecmp(str, "+OK", 3)) {
 	return IMTEST_OK;
     } else {
 	return IMTEST_FAIL;
@@ -1968,7 +1968,7 @@
     
     printf("S: %s", str);
     
-    if (!strncasecmp(str, "+OK ", 4)) {
+    if (!strncasecmp(str, "+OK", 3)) {
 	return IMTEST_OK;
     } else {
 	return IMTEST_FAIL;
@@ -2233,7 +2233,7 @@
       &imap_init_conn, &generic_pipe, &imap_reset
     },
     { "pop3", "pop3s", "pop",
-      { 0, "+OK ", &pop3_parse_banner },
+      { 0, "+OK", &pop3_parse_banner },
       { "CAPA", ".", "STLS", "SASL ", NULL },
       { "STLS", "+OK", "-ERR", 0 },
       { "AUTH", 255, 0, "+OK", "-ERR", "+ ", "*", NULL, 0 },
@@ -2525,6 +2525,12 @@
 	    prot_free(pin);
 	    prot_free(pout);
 	    
+	    /* Properly shutdown TLS so that session can be reused */
+	    if (tls_conn) {
+		SSL_shutdown(tls_conn);
+		SSL_set_shutdown(tls_conn, SSL_SENT_SHUTDOWN|SSL_RECEIVED_SHUTDOWN);
+	    }
+	    
 	    close(sock);
 	    
 	    sasl_dispose(&conn);
@@ -2624,7 +2630,6 @@
 	}
 	
 	if (rock) free(rock);
-	if (mechlist) free(mechlist);
 	
 	if (result == IMTEST_OK) {
 	    printf("Authenticated.\n");
@@ -2645,15 +2650,41 @@
 	} else {
 	    printf("Security strength factor: %d\n", ext_ssf + ssf);
 
-	    if (ssf && protocol->sasl_cmd.auto_capa) {
+	    if (ssf) {
 		/* ask for the capabilities again */
+		char *new_mechlist;
+
 		if (verbose==1)
 		    printf("Asking for capabilities again "
 			   "since they might have changed\n");
-		mechlist = ask_capability(protocol, &server_supports_tls, 1);
-		if (mechlist) free(mechlist);
+		if (!strcmp(protocol->protocol, "sieve")) {
+		    /* XXX  Hack to handle ManageSieve servers.
+		     * No way to tell from protocol if server will
+		     * automatically send capabilities, so we treat it
+		     * as optional.
+		     */
+		    char ch;
+
+		    /* wait and probe for possible auto-capability response*/
+		    usleep(250000);
+		    prot_NONBLOCK(pin);
+		    if ((ch = prot_getc(pin)) != EOF) {
+			prot_ungetc(ch, pin);
+		    } else {
+			protocol->sasl_cmd.auto_capa = 0;
+		    }
+		    prot_BLOCK(pin);
 	    }
-	}
+		new_mechlist = ask_capability(protocol, &server_supports_tls,
+					      protocol->sasl_cmd.auto_capa);
+		if (new_mechlist && strcmp(new_mechlist, mechlist)) {
+		    printf("WARNING: possible MITM attack: "
+			   "list of available SASL mechanisms changed\n");
+		    free(new_mechlist);
+	}
+	    }
+	}
+	if (mechlist) free(mechlist);
 
     } while (--reauth);
 

Modified: branches/cyrus23/cyrus-imapd-2.3-development/lib/cyrusdb_berkeley.c
URL: https://mail.incase.de/viewcvs/branches/cyrus23/cyrus-imapd-2.3-development/lib/cyrusdb_berkeley.c?rev=771&root=cyrus22&r1=770&r2=3D771&view=diff
==============================================================================
--- branches/cyrus23/cyrus-imapd-2.3-development/lib/cyrusdb_berkeley.c (original)
+++ branches/cyrus23/cyrus-imapd-2.3-development/lib/cyrusdb_berkeley.c Thu Apr 23 19:56:51 2009
@@ -39,7 +39,7 @@
  * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
  * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  *
- * $Id: cyrusdb_berkeley.c,v 1.22 2008/03/24 17:43:08 murch Exp $
+ * $Id: cyrusdb_berkeley.c,v 1.23 2009/03/10 02:56:22 brong Exp $
  */
 
 #include <config.h>
@@ -874,6 +874,8 @@
 		   (unsigned long) txn_id(tid));
     }
     r = db->del(db, tid, &k, 0);
+    if (force && r == DB_NOTFOUND) 
+	r = CYRUSDB_OK;  /* ignore not found errors */
     if (!mytid) {
 	/* finish txn for the write */
 	if (r) {
@@ -906,8 +908,6 @@
 	}
 	if (r == DB_LOCK_DEADLOCK) {
 	    r = CYRUSDB_AGAIN;
-	} else if (force && r == DB_NOTFOUND) {
-	    r = CYRUSDB_OK;  /* ignore not found errors */
 	} else {
 	    syslog(LOG_ERR, "DBERROR: mydelete: error deleting %s: %s",
 		   key, db_strerror(r));

Modified: branches/cyrus23/cyrus-imapd-2.3-development/lib/cyrusdb_quotalegacy.c
URL: https://mail.incase.de/viewcvs/branches/cyrus23/cyrus-imapd-2.3-development/lib/cyrusdb_quotalegacy.c?rev=771&root=cyrus22&r1=770&r2=771&view=diff
==============================================================================
--- branches/cyrus23/cyrus-imapd-2.3-development/lib/cyrusdb_quotalegacy.c (original)
+++ branches/cyrus23/cyrus-imapd-2.3-development/lib/cyrusdb_quotalegacy.c Thu Apr 23 19:56:51 2009
@@ -39,7 +39,7 @@
  * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
  * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  *
- * $Id: cyrusdb_quotalegacy.c,v 1.19 2008/09/19 17:10:51 murch Exp $
+ * $Id: cyrusdb_quotalegacy.c,v 1.20 2009/01/14 15:54:42 murch Exp $
  */
 
 #include <config.h>
@@ -529,7 +529,8 @@
 		if (!strncmp(next->d_name, prefix, strlen(prefix))) {
 		    if (pathbuf->count == pathbuf->alloc) {
 			pathbuf->alloc += PATH_ALLOC;
-			pathbuf->path = xrealloc(pathbuf->path, pathbuf->alloc);
+			pathbuf->path = xrealloc(pathbuf->path,
+						 pathbuf->alloc * sizeof(char *));
 		    }
 		    pathbuf->path[pathbuf->count] = xmalloc(MAX_QUOTA_PATH+1);
 		    sprintf(pathbuf->path[pathbuf->count++],
@@ -551,7 +552,8 @@
 	if (!stat(quota_path, &buf)) {
 	    if (pathbuf->count == pathbuf->alloc) {
 		pathbuf->alloc += PATH_ALLOC;
-		pathbuf->path = xrealloc(pathbuf->path, pathbuf->alloc);
+		pathbuf->path = xrealloc(pathbuf->path,
+					 pathbuf->alloc * sizeof(char *));
 	    }
 	    pathbuf->path[pathbuf->count] = xmalloc(MAX_QUOTA_PATH+1);
 	    sprintf(pathbuf->path[pathbuf->count++],

Modified: branches/cyrus23/cyrus-imapd-2.3-development/lib/imapoptions
URL: https://mail.incase.de/viewcvs/branches/cyrus23/cyrus-imapd-2.3-development/lib/imapoptions?rev=771&root=cyrus22&r1=770&r2=771&view=diff
==============================================================================
--- branches/cyrus23/cyrus-imapd-2.3-development/lib/imapoptions (original)
+++ branches/cyrus23/cyrus-imapd-2.3-development/lib/imapoptions Thu Apr 23 19:56:51 2009
@@ -43,7 +43,7 @@
 .\" AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
 .\" OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 .\" 
-.\" $Id: imapoptions,v 1.59 2008/10/08 17:18:12 wescraig Exp $
+.\" $Id: imapoptions,v 1.62 2009/03/06 03:52:55 brong Exp $
 
 .SH NAME
 imapd.conf \- IMAP configuration file
@@ -534,9 +534,21 @@
 /* Include notations in the protocol telemetry logs indicating the number of
    seconds since the last command or response. */
 
+{ "mailbox_default_options", 0, INT }
+/* Default "options" field for the mailbox on create.  You'll want to know
+   what you're doing before setting this, but it can apply some default
+   annotations like condstore or duplicate supression */
+
 { "mailnotifier", NULL, STRING }
 /* Notifyd(8) method to use for "MAIL" notifications.  If not set, "MAIL"
    notifications are disabled. */
+
+{ "maxheaderlines", 1000, INT }
+/* Maximum number of lines of header that will be processed into cache
+   records.  Default 1000.  If set to zero, it is unlimited.
+   If a message hits the limit, an error will be logged and the rest of
+   the lines in the header will be skipped.  This is to avoid malformed
+   messages causing giant cache records */
 
 { "maxmessagesize", 0, INT }
 /* Maximum incoming LMTP message size.  If non-zero, lmtpd will reject
@@ -944,10 +956,6 @@
 /* If enabled, timsieved will emit a capability response after a successful
    SASL authentication, per draft-martin-managesieve-12.txt . */
 
-{ "sieve_sasl_expect_unsolicited_capability", 0, SWITCH }
-/* If enabled, timsieved will expect a capability response after a successful
-   SASL authentication, per draft-martin-mangesieve-12.txt . */
-
 { "sievedir", "/usr/sieve", STRING }
 /* If sieveusehomedir is false, this directory is searched for Sieve
    scripts. */

Modified: branches/cyrus23/cyrus-imapd-2.3-development/lib/imapopts.c
URL: https://mail.incase.de/viewcvs/branches/cyrus23/cyrus-imapd-2.3-development/lib/imapopts.c?rev=771&root=cyrus22&r1=770&r2=771&view=diff
==============================================================================
--- branches/cyrus23/cyrus-imapd-2.3-development/lib/imapopts.c (original)
+++ branches/cyrus23/cyrus-imapd-2.3-development/lib/imapopts.c Thu Apr 23 19:56:51 2009
@@ -119,7 +119,9 @@
   { IMAPOPT_LOGINREALMS, "loginrealms", 0, {(void *)("")}, OPT_STRING, {  { NULL, IMAP_ENUM_ZERO } } },
   { IMAPOPT_LOGINUSEACL, "loginuseacl", 0, {(void*)0}, OPT_SWITCH, {  { NULL, IMAP_ENUM_ZERO } } },
   { IMAPOPT_LOGTIMESTAMPS, "logtimestamps", 0, {(void*)0}, OPT_SWITCH, {  { NULL, IMAP_ENUM_ZERO } } },
+  { IMAPOPT_MAILBOX_DEFAULT_OPTIONS, "mailbox_default_options", 0, {(void*)0}, OPT_INT, {  { NULL, IMAP_ENUM_ZERO } } },
   { IMAPOPT_MAILNOTIFIER, "mailnotifier", 0, {(void *)(NULL)}, OPT_STRING, {  { NULL, IMAP_ENUM_ZERO } } },
+  { IMAPOPT_MAXHEADERLINES, "maxheaderlines", 0, {(void*)1000}, OPT_INT, {  { NULL, IMAP_ENUM_ZERO } } },
   { IMAPOPT_MAXMESSAGESIZE, "maxmessagesize", 0, {(void*)0}, OPT_INT, {  { NULL, IMAP_ENUM_ZERO } } },
   { IMAPOPT_MAXQUOTED, "maxquoted", 0, {(void*)131072}, OPT_INT, {  { NULL, IMAP_ENUM_ZERO } } },
   { IMAPOPT_MAXWORD, "maxword", 0, {(void*)131072}, OPT_INT, {  { NULL, IMAP_ENUM_ZERO } } },
@@ -192,7 +194,6 @@
   { IMAPOPT_SIEVE_MAXSCRIPTS, "sieve_maxscripts", 0, {(void*)5}, OPT_INT, {  { NULL, IMAP_ENUM_ZERO } } },
   { IMAPOPT_SIEVE_UTF8FILEINTO, "sieve_utf8fileinto", 0, {(void*)0}, OPT_SWITCH, {  { NULL, IMAP_ENUM_ZERO } } },
   { IMAPOPT_SIEVE_SASL_SEND_UNSOLICITED_CAPABILITY, "sieve_sasl_send_unsolicited_capability", 0, {(void*)0}, OPT_SWITCH, {  { NULL, IMAP_ENUM_ZERO } } },
-  { IMAPOPT_SIEVE_SASL_EXPECT_UNSOLICITED_CAPABILITY, "sieve_sasl_expect_unsolicited_capability", 0, {(void*)0}, OPT_SWITCH, {  { NULL, IMAP_ENUM_ZERO } } },
   { IMAPOPT_SIEVEDIR, "sievedir", 0, {(void *)("/usr/sieve")}, OPT_STRING, {  { NULL, IMAP_ENUM_ZERO } } },
   { IMAPOPT_SIEVENOTIFIER, "sievenotifier", 0, {(void *)(NULL)}, OPT_STRING, {  { NULL, IMAP_ENUM_ZERO } } },
   { IMAPOPT_SIEVEUSEHOMEDIR, "sieveusehomedir", 0, {(void*)0}, OPT_SWITCH, {  { NULL, IMAP_ENUM_ZERO } } },

Modified: branches/cyrus23/cyrus-imapd-2.3-development/lib/imapopts.h
URL: https://mail.incase.de/viewcvs/branches/cyrus23/cyrus-imapd-2.3-development/lib/imapopts.h?rev=771&root=cyrus22&r1=770&r2=771&view=diff
==============================================================================
--- branches/cyrus23/cyrus-imapd-2.3-development/lib/imapopts.h (original)
+++ branches/cyrus23/cyrus-imapd-2.3-development/lib/imapopts.h Thu Apr 23 19:56:51 2009
@@ -106,7 +106,9 @@
   IMAPOPT_LOGINREALMS,
   IMAPOPT_LOGINUSEACL,
   IMAPOPT_LOGTIMESTAMPS,
+  IMAPOPT_MAILBOX_DEFAULT_OPTIONS,
   IMAPOPT_MAILNOTIFIER,
+  IMAPOPT_MAXHEADERLINES,
   IMAPOPT_MAXMESSAGESIZE,
   IMAPOPT_MAXQUOTED,
   IMAPOPT_MAXWORD,
@@ -179,7 +181,6 @@
   IMAPOPT_SIEVE_MAXSCRIPTS,
   IMAPOPT_SIEVE_UTF8FILEINTO,
   IMAPOPT_SIEVE_SASL_SEND_UNSOLICITED_CAPABILITY,
-  IMAPOPT_SIEVE_SASL_EXPECT_UNSOLICITED_CAPABILITY,
   IMAPOPT_SIEVEDIR,
   IMAPOPT_SIEVENOTIFIER,
   IMAPOPT_SIEVEUSEHOMEDIR,

Modified: branches/cyrus23/cyrus-imapd-2.3-development/lib/prot.c
URL: https://mail.incase.de/viewcvs/branches/cyrus23/cyrus-imapd-2.3-development/lib/prot.c?rev=771&root=cyrus22&r1=770&r2=771&view=
3Ddiff
==============================================================================
--- branches/cyrus23/cyrus-imapd-2.3-development/lib/prot.c (original)
+++ branches/cyrus23/cyrus-imapd-2.3-development/lib/prot.c Thu Apr 23 19:56:51 2009
@@ -39,7 +39,7 @@
  * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
  * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  *
- * $Id: prot.c,v 1.94 2008/03/24 17:43:09 murch Exp $
+ * $Id: prot.c,v 1.96 2009/02/16 18:13:22 murch Exp $
  */
 
 #include <config.h>
@@ -154,6 +154,50 @@
 #endif /* HAVE_SSL */
 
 /*
+ * Decode data sent via a SASL security layer. Returns EOF on error.
+ */
+int prot_sasldecode(struct protstream *s, int n)
+{
+    int result;
+    const char *out;
+    unsigned outlen;
+    
+    assert(!s->write);
+
+    /* decode the input */
+    result = sasl_decode(s->conn, (const char *) s->buf, n, 
+			 &out, &outlen);
+
+    if (result != SASL_OK) {
+	char errbuf[256];
+	const char *ed = sasl_errdetail(s->conn);
+
+	snprintf(errbuf, 256, "decoding error: %s; %s",
+		 sasl_errstring(result, NULL, NULL),
+		 ed ? ed : "no detail");
+	s->error = xstrdup(errbuf);
+	return EOF;
+    }
+   
+    if (outlen > 0) {
+	/* XXX can we just serve data from 'out' without copying
+	   it to s->buf ? */
+	if (outlen > s->buf_size) {
+	    s->buf = (unsigned char *) 
+		xrealloc(s->buf, sizeof(char) * (outlen + 4));
+	    s->buf_size = outlen;
+	}
+	memcpy(s->buf, out, outlen);
+	s->ptr = s->buf;
+	s->cnt = outlen;
+    } else {		/* didn't decode anything */
+	s->cnt = 0;
+    }
+
+    return 0;
+}
+
+/*
  * Turn on SASL for this connection
  */
 
@@ -179,7 +223,6 @@
     s->saslssf = *((const int *) ssfp);
 
     if (s->write) {
-	int result;
 	const void *maxp;
 	unsigned int max;
 
@@ -199,8 +242,8 @@
 	s->cnt = max;
     }
     else if (s->cnt) {  
-	/* flush any pending input */
-	s->cnt = 0;
+	/* decode any pending input */
+	if (prot_sasldecode(s, s->cnt) == EOF) return EOF;
     }
 
     return 0;
@@ -481,43 +524,10 @@
 	}
 	
 	if (s->saslssf) { /* decode it */
-	    int result;
-	    const char *out;
-	    unsigned outlen;
-	    
-	    /* Decode the input token */
-	    result = sasl_decode(s->conn, (const char *) s->buf, n, 
-				 &out, &outlen);
-	    
-	    if (result != SASL_OK) {
-		char errbuf[256];
-		const char *ed = sasl_errdetail(s->conn);
-
-		snprintf(errbuf, 256, "decoding error: %s; %s",
-			 sasl_errstring(result, NULL, NULL),
-			 ed ? ed : "no detail");
-		s->error = xstrdup(errbuf);
-		return EOF;
-	    }
-	    
-	    if (outlen > 0) {
-		/* XXX can we just serve data from 'out' without copying
-		   it to s->buf ? */
-		if (outlen > s->buf_size) {
-		    s->buf = (unsigned char *) 
-			xrealloc(s->buf, sizeof(char) * (outlen + 4));
-		    s->buf_size = outlen;
-		}
-		memcpy(s->buf, out, outlen);
-		s->ptr = s->buf + 1;
-		s->cnt = outlen;
-	    } else {		/* didn't decode anything */
-		s->cnt = 0;
-	    }
-	    
+	    if (prot_sasldecode(s, n) == EOF) return EOF;
 	} else {
 	    /* No protection function, just use the raw data */
-	    s->ptr = s->buf+1;
+	    s->ptr = s->buf;
 	    s->cnt = n;
 	}
 	
@@ -545,7 +555,7 @@
 	    }
 
 	    s->cnt--;		/* we return the first char */
-	    return *s->buf;
+	    return *s->ptr++;
 	}
     } while (1);
 }
@@ -582,6 +592,8 @@
 		left -= n;
 	    }
 	} while (left);
+
+	fsync(s->logfd);
     }
 }
 

Modified: branches/cyrus23/cyrus-imapd-2.3-development/perl/sieve/lib/isieve.c
URL: https://mail.incase.de/viewcvs/branches/cyrus23/cyrus-imapd-2.3-development/perl/sieve/lib/isieve.c?rev=771&root=cyrus22&r1=770&r2=
3D771&view=diff
==============================================================================
--- branches/cyrus23/cyrus-imapd-2.3-development/perl/sieve/lib/isieve.c (original)
+++ branches/cyrus23/cyrus-imapd-2.3-development/perl/sieve/lib/isieve.c Thu Apr 23 19:56:51 2009
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998-2003 Carnegie Mellon University.  All rights reserved.
+ * Copyright (c) 1994-2008 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
@@ -15,14 +15,15 @@
  *
  * 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
+ *    prior written permission. For permission or any 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
+ *      Center for Technology Transfer and Enterprise Creation
+ *      4615 Forbes Avenue
+ *      Suite 302
+ *      Pittsburgh, PA  15213
+ *      (412) 268-7393, fax: (412) 268-7395
+ *      innovation at andrew.cmu.edu
  *
  * 4. Redistributions of any form whatsoever must retain the following
  *    acknowledgment:
@@ -37,9 +38,8 @@
  * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
  * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  *
+ * $Id: isieve.c,v 1.36 2009/02/16 18:18:10 murch Exp $
  */
-
-/* $Id: isieve.c,v 1.30 2006/11/30 17:11:24 murch Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include <config.h>
@@ -55,6 +55,7 @@
 #include <netinet/in.h>
 #include <netdb.h>
 #include <string.h>
+#include <unistd.h>
 
 #include <sasl/sasl.h>
 #include <sasl/saslutil.h>
@@ -208,10 +209,14 @@
   addrsize=sizeof(struct sockaddr_storage);
   if (getsockname(obj->sock,(struct sockaddr *)&saddr_l,&addrsize)!=0)
       return -1;
-
+#if 0
+  /* XXX  The following line causes problems with KERBEROS_V4 decoding.
+   * We're not sure why its an issue, but this code isn't used in any of 
+   * our other client code (imtest.c, backend.c), so we're removing it.
+   */
   /* set the port manually since getsockname is stupid and doesn't */
   ((struct sockaddr_in *)&saddr_l)->sin_port = htons(obj->port);
-
+#endif
   if (iptostring((struct sockaddr *)&saddr_r, addrsize, remoteip, 60))
       return -1;
 
@@ -297,6 +302,33 @@
   }
   
   return cap;
+}
+
+int detect_mitm(isieve_t *obj, char *mechlist)
+{
+    char *new_mechlist;
+    int ch, r = 0;
+
+    /* wait and probe for possible automatic capability response */
+    usleep(250000);
+    prot_NONBLOCK(obj->pin);
+    if ((ch = prot_getc(obj->pin)) != EOF) {
+	/* automatic capability response */
+	prot_ungetc(ch, obj->pin);
+    } else {
+	/* manually ask for capabilities */
+	prot_printf(obj->pout, "CAPABILITY\r\n");
+	prot_flush(obj->pout);
+    }
+    prot_BLOCK(obj->pin);
+
+    if ((new_mechlist = read_capability(obj))) {
+	/* if the server still advertises SASL mechs, compare lists */
+	r = strcmp(new_mechlist, mechlist);
+	free(new_mechlist);
+    }
+
+    return r;
 }
 
 static int getauthline(isieve_t *obj, char **line, unsigned int *linelen,
@@ -353,7 +385,7 @@
 
 
 int auth_sasl(char *mechlist, isieve_t *obj, const char **mechusing,
-	      char **errstr)
+	      sasl_ssf_t *ssf, char **errstr)
 {
   sasl_interact_t *client_interact=NULL;
   int saslresult=SASL_INTERACT;
@@ -462,6 +494,15 @@
 	      return -1;
       }
 
+      if (ssf) {
+	  const void *ssfp;
+
+	  saslresult = sasl_getprop(obj->conn, SASL_SSF, &ssfp);
+	  if(saslresult != SASL_OK) return -1;
+
+	  *ssf = *((sasl_ssf_t *) ssfp);
+      }
+
       /* turn on layer if need be */
       prot_setsasl(obj->pin,  obj->conn);
       prot_setsasl(obj->pout, obj->conn);
@@ -510,6 +551,7 @@
     const char *scheme = "sieve://";
     char *host, *p;
     sasl_callback_t *callbacks;
+    sasl_ssf_t ssf;
 
     /* check scheme */
     if (strncasecmp(refer_to, scheme, strlen(scheme)))
@@ -592,7 +634,7 @@
 
     do {
 	mtried = NULL;
-	ret = auth_sasl(mechlist, obj_new, &mtried, &errstr);
+	ret = auth_sasl(mechlist, obj_new, &mtried, &ssf, &errstr);
 	if(ret) init_sasl(obj_new, 128, callbacks);
 
 	if(mtried) {
@@ -620,6 +662,16 @@
     /* xxx leak? */
     if(ret) return STAT_NO;
 
+    if (ssf) {
+        /* SASL security layer negotiated --
+	   check if SASL mech list changed */
+        if (detect_mitm(obj_new, mechlist)) {
+	    free(mechlist);
+	    return STAT_NO;
+	}
+    }
+    free(mechlist);
+
     /* free old isieve_t */
     sieve_dispose(obj);
 

Modified: branches/cyrus23/cyrus-imapd-2.3-development/perl/sieve/lib/isieve.h
URL: https://mail.incase.de/viewcvs/branches/cyrus23/cyrus-imapd-2.3-development/perl/sieve/lib/isieve.h?rev=771&root=cyrus22&r1=770&r2=
3D771&view=diff
==============================================================================
--- branches/cyrus23/cyrus-imapd-2.3-development/perl/sieve/lib/isieve.h (original)
+++ branches/cyrus23/cyrus-imapd-2.3-development/perl/sieve/lib/isieve.h Thu Apr 23 19:56:51 2009
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998-2003 Carnegie Mellon University.  All rights reserved.
+ * Copyright (c) 1994-2008 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
@@ -15,14 +15,15 @@
  *
  * 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
+ *    prior written permission. For permission or any 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
+ *      Center for Technology Transfer and Enterprise Creation
+ *      4615 Forbes Avenue
+ *      Suite 302
+ *      Pittsburgh, PA  15213
+ *      (412) 268-7393, fax: (412) 268-7395
+ *      innovation at andrew.cmu.edu
  *
  * 4. Redistributions of any form whatsoever must retain the following
  *    acknowledgment:
@@ -37,9 +38,8 @@
  * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
  * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  *
+ * $Id: isieve.h,v 1.13 2009/01/14 15:50:47 murch Exp $
  */
-
-/* $Id: isieve.h,v 1.10 2003/02/13 20:15:53 rjs3 Exp $ */
 
 #ifndef ISIEVE_H_
 #define ISIEVE_H_
@@ -60,6 +60,7 @@
 	      sasl_callback_t *callbacks);
 
 char * read_capability(isieve_t *obj);
+int detect_mitm(isieve_t *obj, char *mechlist);
 
 typedef enum {
     STAT_CONT = 0,
@@ -67,7 +68,7 @@
     STAT_OK = 2
 } imt_stat;
 
-int auth_sasl(char *mechlist, isieve_t *obj, const char **mechusing, char **errstr);
+int auth_sasl(char *mechlist, isieve_t *obj, const char **mechusing, sasl_ssf_t *ssf, char **errstr);
 
 int isieve_logout(isieve_t **obj);
 int isieve_put_file(isieve_t *obj, char *filename, char *destname,

Modified: branches/cyrus23/cyrus-imapd-2.3-development/perl/sieve/managesieve/managesieve.xs
URL: https://mail.incase.de/viewcvs/branches/cyrus23/cyrus-imapd-2.3-development/perl/sieve/managesieve/managesieve.xs?rev=771&root=cyrus22&r1=770&r2=771&view=diff
==============================================================================
--- branches/cyrus23/cyrus-imapd-2.3-development/perl/sieve/managesieve/managesieve.xs (original)
+++ branches/cyrus23/cyrus-imapd-2.3-development/perl/sieve/managesieve/managesieve.xs Thu Apr 23 19:56:51 2009
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998-2000 Carnegie Mellon University.  All rights reserved.
+ * Copyright (c) 1994-2008 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
@@ -15,14 +15,15 @@
  *
  * 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
+ *    prior written permission. For permission or any 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
+ *      Center for Technology Transfer and Enterprise Creation
+ *      4615 Forbes Avenue
+ *      Suite 302
+ *      Pittsburgh, PA  15213
+ *      (412) 268-7393, fax: (412) 268-7395
+ *      innovation at andrew.cmu.edu
  *
  * 4. Redistributions of any form whatsoever must retain the following
  *    acknowledgment:
@@ -37,9 +38,8 @@
  * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
  * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  *
+ * $Id: managesieve.xs,v 1.29 2009/01/14 15:50:47 murch Exp $
  */
-
-/* $Id: managesieve.xs,v 1.23 2006/11/30 17:11:24 murch Exp $ */
 
 #ifdef __cplusplus
 extern "C" {
@@ -66,30 +66,6 @@
 #include "isieve.h"
 #include "util.h"
 #include "xmalloc.h"
-
-static int
-not_here(s)
-char *s;
-{
-    croak("%s not implemented on this architecture", s);
-    return -1;
-}
-
-static double
-constant(name, arg)
-char *name;
-int arg;
-{
-    errno = 0;
-    switch (*name) {
-    }
-    errno = EINVAL;
-    return 0;
-
-not_there:
-    errno = ENOENT;
-    return 0;
-}
 
 void fatal(const char *s, int t)
 {
@@ -221,14 +197,14 @@
   PREINIT:
   Sieveobj ret = NULL;
   sasl_callback_t *callbacks;
-  int sock,port;
-  sasl_conn_t *saslconn;
+  int port;
   int r;
   struct servent *serv;
   char *mechlist=NULL,*mlist=NULL;
   const char *mtried;
   isieve_t *obj;
   char *p;
+  sasl_ssf_t ssf;
 
   CODE:
 
@@ -302,7 +278,7 @@
   /* loop through all the mechanisms */
   do {
     mtried = NULL;
-    r = auth_sasl(mlist, obj, &mtried, &globalerr);
+    r = auth_sasl(mlist, obj, &mtried, &ssf, &globalerr);
 
     if(r) init_sasl(obj, 128, callbacks);
 
@@ -334,6 +310,19 @@
 	free(ret);
 	XSRETURN_UNDEF;
   }
+
+  if (ssf) {
+        /* SASL security layer negotiated --
+	   check if SASL mech list changed */
+        if (detect_mitm(obj, mechlist)) {
+	    globalerr = "possible MITM attack: "
+		"list of available SASL mechamisms changed";
+	    free(mechlist);
+	    XSRETURN_UNDEF;
+	}
+  }
+  free(mechlist);
+
   ST(0) = sv_newmortal();
   sv_setref_pv(ST(0), ret->class, (void *) ret);
 

Modified: branches/cyrus23/cyrus-imapd-2.3-development/sieve/comparator.c
URL: https://mail.incase.de/viewcvs/branches/cyrus23/cyrus-imapd-2.3-development/sieve/comparator.c?rev=771&root=cyrus22&r1=770&r2=771&view=diff
==============================================================================
--- branches/cyrus23/cyrus-imapd-2.3-development/sieve/comparator.c (original)
+++ branches/cyrus23/cyrus-imapd-2.3-development/sieve/comparator.c Thu Apr 23 19:56:51 2009
@@ -1,30 +1,48 @@
 /* comparator.c -- comparator functions
  * Larry Greenfield
  * Ken Murchison (rewritten to handle relational ops and non-terminated text)
- * $Id: comparator.c,v 1.18 2006/11/30 17:11:24 murch Exp $
+ *
+ * Copyright (c) 1994-2008 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 legal
+ *    details, please contact
+ *      Carnegie Mellon University
+ *      Center for Technology Transfer and Enterprise Creation
+ *      4615 Forbes Avenue
+ *      Suite 302
+ *      Pittsburgh, PA  15213
+ *      (412) 268-7393, fax: (412) 268-7395
+ *      innovation 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.
+ *
+ * $Id: comparator.c,v 1.23 2009/02/03 05:14:51 brong Exp $
  */
-/***********************************************************
-        Copyright 1999 by Carnegie Mellon University
-
-                      All Rights Reserved
-
-Permission to use, copy, modify, and distribute this software and its
-documentation for any purpose and without fee is hereby granted,
-provided that the above copyright notice appear in all copies and that
-both that copyright notice and this permission notice appear in
-supporting documentation, and that the name of Carnegie Mellon
-University not be used in advertising or publicity pertaining to
-distribution of the software without specific, written prior
-permission.
-
-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.
-******************************************************************/
 
 #ifdef HAVE_CONFIG_H
 #include <config.h>
@@ -226,7 +244,7 @@
 		t++; tlen--;
 	    }
 	case '\\':
-	    p++;
+	    c = *p++;
 	    /* falls through */
 	default:
 	    if ((c == *t) || (casemap && (toupper(c) == toupper(*t)))) {
@@ -252,17 +270,30 @@
 static int octet_regex(const char *text, size_t tlen, const char *pat,
                        void *rock __attribute__((unused)))
 {
-    if (!text[tlen]) {
-	/* NUL-terminated string */
-	return (!regexec((regex_t *) pat, text, 0, NULL, 0));
-    }
-    else {
-	/* regexec() requires a NUL-terminated string */
+    int r;
+
+#ifdef REG_STARTEND
+    /* pcre, BSD, some linuxes support this handy trick */
+    regmatch_t pm[1];
+
+    pm[0].rm_so = 0;
+    pm[0].rm_eo = tlen;
+    r = !regexec((regex_t *) pat, text, 0, &pm, REG_STARTEND);
+#else
+#ifdef HAVE_RX_POSIX_H
+    /* rx provides regnexec, that will work too */
+    r = !regnexec((regex_t *) pat, text, tlen, 0, NULL, 0);
+#else
+    /* regexec() requires a NUL-terminated string, and we have no
+     * guarantee that "text" is one.  Also, it may be only exactly
+     * tlen's length, so we can't safely check.  Always dup. */
 	char *buf = (char *) xstrndup(text, tlen);
-	int r = !regexec((regex_t *) pat, buf, 0, NULL, 0);
+    r = !regexec((regex_t *) pat, buf, 0, NULL, 0);
 	free(buf);
+#endif /* HAVE_RX_POSIX_H */
+#endif /* REG_STARTEND */
+
 	return r;
-    }
 }
 #endif
 

Modified: branches/cyrus23/cyrus-imapd-2.3-development/timsieved/actions.c
URL: https://mail.incase.de/viewcvs/branches/cyrus23/cyrus-imapd-2.3-development/timsieved/actions.c?rev=771&root=cyrus22&r1=770&r2=771&view=diff
==============================================================================
--- branches/cyrus23/cyrus-imapd-2.3-development/timsieved/actions.c (original)
+++ branches/cyrus23/cyrus-imapd-2.3-development/timsieved/actions.c Thu Apr 23 19:56:51 2009
@@ -40,7 +40,7 @@
  * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
  * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  *
- * $Id: actions.c,v 1.45 2008/10/08 15:47:08 murch Exp $
+ * $Id: actions.c,v 1.46 2009/01/14 15:50:47 murch Exp $
  */
 
 #ifdef HAVE_CONFIG_H
@@ -179,7 +179,7 @@
 }
 
 int capabilities(struct protstream *conn, sasl_conn_t *saslconn,
-		 int starttls_done, int authenticated)
+		 int starttls_done, int authenticated, sasl_ssf_t sasl_ssf)
 {
     const char *sasllist;
     int mechcount;
@@ -190,7 +190,7 @@
 		config_mupdate_server ? " (Murder)" : "", CYRUS_VERSION);
     
     /* SASL */
-    if (authenticated != 1 &&
+    if ((!authenticated || sasl_ssf) &&
 	sasl_listmech(saslconn, NULL, 
 		    "\"SASL\" \"", " ", "\"\r\n",
 		    &sasllist,

Modified: branches/cyrus23/cyrus-imapd-2.3-development/timsieved/actions.h
URL: https://mail.incase.de/viewcvs/branches/cyrus23/cyrus-imapd-2.3-development/timsieved/actions.h?rev=771&root=cyrus22&r1=770&r2=771&view=diff
==============================================================================
--- branches/cyrus23/cyrus-imapd-2.3-development/timsieved/actions.h (original)
+++ branches/cyrus23/cyrus-imapd-2.3-development/timsieved/actions.h Thu Apr 23 19:56:51 2009
@@ -41,7 +41,7 @@
  * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
  * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  *
- * $Id: actions.h,v 1.12 2008/03/24 20:20:57 murch Exp $
+ * $Id: actions.h,v 1.13 2009/01/14 15:50:47 murch Exp $
  */
 
 #ifndef _ACTIONS_H_
@@ -57,7 +57,7 @@
  */
 
 int capabilities(struct protstream *conn, sasl_conn_t *saslconn,
-		 int starttls_done, int authenticated);
+		 int starttls_done, int authenticated, sasl_ssf_t sasl_ssf);
 
 /*
  * Get a sieve scripe with name "name" and output it's contents

Modified: branches/cyrus23/cyrus-imapd-2.3-development/timsieved/parser.c
URL: https://mail.incase.de/viewcvs/branches/cyrus23/cyrus-imapd-2.3-development/timsieved/parser.c?rev=771&root=cyrus22&r1=770&r2=771&view=diff
==============================================================================
--- branches/cyrus23/cyrus-imapd-2.3-development/timsieved/parser.c (original)
+++ branches/cyrus23/cyrus-imapd-2.3-development/timsieved/parser.c Thu Apr 23 19:56:51 2009
@@ -41,7 +41,7 @@
  * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
  * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  *
- * $Id: parser.c,v 1.51 2008/10/08 17:18:13 wescraig Exp $
+ * $Id: parser.c,v 1.53 2009/02/09 05:01:59 brong Exp $
  */
 
 #ifdef HAVE_CONFIG_H
@@ -84,6 +84,7 @@
 int authenticated = 0;
 int verify_only = 0;
 int starttls_done = 0;
+sasl_ssf_t sasl_ssf = 0;
 #ifdef HAVE_SSL
 /* our tls connection, if any */
 static SSL *tls_conn = NULL;
@@ -241,7 +242,8 @@
       if(referral_host)
 	  goto do_referral;
 
-      capabilities(sieved_out, sieved_saslconn, starttls_done, authenticated);
+      capabilities(sieved_out, sieved_saslconn, starttls_done, authenticated,
+		   sasl_ssf);
       break;
 
   case HAVESPACE:
@@ -527,7 +529,7 @@
   const char *serverout=NULL;
   unsigned int serveroutlen;
   const char *errstr=NULL;
-  const void *canon_user, *sasl_ssf;
+  const void *canon_user, *val;
   char *username;
   int ret = TRUE;
 
@@ -685,7 +687,7 @@
   if (!verify_only) {
       /* Check for a remote mailbox (should we setup a redirect?) */
       struct namespace sieved_namespace;
-      char inboxname[MAX_MAILBOX_NAME];
+      char inboxname[MAX_MAILBOX_BUFFER];
       char *server;
       int type = 0, r;
       
@@ -770,11 +772,6 @@
 		  if(c) *c = '\0';
 	      }
 
-	      if (config_getswitch(IMAPOPT_SIEVE_SASL_EXPECT_UNSOLICITED_CAPABILITY)) {
-		  sieve_protocol.sasl_cmd.auto_capa = 1;
-	      } else {
-		  sieve_protocol.sasl_cmd.auto_capa = 0;
-	      }
 	      backend = backend_connect(NULL, server, &sieve_protocol,
 					username, NULL, &statusline);
 
@@ -825,11 +822,14 @@
   prot_setsasl(sieved_in, sieved_saslconn);
   prot_setsasl(sieved_out, sieved_saslconn);
 
-  if (config_getswitch(IMAPOPT_SIEVE_SASL_SEND_UNSOLICITED_CAPABILITY)) {
-      sasl_getprop(sieved_saslconn, SASL_SSF, &sasl_ssf);
-      if (*((sasl_ssf_t *) sasl_ssf)) {
-	  capabilities(sieved_out, sieved_saslconn, starttls_done, 2);
-      }
+  sasl_getprop(sieved_saslconn, SASL_SSF, &val);
+  sasl_ssf = *((sasl_ssf_t *) val);
+
+  if (sasl_ssf &&
+      config_getswitch(IMAPOPT_SIEVE_SASL_SEND_UNSOLICITED_CAPABILITY)) {
+      capabilities(sieved_out, sieved_saslconn, starttls_done, authenticated,
+		   sasl_ssf);
+      prot_flush(sieved_out);
   }
 
   /* Create telemetry log */
@@ -908,7 +908,8 @@
 
     starttls_done = 1;
 
-    return capabilities(sieved_out, sieved_saslconn, starttls_done, authenticated);
+    return capabilities(sieved_out, sieved_saslconn, starttls_done,
+			authenticated, sasl_ssf);
 }
 #else
 static int cmd_starttls(struct protstream *sieved_out, struct protstream *sieved_in)

Modified: branches/cyrus23/cyrus-imapd-2.3-development/timsieved/timsieved.c
URL: https://mail.incase.de/viewcvs/branches/cyrus23/cyrus-imapd-2.3-development/timsieved/timsieved.c?rev=771&root=cyrus22&r1=770&r2=771&view=diff
==============================================================================
--- branches/cyrus23/cyrus-imapd-2.3-development/timsieved/timsieved.c (original)
+++ branches/cyrus23/cyrus-imapd-2.3-development/timsieved/timsieved.c Thu Apr 23 19:56:51 2009
@@ -41,7 +41,7 @@
  * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
  * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  *
- * $Id: timsieved.c,v 1.62 2008/03/24 20:20:57 murch Exp $
+ * $Id: timsieved.c,v 1.63 2009/01/14 15:50:47 murch Exp $
  */
 
 #ifdef HAVE_CONFIG_H
@@ -182,7 +182,7 @@
     
     chdir("/tmp/");
 
-    capabilities(sieved_out, sieved_saslconn, 0, 0);
+    capabilities(sieved_out, sieved_saslconn, 0, 0, 0);
 
     /* initialize lexer */
     lex_init();




More information about the Pkg-Cyrus-imapd-Debian-devel mailing list