-
Notifications
You must be signed in to change notification settings - Fork 153
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot subscribe shared folder if destination mailbox name is a prefix of source mailbox name #5146
Comments
@ksmurchison I haven't looked at code yet, but Martin's analysis here smells right.
Any thoughts on this concern? I'm not real familiar with these newer APIs yet, but it'd be easy enough for me to write a test case to reproduce the problem, so I'm happy to have a go at tackling a fix. Not sure what kind of dragons to expect though! |
@elliefm The analysis sounds correct. If you want to take a shot at it, feel free. Let me know if you run into issues. |
Ellie, Ken, thank you for quick response. My primary concern regarding any fixes inside |
Looking over how Once the actual bug is fixed, it might be possible to find and fix up bad subscriptions where this has occurred by looking for subscriptions to e.g. |
I've got a test now that confirms the problem still happens on the master branch. We might be able to automatically repair the bad subscriptions data from |
I think I would rename |
It looks like the SUBSCRIBE command succeeds, but since the record created is rubbish, it's a bit like being subscribed to a mailbox that doesn't exist, it doesn't show up in LSUB or LIST responses. I wonder what the UNSUBSCRIBE behaviour is... |
Ahh interesting, you can unsubscribe from one of these mailboxes, spelling the mailbox name correctly, and it will find and remove the bad entry from the subscriptions file. Which makes sense because it's only the db-level operations that have the bad conversion, the rest of the time the mailbox name is correct. |
Hello,
we’ve found a bug in Cyrus 3.6 where it is impossible to share a mailbox folder from one mailbox to another when the destination mailbox name is a prefix of the source mailbox name. It’s reproducible by these steps:
[email protected]
and[email protected]
. It’s crucial thatmartin
is a prefix ofmartin123
.[email protected]/SharedFolder
.[email protected]
has access to[email protected]/SharedFolder
. I.e.cyradm listacl
looks like:SharedFolder
from[email protected]
. Then, although ACL is properly set, the subscription doesn’t happen and[email protected]
doesn’t see the shared folder.While investigating this issue we noticed that there’s a strange record in martin.sub subscriptions file: instead of the expected
Nsomedomain.com.user.martin123.SharedFolder
, there’sNINBOX123.SharedFolder
. That is, the common prefix of the two mailboxes was replaced by stringINBOX
. If we copy .sub file from another mailbox that containsNsomedomain.com.user.martin123.SharedFolder
, subscription of the shared folder works fine.After quick inspection of the source code I think the issue is caused by function
mboxlist_dbname_to_key()
in mboxlist.c. This function rewrites mbname to"INBOX"
based on a trivialstrncmp()
comparison and ignores the possibility that mbname can be a partial prefix of a longer mailbox name. Then, when called frommboxlist_changesub()
,dbname
points to a different mailbox thanuserid
andmboxlist_dbname_to_key()
rewritesdbname
to a nonexisting bogus name.I think that
mboxlist_dbname_to_key()
should rewrite mbname to"INBOX"
only if it’s followed by a separator or end of string. However,mboxlist_dbname_to_key()
is called from a number of other places, so I don’t want to propose a patch without deeper knowledge of the code. Finally, note that there’s similarstrncmp()
-based string replacement of"INBOX"
to mbname inmboxlist_dbname_from_key()
. Perhaps this function should perform prefix sanity checks as well?We’ve found this bug in Cyrus IMAP 3.6 (3.6.1-4+deb12u3) in Debian 12. Cyrus IMAP 3.4.x and older seem to be unaffected. Master branch on github contains the same
mboxlist_dbname_to_key()
andmboxlist_changesub()
code so I assume that all versions after 3.6 have this bug too. Note that our setup uses optionsaltnamespace: yes
andmailbox_legacy_dirs: yes
(not sure if it’s relevant).Best regards,
Martin
The text was updated successfully, but these errors were encountered: