[prev in list] [next in list] [prev in thread] [next in thread]
List: cyrus-cvs
Subject: [Cyrus-CVS] rjs3; src/cyrus/imap ctl_mboxlist.c imapd.c mbdump.c mboxlist.c mboxlist.h reconstruct.c
From: rjs3 () andrew ! cmu ! edu
Date: 2002-03-29 0:04:00
[Download RAW message or body]
Update of /afs/andrew.cmu.edu/system/cvs/src/cyrus/imap
In directory gobo.andrew.cmu.edu:/afs/andrew.cmu.edu/system/src/local/cyrus/053/imap
Modified Files:
ctl_mboxlist.c imapd.c mbdump.c mboxlist.c mboxlist.h
reconstruct.c seen.h seen_bigdb.c seen_db.c
Log Message:
alpha-quality recursive user moves with seen state, subscriptions, and sieve
scripts
Index: src/cyrus/imap/ctl_mboxlist.c
diff -u src/cyrus/imap/ctl_mboxlist.c:1.32 src/cyrus/imap/ctl_mboxlist.c:1.33
--- src/cyrus/imap/ctl_mboxlist.c:1.32 Tue Mar 26 14:24:54 2002
+++ src/cyrus/imap/ctl_mboxlist.c Thu Mar 28 19:03:53 2002
@@ -40,7 +40,7 @@
*
*/
-/* $Id: ctl_mboxlist.c,v 1.32 2002/03/26 19:24:54 rjs3 Exp $ */
+/* $Id: ctl_mboxlist.c,v 1.33 2002/03/29 00:03:53 rjs3 Exp $ */
/* currently doesn't catch signals; probably SHOULD */
@@ -395,7 +395,7 @@
while(unflag_head) {
struct mb_node *me = unflag_head;
int type;
- char *part, *acl;
+ char *part, *acl, *newpart;
unflag_head = unflag_head->next;
@@ -406,9 +406,14 @@
me->mailbox);
exit(1);
}
-
+
+ /* Reset the partition! */
+ newpart = strchr(part, '!');
+ if(!newpart) newpart = part;
+ else newpart++;
+
ret = mboxlist_update(me->mailbox, type & ~MBTYPE_MOVING,
- part, acl);
+ newpart, acl);
if(ret) {
fprintf(stderr,
"couldn't perform update to un-remote-flag %s\n",
Index: src/cyrus/imap/imapd.c
diff -u src/cyrus/imap/imapd.c:1.369 src/cyrus/imap/imapd.c:1.370
--- src/cyrus/imap/imapd.c:1.369 Wed Mar 27 18:40:04 2002
+++ src/cyrus/imap/imapd.c Thu Mar 28 19:03:53 2002
@@ -38,7 +38,7 @@
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: imapd.c,v 1.369 2002/03/27 23:40:04 rjs3 Exp $ */
+/* $Id: imapd.c,v 1.370 2002/03/29 00:03:53 rjs3 Exp $ */
#include <config.h>
@@ -2220,6 +2220,8 @@
if(mupdate_server) {
prot_printf(imapd_out, " MUPDATE=mupdate://%s/", mupdate_server);
}
+
+ prot_printf(imapd_out, " MAILBOX-REFERRALS");
/* add the SASL mechs */
if (sasl_listmech(imapd_saslconn, NULL,
@@ -3513,10 +3515,12 @@
}
if (!r) {
+ /* xxx we do forced user creates on LOCALCREATE to facilitate
+ * mailbox moves */
r = mboxlist_createmailbox(mailboxname, 0, partition,
imapd_userisadmin,
imapd_userid, imapd_authstate,
- localonly);
+ localonly, localonly);
if (r == IMAP_PERMISSION_DENIED && !strcasecmp(name, "INBOX") &&
(autocreatequota = config_getint("autocreatequota", 0))) {
@@ -3524,7 +3528,7 @@
/* Auto create */
r = mboxlist_createmailbox(mailboxname, 0,
partition, 1, imapd_userid,
- imapd_authstate, 0);
+ imapd_authstate, 0, 0);
if (!r && autocreatequota > 0) {
(void) mboxlist_setquota(mailboxname, autocreatequota);
@@ -5864,7 +5868,6 @@
return r;
}
-/* xxx need to handle prereserved case */
static int do_xfer_single(char *toserver, char *name, char *mailboxname,
int mbflags,
char *path, char *part, char *acl,
@@ -5941,7 +5944,8 @@
}
/* Step 3: mupdate.DEACTIVATE(mailbox, newserver) */
- if(!r) {
+ /* (only if mailbox has not been already deactivated by our caller) */
+ if(!r && !prereserved) {
backout_remoteflag = 1;
/* Note we are making the reservation on OUR host so that recovery
@@ -6077,6 +6081,59 @@
return r;
}
+struct xfer_user_rock
+{
+ char *toserver;
+ mupdate_handle *h;
+};
+
+static int xfer_user_cb(char *name,
+ int matchlen __attribute__((unused)),
+ int maycreate __attribute__((unused)),
+ void *rock)
+{
+ mupdate_handle *mupdate_h = ((struct xfer_user_rock *)rock)->h;
+ char *toserver = ((struct xfer_user_rock *)rock)->toserver;
+ char externalname[MAX_MAILBOX_NAME];
+ int mbflags;
+ int r = 0;
+ char *inpath, *inpart, *inacl;
+ char *path = NULL, *part = NULL, *acl = NULL;
+
+ if (!r) {
+ /* NOTE: NOT mlookup() because we don't want to issue a referral */
+ /* xxx but what happens if they are remote
+ * mailboxes? */
+ r = mboxlist_detail(name, &mbflags,
+ &inpath, &inpart, &inacl, NULL);
+ }
+
+ if (!r) {
+ path = xstrdup(inpath);
+ part = xstrdup(inpart);
+ acl = xstrdup(inacl);
+ }
+
+ if(!r) {
+ r = (*imapd_namespace.mboxname_toexternal)(&imapd_namespace,
+ name,
+ imapd_userid,
+ externalname);
+ }
+
+ if(!r) {
+ r = do_xfer_single(toserver, externalname, name, mbflags,
+ path, part, acl, 0, mupdate_h);
+ }
+
+ if(path) free(path);
+ if(part) free(part);
+ if(acl) free(acl);
+
+ return r;
+}
+
+
void cmd_xfer(char *tag, char *toserver, char *name)
{
int r = 0;
@@ -6100,6 +6157,13 @@
r = IMAP_SERVER_UNAVAILABLE;
}
+ if (!r) {
+ r = (*imapd_namespace.mboxname_tointernal)(&imapd_namespace,
+ name,
+ imapd_userid,
+ mailboxname);
+ }
+
if(!strncmp(mailboxname, "user.", 5) && !strchr(mailboxname+5, '.')) {
if (!strcmp(mailboxname+5, imapd_userid)) {
/* don't move your own inbox, that could be troublesome */
@@ -6108,13 +6172,6 @@
moving_user = 1;
}
}
-
- if (!r) {
- r = (*imapd_namespace.mboxname_tointernal)(&imapd_namespace,
- name,
- imapd_userid,
- mailboxname);
- }
if (!r) {
r = mlookup(tag, name, mailboxname, &mbflags,
@@ -6156,16 +6213,27 @@
else backout_mupdate = 1;
}
- /* recursively move aIndex: src/cyrus/imap/mbdump.c
diff -u src/cyrus/imap/mbdump.c:1.12 src/cyrus/imap/mbdump.c:1.13
--- src/cyrus/imap/mbdump.c:1.12 Thu Apr 4 17:22:39 2002
+++ src/cyrus/imap/mbdump.c Fri Apr 5 13:51:56 2002
@@ -1,5 +1,5 @@
/* mbdump.c -- Mailbox dump routines
- * $Id: mbdump.c,v 1.12 2002/04/04 22:22:39 rjs3 Exp $
+ * $Id: mbdump.c,v 1.13 2002/04/05 18:51:56 rjs3 Exp $
* Copyright (c) 1998-2000 Carnegie Mellon University. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -556,8 +556,11 @@
strcpy(fnamebuf, s);
free(s);
} else if (userid && !strcmp(file.s, "SEEN")) {
- /* xxx we want to merge this one, in an ideal world... */
char *s = seen_getpath(userid);
+
+ /* xxx lock current seen state */
+ /* xxx set fname buf to <seen state>.NEW */
+
strcpy(fnamebuf, s);
free(s);
} else if (userid && !strncmp(file.s, "SIEVE", 5)) {
@@ -634,6 +637,10 @@
}
close(curfile);
+
+ /* xxx if this was seen state, perform a merge,
+ and remove the <seen state>.new file,
+ and unlock the seen state */
if(c == ')') break;
}
Index: src/cyrus/imap/mboxlist.c
diff -u src/cyrus/imap/mboxlist.c:1.181 src/cyrus/imap/mboxlist.c:1.182
--- src/cyrus/imap/mboxlist.c:1.181 Thu Apr 4 17:22:39 2002
+++ src/cyrus/imap/mboxlist.c Fri Apr 5 13:51:56 2002
@@ -40,7 +40,7 @@
*
*/
/*
- * $Id: mboxlist.c,v 1.181 2002/04/04 22:22:39 rjs3 Exp $
+ * $Id: mboxlist.c,v 1.182 2002/04/05 18:51:56 rjs3 Exp $
*/
#include <config.h>
@@ -92,8 +92,6 @@
static int mboxlist_dbopen = 0;
-static const char *mupdate_server = NULL;
-
static int mboxlist_opensubs();
static void mboxlist_closesubs();
@@ -582,8 +580,8 @@
}
/* 4. Create mupdate reservation */
- if (mupdate_server && !localonly) {
- r = mupdate_connect(mupdate_server, NULL, &mupdate_h, NULL);
+ if (config_mupdate_server && !localonly) {
+ r = mupdate_connect(config_mupdate_server, NULL, &mupdate_h, NULL);
if(r) {
syslog(LOG_ERR,
"can not connect to mupdate server for reservation on '%s'",
@@ -652,14 +650,14 @@
}
/* delete mupdate entry if we made it */
- if (madereserved == 1 && mupdate_server) {
+ if (madereserved == 1 && config_mupdate_server) {
r2 = mupdate_delete(mupdate_h, name);
if(r2 > 0) {
/* Disconnect, reconnect, and retry */
syslog(LOG_WARNING,
"MUPDATE: lost connection, retrying");
mupdate_disconnect(&mupdate_h);
- r2 = mupdate_connect(mupdate_server, NULL,
+ r2 = mupdate_connect(config_mupdate_server, NULL,
&mupdate_h, NULL);
if(!r2) {
r2 = mupdate_delete(mupdate_h, name);
@@ -684,7 +682,7 @@
/* 9. set MUPDATE entry as commited (CRASH: commited) */
/* xxx maybe we should roll back if this fails? */
- if (!r && mupdate_server && !localonly) {
+ if (!r && config_mupdate_server && !localonly) {
/* commit the mailbox in MUPDATE */
sprintf(buf, "%s!%s", config_servername, newpartition);
@@ -694,7 +692,7 @@
syslog(LOG_WARNING,
"MUPDATE: lost connection, retrying");
mupdate_disconnect(&mupdate_h);
- r = mupdate_connect(mupdate_server, NULL, &mupdate_h, NULL);
+ r = mupdate_connect(config_mupdate_server, NULL, &mupdate_h, NULL);
if(!r) {
r = mupdate_activate(mupdate_h, name, buf, acl);
}
@@ -705,7 +703,7 @@
}
}
- if(mupdate_server && mupdate_h) mupdate_disconnect(&mupdate_h);
+ if(config_mupdate_server && mupdate_h) mupdate_disconnect(&mupdate_h);
if (acl) free(acl);
if (newpartition) free(newpartition);
@@ -824,9 +822,9 @@
/* remove from mupdate */
/* xxx this can lead to inconsistancies if the later stuff fails */
- if (!r && !local_only && mupdate_server) {
+ if (!r && !local_only && config_mupdate_server) {
/* delete the mailbox in MUPDATE */
- r = mupdate_connect(mupdate_server, NULL, &mupdate_h, NULL);
+ r = mupdate_connect(config_mupdate_server, NULL, &mupdate_h, NULL);
if(r) {
syslog(LOG_ERR,
"can not connect to mupdate server for delete of '%s'",
@@ -1020,12 +1018,12 @@
}
}
- if (!r && !partitionmove && mupdate_server) {
+ if (!r && !partitionmove && config_mupdate_server) {
/* Reserve new name in MUPDATE */
char buf[MAX_PARTITION_LEN + HOSTNAME_SIZE + 2];
sprintf(buf, "%s!%s", config_servername, newpartition);
- r = mupdate_connect(mupdate_server, NULL, &mupdate_h, NULL);
+ r = mupdate_connect(config_mupdate_server, NULL, &mupdate_h, NULL);
if(r) {
syslog(LOG_ERR,
"can not connect to mupdate server for reservation on '%s'",
@@ -1043,12 +1041,12 @@
}
madenew = 1;
- } else if(!r && partitionmove && mupdate_server) {
+ } else if(!r && partitionmove && config_mupdate_server) {
/* commit the update to MUPDATE */
char buf[MAX_PARTITION_LEN + HOSTNAME_SIZE + 2];
sprintf(buf, "%s!%s", config_servername, newpartition);
- r = mupdate_connect(mupdate_server, NULL, &mupdate_h, NULL);
+ r = mupdate_connect(config_mupdate_server, NULL, &mupdate_h, NULL);
if(r) {
syslog(LOG_ERR,
"can not connect to mupdate server for reservation on '%s'",
@@ -1123,14 +1121,14 @@
}
/* unroll mupdate operations if neceIndex: src/cyrus/imap/mboxlist.h
diff -u src/cyrus/imap/mboxlist.h:1.28 src/cyrus/imap/mboxlist.h:1.29
--- src/cyrus/imap/mboxlist.h:1.28 Thu Mar 28 19:03:57 2002
+++ src/cyrus/imap/mboxlist.h Thu Apr 4 17:22:39 2002
@@ -40,7 +40,7 @@
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
*
- * $Id: mboxlist.h,v 1.28 2002/03/29 00:03:57 rjs3 Exp $
+ * $Id: mboxlist.h,v 1.29 2002/04/04 22:22:39 rjs3 Exp $
*/
#ifndef INCLUDED_MBOXLIST_H
@@ -164,6 +164,7 @@
/* set or create quota root */
int mboxlist_setquota(const char *root, int newquota);
+int mboxlist_unsetquota(const char *root);
/* returns a malloc() string that is the representation in the mailboxes
file. for ctl_mboxlist */
Index: src/cyrus/imap/reconstruct.c
diff -u src/cyrus/imap/reconstruct.c:1.67 src/cyrus/imap/reconstruct.c:1.68
--- src/cyrus/imap/reconstruct.c:1.67 Thu Mar 28 19:03:57 2002
+++ src/cyrus/imap/reconstruct.c Sat Mar 30 14:46:57 2002
@@ -39,7 +39,7 @@
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: reconstruct.c,v 1.67 2002/03/29 00:03:57 rjs3 Exp $ */
+/* $Id: reconstruct.c,v 1.68 2002/03/30 19:46:57 ken3 Exp $ */
#include <config.h>
@@ -134,7 +134,7 @@
if (geteuid() == 0) fatal("must run as the Cyrus user", EC_USAGE);
/* Ensure we're up-to-date on the index file format */
- assert(INDEX_HEADER_SIZE == (OFFSET_FLAGGED+4));
+ assert(INDEX_HEADER_SIZE == (OFFSET_SPARE3+4));
assert(INDEX_RECORD_SIZE == (OFFSET_USER_FLAGS+MAX_USER_FLAGS/8));
while ((opt = getopt(argc, argv, "C:rmf")) != EOF) {
@@ -356,6 +356,9 @@
mailbox.last_uid = 0;
mailbox.last_appenddate = 0;
mailbox.uidvalidity = time(0);
+ /* If we can't read the index, assume new UIDL so that stupid clients
+ will retrieve all of the messages in the mailbox. */
+ mailbox.pop3_new_uidl = 1;
}
else {
(void) mailbox_lock_index(&mailbox);
@@ -469,6 +472,9 @@
else {
/* Message file write time is good estimate of internaldate */
message_index.internaldate = sbuf.st_mtime;
+ /* If we are recovering a message, assume new UIDL
+ so that stupid clients will retrieve this message */
+ mailbox.pop3_new_uidl = 1;
}
message_index.last_updated = time(0);
@@ -535,6 +541,7 @@
*((bit32 *)(buf+OFFSET_DELETED)) = htonl(new_deleted);
*((bit32 *)(buf+OFFSET_ANSWERED)) = htonl(new_answered);
*((bit32 *)(buf+OFFSET_FLAGGED)) = htonl(new_flagged);
+ *((bit32 *)(buf+OFFSET_POP3_NEW_UIDL)) = htonl(mailbox.pop3_new_uidl);
n = fwrite(buf, 1, INDEX_HEADER_SIZE, newindex);
fflush(newindex);
Index: src/cyrus/imap/seen.h
diff -u src/cyrus/imap/seen.h:1.8 src/cyrus/imap/seen.h:1.9
--- src/cyrus/imap/seen.h:1.8 Thu Feb 28 15:33:20 2002
+++ src/cyrus/imap/seen.h Thu Mar 28 19:03:57 2002
@@ -1,5 +1,5 @@
/* seen.h -- abstract interface for /Recent and /Seen information
- $Id: seen.h,v 1.8 2002/02/28 20:33:20 rjs3 Exp $
+ $Id: seen.h,v 1.9 2002/03/29 00:03:57 rjs3 Exp $
* Copyright (c) 2000 Carnegie Mellon University. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -90,5 +90,9 @@
/* done with all seen operations for this process */
int seen_done(void);
+
+/* Return a path to the seen database for the given user (or NULL if we are
+ * using bigdb) */
+char *seen_getpath(const char *userid);
#endif /* SEEN_LOCAL_H */
Index: src/cyrus/imap/seen_bigdb.c
diff -u src/cyrus/imap/seen_bigdb.c:1.1 src/cyrus/imap/seen_bigdb.c:1.2
--- src/cyrus/imap/seen_bigdb.c:1.1 Tue Dec 26 01:26:24 2000
+++ src/cyrus/imap/seen_bigdb.c Thu Mar 28 19:03:57 2002
@@ -1,5 +1,5 @@
/* seen_db.c -- implementation of seen database using per-user berkeley db
- $Id: seen_bigdb.c,v 1.1 2000/12/26 06:26:24 leg Exp $
+ $Id: seen_bigdb.c,v 1.2 2002/03/29 00:03:57 rjs3 Exp $
* Copyright (c) 2000 Carnegie Mellon University. All rights reserved.
*
@@ -87,6 +87,12 @@
static int seen_inited = 0;
static struct db *bigdb;
+
+/* Stub */
+char *seen_getpath(const char *userid)
+{
+ return NULL;
+}
static void seen_init(void)
{
Index: src/cyrus/imap/seen_db.c
diff -u src/cyrus/imap/seen_db.c:1.27 src/cyrus/imap/seen_db.c:1.28
--- src/cyrus/imap/seen_db.c:1.27 Sun Feb 24 18:40:45 2002
+++ src/cyrus/imap/seen_db.c Thu Mar 28 19:03:57 2002
@@ -1,5 +1,5 @@
/* seen_db.c -- implementation of seen database using per-user berkeley db
- $Id: seen_db.c,v 1.27 2002/02/24 23:40:45 leg Exp $
+ $Id: seen_db.c,v 1.28 2002/03/29 00:03:57 rjs3 Exp $
* Copyright (c) 2000 Carnegie Mellon University. All rights reserved.
*
@@ -102,7 +102,7 @@
}
}
-static char *getpath(const char *userid)
+char *seen_getpath(const char *userid)
{
char *fname = xmalloc(strlen(config_dir) + sizeof(FNAME_USERDIR) +
strlen(userid) + sizeof(FNAME_SEENSUFFIX) + 10);
@@ -156,7 +156,7 @@
}
/* open the seendb corresponding to user */
- fname = getpath(user);
+ fname = seen_getpath(user);
r = DB->open(fname, &seendb->db);
if (r != 0) {
syslog(LOG_ERR, "DBERROR: opening %s: %s", fname,
@@ -453,7 +453,7 @@
int seen_delete_user(const char *user)
{
- char *fname = getpath(user);
+ char *fname = seen_getpath(user);
int r = 0;
if (SEEN_DEBUG) {
end of message
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic