Geändert:

* Cyrus-IMAP downgrade auf 2.2.12 mit einer Menge Patches,
    doch die Probleme bleiben bestehen...
  * SSH-Schönheitsfehler im Webinterface behoben.


git-svn-id: http://svn.ipfire.org/svn/ipfire/trunk@181 ea5c0bd1-69bd-2848-81d8-4f18e57aeed8
This commit is contained in:
ms
2006-06-22 11:54:33 +00:00
parent f0ca8c34a1
commit b40388bb90
30 changed files with 5271 additions and 378 deletions

View File

@@ -0,0 +1,6 @@
ENABLE_SSH_KEYS=on
ENABLE_SSH_PROTOCOL1=off
ENABLE_SSH_PASSWORDS=on
ENABLE_SSH_PORTFW=off
ENABLE_SSH=on
__CGI__=CGI=HASH(0x840b7a0)

View File

@@ -13,10 +13,10 @@ SERVICES {
imaps cmd="imapd -s" listen="imaps" prefork=0
pop3 cmd="pop3d" listen="pop3" prefork=0
pop3s cmd="pop3d -s" listen="pop3s" prefork=0
sieve cmd="timsieved" listen="sieve" prefork=0
sieve cmd="timsieved" listen="127.0.0.1:2000" prefork=0
# at least one LMTP is required for delivery
# lmtp cmd="lmtpd" listen="lmtp" prefork=0
lmtp cmd="lmtpd" listen="127.0.0.1:24" prefork=0
lmtpunix cmd="lmtpd" listen="/var/imap/socket/lmtp" prefork=0
# this is only necessary if using notifications

View File

@@ -5,7 +5,7 @@ admins: cyrus
allowanonymouslogin: no
allowplaintext: yes
sasl_mech_list: PLAIN
servername: servername
servername: localhost
autocreatequota: 10000
reject8bit: no
quotawarn: 90
@@ -18,7 +18,9 @@ sievedir: /usr/sieve
sendmail: /usr/sbin/sendmail
sieve_maxscriptsize: 32
sieve_maxscripts: 5
lmtpsocket: /var/imap/socket/lmtp
#unixhierarchysep: yes
echo tls_ca_file: /var/imap/server.pem
echo tls_cert_file: /var/imap/server.pem
echo tls_key_file: /var/imap/server.pem
#echo tls_ca_file: /var/imap/server.pem
#echo tls_cert_file: /var/imap/server.pem
#echo tls_key_file: /var/imap/server.pem
#hashimapspool: yes

View File

@@ -78,4 +78,4 @@ ifmail unix - n n - - pipe
bsmtp unix - n n - - pipe
flags=Fq. user=foo argv=/usr/local/sbin/bsmtp -f $sender $nexthop $recipient
procmail unix - n n - 20 pipe
flags=R user=cyrus argv=/usr/bin/procmail -r SENDER=${sender} -t -m USER=${user} EXTENSION=${extension} /etc/procmailrc
flags=R user=cyrus argv=/usr/bin/procmail -r SENDER=${sender} -t -m USER=${user} EXTENSION=${extension} /etc/procmailrc

File diff suppressed because it is too large Load Diff

View File

@@ -54,6 +54,7 @@
* coreutils-5.93
* cups-1.1.23-source
* cxacru-2003-10-05
* cyrus-imapd-2.2.12
* cyrus-imapd-2.2.13
* cyrus-sasl-2.1.21
* cyrus-sasl-2.1.21-ldap

View File

@@ -82,6 +82,7 @@ $(TARGET) :
cp $(DIR_SRC)/config/cfgroot/net-traffic-lib.pl $(CONFIG_ROOT)/net-traffic/net-traffic-lib.pl
cp $(DIR_SRC)/config/cfgroot/nfs-server $(CONFIG_ROOT)/nfs/nfs-server
cp $(DIR_SRC)/config/cfgroot/proxy-acl $(CONFIG_ROOT)/proxy/acl-1.4
cp $(DIR_SRC)/config/cfgroot/ssh-settings $(CONFIG_ROOT)/remote/settings
cp $(DIR_SRC)/config/cfgroot/xtaccess-config $(CONFIG_ROOT)/xtaccess/config
cp $(DIR_SRC)/config/cfgroot/time-settings $(CONFIG_ROOT)/time/settings
cp $(DIR_SRC)/config/cfgroot/logging-settings $(CONFIG_ROOT)/logging/settings

View File

@@ -26,7 +26,7 @@
include Config
VER = 2.2.13
VER = 2.2.12
THISAPP = cyrus-imapd-$(VER)
DL_FILE = $(THISAPP).tar.gz
@@ -44,7 +44,7 @@ objects = $(DL_FILE)
$(DL_FILE) = $(DL_FROM)/$(DL_FILE)
$(DL_FILE)_MD5 = 3ff679714836d1d7b1e1df0e026d4844
$(DL_FILE)_MD5 = 70b3bba526a8d36d3bb23a87d37e9188
install : $(TARGET)
@@ -77,7 +77,32 @@ $(subst %,%_MD5,$(objects)) :
$(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects))
@$(PREBUILD)
@rm -rf $(DIR_APP) && cd $(DIR_SRC) && tar zxf $(DIR_DL)/$(DL_FILE)
cd $(DIR_APP) && ./configure --prefix=/usr --sysconfdir=/var/ipfire/cyrusimap --with-auth=unix --with-perl --with-sasl --without-ucdsnmp
cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/cyrus-imapd-2.2.12-no_transfig.patch
cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/cyrus-imapd-2.2.12-autocreate-0.9.4.diff
cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/cyrus-imapd-2.2.12-autosievefolder-0.6.diff
cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/cyrus-imapd-2.2.12-rmquota+deletemailbox-0.2-1.diff
cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/cyrus-imapd-2.1.3-flock.patch
cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/cyrus-imapd-2.2.12-munge8bit.patch
cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/cyrus-imapd-2.1.16-getrlimit.patch
cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/cyrus-imapd-2.2.10-groupcache.patch
cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/cyrus-imapd-2.2.12-seenstate.patch
cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/cyrus-imapd-acceptinvalidfrom.patch
cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/cyrus-imapd-2.3.3-deleteacl_invalid_identifier_fix.patch
cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/cyrus-imapd-2.2.12-notify_sms.patch
cd $(DIR_APP) && patch -Np0 < $(DIR_SRC)/src/patches/cyrus-imapd-2.2.12-gcc4.patch
cd $(DIR_APP) && patch -Np0 < $(DIR_SRC)/src/patches/timsieved_reset_sasl_conn.patch
cd $(DIR_APP) && patch -Np0 < $(DIR_SRC)/src/patches/allow_auth_plain_proxying.patch
cd $(DIR_APP) && patch -Np0 < $(DIR_SRC)/src/patches/authid_normalize.patch
cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/cyrus-imapd-2.2.12-64bit_quota-p1.patch
# cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/cyrus-imapd-2.2.12-64bit_quota-p2.patch
cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/cyrus-imapd-2.2.12-singleinstancestore.patch
cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/cyrus-imapd-2.2.12-spool.patch
cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/cyrus-imapd-2.2.12-mupdate-thread-safe.patch
cp -f /usr/include/et/com_err.h /usr/include/com_err.h
cd $(DIR_APP) && ./configure --prefix=/usr --with-service-path=/usr/lib/cyrus \
--with-cyrus-prefix=/usr/lib/cyrus --sysconfdir=/var/ipfire/cyrusimap \
--with-auth=unix --with-perl --with-sasl --with-idle=idled \
--with-syslogfacility=MAIL --enable-listext --without-snmp
cd $(DIR_APP) && make depend
cd $(DIR_APP) && make
cd $(DIR_APP) && make install
@@ -97,5 +122,5 @@ $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects))
chown cyrus.mail /var/imap/socket
# Wenn das Dateisystem ext2 w<>re...
# cd /var/imap && chattr +S user quota user/* quota/* && chattr +S /var/spool/imap /var/spool/imap/*
@rm -rf $(DIR_APP)
@rm -rf $(DIR_APP) /usr/include/com_err.h
@$(POSTBUILD)

View File

@@ -8,34 +8,36 @@ usr/bin/pop3test
usr/bin/sieveshell
usr/bin/sivtest
usr/bin/smtptest
#usr/cyrus
#usr/cyrus/bin
usr/cyrus/bin/arbitron
usr/cyrus/bin/chk_cyrus
usr/cyrus/bin/ctl_cyrusdb
usr/cyrus/bin/ctl_deliver
usr/cyrus/bin/ctl_mboxlist
usr/cyrus/bin/cvt_cyrusdb
usr/cyrus/bin/cyr_expire
usr/cyrus/bin/cyrdump
usr/cyrus/bin/deliver
usr/cyrus/bin/fud
usr/cyrus/bin/imapd
usr/cyrus/bin/ipurge
usr/cyrus/bin/lmtpd
usr/cyrus/bin/master
usr/cyrus/bin/mbexamine
usr/cyrus/bin/mbpath
usr/cyrus/bin/notifyd
usr/cyrus/bin/pop3d
usr/cyrus/bin/pop3proxyd
usr/cyrus/bin/quota
usr/cyrus/bin/reconstruct
usr/cyrus/bin/sievec
usr/cyrus/bin/smmapd
usr/cyrus/bin/squatter
usr/cyrus/bin/timsieved
usr/cyrus/bin/tls_prune
#usr/lib/cyrus
usr/lib/cyrus/arbitron
usr/lib/cyrus/chk_cyrus
usr/lib/cyrus/compile_sieve
usr/lib/cyrus/ctl_cyrusdb
usr/lib/cyrus/ctl_deliver
usr/lib/cyrus/ctl_mboxlist
usr/lib/cyrus/cvt_cyrusdb
usr/lib/cyrus/cyr_expire
usr/lib/cyrus/cyrdump
usr/lib/cyrus/deliver
usr/lib/cyrus/fud
usr/lib/cyrus/idled
usr/lib/cyrus/imapd
usr/lib/cyrus/ipurge
usr/lib/cyrus/lmtpd
usr/lib/cyrus/master
usr/lib/cyrus/mbexamine
usr/lib/cyrus/mbpath
usr/lib/cyrus/notifyd
usr/lib/cyrus/pop3d
usr/lib/cyrus/pop3proxyd
usr/lib/cyrus/quota
usr/lib/cyrus/reconstruct
usr/lib/cyrus/sievec
usr/lib/cyrus/smmapd
usr/lib/cyrus/squatter
usr/lib/cyrus/timsieved
usr/lib/cyrus/tls_prune
#usr/include/cyrus/byteorder64.h
#usr/include/cyrus
#usr/include/cyrus/acl.h
#usr/include/cyrus/assert.h
@@ -87,7 +89,7 @@ usr/lib/perl5/site_perl/5.8.5/i386-linux/Cyrus/SIEVE/managesieve.pm
usr/lib/perl5/site_perl/5.8.5/i386-linux/auto/Cyrus/IMAP/IMAP.bs
usr/lib/perl5/site_perl/5.8.5/i386-linux/auto/Cyrus/IMAP/IMAP.so
#usr/lib/perl5/site_perl/5.8.5/i386-linux/auto/Cyrus/SIEVE
usr/lib/perl5/site_perl/5.8.5/i386-linux/auto/Cyrus/SIEVE/managesieve
#usr/lib/perl5/site_perl/5.8.5/i386-linux/auto/Cyrus/SIEVE/managesieve
#usr/lib/perl5/site_perl/5.8.5/i386-linux/auto/Cyrus/SIEVE/managesieve/.packlist
usr/lib/perl5/site_perl/5.8.5/i386-linux/auto/Cyrus/SIEVE/managesieve/managesieve.bs
usr/lib/perl5/site_perl/5.8.5/i386-linux/auto/Cyrus/SIEVE/managesieve/managesieve.so
@@ -139,4 +141,5 @@ usr/lib/perl5/site_perl/5.8.5/i386-linux/auto/Cyrus/SIEVE/managesieve/managesiev
#usr/share/man/man8/tls_prune.8
var/imap
var/log/imap
usr/sieve
usr/sieve
var/ipfire/cyrusimap

View File

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

View File

@@ -0,0 +1,77 @@
--- lib/auth_unix.c
+++ lib/auth_unix.c 2004/05/31 11:32:50
@@ -159,10 +159,12 @@
size_t len;
{
static char retbuf[81];
+ char backup[81];
struct group *grp;
char sawalpha;
char *p;
int username_tolower = 0;
+ int ic,rbc;
if(!len) len = strlen(identifier);
if(len >= sizeof(retbuf)) return NULL;
@@ -210,6 +212,22 @@
if (!sawalpha) return NULL; /* has to be one alpha char */
+ if( (libcyrus_config_getswitch(CYRUSOPT_NORMALIZEUID) == 1) ) {
+ strcpy(backup,retbuf);
+ /* remove leading blanks */
+ for(ic=0; isblank(backup[ic]); ic++);
+ for(rbc=0; backup[ic]; ic++) {
+ retbuf[rbc] = ( isalpha(backup[ic]) ?
+ tolower(backup[ic]) : backup[ic] );
+ rbc++;
+ }
+ retbuf[rbc] = '\0';
+ /* remove trailing blanks */
+ for(--rbc; isblank(retbuf[rbc]); rbc--) {
+ retbuf[rbc] = '\0';
+ }
+ }
+
return retbuf;
}
--- lib/imapoptions
+++ lib/imapoptions 2004/05/31 11:32:50
@@ -832,6 +832,11 @@
interface, otherwise the user is assumed to be in the default
domain (if set). */
+{ "normalizeuid", 0, SWITCH }
+/* Lowercase uid and strip leading and trailing blanks. It is recommended
+ to set this to yes, especially if OpenLDAP is used as authentication
+ source. */
+
/*
.SH SEE ALSO
.PP
--- lib/libcyr_cfg.c
+++ lib/libcyr_cfg.c 2004/05/31 11:32:50
@@ -118,6 +118,11 @@
CFGVAL(int, 100),
CYRUS_OPT_INT },
+ { CYRUSOPT_NORMALIZEUID,
+ (union cyrus_config_value)((int)1),
+ CYRUS_OPT_SWITCH },
+
+
{ CYRUSOPT_LAST, { NULL }, CYRUS_OPT_NOTOPT }
};
--- lib/libcyr_cfg.h
+++ lib/libcyr_cfg.h 2004/05/31 11:33:10
@@ -97,6 +97,8 @@
CYRUSOPT_BERKELEY_LOCKS_MAX,
/* BDB max txns (100) */
CYRUSOPT_BERKELEY_TXNS_MAX,
+ /* Lowercase uid and strip leading and trailing blanks (OFF) */
+ CYRUSOPT_NORMALIZEUID,
CYRUSOPT_LAST

View File

@@ -0,0 +1,23 @@
--- cyrus-imapd-2.1.16/master/master.c.getrlimit 2003-12-28 17:32:46.000000000 +0100
+++ cyrus-imapd-2.1.16/master/master.c 2003-12-28 17:43:56.000000000 +0100
@@ -1208,12 +1208,10 @@
rl.rlim_cur = x;
rl.rlim_max = x;
if (setrlimit(RLIMIT_NUMFDS, &rl) < 0) {
- syslog(LOG_ERR, "setrlimit: Unable to set file descriptors limit to %ld: %m", x);
#ifdef HAVE_GETRLIMIT
if (!getrlimit(RLIMIT_NUMFDS, &rl)) {
- syslog(LOG_ERR, "retrying with %ld (current max)", rl.rlim_max);
rl.rlim_cur = rl.rlim_max;
if (setrlimit(RLIMIT_NUMFDS, &rl) < 0) {
syslog(LOG_ERR, "setrlimit: Unable to set file descriptors limit to %ld: %m", x);
@@ -1228,6 +1226,7 @@
rl.rlim_max);
}
#else
+ syslog(LOG_ERR, "setrlimit: Unable to set file descriptors limit to %ld: %m", x);
}
#endif /* HAVE_GETRLIMIT */
}

View File

@@ -0,0 +1,77 @@
--- cyrus-imapd-2.1.3/lib/lock_flock.c Tue Oct 2 16:08:13 2001
+++ cyrus-imapd-2.1.3-patched/lib/lock_flock.c Tue Apr 16 09:44:58 2002
@@ -51,6 +51,10 @@
#endif
#include "lock.h"
+#include <syslog.h>
+
+/* Locking timeout parameter */
+#define MAXTIME 99
const char *lock_method_desc = "flock";
@@ -69,6 +73,18 @@
* 'failaction' is provided, it is filled in with a pointer to a fixed
* string naming the action that failed.
*
+ * Modified by jwade 4/16/2002 to work around seen file locking problem
+ * Added locking timeout parameter to allow processes that are
+ * waiting for a lock to eventually time out
+ *
+ * Calls flock() in non-blocking fashion and then retries until a
+ * maximum delay is reached or the lock succeeds.
+ *
+ * As written, uses a quadratic backoff on retries with MAXTIME being
+ * the longest interval delay. Total delay time is the sum of the squares
+ * of all integers whose square is less than MAXTIME. In the case of
+ * MAXTIME = 99 this is 0+1+4+9+16+25+36+49+64+81= 285 Seconds
+ * This time is arbitrary and can be adjusted
*/
int lock_reopen(fd, filename, sbuf, failaction)
int fd;
@@ -79,17 +95,29 @@
int r;
struct stat sbuffile, sbufspare;
int newfd;
+ int delay=0, i=0;
if (!sbuf) sbuf = &sbufspare;
- for (;;) {
- r = flock(fd, LOCK_EX);
+ for(i=0,delay=0;;) {
+ r = flock(fd, LOCK_EX|LOCK_NB);
if (r == -1) {
- if (errno == EINTR) continue;
- if (failaction) *failaction = "locking";
+ if (errno == EINTR) {
+ continue;
+ }
+ else if ((errno == EWOULDBLOCK) && (delay < MAXTIME)) {
+ syslog(LOG_DEBUG, "lock: reopen-blocked sleeping for %d on interval %d (%d, %s)" , delay, i, fd, filename);
+ sleep(delay);
+ i++;
+ delay = i*i;
+ continue;
+ }
+ if (failaction) {
+ if (delay >= MAXTIME) *failaction = "locking_timeout";
+ else *failaction = "locking";
+ }
return -1;
}
-
fstat(fd, sbuf);
r = stat(filename, &sbuffile);
if (r == -1) {
@@ -97,9 +125,7 @@
flock(fd, LOCK_UN);
return -1;
}
-
if (sbuf->st_ino == sbuffile.st_ino) return 0;
-
newfd = open(filename, O_RDWR);
if (newfd == -1) {
if (failaction) *failaction = "opening";

View File

@@ -0,0 +1,43 @@
diff -Naur cyrus-imapd-2.2.10.orig/lib/auth_unix.c cyrus-imapd-2.2.10/lib/auth_unix.c
--- cyrus-imapd-2.2.10.orig/lib/auth_unix.c Tue Sep 14 00:49:29 2004
+++ cyrus-imapd-2.2.10/lib/auth_unix.c Thu Dec 16 08:36:32 2004
@@ -48,6 +48,7 @@
#include <stdlib.h>
#include <pwd.h>
#include <grp.h>
+#include <stdio.h>
#include <ctype.h>
#include <string.h>
@@ -226,6 +227,10 @@
struct passwd *pwd;
struct group *grp;
char **mem;
+ FILE *groupcache;
+ char fnamebuf[1024];
+ const char *config_dir =
+ libcyrus_config_getstring(CYRUSOPT_CONFIG_DIR);
identifier = auth_canonifyid(identifier, 0);
if (!identifier) return 0;
@@ -242,8 +247,11 @@
pwd = getpwnam(identifier);
+ strcpy(fnamebuf, config_dir);
+ strcat(fnamebuf, "/group.cache");
+ groupcache = fopen(fnamebuf, "r");
setgrent();
- while ((grp = getgrent())) {
+ while (grp = ( (groupcache) ? fgetgrent(groupcache) : getgrent() )) {
for (mem = grp->gr_mem; *mem; mem++) {
if (!strcmp(*mem, identifier)) break;
}
@@ -256,6 +264,7 @@
}
}
endgrent();
+ if (groupcache) fclose(groupcache);
return newstate;
}

View File

@@ -0,0 +1,647 @@
diff -Naur cyrus-imapd-2.2.12.orig/configure.in cyrus-imapd-2.2.12/configure.in
--- cyrus-imapd-2.2.12.orig/configure.in 2005-01-19 00:46:00.000000000 +0100
+++ cyrus-imapd-2.2.12/configure.in 2006-04-25 07:35:25.000000000 +0200
@@ -100,6 +100,15 @@
fi
AC_C_INLINE
+dnl Check if `long long int' is available
+AC_CHECK_SIZEOF(long long int)
+AC_CHECK_SIZEOF(unsigned long long int)
+if test "$ac_cv_sizeof_long_long_int" -eq 8 -a \
+ "$ac_cv_sizeof_unsigned_long_long_int" -eq 8; then
+ AC_DEFINE(HAVE_LONG_LONG_INT,[],[Does the compiler support long long int?])
+ AC_C_BIGENDIAN
+fi
+
CMU_C___ATTRIBUTE__
CMU_C_FPIC
diff -Naur cyrus-imapd-2.2.12.orig/imap/append.c cyrus-imapd-2.2.12/imap/append.c
--- cyrus-imapd-2.2.12.orig/imap/append.c 2004-05-22 05:45:48.000000000 +0200
+++ cyrus-imapd-2.2.12/imap/append.c 2006-04-25 07:35:25.000000000 +0200
@@ -140,7 +140,7 @@
if (!r) {
if (m.quota.limit >= 0 && quotacheck >= 0 &&
m.quota.used + quotacheck >
- ((unsigned) m.quota.limit * QUOTA_UNITS)) {
+ ((uquota_t) m.quota.limit * QUOTA_UNITS)) {
r = IMAP_QUOTA_EXCEEDED;
}
}
@@ -208,7 +208,7 @@
if (!r) {
if (as->m.quota.limit >= 0 && quotacheck >= 0 &&
as->m.quota.used + quotacheck >
- ((unsigned) as->m.quota.limit * QUOTA_UNITS)) {
+ ((uquota_t) as->m.quota.limit * QUOTA_UNITS)) {
quota_abort(&as->tid);
mailbox_close(&as->m);
r = IMAP_QUOTA_EXCEEDED;
diff -Naur cyrus-imapd-2.2.12.orig/imap/imapd.c cyrus-imapd-2.2.12/imap/imapd.c
--- cyrus-imapd-2.2.12.orig/imap/imapd.c 2005-02-14 07:39:55.000000000 +0100
+++ cyrus-imapd-2.2.12/imap/imapd.c 2006-04-25 07:35:25.000000000 +0200
@@ -2626,10 +2626,10 @@
*/
int warnsize = config_getint(IMAPOPT_QUOTAWARNKB);
if (warnsize <= 0 || warnsize >= imapd_mailbox->quota.limit ||
- (int)((imapd_mailbox->quota.limit * QUOTA_UNITS) -
- imapd_mailbox->quota.used) < (warnsize * QUOTA_UNITS)) {
+ ((uquota_t) (imapd_mailbox->quota.limit - warnsize)) * QUOTA_UNITS <
+ imapd_mailbox->quota.used) {
usage = ((double) imapd_mailbox->quota.used * 100.0) / (double)
- (imapd_mailbox->quota.limit * QUOTA_UNITS);
+ ((uquota_t) imapd_mailbox->quota.limit * QUOTA_UNITS);
if (usage >= 100.0) {
prot_printf(imapd_out, "* NO [ALERT] %s\r\n",
error_message(IMAP_NO_OVERQUOTA));
@@ -4626,7 +4626,7 @@
printastring(name);
prot_printf(imapd_out, " (");
if (quota.limit >= 0) {
- prot_printf(imapd_out, "STORAGE %lu %d",
+ prot_printf(imapd_out, "STORAGE " UQUOTA_T_FMT " %d",
quota.used/QUOTA_UNITS, quota.limit);
}
prot_printf(imapd_out, ")\r\n");
@@ -4688,7 +4688,7 @@
printastring(mailboxname);
prot_printf(imapd_out, " (");
if (mailbox.quota.limit >= 0) {
- prot_printf(imapd_out, "STORAGE %lu %d",
+ prot_printf(imapd_out, "STORAGE " UQUOTA_T_FMT " %d",
mailbox.quota.used/QUOTA_UNITS,
mailbox.quota.limit);
}
diff -Naur cyrus-imapd-2.2.12.orig/imap/mailbox.c cyrus-imapd-2.2.12/imap/mailbox.c
--- cyrus-imapd-2.2.12.orig/imap/mailbox.c 2005-02-14 07:39:57.000000000 +0100
+++ cyrus-imapd-2.2.12/imap/mailbox.c 2006-04-25 07:36:13.000000000 +0200
@@ -84,6 +84,7 @@
#include "seen.h"
#include "util.h"
#include "xmalloc.h"
+#include "byteorder64.h"
static int mailbox_doing_reconstruct = 0;
#define zeromailbox(m) { memset(&m, 0, sizeof(struct mailbox)); \
@@ -788,8 +789,17 @@
mailbox->last_uid =
ntohl(*((bit32 *)(mailbox->index_base+OFFSET_LAST_UID)));
- mailbox->quota_mailbox_used =
- ntohl(*((bit32 *)(mailbox->index_base+OFFSET_QUOTA_MAILBOX_USED-quota_upgrade_offset)));
+#ifdef HAVE_LONG_LONG_INT
+ if (mailbox->minor_version > 5) {
+ /* newer versions may use 64bit quotas now */
+ mailbox->quota_mailbox_used =
+ ntohll(*((bit64 *)(mailbox->index_base+OFFSET_QUOTA_MAILBOX_USED64)));
+ } else
+#endif
+ {
+ mailbox->quota_mailbox_used =
+ ntohl(*((bit32 *)(mailbox->index_base+OFFSET_QUOTA_MAILBOX_USED-quota_upgrade_offset)));
+ }
if (mailbox->start_offset < OFFSET_POP3_LAST_LOGIN-quota_upgrade_offset+sizeof(bit32)) {
mailbox->pop3_last_login = 0;
@@ -1183,9 +1193,18 @@
*((bit32 *)(buf+OFFSET_EXISTS)) = htonl(mailbox->exists);
*((bit32 *)(buf+OFFSET_LAST_APPENDDATE)) = htonl(mailbox->last_appenddate);
*((bit32 *)(buf+OFFSET_LAST_UID)) = htonl(mailbox->last_uid);
- *((bit32 *)(buf+OFFSET_QUOTA_RESERVED_FIELD)) = htonl(0); /* RESERVED */
+
+ /* quotas may be 64bit now */
+#ifdef HAVE_LONG_LONG_INT
+ *((bit64 *)(buf+OFFSET_QUOTA_MAILBOX_USED64)) =
+ htonll(mailbox->quota_mailbox_used);
+#else
+ /* zero the unused 32bits */
+ *((bit32 *)(buf+OFFSET_QUOTA_MAILBOX_USED64)) = htonl(0);
*((bit32 *)(buf+OFFSET_QUOTA_MAILBOX_USED)) =
htonl(mailbox->quota_mailbox_used);
+#endif
+
*((bit32 *)(buf+OFFSET_POP3_LAST_LOGIN)) = htonl(mailbox->pop3_last_login);
*((bit32 *)(buf+OFFSET_UIDVALIDITY)) = htonl(mailbox->uidvalidity);
*((bit32 *)(buf+OFFSET_DELETED)) = htonl(mailbox->deleted);
@@ -1430,9 +1449,18 @@
*((bit32 *)(buf+OFFSET_EXISTS)) = htonl(mailbox->exists);
*((bit32 *)(buf+OFFSET_LAST_APPENDDATE)) = htonl(mailbox->last_appenddate);
*((bit32 *)(buf+OFFSET_LAST_UID)) = htonl(mailbox->last_uid);
- /* OFFSET_QUOTA_RESERVED_FIELD left as zero */
+
+ /* newer versions may use 64bit quotas */
+#ifdef HAVE_LONG_LONG_INT
+ *((bit64 *)(buf+OFFSET_QUOTA_MAILBOX_USED64)) =
+ htonll(mailbox->quota_mailbox_used);
+#else
+ /* zero the unused 32bits */
+ *((bit32 *)(buf+OFFSET_QUOTA_MAILBOX_USED64)) = htonl(0);
*((bit32 *)(buf+OFFSET_QUOTA_MAILBOX_USED)) =
htonl(mailbox->quota_mailbox_used);
+#endif
+
*((bit32 *)(buf+OFFSET_POP3_LAST_LOGIN)) = htonl(mailbox->pop3_last_login);
*((bit32 *)(buf+OFFSET_UIDVALIDITY)) = htonl(mailbox->uidvalidity);
*((bit32 *)(buf+OFFSET_DELETED)) = htonl(mailbox->deleted);
@@ -1608,7 +1636,8 @@
size_t fnamebuf_len;
FILE *newindex = NULL, *newcache = NULL;
unsigned long *deleted;
- unsigned numdeleted = 0, quotadeleted = 0;
+ unsigned numdeleted = 0;
+ uquota_t quotadeleted = 0;
unsigned numansweredflag = 0;
unsigned numdeletedflag = 0;
unsigned numflaggedflag = 0;
@@ -1829,8 +1858,13 @@
*((bit32 *)(buf+OFFSET_FLAGGED)) = htonl(newflagged);
/* Fix up quota_mailbox_used */
+#ifdef HAVE_LONG_LONG_INT
+ *((bit64 *)(buf+OFFSET_QUOTA_MAILBOX_USED64)) =
+ htonll(ntohll(*((bit64 *)(buf+OFFSET_QUOTA_MAILBOX_USED64)))-quotadeleted);
+#else
*((bit32 *)(buf+OFFSET_QUOTA_MAILBOX_USED)) =
htonl(ntohl(*((bit32 *)(buf+OFFSET_QUOTA_MAILBOX_USED)))-quotadeleted);
+#endif
/* Fix up start offset if necessary */
if (mailbox->start_offset < INDEX_HEADER_SIZE) {
*((bit32 *)(buf+OFFSET_START_OFFSET)) = htonl(INDEX_HEADER_SIZE);
@@ -1862,7 +1896,7 @@
if (!r) quota_commit(&tid);
else {
syslog(LOG_ERR,
- "LOSTQUOTA: unable to record free of %u bytes in quota %s",
+ "LOSTQUOTA: unable to record free of " UQUOTA_T_FMT " bytes in quota %s",
quotadeleted, mailbox->quota.root);
}
}
@@ -2250,7 +2284,7 @@
strcmp(oldmailbox->quota.root, newmailbox->quota.root) != 0) {
if (!r && newmailbox->quota.limit >= 0 &&
newmailbox->quota.used + oldmailbox->quota_mailbox_used >
- ((unsigned) newmailbox->quota.limit * QUOTA_UNITS)) {
+ ((uquota_t) newmailbox->quota.limit * QUOTA_UNITS)) {
r = IMAP_QUOTA_EXCEEDED;
}
}
@@ -2464,7 +2498,7 @@
strcmp(oldmailbox.quota.root, newmailbox.quota.root) != 0) {
if (!r && newmailbox.quota.limit >= 0 &&
newmailbox.quota.used + oldmailbox.quota_mailbox_used >
- ((unsigned) newmailbox.quota.limit * QUOTA_UNITS)) {
+ ((uquota_t) newmailbox.quota.limit * QUOTA_UNITS)) {
r = IMAP_QUOTA_EXCEEDED;
}
}
@@ -2617,7 +2651,7 @@
else if (r2 == IMAP_QUOTAROOT_NONEXISTENT) r2 = 0;
if (r2) {
syslog(LOG_ERR,
- "LOSTQUOTA: unable to record use of %lu bytes in quota %s",
+ "LOSTQUOTA: unable to record use of " UQUOTA_T_FMT " bytes in quota %s",
newmailbox.quota_mailbox_used, newmailbox.quota.root);
}
}
diff -Naur cyrus-imapd-2.2.12.orig/imap/mailbox.h cyrus-imapd-2.2.12/imap/mailbox.h
--- cyrus-imapd-2.2.12.orig/imap/mailbox.h 2004-01-22 22:17:09.000000000 +0100
+++ cyrus-imapd-2.2.12/imap/mailbox.h 2006-04-25 07:35:25.000000000 +0200
@@ -45,6 +45,7 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <limits.h>
+#include <config.h>
#include "auth.h"
#include "quota.h"
@@ -61,6 +62,10 @@
#error dont know what to use for bit32
#endif
+#ifdef HAVE_LONG_LONG_INT
+typedef unsigned long long int bit64;
+#endif
+
#define MAX_MAILBOX_NAME 490
#define MAX_MAILBOX_PATH 4096
@@ -126,7 +131,7 @@
unsigned long exists;
time_t last_appenddate;
unsigned long last_uid;
- unsigned long quota_mailbox_used;
+ uquota_t quota_mailbox_used;
unsigned long pop3_last_login;
unsigned long uidvalidity;
@@ -168,8 +173,8 @@
#define OFFSET_EXISTS 20
#define OFFSET_LAST_APPENDDATE 24
#define OFFSET_LAST_UID 28
-#define OFFSET_QUOTA_RESERVED_FIELD 32 /* Reserved for 64bit quotas */
-#define OFFSET_QUOTA_MAILBOX_USED 36
+#define OFFSET_QUOTA_MAILBOX_USED64 32 /* offset for 64bit quotas */
+#define OFFSET_QUOTA_MAILBOX_USED 36 /* offset for 32bit quotas */
#define OFFSET_POP3_LAST_LOGIN 40
#define OFFSET_UIDVALIDITY 44
#define OFFSET_DELETED 48 /* added for ACAP */
diff -Naur cyrus-imapd-2.2.12.orig/imap/mbdump.c cyrus-imapd-2.2.12/imap/mbdump.c
--- cyrus-imapd-2.2.12.orig/imap/mbdump.c 2004-05-22 05:45:51.000000000 +0200
+++ cyrus-imapd-2.2.12/imap/mbdump.c 2006-04-25 07:35:25.000000000 +0200
@@ -507,7 +507,7 @@
{
struct buf file, data;
char c;
- int quotaused = 0;
+ uquota_t quotaused = 0;
int r = 0;
int curfile = -1;
const char *userid = NULL;
diff -Naur cyrus-imapd-2.2.12.orig/imap/mbexamine.c cyrus-imapd-2.2.12/imap/mbexamine.c
--- cyrus-imapd-2.2.12.orig/imap/mbexamine.c 2004-12-17 17:32:16.000000000 +0100
+++ cyrus-imapd-2.2.12/imap/mbexamine.c 2006-04-25 07:35:25.000000000 +0200
@@ -266,7 +266,7 @@
printf(" Minor Version: %d\n", mailbox.minor_version);
printf(" Header Size: %ld bytes Record Size: %ld bytes\n",
mailbox.start_offset, mailbox.record_size);
- printf(" Number of Messages: %lu Mailbox Size: %lu bytes\n",
+ printf(" Number of Messages: %lu Mailbox Size: " UQUOTA_T_FMT " bytes\n",
mailbox.exists, mailbox.quota_mailbox_used);
printf(" Last Append Date: (%ld) %s", mailbox.last_appenddate,
ctime(&mailbox.last_appenddate));
diff -Naur cyrus-imapd-2.2.12.orig/imap/quota.c cyrus-imapd-2.2.12/imap/quota.c
--- cyrus-imapd-2.2.12.orig/imap/quota.c 2004-06-30 21:23:26.000000000 +0200
+++ cyrus-imapd-2.2.12/imap/quota.c 2006-04-25 07:35:25.000000000 +0200
@@ -120,7 +120,7 @@
struct quota quota;
int refcount;
int deleted;
- unsigned long newused;
+ uquota_t newused;
};
#define QUOTAGROW 300
@@ -251,7 +251,7 @@
}
memset(&quota[quota_num], 0, sizeof(struct quotaentry));
quota[quota_num].quota.root = xstrndup(key, keylen);
- sscanf(data, "%lu %d",
+ sscanf(data, UQUOTA_T_FMT " %d",
&quota[quota_num].quota.used, &quota[quota_num].quota.limit);
quota_num++;
@@ -422,7 +422,7 @@
(*count)++;
}
if (quota[thisquota].quota.used != quota[thisquota].newused) {
- printf("%s: usage was %lu, now %lu\n", quota[thisquota].quota.root,
+ printf("%s: usage was " UQUOTA_T_FMT ", now " UQUOTA_T_FMT "\n", quota[thisquota].quota.root,
quota[thisquota].quota.used, quota[thisquota].newused);
quota[thisquota].quota.used = quota[thisquota].newused;
r = quota_write(&quota[thisquota].quota, tid);
@@ -489,12 +489,12 @@
int i;
char buf[MAX_MAILBOX_PATH+1];
- printf(" Quota %% Used Used Root\n");
+ printf(" Quota %% Used Used Root\n");
for (i = 0; i < quota_num; i++) {
if (quota[i].deleted) continue;
if (quota[i].quota.limit > 0) {
- printf(" %7d %7ld", quota[i].quota.limit,
+ printf(" %7d " QUOTA_REPORT_FMT , quota[i].quota.limit,
((quota[i].quota.used / QUOTA_UNITS) * 100) / quota[i].quota.limit);
}
else if (quota[i].quota.limit == 0) {
@@ -507,6 +507,6 @@
(*quota_namespace.mboxname_toexternal)(&quota_namespace,
quota[i].quota.root,
"cyrus", buf);
- printf(" %7ld %s\n", quota[i].quota.used / QUOTA_UNITS, buf);
+ printf(" " QUOTA_REPORT_FMT " %s\n", quota[i].quota.used / QUOTA_UNITS, buf);
}
}
diff -Naur cyrus-imapd-2.2.12.orig/imap/quota_db.c cyrus-imapd-2.2.12/imap/quota_db.c
--- cyrus-imapd-2.2.12.orig/imap/quota_db.c 2004-05-22 05:45:52.000000000 +0200
+++ cyrus-imapd-2.2.12/imap/quota_db.c 2006-04-25 07:35:25.000000000 +0200
@@ -89,7 +89,7 @@
switch (r) {
case CYRUSDB_OK:
- sscanf(data, "%lu %d", &quota->used, &quota->limit);
+ sscanf(data, UQUOTA_T_FMT " %d", &quota->used, &quota->limit);
break;
case CYRUSDB_AGAIN:
@@ -151,7 +151,7 @@
if (!qrlen) return IMAP_QUOTAROOT_NONEXISTENT;
len = snprintf(buf, sizeof(buf) - 1,
- "%lu %d", quota->used, quota->limit);
+ UQUOTA_T_FMT " %d", quota->used, quota->limit);
r = QDB->store(qdb, quota->root, qrlen, buf, len, tid);
switch (r) {
diff -Naur cyrus-imapd-2.2.12.orig/imap/quota.h cyrus-imapd-2.2.12/imap/quota.h
--- cyrus-imapd-2.2.12.orig/imap/quota.h 2004-02-27 18:44:56.000000000 +0100
+++ cyrus-imapd-2.2.12/imap/quota.h 2006-04-25 07:35:25.000000000 +0200
@@ -45,18 +45,37 @@
#define INCLUDED_QUOTA_H
#include "cyrusdb.h"
+#include <config.h>
#define FNAME_QUOTADB "/quotas.db"
#define QUOTA_UNITS (1024)
+/* Define the proper quota type, it should either be a
+ * long or a long long int depending upon what the
+ * the compiler supports.
+ */
+#ifdef HAVE_LONG_LONG_INT
+typedef unsigned long long int uquota_t;
+typedef long long int quota_t;
+#define UQUOTA_T_FMT "%llu"
+#define QUOTA_T_FMT "%lld"
+#define QUOTA_REPORT_FMT "%8llu"
+#else
+typedef unsigned long uquota_t;
+typedef long quota_t;
+#define UQUOTA_T_FMT "%lu"
+#define QUOTA_T_FMT "%ld"
+#define QUOTA_REPORT_FMT "%8lu"
+#endif
+
extern struct db *qdb;
struct quota {
char *root;
/* Information in quota entry */
- unsigned long used;
+ uquota_t used;
int limit; /* in QUOTA_UNITS */
};
diff -Naur cyrus-imapd-2.2.12.orig/imap/reconstruct.c cyrus-imapd-2.2.12/imap/reconstruct.c
--- cyrus-imapd-2.2.12.orig/imap/reconstruct.c 2004-10-11 16:01:24.000000000 +0200
+++ cyrus-imapd-2.2.12/imap/reconstruct.c 2006-04-25 07:35:25.000000000 +0200
@@ -93,6 +93,7 @@
#include "retry.h"
#include "convert_code.h"
#include "util.h"
+#include "byteorder64.h"
extern int optind;
extern char *optarg;
@@ -434,7 +435,7 @@
char *list_acl, *list_part;
int list_type;
- unsigned long new_quota = 0;
+ uquota_t new_quota = 0;
struct index_record message_index, old_index;
static struct index_record zero_index;
@@ -690,7 +691,14 @@
*((bit32 *)(buf+OFFSET_EXISTS)) = htonl(new_exists);
*((bit32 *)(buf+OFFSET_LAST_APPENDDATE)) = htonl(mailbox.last_appenddate);
*((bit32 *)(buf+OFFSET_LAST_UID)) = htonl(mailbox.last_uid);
+
+ /* quotas may be 64bit now */
+#ifdef HAVE_LONG_LONG_INT
+ *((bit64 *)(buf+OFFSET_QUOTA_MAILBOX_USED64)) = htonll(new_quota);
+#else
*((bit32 *)(buf+OFFSET_QUOTA_MAILBOX_USED)) = htonl(new_quota);
+#endif
+
*((bit32 *)(buf+OFFSET_POP3_LAST_LOGIN)) = htonl(mailbox.pop3_last_login);
*((bit32 *)(buf+OFFSET_UIDVALIDITY)) = htonl(mailbox.uidvalidity);
*((bit32 *)(buf+OFFSET_DELETED)) = htonl(new_deleted);
diff -Naur cyrus-imapd-2.2.12.orig/lib/byteorder64.c cyrus-imapd-2.2.12/lib/byteorder64.c
--- cyrus-imapd-2.2.12.orig/lib/byteorder64.c 1970-01-01 01:00:00.000000000 +0100
+++ cyrus-imapd-2.2.12/lib/byteorder64.c 2006-04-25 07:35:25.000000000 +0200
@@ -0,0 +1,95 @@
+/* byteorder64.c -- convert 64-bit values between host and network byte order
+ *
+ * Copyright (c) 2004 Carnegie Mellon University. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The name "Carnegie Mellon University" must not be used to
+ * endorse or promote products derived from this software without
+ * prior written permission. For permission or any other legal
+ * details, please contact
+ * Office of Technology Transfer
+ * Carnegie Mellon University
+ * 5000 Forbes Avenue
+ * Pittsburgh, PA 15213-3890
+ * (412) 268-4387, fax: (412) 268-7395
+ * tech-transfer@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: byteorder64.c,v 1.1.2.1 2004/08/09 18:51:21 ken3 Exp $
+ */
+
+#include <config.h>
+
+#if defined(HAVE_LONG_LONG_INT) && !defined(WORDS_BIGENDIAN)
+
+#include <netinet/in.h>
+
+/* Structure used to swap the bytes in a 64-bit unsigned long long. */
+union byteswap_64_u {
+ unsigned long long a;
+ uint32_t b[2];
+};
+
+/* Function to byteswap 64bit unsigned integers on
+ * little endian machines to big endian network order.
+ * On big endian machines this will be a null macro.
+ * The macro htonll() is defined in byteorder64.h,
+ * and if needed refers to _htonll() here.
+ */
+unsigned long long _htonll(unsigned long long x)
+{
+ union byteswap_64_u u1;
+ union byteswap_64_u u2;
+
+ u1.a = x;
+
+ u2.b[0] = htonl(u1.b[1]);
+ u2.b[1] = htonl(u1.b[0]);
+
+ return u2.a;
+}
+
+
+/* Function to byteswap big endian 64bit unsigned integers
+ * back to little endian host order on little endian machines.
+ * As above, on big endian machines this will be a null macro.
+ * The macro ntohll() is defined in byteorder64.h, and if needed,
+ * refers to _ntohll() here.
+ */
+unsigned long long _ntohll(unsigned long long x)
+{
+ union byteswap_64_u u1;
+ union byteswap_64_u u2;
+
+ u1.a = x;
+
+ u2.b[1] = ntohl(u1.b[0]);
+ u2.b[0] = ntohl(u1.b[1]);
+
+ return u2.a;
+}
+
+#endif /* defined(HAVE_LONG_LONG_INT) && !defined(WORDS_BIGENDIAN) */
diff -Naur cyrus-imapd-2.2.12.orig/lib/byteorder64.h cyrus-imapd-2.2.12/lib/byteorder64.h
--- cyrus-imapd-2.2.12.orig/lib/byteorder64.h 1970-01-01 01:00:00.000000000 +0100
+++ cyrus-imapd-2.2.12/lib/byteorder64.h 2006-04-25 07:35:25.000000000 +0200
@@ -0,0 +1,65 @@
+/* byteorder64.h -- convert 64-bit values between host and network byte order
+ *
+ * Copyright (c) 2004 Carnegie Mellon University. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The name "Carnegie Mellon University" must not be used to
+ * endorse or promote products derived from this software without
+ * prior written permission. For permission or any other legal
+ * details, please contact
+ * Office of Technology Transfer
+ * Carnegie Mellon University
+ * 5000 Forbes Avenue
+ * Pittsburgh, PA 15213-3890
+ * (412) 268-4387, fax: (412) 268-7395
+ * tech-transfer@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: byteorder64.h,v 1.1.2.2 2004/08/16 11:44:34 ken3 Exp $
+ */
+
+#ifndef _BYTEORDER64_H
+#define _BYTEORDER64_H
+
+#include <config.h>
+
+#ifdef HAVE_LONG_LONG_INT
+
+/* 64-bit host/network byte-order swap macros */
+#ifdef WORDS_BIGENDIAN
+#define htonll(x) (x)
+#define ntohll(x) (x)
+#else
+#define htonll(x) _htonll(x)
+#define ntohll(x) _ntohll(x)
+
+/* little-endian 64-bit host/network byte-order swap functions */
+extern unsigned long long _htonll(unsigned long long);
+extern unsigned long long _ntohll(unsigned long long);
+
+#endif /* WORDS_BIGENDIAN */
+#endif /* HAVE_LONG_LONG_INT */
+#endif /* _BYTEORDER64_H */
diff -Naur cyrus-imapd-2.2.12.orig/lib/Makefile.in cyrus-imapd-2.2.12/lib/Makefile.in
--- cyrus-imapd-2.2.12.orig/lib/Makefile.in 2004-05-28 20:03:04.000000000 +0200
+++ cyrus-imapd-2.2.12/lib/Makefile.in 2006-04-25 07:35:25.000000000 +0200
@@ -85,7 +85,7 @@
$(srcdir)/lsort.h $(srcdir)/stristr.h \
$(srcdir)/util.h $(srcdir)/xmalloc.h $(srcdir)/imapurl.h \
$(srcdir)/cyrusdb.h $(srcdir)/iptostring.h $(srcdir)/rfc822date.h \
- $(srcdir)/libcyr_cfg.h
+ $(srcdir)/libcyr_cfg.h $(srcdir)/byteorder64.h
LIBCYR_OBJS = acl.o bsearch.o charset.o glob.o retry.o util.o \
libcyr_cfg.o mkgmtime.o prot.o parseaddr.o imclient.o imparse.o \
@@ -93,7 +93,7 @@
chartable.o imapurl.o nonblock_@WITH_NONBLOCK@.o lock_@WITH_LOCK@.o \
gmtoff_@WITH_GMTOFF@.o map_@WITH_MAP@.o $(ACL) $(AUTH) \
@LIBOBJS@ @CYRUSDB_OBJS@ \
- iptostring.o xmalloc.o wildmat.o
+ iptostring.o xmalloc.o wildmat.o byteorder64.o
LIBCYRM_HDRS = $(srcdir)/hash.h $(srcdir)/mpool.h $(srcdir)/xmalloc.h \
$(srcdir)/strhash.o $(srcdir)/libconfig.h $(srcdir)/assert.h \
diff -Naur cyrus-imapd-2.2.12.orig/lib/prot.c cyrus-imapd-2.2.12/lib/prot.c
--- cyrus-imapd-2.2.12.orig/lib/prot.c 2004-02-27 23:08:56.000000000 +0100
+++ cyrus-imapd-2.2.12/lib/prot.c 2006-04-25 07:35:25.000000000 +0200
@@ -894,6 +894,31 @@
prot_write(s, buf, strlen(buf));
break;
+#ifdef HAVE_LONG_LONG_INT
+ case 'l': {
+ long long int ll;
+ unsigned long long int ull;
+
+ switch (*++percent) {
+ case 'd':
+ ll = va_arg(pvar, long long int);
+ snprintf(buf, sizeof(buf), "%lld", ll);
+ prot_write(s, buf, strlen(buf));
+ break;
+
+ case 'u':
+ ull = va_arg(pvar, unsigned long long int);
+ snprintf(buf, sizeof(buf), "%llu", ull);
+ prot_write(s, buf, strlen(buf));
+ break;
+
+ default:
+ abort();
+ }
+ break;
+ }
+#endif
+
default:
abort();
}

View File

@@ -0,0 +1,24 @@
diff -urN cyrus-imapd-2.2.12~/imap/mailbox.c cyrus-imapd-2.2.12/imap/mailbox.c
--- cyrus-imapd-2.2.12~/imap/mailbox.c 2005-02-14 07:39:57.000000000 +0100
+++ cyrus-imapd-2.2.12/imap/mailbox.c 2005-08-30 12:13:34.000000000 +0200
@@ -2132,7 +2165,7 @@
r = quota_write(&mailbox->quota, &tid);
if (r) {
syslog(LOG_ERR,
- "LOSTQUOTA: unable to record free of %lu bytes in quota %s",
+ "LOSTQUOTA: unable to record free of " UQUOTA_T_FMT " bytes in quota %s",
mailbox->quota_mailbox_used, mailbox->quota.root);
}
else
diff -urN cyrus-imapd-2.2.12~/imap/mboxlist.c cyrus-imapd-2.2.12/imap/mboxlist.c
--- cyrus-imapd-2.2.12~/imap/mboxlist.c 2004-07-26 20:08:03.000000000 +0200
+++ cyrus-imapd-2.2.12/imap/mboxlist.c 2005-08-30 12:09:28.000000000 +0200
@@ -2540,7 +2540,7 @@
r = quota_write(&mailbox.quota, tid);
if (r) {
syslog(LOG_ERR,
- "LOSTQUOTA: unable to record free of %lu bytes in quota %s",
+ "LOSTQUOTA: unable to record free of " UQUOTA_T_FMT " bytes in quota %s",
mailbox.quota_mailbox_used, mailbox.quota.root);
}
free(mailbox.quota.root);

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,193 @@
diff -Naur cyrus-imapd-2.2.12/README.autosievefolder cyrus-imapd-2.2.12-autosieve.uncompiled/README.autosievefolder
--- cyrus-imapd-2.2.12/README.autosievefolder 1970-01-01 02:00:00 +0200
+++ cyrus-imapd-2.2.12-autosieve.uncompiled/README.autosievefolder 2005-02-15 13:59:51 +0200
@@ -0,0 +1,42 @@
+Cyrus IMAP autosievefolder patch
+----------------------------------
+
+NOTE : This patch has been created at the University of Athens. For more info, as well
+as more patches on Cyrus IMAPD server, please visit http://email.uoa.gr
+
+
+ When the lmtpd daemon receives an email message prior to delivering it to the
+INBOX folder of the user, checks if the user has specified sieve filters. If the
+user has specified sieve filters the filters are evaluated. If the message matches
+any of the filters the action that is specified in the filter is executed. If the action
+is FileInto it is stored in the subfolder specified in the filter. If the
+subfolder doesn't exist then the message is sent to the INBOX folder of the user.
+
+ With this patch if the folder doesn't exist AND the name of the subfolder is
+specified in the autosievefolders option, OR the anysievefolder is set to
+yes in the cyrus-imap configuration file then the subfolder is created and the mail
+is stored there.
+
+
+Check the following options of the imapd.conf file
+==================================================
+
+* anysievefolder : It must be "yes" in order to permit the autocreation of any
+INBOX subfolder requested by a sieve filter, through the "fileinto" action. (default = no)
+* autosievefolders : It is a "|" separated list of subfolders of INBOX that will be
+automatically created, if requested by a sieve filter, through the "fileinto"
+action. (default = null)
+ i.e. autosievefolders: Junk | Spam
+
+WARNING: anysievefolder, takes precedence over autosievefolders . Which means that if
+anysievefolder is set to "yes", cyrus will create any INBOX subfolder requested, no-matter what the value of autosievefolders is.
+
+
+Things to be done
+=================
+
+1. Support cyrus wildcards in the autosievefolders option.
+
+
+For more information and updates please visit http://email.uoa.gr/projects/cyrus/autosievefolder
+
diff -Naur cyrus-imapd-2.2.12/imap/lmtp_sieve.c cyrus-imapd-2.2.12-autosieve.uncompiled/imap/lmtp_sieve.c
--- cyrus-imapd-2.2.12/imap/lmtp_sieve.c 2004-06-01 16:47:16 +0300
+++ cyrus-imapd-2.2.12-autosieve.uncompiled/imap/lmtp_sieve.c 2005-02-15 13:59:51 +0200
@@ -72,6 +72,8 @@
#include "util.h"
#include "version.h"
#include "xmalloc.h"
+#include "imap_err.h"
+
static int sieve_usehomedir = 0;
static const char *sieve_dir = NULL;
@@ -98,6 +100,9 @@
int quotaoverride,
int acloverride);
+static int autosieve_subfolder(char *userid, struct auth_state *auth_state,
+ char *subfolder, struct namespace *namespace);
+
static char *make_sieve_db(const char *user)
{
static char buf[MAX_MAILBOX_PATH+1];
@@ -312,6 +317,7 @@
}
+
static int sieve_redirect(void *ac,
void *ic __attribute__((unused)),
void *sc, void *mc, const char **errmsg)
@@ -444,7 +450,18 @@
sd->username, mdata->notifyheader,
namebuf, quotaoverride, 0);
}
-
+ if (ret == IMAP_MAILBOX_NONEXISTENT) {
+ /* if "plus" folder under INBOX, then try to create it */
+ syslog(LOG_DEBUG, "calling autosieve folder for : %s", namebuf);
+ ret = autosieve_subfolder((char *) sd->username, sd->authstate, namebuf, mdata->namespace);
+
+ if (!ret)
+ ret = deliver_mailbox(md->data, mdata->stage, md->size,
+ fc->imapflags->flag, fc->imapflags->nflags,
+ (char *) sd->username, sd->authstate, md->id,
+ sd->username, mdata->notifyheader,
+ namebuf, quotaoverride, 0);
+ }
if (!ret) {
snmp_increment(SIEVE_FILEINTO, 1);
return SIEVE_OK;
@@ -882,3 +899,77 @@
return r;
}
+
+
+#define SEP '|'
+
+static int autosieve_subfolder(char *userid, struct auth_state *auth_state,
+ char *subfolder, struct namespace *namespace)
+{
+ char option_name_external[MAX_MAILBOX_NAME + 1];
+ char option_name_internal[MAX_MAILBOX_NAME + 1];
+ const char *subf ;
+ char *p, *q, *next_subf;
+ int len, r = 0;
+ int createsievefolder = 0;
+
+ /* Check if subfolder or userid are NULL */
+ if(subfolder == NULL || userid == NULL)
+ return IMAP_MAILBOX_NONEXISTENT;
+
+ if (config_getswitch(IMAPOPT_ANYSIEVEFOLDER))
+ createsievefolder = 1;
+ else if ((subf = config_getstring(IMAPOPT_AUTOSIEVEFOLDERS)) != NULL) {
+ /* Roll through subf */
+ next_subf = (char *) subf;
+ while (*next_subf) {
+ for (p = next_subf ; isspace((int) *p) || *p == SEP ; p++);
+ for (next_subf = p ; *next_subf && *next_subf != SEP ; next_subf++);
+ for (q = next_subf ; q > p && (isspace((int) *q) || *q == SEP || !*q); q--);
+
+ if (!*p) continue;
+
+ len = q - p + 1;
+ /*
+ * This is a preliminary length check based on the assumption
+ * that the *final* internal format will be something
+ * like user.userid.subfolder(s).
+ */
+ if (len > sizeof(option_name_external) - strlen(userid) - 5)
+ return IMAP_MAILBOX_BADNAME;
+
+ strlcpy(option_name_external, namespace->prefix[NAMESPACE_INBOX], sizeof(option_name_external));
+ strncat(option_name_external, p, len);
+
+ /*
+ * Transform the option folder name to internal namespace and compare it
+ * with what must be created.
+ */
+ r = namespace->mboxname_tointernal(namespace, option_name_external, userid, option_name_internal);
+ if (r) continue;
+
+ if (!strcmp(option_name_internal, subfolder)) {
+ createsievefolder = 1;
+ break;
+ }
+ }
+ }
+
+ if (createsievefolder) {
+ /* Folder is already in internal namespace format */
+ r = mboxlist_createmailbox(subfolder, MAILBOX_FORMAT_NORMAL, NULL,
+ 1, userid, auth_state, 0, 0, 0);
+ if (!r) {
+ mboxlist_changesub(subfolder, userid, auth_state, 1, 1);
+ syslog(LOG_DEBUG, "autosievefolder: User %s, folder %s creation succeeded.",
+ userid, subfolder);
+ return 0;
+ } else {
+ syslog(LOG_ERR, "autosievefolder: User %s, folder %s creation failed. %s",
+ userid, subfolder,error_message(r));
+ return r;
+ }
+ } else
+ return IMAP_MAILBOX_NONEXISTENT;
+}
+
diff -Naur cyrus-imapd-2.2.12/lib/imapoptions cyrus-imapd-2.2.12-autosieve.uncompiled/lib/imapoptions
--- cyrus-imapd-2.2.12/lib/imapoptions 2004-07-21 22:07:45 +0300
+++ cyrus-imapd-2.2.12-autosieve.uncompiled/lib/imapoptions 2005-02-15 13:59:51 +0200
@@ -752,6 +752,15 @@
/* If enabled, lmtpd will look for Sieve scripts in user's home
directories: ~user/.sieve. */
+{ "anysievefolder", 0, SWITCH }
+/* It must be "yes" in order to permit the autocreation of any INBOX subfolder
+ requested by a sieve filter, through the "fileinto" action. (default = no) */
+
+{ "autosievefolders", NULL, STRING }
+/* It is a "|" separated list of subfolders of INBOX that will be automatically created,
+ if requested by a sieve filter, through the "fileinto" action. (default = null)
+ i.e. autosievefolders: Junk | Spam */
+
{ "singleinstancestore", 1, SWITCH }
/* If enabled, lmtpd and nntpd attempt to only write one copy of a message per
partition and create hard links, resulting in a potentially large

View File

@@ -0,0 +1,48 @@
--- tools/config2header 2005/04/13 08:56:16 1.1
+++ tools/config2header 2005/04/13 08:57:48
@@ -214,7 +214,6 @@
print HFILE <<EOF
IMAPOPT_LAST
};
-extern struct imapopt_s imapopts[];
enum enum_value {
IMAP_ENUM_ZERO = 0,
@@ -260,6 +259,9 @@
print HFILE <<EOF
};
+
+extern struct imapopt_s imapopts[];
+
#endif /* INCLUDED_IMAPOPTIONS_H */
EOF
;
--- imap/fud.c 2005/04/13 09:19:05 1.1
+++ imap/fud.c 2005/04/13 09:20:02
@@ -202,6 +202,7 @@
r = begin_handling();
shut_down(r);
+ return 0;
}
static void cyrus_timeout(int signo __attribute__((unused)))
--- imap/smmapd.c 2005/04/13 09:19:12 1.1
+++ imap/smmapd.c 2005/04/13 09:19:50
@@ -199,6 +199,7 @@
r = begin_handling();
shut_down(r);
+ return 0;
}
int verify_user(const char *key, long quotacheck,
--- notifyd/notifyd.c 2005/04/13 09:19:23 1.1
+++ notifyd/notifyd.c 2005/04/13 09:19:39
@@ -266,4 +266,5 @@
r = do_notify();
shut_down(r);
+ return 0;
}

View File

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

View File

@@ -0,0 +1,41 @@
diff -Naur cyrus-imapd-2.2.12.orig/imap/mupdate.c cyrus-imapd-2.2.12/imap/mupdate.c
--- cyrus-imapd-2.2.12.orig/imap/mupdate.c 2004-12-17 17:32:16.000000000 +0100
+++ cyrus-imapd-2.2.12/imap/mupdate.c 2005-11-04 14:24:04.000000000 +0100
@@ -460,9 +460,36 @@
return 0;
}
+
+/*
+ * The auth_*.c backends called by mysasl_proxy_policy()
+ * use static variables which we need to protect with a mutex.
+ */
+static pthread_mutex_t proxy_policy_mutex = PTHREAD_MUTEX_INITIALIZER;
+
+static int mupdate_proxy_policy(sasl_conn_t *conn,
+ void *context,
+ const char *requested_user, unsigned rlen,
+ const char *auth_identity, unsigned alen,
+ const char *def_realm,
+ unsigned urlen,
+ struct propctx *propctx)
+{
+ int r;
+
+ pthread_mutex_lock(&proxy_policy_mutex); /* LOCK */
+
+ r = mysasl_proxy_policy(conn, context, requested_user, rlen,
+ auth_identity, alen, def_realm, urlen, propctx);
+
+ pthread_mutex_unlock(&proxy_policy_mutex); /* UNLOCK */
+
+ return r;
+}
+
static struct sasl_callback mysasl_cb[] = {
{ SASL_CB_GETOPT, &mysasl_config, NULL },
- { SASL_CB_PROXY_POLICY, &mysasl_proxy_policy, NULL },
+ { SASL_CB_PROXY_POLICY, &mupdate_proxy_policy, NULL },
{ SASL_CB_LIST_END, NULL, NULL }
};

View File

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

View File

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

View File

@@ -0,0 +1,491 @@
diff -Naur cyrus-imapd-2.2.12.orig/imap/ctl_cyrusdb.c cyrus-imapd-2.2.12/imap/ctl_cyrusdb.c
--- cyrus-imapd-2.2.12.orig/imap/ctl_cyrusdb.c Tue Jul 13 04:34:20 2004
+++ cyrus-imapd-2.2.12/imap/ctl_cyrusdb.c Mon Mar 7 11:30:58 2005
@@ -136,7 +136,7 @@
/* if it is MBTYPE_RESERVED, unset it & call mboxlist_delete */
if(!r && (mbtype & MBTYPE_RESERVE)) {
if(!r) {
- r = mboxlist_deletemailbox(name, 1, NULL, NULL, 0, 0, 1);
+ r = mboxlist_deletemailbox(name, 1, NULL, NULL, 0, 0, 1, 1);
if(r) {
/* log the error */
syslog(LOG_ERR,
diff -Naur cyrus-imapd-2.2.12.orig/imap/ctl_mboxlist.c cyrus-imapd-2.2.12/imap/ctl_mboxlist.c
--- cyrus-imapd-2.2.12.orig/imap/ctl_mboxlist.c Sat May 22 05:45:48 2004
+++ cyrus-imapd-2.2.12/imap/ctl_mboxlist.c Mon Mar 7 11:30:58 2005
@@ -456,7 +456,7 @@
wipe_head = wipe_head->next;
- ret = mboxlist_deletemailbox(me->mailbox, 1, "", NULL, 0, 1, 1);
+ ret = mboxlist_deletemailbox(me->mailbox, 1, "", NULL, 0, 1, 1, 1);
if(ret) {
fprintf(stderr, "couldn't delete defunct mailbox %s\n",
me->mailbox);
diff -Naur cyrus-imapd-2.2.12.orig/imap/imapd.c cyrus-imapd-2.2.12/imap/imapd.c
--- cyrus-imapd-2.2.12.orig/imap/imapd.c Mon Feb 14 07:39:55 2005
+++ cyrus-imapd-2.2.12/imap/imapd.c Mon Mar 7 11:30:58 2005
@@ -3724,7 +3724,7 @@
r = mboxlist_deletemailbox(name, imapd_userisadmin,
imapd_userid, imapd_authstate,
- 0, 0, 0);
+ 0, 0, 0, 1);
if(r) {
prot_printf(imapd_out, "* NO delete %s: %s\r\n",
@@ -3743,6 +3743,12 @@
char mailboxname[MAX_MAILBOX_NAME+1];
char *p;
int domainlen = 0;
+ int keepQuota = 1;
+
+ if(name && *name == '+') {
+ keepQuota = 0;
+ name++;
+ }
r = (*imapd_namespace.mboxname_tointernal)(&imapd_namespace, name,
imapd_userid, mailboxname);
@@ -3753,7 +3759,7 @@
r = mboxlist_deletemailbox(mailboxname, imapd_userisadmin,
imapd_userid, imapd_authstate, 1,
- localonly, 0);
+ localonly, 0, keepQuota);
}
/* was it a top-level user mailbox? */
@@ -4718,6 +4724,7 @@
{
int newquota = -1;
int badresource = 0;
+ int rmquota = 0;
int c;
int force = 0;
static struct buf arg;
@@ -4732,7 +4739,8 @@
if (c != ')' || arg.s[0] != '\0') {
for (;;) {
if (c != ' ') goto badlist;
- if (strcasecmp(arg.s, "storage") != 0) badresource = 1;
+ if (strcasecmp(arg.s, "remove") == 0) rmquota = 1;
+ else if (strcasecmp(arg.s, "storage") != 0) badresource = 1;
c = getword(imapd_in, &arg);
if (c != ' ' && c != ')') goto badlist;
if (arg.s[0] == '\0') goto badlist;
@@ -4769,7 +4777,10 @@
imapd_userid, mailboxname);
if (!r) {
- r = mboxlist_setquota(mailboxname, newquota, force);
+ if(!rmquota)
+ r = mboxlist_setquota(mailboxname, newquota, force);
+ else
+ r = mboxlist_unsetquota(mailboxname);
}
}
@@ -6416,7 +6427,7 @@
/* note also that we need to remember to let proxyadmins do this */
r = mboxlist_deletemailbox(mailboxname,
imapd_userisadmin || imapd_userisproxyadmin,
- imapd_userid, imapd_authstate, 0, 1, 0);
+ imapd_userid, imapd_authstate, 0, 1, 0, 1);
if(r) syslog(LOG_ERR,
"Could not delete local mailbox during move of %s",
mailboxname);
diff -Naur cyrus-imapd-2.2.12.orig/imap/mailbox.c cyrus-imapd-2.2.12/imap/mailbox.c
--- cyrus-imapd-2.2.12.orig/imap/mailbox.c Mon Feb 14 07:39:57 2005
+++ cyrus-imapd-2.2.12/imap/mailbox.c Mon Mar 7 11:30:58 2005
@@ -2117,27 +2117,7 @@
seen_delete_mailbox(mailbox);
- if (delete_quota_root && !rquota) {
- quota_delete(&mailbox->quota, &tid);
- free(mailbox->quota.root);
- mailbox->quota.root = NULL;
- } else if (!rquota) {
- /* Free any quota being used by this mailbox */
- if (mailbox->quota.used >= mailbox->quota_mailbox_used) {
- mailbox->quota.used -= mailbox->quota_mailbox_used;
- }
- else {
- mailbox->quota.used = 0;
- }
- r = quota_write(&mailbox->quota, &tid);
- if (r) {
- syslog(LOG_ERR,
- "LOSTQUOTA: unable to record free of %lu bytes in quota %s",
- mailbox->quota_mailbox_used, mailbox->quota.root);
- }
- else
- quota_commit(&tid);
- }
+ mailbox_updatequota(mailbox,NULL);
/* remove all files in directory */
strlcpy(buf, mailbox->path, sizeof(buf));
@@ -2751,3 +2731,49 @@
if (*p == '.') *p = '/';
}
}
+
+
+/* This function is used to update the quota. Can be used to replace
+ * identical parts of the code, and can be quite handy some times
+ * The tid is used in order to make possible to make the quota update
+ * being a part of a bigger transaction to the quota db */
+int mailbox_updatequota(struct mailbox *mailbox, struct txn **tid)
+{
+ int r = 0, havetid = 0;
+ struct txn **ltid = NULL;
+
+ if(tid) {
+ ltid = tid;
+ havetid = 1;
+ }
+ /* Ensure that we are locked */
+ if(!mailbox->header_lock_count) return IMAP_INTERNAL;
+
+
+ if(mailbox->quota.root) {
+ r = quota_read(&mailbox->quota, ltid, 1);
+ if( r == 0 ) {
+ if (mailbox->quota.used >= mailbox->quota_mailbox_used) {
+ mailbox->quota.used -= mailbox->quota_mailbox_used;
+ }
+ else {
+ mailbox->quota.used = 0;
+ }
+ r = quota_write(&mailbox->quota, ltid);
+ if (r) {
+ syslog(LOG_ERR,
+ "LOSTQUOTA: unable to record free of %lu bytes in quota %s",
+ mailbox->quota_mailbox_used, mailbox->quota.root);
+ }
+ else if(!havetid)
+ quota_commit(tid);
+ }
+ /* It is not a big mistake not to have quota .. just remove from the mailbox */
+ else if ( r == IMAP_QUOTAROOT_NONEXISTENT) {
+ free(mailbox->quota.root);
+ r = 0;
+ }
+ }
+ return r;
+}
+
diff -Naur cyrus-imapd-2.2.12.orig/imap/mailbox.h cyrus-imapd-2.2.12/imap/mailbox.h
--- cyrus-imapd-2.2.12.orig/imap/mailbox.h Thu Jan 22 22:17:09 2004
+++ cyrus-imapd-2.2.12/imap/mailbox.h Mon Mar 7 11:30:58 2005
@@ -305,6 +305,8 @@
struct mailbox *mailboxp);
extern int mailbox_delete(struct mailbox *mailbox, int delete_quota_root);
+extern int mailbox_updatequota(struct mailbox *mailbox, struct txn **tid);
+
extern int mailbox_rename_copy(struct mailbox *oldmailbox,
const char *newname, char *newpath,
bit32 *olduidvalidityp, bit32 *newuidvalidityp,
diff -Naur cyrus-imapd-2.2.12.orig/imap/mboxlist.c cyrus-imapd-2.2.12/imap/mboxlist.c
--- cyrus-imapd-2.2.12.orig/imap/mboxlist.c Mon Jul 26 20:08:03 2004
+++ cyrus-imapd-2.2.12/imap/mboxlist.c Mon Mar 7 11:30:58 2005
@@ -93,6 +93,11 @@
static int mboxlist_opensubs();
static void mboxlist_closesubs();
+static int child_cb(char *name,
+ int matchlen __attribute__((unused)),
+ int maycreate __attribute__((unused)),
+ void *rock);
+
static int mboxlist_rmquota(const char *name, int matchlen, int maycreate,
void *rock);
static int mboxlist_changequota(const char *name, int matchlen, int maycreate,
@@ -100,6 +105,7 @@
struct change_rock {
struct quota *quota;
+ struct quota *oldquota;
struct txn **tid;
};
@@ -893,9 +899,9 @@
*/
int mboxlist_deletemailbox(const char *name, int isadmin, char *userid,
struct auth_state *auth_state, int checkacl,
- int local_only, int force)
+ int local_only, int force, int keepQuota)
{
- int r;
+ int r, has_children = 0;
char *acl;
long access;
struct mailbox mailbox;
@@ -907,6 +913,7 @@
int deleteright = get_deleteright();
const char *p;
mupdate_handle *mupdate_h = NULL;
+ char *quotaroot = NULL;
if(!isadmin && force) return IMAP_PERMISSION_DENIED;
@@ -1018,13 +1025,44 @@
if ((r && !force) || isremote) goto done;
- if (!r || force) r = mailbox_delete(&mailbox, deletequotaroot);
+ if (!r || force) {
+ /* first we have to keep the previous quota root in order to delete it */
+ if(mailbox.quota.root)
+ quotaroot = xstrdup(mailbox.quota.root);
+ r = mailbox_delete(&mailbox, deletequotaroot);
+ }
/*
* See if we have to remove mailbox's quota root
*/
- if (!r && mailbox.quota.root != NULL) {
+ if (!r && quotaroot != NULL) {
/* xxx look for any other mailboxes in this quotaroot */
+ /* If we have not asked to remove the quota (default behaviour), we check
+ * whether there are any subfolders beneeth the quota root. If there aren't
+ * any subfolders the reasonable thing is to delete the quota */
+ if(keepQuota) {
+ char pattern[MAX_MAILBOX_PATH+1];
+ strlcpy(pattern, quotaroot, sizeof(pattern));
+ if (config_virtdomains && name[strlen(name)-1] == '!') {
+ strlcat(pattern, "*", sizeof(pattern));
+ }
+ else {
+ strlcat(pattern, ".*", sizeof(pattern));
+ }
+ /* find if there are subfolders. Then we want to
+ * keep the existing quota */
+ mboxlist_findall(NULL, pattern, isadmin, userid,
+ auth_state, child_cb, (void *) &has_children);
+
+ if(!has_children)
+ if(!mboxlist_mylookup(quotaroot, NULL, NULL, NULL, NULL, NULL, 0 ))
+ has_children = 1;
+ }
+ /* If we want to remove the quota explicitely or the quota root folder has no subfolders
+ * we execute the rmquota patch */
+ if(!keepQuota || !has_children )
+ mboxlist_unsetquota(quotaroot);
+ free(quotaroot);
}
done:
@@ -2357,6 +2395,7 @@
if (r) return r;
crock.quota = &quota;
+ crock.oldquota = NULL;
crock.tid = &tid;
/* top level mailbox */
if(have_mailbox)
@@ -2375,17 +2414,21 @@
*/
int mboxlist_unsetquota(const char *root)
{
+ char newquota[MAX_MAILBOX_PATH+1];
char pattern[MAX_MAILBOX_PATH+1];
struct quota quota;
- int r=0;
+ struct change_rock crock;
+ int r=0, k=0;
if (!root[0] || root[0] == '.' || strchr(root, '/')
|| strchr(root, '*') || strchr(root, '%') || strchr(root, '?')) {
return IMAP_MAILBOX_BADNAME;
}
+
+ crock.tid=NULL;
quota.root = (char *) root;
- r = quota_read(&quota, NULL, 0);
+ r = quota_read(&quota, crock.tid, 0);
if (r == IMAP_QUOTAROOT_NONEXISTENT) {
/* already unset */
return 0;
@@ -2402,13 +2445,45 @@
}
else
strlcat(pattern, ".*", sizeof(pattern));
-
- /* top level mailbox */
- mboxlist_rmquota(root, 0, 0, (void *)root);
- /* submailboxes - we're using internal names here */
- mboxlist_findall(NULL, pattern, 1, 0, 0, mboxlist_rmquota, (void *)root);
- r = quota_delete(&quota, NULL);
+ r = quota_delete(&quota, crock.tid);
+
+ /* If we cannot delete the quota then abort the operation */
+ if(!r) {
+ /* quota_findroot performs several checks that we can
+ * assume that are already done, and don't have to perform
+ * them again. One of them is that it returns 1 only if
+ * quotaroot exists.
+ */
+ if(quota_findroot(newquota, sizeof(newquota), root)) {
+ struct quota rootquota;
+ rootquota.root = newquota;
+ k = quota_read(&rootquota, crock.tid, 0);
+ if (!k) {
+ crock.quota = &rootquota;
+ crock.oldquota = &quota;
+ /* top level mailbox */
+ k = mboxlist_changequota(root, 0, 0, &crock);
+ }
+ /* submailboxes - we're using internal names here */
+ if (!k)
+ k = mboxlist_findall(NULL, pattern, 1, 0, 0, mboxlist_changequota, &crock);
+ if(!k)
+ k = quota_write(&rootquota, crock.tid);
+
+ }
+ else {
+ /* top level mailbox */
+ mboxlist_rmquota(root, 0, 0, (void *)root);
+ /* submailboxes - we're using internal names here */
+ mboxlist_findall(NULL, pattern, 1, 0, 0, mboxlist_rmquota, (void *)root);
+ }
+ }
+
+ if(!r && !k)
+ quota_commit(crock.tid);
+ else
+ quota_abort(crock.tid);
return r;
}
@@ -2506,6 +2581,7 @@
struct mailbox mailbox;
struct change_rock *crock = (struct change_rock *) rock;
struct quota *mboxlist_newquota = crock->quota;
+ struct quota *mboxlist_oldquota = crock->oldquota;
struct txn **tid = crock->tid;
assert(rock != NULL);
@@ -2523,27 +2599,24 @@
if (r) goto error;
if (mailbox.quota.root) {
- if (strlen(mailbox.quota.root) >= strlen(mboxlist_newquota->root)) {
- /* Part of a child quota root */
- mailbox_close(&mailbox);
- return 0;
- }
-
- r = quota_read(&mailbox.quota, tid, 1);
- if (r) goto error;
- if (mailbox.quota.used >= mailbox.quota_mailbox_used) {
- mailbox.quota.used -= mailbox.quota_mailbox_used;
- }
- else {
- mailbox.quota.used = 0;
- }
- r = quota_write(&mailbox.quota, tid);
- if (r) {
- syslog(LOG_ERR,
- "LOSTQUOTA: unable to record free of %lu bytes in quota %s",
- mailbox.quota_mailbox_used, mailbox.quota.root);
- }
- free(mailbox.quota.root);
+ if(mboxlist_oldquota) {
+ if (strlen(mailbox.quota.root) > strlen(mboxlist_oldquota->root)) {
+ /* Part of a child quota root */
+ mailbox_close(&mailbox);
+ return 0;
+ }
+ }
+ else {
+ if (strlen(mailbox.quota.root) >= strlen(mboxlist_newquota->root)) {
+ /* Part of a child quota root */
+ mailbox_close(&mailbox);
+ return 0;
+ }
+ }
+
+ r = mailbox_updatequota(&mailbox,tid);
+ if (r)
+ goto error;
}
mailbox.quota.root = xstrdup(mboxlist_newquota->root);
@@ -2553,18 +2626,24 @@
mboxlist_newquota->used += mailbox.quota_mailbox_used;
mailbox_close(&mailbox);
return 0;
-
+
error:
mailbox_close(&mailbox);
+ syslog(LOG_ERR, "LOSTQUOTA: unable to change quota root for %s to %s: %s. \
+ Command aborted. Run reconstruct to make sure mailboxes \
+ are in consistent state",
+ name, mboxlist_newquota->root, error_message(r));
+ return 1;
error_noclose:
syslog(LOG_ERR, "LOSTQUOTA: unable to change quota root for %s to %s: %s",
- name, mboxlist_newquota->root, error_message(r));
+ name, mboxlist_newquota->root, error_message(r));
/* Note, we're a callback, and it's not a huge tragedy if we
* fail, so we don't ever return a failure */
return 0;
}
+
/* must be called after cyrus_init */
void mboxlist_init(int myflags)
{
diff -Naur cyrus-imapd-2.2.12.orig/imap/mboxlist.h cyrus-imapd-2.2.12/imap/mboxlist.h
--- cyrus-imapd-2.2.12.orig/imap/mboxlist.h Wed Mar 17 19:07:49 2004
+++ cyrus-imapd-2.2.12/imap/mboxlist.h Mon Mar 7 11:30:58 2005
@@ -122,7 +122,7 @@
* the planet */
int mboxlist_deletemailbox(const char *name, int isadmin, char *userid,
struct auth_state *auth_state, int checkacl,
- int local_only, int force);
+ int local_only, int force, int keepQuota);
/* Rename/move a mailbox (hierarchical) */
int mboxlist_renamemailbox(char *oldname, char *newname, char *partition,
diff -Naur cyrus-imapd-2.2.12.orig/imap/mupdate.c cyrus-imapd-2.2.12/imap/mupdate.c
--- cyrus-imapd-2.2.12.orig/imap/mupdate.c Fri Dec 17 17:32:16 2004
+++ cyrus-imapd-2.2.12/imap/mupdate.c Mon Mar 7 11:30:58 2005
@@ -2190,7 +2190,7 @@
remote_boxes.head = r->next;
} else if (ret < 0) {
/* Local without corresponding remote, delete it */
- mboxlist_deletemailbox(l->mailbox, 1, "", NULL, 0, 0, 0);
+ mboxlist_deletemailbox(l->mailbox, 1, "", NULL, 0, 0, 0, 1);
local_boxes.head = l->next;
} else /* (ret > 0) */ {
/* Remote without corresponding local, insert it */
@@ -2205,7 +2205,7 @@
if(l && !r) {
/* we have more deletes to do */
while(l) {
- mboxlist_deletemailbox(l->mailbox, 1, "", NULL, 0, 0, 0);
+ mboxlist_deletemailbox(l->mailbox, 1, "", NULL, 0, 0, 0, 1);
local_boxes.head = l->next;
l = local_boxes.head;
}
diff -Naur cyrus-imapd-2.2.12.orig/imap/nntpd.c cyrus-imapd-2.2.12/imap/nntpd.c
--- cyrus-imapd-2.2.12.orig/imap/nntpd.c Fri Jan 7 21:59:04 2005
+++ cyrus-imapd-2.2.12/imap/nntpd.c Mon Mar 7 11:30:58 2005
@@ -3298,7 +3298,7 @@
/* XXX should we delete right away, or wait until empty? */
r = mboxlist_deletemailbox(mailboxname, 0,
- newsmaster, newsmaster_authstate, 1, 0, 0);
+ newsmaster, newsmaster_authstate, 1, 0, 0, 1);
return r;
}

View File

@@ -0,0 +1,163 @@
# Small patch to Cyrus IMAP 2.2.12 which modifies \Seen state handling to
# make it compatible with Outlook Express. OE makes two connections to a
# given mailfolder: one generates indexes while the other fetches messages.
# Unfortunately it gets confused if \Seen updates caused by the message
# stream aren't immediately flushed and picked up by the index stream.
#
# Apparently Mozilla Thunderbird has the same problem.
#
# This patch is a 2.2.12 port from the patch found here:
# http://www-uxsup.csx.cam.ac.uk/~dpc22/cyrus/patches/2.1.16/seenstate.patch
#
diff -Naur cyrus-imapd-2.2.12.orig/imap/imapd.c cyrus-imapd-2.2.12/imap/imapd.c
--- cyrus-imapd-2.2.12.orig/imap/imapd.c 2005-02-14 07:39:55.000000000 +0100
+++ cyrus-imapd-2.2.12/imap/imapd.c 2006-01-04 07:41:45.000000000 +0100
@@ -3095,6 +3095,10 @@
snprintf(mytime, sizeof(mytime), "%2.3f",
(clock() - start) / (double) CLOCKS_PER_SEC);
+ /* Checkpoint \Seen immediately after each FETCH completes. Checks for
+ * changes from other processes at the same time */
+ index_check_existing(imapd_mailbox, usinguid, 1);
+
if (r) {
prot_printf(imapd_out, "%s NO %s (%s sec)\r\n", tag,
error_message(r), mytime);
@@ -3219,7 +3223,8 @@
index_fetch(imapd_mailbox, msgno, 0, &fetchargs, &fetchedsomething);
- index_check(imapd_mailbox, 0, 0);
+ /* Vanilla index_check() can generate illegal EXPUNGE events */
+ index_check_existing(imapd_mailbox, 0, 1);
if (fetchedsomething) {
prot_printf(imapd_out, "%s OK %s\r\n", tag,
@@ -3352,7 +3357,9 @@
flag, nflags);
if (usinguid) {
- index_check(imapd_mailbox, 1, 0);
+ index_check(imapd_mailbox, 1, 1); /* Check \Seen too */
+ } else {
+ index_check_existing(imapd_mailbox, 0, 1);
}
if (r) {
diff -Naur cyrus-imapd-2.2.12.orig/imap/imapd.h cyrus-imapd-2.2.12/imap/imapd.h
--- cyrus-imapd-2.2.12.orig/imap/imapd.h 2004-06-22 23:36:18.000000000 +0200
+++ cyrus-imapd-2.2.12/imap/imapd.h 2006-01-04 07:41:45.000000000 +0100
@@ -232,6 +232,8 @@
extern void index_operatemailbox(struct mailbox *mailbox);
extern void index_check(struct mailbox *mailbox, int usinguid,
int checkseen);
+extern void
+index_check_existing(struct mailbox *mailbox, int usinguid, int checkseen);
extern void index_checkseen(struct mailbox *mailbox, int quiet,
int usinguid, int oldexists);
diff -Naur cyrus-imapd-2.2.12.orig/imap/index.c cyrus-imapd-2.2.12/imap/index.c
--- cyrus-imapd-2.2.12.orig/imap/index.c 2005-02-14 17:42:08.000000000 +0100
+++ cyrus-imapd-2.2.12/imap/index.c 2006-01-04 08:08:51.000000000 +0100
@@ -425,6 +425,53 @@
}
}
+/* Nasty hack to report system + user flags updates without checking for
+ * new mail or expunge (relies on index atomic rewrite+rename for expunge).
+ *
+ * Needed to keep Outlook Express happy without breaking IMAP concurrent
+ * access regime which (quite correctly) prohibits unsolicited EXPUNGE and
+ * EXIST responses for non-UID versions of FETCH and STORE. Otherwise you
+ * can end up with hilarous situations such as:
+ *
+ * . FETCH 2 fast
+ * * EXPUNGE 1 <-- from concurrent session.
+ * . FETCH (data relating to previous message _3_, if it exists)
+ *
+ */
+
+void
+index_check_existing(struct mailbox *mailbox, int usinguid, int checkseen)
+{
+ struct stat sbuf;
+ int msgno, i;
+ bit32 user_flags[MAX_USER_FLAGS/32];
+
+ if (imapd_exists == -1)
+ return;
+
+ /* Bail out if the mailbox was rotated under our feet */
+ if ((index_len > 0) &&
+ ((stat(FNAME_INDEX+1, &sbuf) != 0) ||
+ (sbuf.st_ino != mailbox->index_ino) ||
+ (index_ino != mailbox->index_ino)))
+ return;
+
+ if (checkseen)
+ index_checkseen(mailbox, 0, usinguid, imapd_exists);
+
+ for (msgno = 1; msgno <= imapd_exists; msgno++) {
+ if (flagreport[msgno] < LAST_UPDATED(msgno)) {
+ for (i = 0; i < VECTOR_SIZE(user_flags); i++) {
+ user_flags[i] = USER_FLAGS(msgno, i);
+ }
+ index_fetchflags(mailbox, msgno, SYSTEM_FLAGS(msgno), user_flags,
+ LAST_UPDATED(msgno));
+ if (usinguid) prot_printf(imapd_out, " UID %u", UID(msgno));
+ prot_printf(imapd_out, ")\r\n");
+ }
+ }
+}
+
/*
* Checkpoint the user's \Seen state
*
@@ -458,6 +505,7 @@
char *saveseenuids, *save;
int savealloced;
unsigned start, newallseen, inrange, usecomma;
+ mailbox_notifyproc_t *updatenotifier;
if (!keepingseen || !seendb) return;
if (imapd_exists == 0) {
@@ -731,6 +779,9 @@
free(newseenuids);
seenuids = saveseenuids;
+
+ updatenotifier = mailbox_get_updatenotifier();
+ if (updatenotifier) updatenotifier(mailbox);
}
diff -Naur cyrus-imapd-2.2.12.orig/imap/mailbox.c cyrus-imapd-2.2.12/imap/mailbox.c
--- cyrus-imapd-2.2.12.orig/imap/mailbox.c 2005-02-14 07:39:57.000000000 +0100
+++ cyrus-imapd-2.2.12/imap/mailbox.c 2006-01-04 07:41:45.000000000 +0100
@@ -230,6 +230,14 @@
}
/*
+ * Get the updatenotifier function
+ */
+mailbox_notifyproc_t *mailbox_get_updatenotifier(void)
+{
+ return updatenotifier;
+}
+
+/*
* Create connection to acappush (obsolete)
*/
int mailbox_initialize(void)
diff -Naur cyrus-imapd-2.2.12.orig/imap/mailbox.h cyrus-imapd-2.2.12/imap/mailbox.h
--- cyrus-imapd-2.2.12.orig/imap/mailbox.h 2004-01-22 22:17:09.000000000 +0100
+++ cyrus-imapd-2.2.12/imap/mailbox.h 2006-01-04 07:41:45.000000000 +0100
@@ -224,6 +224,8 @@
extern void mailbox_set_updatenotifier(mailbox_notifyproc_t *notifyproc);
+extern mailbox_notifyproc_t *mailbox_get_updatenotifier(void);
+
extern int mailbox_initialize(void);
extern char *mailbox_message_fname(struct mailbox *mailbox,

View File

@@ -0,0 +1,144 @@
diff -Naur cyrus-imapd-2.2.12/imap/append.c cyrus-imapd-2.2.12.cvs/imap/append.c
--- cyrus-imapd-2.2.12/imap/append.c 2004-05-22 05:45:48.000000000 +0200
+++ cyrus-imapd-2.2.12.cvs/imap/append.c 2005-06-03 07:10:24.000000000 +0200
@@ -1,5 +1,5 @@
/* append.c -- Routines for appending messages to a mailbox
- * $Id: append.c,v 1.107 2004/05/22 03:45:48 rjs3 Exp $
+ * $Id: append.c,v 1.108 2005/06/02 15:47:50 ken3 Exp $
*
* Copyright (c)1998, 2000 Carnegie Mellon University. All rights reserved.
*
@@ -801,7 +801,8 @@
int append_copy(struct mailbox *mailbox,
struct appendstate *as,
int nummsg,
- struct copymsg *copymsg)
+ struct copymsg *copymsg,
+ int nolink)
{
struct mailbox *append_mailbox = &as->m;
int msg;
@@ -845,7 +846,7 @@
mailbox_message_get_fname(mailbox, copymsg[msg].uid, fnamebuf,
sizeof(fnamebuf));
/* Link/copy message file */
- r = mailbox_copyfile(fnamebuf, fname, 0);
+ r = mailbox_copyfile(fnamebuf, fname, nolink);
if (r) goto fail;
/* Write out cache info, copy other info */
diff -Naur cyrus-imapd-2.2.12/imap/append.h cyrus-imapd-2.2.12.cvs/imap/append.h
--- cyrus-imapd-2.2.12/imap/append.h 2004-01-22 22:17:07.000000000 +0100
+++ cyrus-imapd-2.2.12.cvs/imap/append.h 2005-06-03 07:10:24.000000000 +0200
@@ -1,5 +1,5 @@
/* append.h -- Description of messages to be copied
- * $Id: append.h,v 1.26 2004/01/22 21:17:07 ken3 Exp $
+ * $Id: append.h,v 1.27 2005/06/02 15:47:51 ken3 Exp $
*
* Copyright (c) 1998, 2000 Carnegie Mellon University. All rights reserved.
*
@@ -137,7 +137,7 @@
extern int append_copy(struct mailbox *mailbox,
struct appendstate *append_mailbox,
- int nummsg, struct copymsg *copymsg);
+ int nummsg, struct copymsg *copymsg, int nolink);
extern int append_collectnews(struct appendstate *mailbox,
const char *group, unsigned long feeduid);
diff -Naur cyrus-imapd-2.2.12/imap/imapd.c cyrus-imapd-2.2.12.cvs/imap/imapd.c
--- cyrus-imapd-2.2.12/imap/imapd.c 2005-02-14 07:39:55.000000000 +0100
+++ cyrus-imapd-2.2.12.cvs/imap/imapd.c 2005-06-03 07:11:52.000000000 +0200
@@ -38,7 +38,7 @@
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: imapd.c,v 1.490 2005/02/14 06:39:55 shadow Exp $ */
+/* $Id: imapd.c,v 1.493 2005/06/02 15:47:51 ken3 Exp $ */
#include <config.h>
@@ -3593,7 +3593,7 @@
imapd_userid, mailboxname);
if (!r) {
r = index_copy(imapd_mailbox, sequence, usinguid, mailboxname,
- &copyuid);
+ &copyuid, !config_getswitch(IMAPOPT_SINGLEINSTANCESTORE));
}
index_check(imapd_mailbox, usinguid, 0);
diff -Naur cyrus-imapd-2.2.12/imap/imapd.h cyrus-imapd-2.2.12.cvs/imap/imapd.h
--- cyrus-imapd-2.2.12/imap/imapd.h 2004-06-22 23:36:18.000000000 +0200
+++ cyrus-imapd-2.2.12.cvs/imap/imapd.h 2005-06-03 07:10:24.000000000 +0200
@@ -1,5 +1,5 @@
/* imapd.h -- Common state for IMAP daemon
- * $Id: imapd.h,v 1.61 2004/06/22 21:36:18 rjs3 Exp $
+ * $Id: imapd.h,v 1.62 2005/06/02 15:47:57 ken3 Exp $
*
* Copyright (c) 1998-2003 Carnegie Mellon University. All rights reserved.
*
@@ -249,7 +249,7 @@
extern int index_thread(struct mailbox *mailbox, int algorithm,
struct searchargs *searchargs, int usinguid);
extern int index_copy(struct mailbox *mailbox, char *sequence,
- int usinguid, char *name, char **copyuidp);
+ int usinguid, char *name, char **copyuidp, int nolink);
extern int index_status(struct mailbox *mailbox, char *name,
int statusitems);
diff -Naur cyrus-imapd-2.2.12/imap/index.c cyrus-imapd-2.2.12.cvs/imap/index.c
--- cyrus-imapd-2.2.12/imap/index.c 2005-02-14 17:42:08.000000000 +0100
+++ cyrus-imapd-2.2.12.cvs/imap/index.c 2005-06-03 07:13:04.000000000 +0200
@@ -41,7 +41,7 @@
*
*/
/*
- * $Id: index.c,v 1.213 2005/02/14 16:42:08 shadow Exp $
+ * $Id: index.c,v 1.218 2005/06/02 15:47:58 ken3 Exp $
*/
#include <config.h>
@@ -1145,7 +1145,8 @@
char *sequence,
int usinguid,
char *name,
- char **copyuidp)
+ char **copyuidp,
+ int nolink)
{
static struct copyargs copyargs;
int i;
@@ -1176,7 +1177,7 @@
if (r) return r;
r = append_copy(mailbox, &append_mailbox, copyargs.nummsg,
- copyargs.copymsg);
+ copyargs.copymsg, nolink);
if (!r) append_commit(&append_mailbox, totalsize,
&uidvalidity, &startuid, &num);
if (!r) {
diff -Naur cyrus-imapd-2.2.12/lib/imapoptions cyrus-imapd-2.2.12.cvs/lib/imapoptions
--- cyrus-imapd-2.2.12/lib/imapoptions 2004-07-21 21:07:45.000000000 +0200
+++ cyrus-imapd-2.2.12.cvs/lib/imapoptions 2005-06-03 07:14:07.000000000 +0200
@@ -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: imapoptions,v 1.30 2004/07/21 19:07:45 rjs3 Exp $
+.\" $Id: imapoptions,v 1.33 2005/06/02 15:47:59 ken3 Exp $
.SH NAME
imapd.conf \- IMAP configuration file
.SH DESCRIPTION
@@ -753,9 +753,9 @@
directories: ~user/.sieve. */
{ "singleinstancestore", 1, SWITCH }
-/* If enabled, lmtpd and nntpd attempt to only write one copy of a message per
- partition and create hard links, resulting in a potentially large
- disk savings. */
+/* If enabled, imapd, lmtpd and nntpd attempt to only write one copy
+ of a message per partition and create hard links, resulting in a
+ potentially large disk savings. */
{ "skiplist_unsafe", 0, SWITCH }
/* If enabled, this option forces the skiplist cyrusdb backend to

View File

@@ -0,0 +1,12 @@
diff -Naur cyrus-imapd-2.2.12.orig/imap/spool.c cyrus-imapd-2.2.12/imap/spool.c
--- cyrus-imapd-2.2.12.orig/imap/spool.c 2004-10-27 22:40:50.000000000 +0200
+++ cyrus-imapd-2.2.12/imap/spool.c 2005-10-24 15:08:37.000000000 +0200
@@ -451,7 +451,7 @@
p[1] = '\n';
p[2] = '\0';
}
- else if (p[0] != '\n' && (strlen(buf) < sizeof(buf)-2)) {
+ else if (p[0] != '\n' && (strlen(buf) < sizeof(buf)-3)) {
/* line contained a \0 not at the end */
r = IMAP_MESSAGE_CONTAINSNULL;
continue;

View File

@@ -0,0 +1,44 @@
diff -Naur cyrus-imapd-2.3.3.orig/lib/acl_afs.c cyrus-imapd-2.3.3/lib/acl_afs.c
--- cyrus-imapd-2.3.3.orig/lib/acl_afs.c 2005-12-13 20:36:11.000000000 +0100
+++ cyrus-imapd-2.3.3/lib/acl_afs.c 2006-04-12 07:28:50.000000000 +0200
@@ -114,6 +114,7 @@
cyrus_acl_canonproc_t *canonproc;
void *canonrock;
{
+ const char *canonid;
char *newidentifier = 0;
char *newacl;
char *thisid, *nextid;
@@ -122,9 +123,14 @@
/* Convert 'identifier' into canonical form */
if (*identifier == '-') {
- char *canonid = auth_canonifyid(identifier+1, 0);
+ canonid = auth_canonifyid(identifier+1, 0);
if (!canonid) {
- return -1;
+ if (access != 0L) {
+ return -1;
+ } else {
+ /* trying to delete invalid/non-existent identifier */
+ canonid = identifier+1;
+ }
}
newidentifier = xmalloc(strlen(canonid)+2);
newidentifier[0] = '-';
@@ -135,9 +141,13 @@
}
}
else {
- identifier = auth_canonifyid(identifier, 0);
- if (!identifier) {
+ canonid = auth_canonifyid(identifier, 0);
+ if (canonid) {
+ identifier = canonid;
+ } else if (access != 0L) {
return -1;
+ } else {
+ /* trying to delete invalid/non-existent identifier */
}
if (canonproc) {
access = canonproc(canonrock, identifier, access);

View File

@@ -0,0 +1,34 @@
--- cyrus-imapd-2.2.6/imap/message.c.acceptinvalidfrom 2004-10-30 15:03:02.220642392 -0700
+++ cyrus-imapd-2.2.6/imap/message.c 2004-10-30 15:06:01.838336352 -0700
@@ -229,6 +229,8 @@
int reject8bit = config_getswitch(IMAPOPT_REJECT8BIT);
int munge8bit = config_getswitch(IMAPOPT_MUNGE8BIT);
int inheader = 1, blankline = 1;
+ char is_from;
+ static const char * from_header = "From ";
while (size) {
n = prot_read(from, buf, size > 4096 ? 4096 : size);
@@ -294,8 +296,20 @@
/* Check for valid header name */
if (sawnl && buf[0] != ' ' && buf[0] != '\t') {
if (buf[0] == ':') return IMAP_MESSAGE_BADHEADER;
- for (p = (unsigned char *)buf; *p != ':'; p++) {
- if (*p <= ' ') return IMAP_MESSAGE_BADHEADER;
+ p = (unsigned char *) buf;
+ if (*p == '>')
+ p++;
+ if (*p == from_header[0])
+ is_from = 0;
+ else
+ is_from = -1;
+ for (; *p != ':' && is_from < 5; p++) {
+ if (is_from > 0 && *p != from_header[is_from])
+ is_from = -1;
+ if (is_from >= 0)
+ is_from++;
+ else
+ if (*p <= ' ') return IMAP_MESSAGE_BADHEADER;
}
}

View File

@@ -0,0 +1,19 @@
--- timsieved/parser.c
+++ timsieved/parser.c 2005/08/24 09:14:42
@@ -664,8 +664,14 @@
if(r) {
/* mboxlist_detail error */
- *errmsg = "mailbox unknown";
- return FALSE;
+ syslog(LOG_ERR, error_message(r));
+
+ if(reset_saslconn(&sieved_saslconn, ssf, authid) != SASL_OK)
+ fatal("could not reset the sasl_conn_t after failure",
+ EC_TEMPFAIL);
+
+ ret = FALSE;
+ goto cleanup;
}
if(type & MBTYPE_REMOTE) {