Skip to content
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

UID MOVE to remote server returns bad COPYUID response #4027

Open
elliefm opened this issue Apr 8, 2022 · 1 comment
Open

UID MOVE to remote server returns bad COPYUID response #4027

elliefm opened this issue Apr 8, 2022 · 1 comment
Labels
3.7 affects 3.7 dev releases Murder

Comments

@elliefm
Copy link
Contributor

elliefm commented Apr 8, 2022

This came up on the info list: https://cyrus.topicbox.com/groups/info/T25c7531b76d23ba0-Mb4348afa7dbb30b2bc95f978/move-mails-between-folders-on-different-backend-servers

If a copy/move is local, then the COPYUID response is calculated locally, and everything's fine.

If the target of the copy/move is remote, then the messages are APPENDed to the target, and the APPENDUID from the remote server's response is copied into the COPYUID response to the client:

cyrus-imapd/imap/imapd.c

Lines 6698 to 6707 in 7f17801

if (res == PROXY_OK) {
if (myrights & ACL_READ) {
appenduid = strchr(s->last_result.s, '[');
/* skip over APPENDUID */
if (appenduid) {
appenduid += strlen("[appenduid ");
b = strchr(appenduid, ']');
if (b) *b = '\0';
prot_printf(imapd_out, "%s OK [COPYUID %s] %s\r\n", tag,
appenduid, error_message(IMAP_OK_COMPLETED));

A similar pattern occurs in imap_proxy.c:

cyrus-imapd/imap/imap_proxy.c

Lines 1170 to 1179 in 7f17801

if (res == PROXY_OK) {
if (myrights & ACL_READ) {
appenduid = strchr(s->last_result.s, '[');
/* skip over APPENDUID */
if (appenduid) {
appenduid += strlen("[appenduid ");
b = strchr(appenduid, ']');
if (b) *b = '\0';
prot_printf(imapd_out, "%s OK [COPYUID %s] %s\r\n", tag,
appenduid, error_message(IMAP_OK_COMPLETED));

But this behaviour makes no sense: the APPENDUID response is specified as having two fields, whereas the COPYUID response has three: https://datatracker.ietf.org/doc/html/rfc4315#section-3

@elliefm elliefm added Murder 3.7 affects 3.7 dev releases labels Apr 8, 2022
@elliefm
Copy link
Contributor Author

elliefm commented Apr 8, 2022

If I'm reading the spec right, I think [APPENDUID uidvalidity newuids] would correspond with [COPYUID uidvalidity olduids newuids].

That is to say, if we were to use the remote values from APPENDUID and copy in the locally-known one, the locally-known one goes in the middle. So we'd need to parse and reassemble the APPENDUID response properly, not just concatenate the locally-known value.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.7 affects 3.7 dev releases Murder
Projects
None yet
Development

No branches or pull requests

1 participant