Subject: | RENAME broken when renaming users with subfolders |
Hi,
When renaming an user who has subfolders, the subsequent calls to rename
subroutine will not work properly. Because the rename subroutine isn't
parsing multiple lines from RENAME result, so it unsynchronizes the "*
OK" results, leaving residual responses in the socket.
For example, performing the follow command:
try RENAME user/a1 user/a2
the IMAP server returns:
* OK rename user/a1 user/a2
* OK rename user/a1/Trash user/a2/Trash
* OK rename user/a1/Sent user/a2/Sent
try OK Completed
once the rename subroutine is checking just the first line, when we call
rename again it returns success, even if it should fail. Because it
reads the second line from the previous response instead of read its own
response lines.
The patch attached solves this issue by consuming all lines from the
socket before return from rename subroutine. Similar thing is done by
quota, expunge and select subroutines.
Admin.pm -> 1.6.7
IMAP server cyrus -> 2.3.16
Subject: | perl-IMAP-Admin-1.6.7-fix-rename.patch |
--- IMAP-Admin-1.6.7.orig/Admin.pm
+++ IMAP-Admin-1.6.7/Admin.pm
@@ -272,6 +272,7 @@
sub rename {
my $self = shift;
+ my @info;
if (!defined($self->{'Socket'})) {
return 1;
@@ -291,6 +292,10 @@
print $fh qq{try RENAME "$old_name" "$new_name"\n};
}
my $try = $self->_read;
+ while ($try =~ /^\* (.*)/) { # danger danger (could lock up needs timeout)
+ push @info, $1;
+ $try = $self->_read;
+ }
if (($try =~ /^try OK/) || ($try =~ /^\* OK/)) {
$self->{'Error'} = 'No Errors';
return 0;