Hi,
 I'm on the same boat.  But it seems that upgrade failure is not
caused by missing utilities, but rather by mailboxes created more than
7 years ago (probably in cyrus 2.x).

Code to upgrade mailboxes
(https://github.com/cyrusimap/cyrus-imapd/blob/add814e90cb2cb5804e5e9c87faca7af253ded4e/imap/mboxlist.c#L5411)
is calling hash_lookup with mbentry->uniqueid - but mbentry->uniqueid
may be NULL, causing NULL pointer dereference and crash.

When I dumped my old mailbox db, I can see that "new" entries have new
% format, with 'I' field, but old ones use legacy format without 'I'
key:

...
user.petr.Inbox2013     0 default petr  lrswipcda
user.petr.Inbox2014     0 default petr  lrswipcda
user.petr.Inbox2015     %(A %(petr lrswipcda) I
ol64w50y514kvpoke32tg6a3 P default V 1569218712 F 1 M 1569218711)
user.petr.Inbox2016     %(A %(petr lrswipcda) I
abommco8w0dxyzyjju8nu2rw P default V 1569218720 F 1 M 1569218719)
...

So to me this looks like upstream problem.  I have applied patch below
on my host, and it seems to have fixed update crash.

--- cyrus-imapd-3.6.0~beta2/imap/mboxlist.c     2022-03-10
15:09:08.000000000 -0800
+++ cyrus-imapd-3.6.0~beta2.new/imap/mboxlist.c 2022-03-31
23:52:52.427711987 -0700
@@ -5408,6 +5408,9 @@
     mbentry->mbtype |= MBTYPE_LEGACY_DIRS;

     int idx = 0;
+    if (mbentry->uniqueid == NULL) {
+        mbentry->uniqueid = xstrdup(makeuuid());
+    }
     ptrarray_t *pa = hash_lookup(mbentry->uniqueid, urock->ids);
     if (!pa) {
         pa = ptrarray_new();


Also I think it would be nice if update code would create new
mailbox.db.NEW, and then rename .db to db.OLD and db.NEW to db on
success, rather than moving mailbox.db to mailbox.db.OLD, and then
perform upgrade - as then you end up with empty mailbox.db, and so 2nd
upgrade attempt succeeds, deleting mailbox.db.OLD and causing data
loss.

And finally I would suggest adding 'mailbox_legacy_dirs: true' to
imapd.conf on upgrade - if upgrade would not have failed, I would have
been for rude awakening when mailboxes for new users would have moved
into uuid directory without any warning.

Thanks,
Petr

P.S.: Sorry about using gmail, my own email server is now in a bit of
disarray :-(

Reply via email to