diff --git a/CREDITS b/CREDITS index 98cf216..5808b84 100644 --- a/CREDITS +++ b/CREDITS @@ -7,11 +7,28 @@ http://www.amazon.com/gp/registry/wishlist/1C9UNDIH3P7R7/ I thank very much all of these people. +Heiko Kirsch +Found the 24 characters bug in username. +In fact this is 76 in Mail::IMAPClient, md5, MIME::Base64::encode. + +Morten W. Petersen +Asked for the default behavior. +All folders, recursively. + +Tobias Müller +Found the buddy max inversion mistake in +the documentation. + +Gavin Atkinson +MailEnable under Windows to Dovecot under FreeBSD +Not really a success. Just a one run copy. +MailEnable does not give its headers. + Simon Matter Had problem with append_string() from Cyrus-IMAPd to Lotus Notes 7.0.2 -Simon's friend (his name ?) +Samuel Graenacher (Simon's friend) Wrote a patch to add flags and date to append_file() Foo Kok Wai diff --git a/ChangeLog b/ChangeLog index c44ce08..bf7cbc6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,15 +1,34 @@ RCS file: RCS/imapsync,v Working file: imapsync -head: 1.213 +head: 1.217 branch: locks: strict access list: symbolic names: keyword substitution: kv -total revisions: 213; selected revisions: 213 +total revisions: 217; selected revisions: 217 description: ---------------------------- +revision 1.217 +date: 2007/03/06 13:12:23; author: gilles; state: Exp; lines: +103 -6 +- Added _cram_md5_2() and authenticate2() to correct a bug + from the Mail::IMAPClient perl library. username can't be + longer than 24 due to a lack of blank second parameter + in MIME::Base64::encode() call. +---------------------------- +revision 1.216 +date: 2007/03/06 04:25:52; author: gilles; state: Exp; lines: +10 -7 +Updated distribution list. +---------------------------- +revision 1.215 +date: 2007/03/06 03:50:35; author: gilles; state: Exp; lines: +16 -8 +Updated documentation. +---------------------------- +revision 1.214 +date: 2007/02/26 10:31:32; author: gilles; state: Exp; lines: +6 -6 +Fixed a mistake in the EXAMPLE section. +---------------------------- revision 1.213 date: 2007/02/16 04:07:19; author: gilles; state: Exp; lines: +168 -11 - Back to append_file() modified -> append_file2() diff --git a/FAQ b/FAQ index 7a1541a..1f75938 100644 --- a/FAQ +++ b/FAQ @@ -152,7 +152,6 @@ Here is an example: --password2 joespassonserver2 \ --exclude '^user\.' - ====================================================================== Q. imapsync fails with the following error: flags from : [\Seen NonJunk]["10-Aug-2006 13:00:30 -0400"] diff --git a/README b/README index 96b92c6..074fff3 100644 --- a/README +++ b/README @@ -3,14 +3,17 @@ NAME Synchronise mailboxes between two imap servers. Good at IMAP migration. More than 32 different IMAP server softwares supported with success. - $Revision: 1.213 $ + $Revision: 1.217 $ INSTALL imapsync works fine under any Unix OS with perl. imapsync works fine under Windows 2000 (at least) and ActiveState's 5.8 Perl - imapsync is already available on the following distributions (at least): - FreeBSD, Debian, Gentoo, NetBSD. + imapsync is already available directly on the following distributions (at least): + FreeBSD, Debian, Gentoo, NetBSD, Darwin, Mandriva. + + imapsync is already available directly on the following distributions: + OpenBSD Get imapsync at http://www.linux-france.org/prj/imapsync/dist/ @@ -29,9 +32,13 @@ INSTALL SYNOPSIS imapsync [options] + To get a description of each option just run imapsync like this : + imapsync --help imapsync + The option list : + imapsync [--host1 server1] [--port1 ] [--user1 ] [--passfile1 ] [--host2 server2] [--port2 ] @@ -71,6 +78,8 @@ DESCRIPTION The command imapsync is a tool allowing incremental and recursive imap transfer from one mailbox to another. + By default all folders are transfered, recursively. + We sometimes need to transfer mailboxes from one imap server to another. This is called migration. @@ -91,7 +100,9 @@ DESCRIPTION you just want to keep a "live" copy of B in A. OPTIONS - Invoke: imapsync --help + To get a description of each option just invoke: + + imapsync --help HISTORY I wrote imapsync because an enterprise (basystemes) paid me to install a @@ -115,7 +126,7 @@ EXAMPLE imapsync --host1 imap.src.fr --user1 buddy --passfile1 /etc/secret1 \ --host2 imap.dest.fr --user2 max --passfile2 /etc/secret2 - Then, you will have buddy's mailbox updated from max's mailbox. + Then, you will have max's mailbox updated from buddy's mailbox. SECURITY You can use --password1 instead of --passfile1 to give the password but @@ -309,5 +320,5 @@ SIMILAR SOFTWARES Feedback (good or bad) will be always welcome. - $Id: imapsync,v 1.213 2007/02/16 04:07:19 gilles Exp $ + $Id: imapsync,v 1.217 2007/03/06 13:12:23 gilles Exp $ diff --git a/TODO b/TODO index 1166b05..b793c86 100644 --- a/TODO +++ b/TODO @@ -2,7 +2,7 @@ TODO file for imapsync ---------------------- Add an option to make imapsync automatically -reconnect when the connection drops? +reconnect when the connection drops Add an entry to http://lsm.execpc.com/lsm/ diff --git a/VERSION b/VERSION index 9c9e6ce..f129285 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.213 +1.217 diff --git a/freshmeat_submition.out b/freshmeat_submition.out index 4de79e1..c8c1b6a 100644 --- a/freshmeat_submition.out +++ b/freshmeat_submition.out @@ -1,9 +1,9 @@ Project: imapsync -Version: 1.200 -Release-Focus: Minor bugfixes +Version: 1.213 +Release-Focus: Major bugfixes Hide: Y Home-Page-URL: http://www.linux-france.org/prj/imapsync/ Gzipped-Tar-URL: http://www.linux-france.org/prj/imapsync/dist/ -Bug fix: corrected memory problem with big messages. +Bug fix: rewrote the way to store messages to avoid freeze problems with some imap servers diff --git a/imapsync b/imapsync index 15f3bb7..9887550 100755 --- a/imapsync +++ b/imapsync @@ -7,15 +7,18 @@ tool. Synchronise mailboxes between two imap servers. Good at IMAP migration. More than 32 different IMAP server softwares supported with success. -$Revision: 1.213 $ +$Revision: 1.217 $ =head1 INSTALL imapsync works fine under any Unix OS with perl. imapsync works fine under Windows 2000 (at least) and ActiveState's 5.8 Perl - imapsync is already available on the following distributions (at least): - FreeBSD, Debian, Gentoo, NetBSD. + imapsync is already available directly on the following distributions (at least): + FreeBSD, Debian, Gentoo, NetBSD, Darwin, Mandriva. + + imapsync is already available directly on the following distributions: + OpenBSD Get imapsync at http://www.linux-france.org/prj/imapsync/dist/ @@ -35,9 +38,13 @@ $Revision: 1.213 $ imapsync [options] +To get a description of each option just run imapsync like this : + imapsync --help imapsync +The option list : + imapsync [--host1 server1] [--port1 ] [--user1 ] [--passfile1 ] [--host2 server2] [--port2 ] @@ -79,8 +86,10 @@ $Revision: 1.213 $ =head1 DESCRIPTION -The command imapsync is a tool allowing incremental and recursive -imap transfer from one mailbox to another. +The command imapsync is a tool allowing incremental and +recursive imap transfer from one mailbox to another. + +By default all folders are transfered, recursively. We sometimes need to transfer mailboxes from one imap server to another. This is called migration. @@ -105,7 +114,9 @@ in case you just want to keep a "live" copy of B in A. =head1 OPTIONS -Invoke: imapsync --help +To get a description of each option just invoke: + +imapsync --help =head1 HISTORY @@ -132,7 +143,7 @@ To synchronize the imap account "buddy" on host imapsync --host1 imap.src.fr --user1 buddy --passfile1 /etc/secret1 \ --host2 imap.dest.fr --user2 max --passfile2 /etc/secret2 -Then, you will have buddy's mailbox updated from max's +Then, you will have max's mailbox updated from buddy's mailbox. =head1 SECURITY @@ -360,7 +371,7 @@ Entries for imapsync: Feedback (good or bad) will be always welcome. -$Id: imapsync,v 1.213 2007/02/16 04:07:19 gilles Exp $ +$Id: imapsync,v 1.217 2007/03/06 13:12:23 gilles Exp $ @@ -419,7 +430,7 @@ my( use vars qw ($opt_G); # missing code for this will be option. -$rcs = ' $Id: imapsync,v 1.213 2007/02/16 04:07:19 gilles Exp $ '; +$rcs = ' $Id: imapsync,v 1.217 2007/03/06 13:12:23 gilles Exp $ '; $rcs =~ m/,v (\d+\.\d+)/; $VERSION = ($1) ? $1 : "UNKNOWN"; @@ -456,8 +467,8 @@ $error=0; my $banner = join("", '$RCSfile: imapsync,v $ ', - '$Revision: 1.213 $ ', - '$Date: 2007/02/16 04:07:19 $ ', + '$Revision: 1.217 $ ', + '$Date: 2007/03/06 13:12:23 $ ', "\n", "Mail::IMAPClient version used here is ", $VERSION_IMAPClient,"\n", @@ -1877,7 +1888,7 @@ sub fetch_hash2 { sub login2 { my $self = shift; - return $self->authenticate($self->Authmechanism,$self->Authcallback) + return $self->authenticate2($self->Authmechanism,$self->Authcallback) if $self->{Authmechanism}; my $id = $self->User; @@ -2011,3 +2022,100 @@ sub parse_headers2 { return $headers; } + + +# From IMAPClient.pm + +sub authenticate2 { + + my $self = shift; + my $scheme = shift; + my $response = shift; + + $scheme ||= $self->Authmechanism; + $response ||= $self->Authcallback; + my $clear = $self->Clear; + + $self->Clear($clear) + if $self->Count >= $clear and $clear > 0; + + my $count = $self->Count($self->Count+1); + + + my $string = "$count AUTHENTICATE $scheme"; + + $self->_record($count,[ $self->_next_index($self->Transaction), + "INPUT", "$string\x0d\x0a"] ); + + my $feedback = $self->_send_line("$string"); + + unless ($feedback) { + $self->LastError("Error sending '$string' to IMAP: $!\n"); + return undef; + } + + my ($code, $output); + + until ($code) { + $output = $self->_read_line or return undef; + foreach my $o (@$output) { + $self->_record($count,$o); # $o is a ref + ($code) = $o->[DATA] =~ /^\+(.*)$/ ; + if ($o->[DATA] =~ /^\*\s+BYE/) { + $self->State(Unconnected); + return undef ; + } + } + } + + return undef if $code =~ /^BAD|^NO/ ; + + if ('CRAM-MD5' eq $scheme && ! $response) { + if ($Mail::IMAPClient::_CRAM_MD5_ERR) { + $self->LastError($Mail::IMAPClient::_CRAM_MD5_ERR); + carp $Mail::IMAPClient::_CRAM_MD5_ERR if $^W; + } else { + $response = \&_cram_md5_2; + } + } + + $feedback = $self->_send_line($response->($code, $self)); + + unless ($feedback) { + $self->LastError("Error sending append msg text to IMAP: $!\n"); + return undef; + } + + $code = ""; # clear code + until ($code) { + $output = $self->_read_line or return undef; + foreach my $o (@$output) { + $self->_record($count,$o); # $o is a ref + if ( ($code) = $o->[DATA] =~ /^\+ (.*)$/ ) { + $feedback = $self->_send_line($response->($code,$self)); + unless ($feedback) { + $self->LastError("Error sending append msg text to IMAP: $!\n"); + return undef; + } + $code = "" ; # Clear code; we're still not finished + } else { + $o->[DATA] =~ /^$count (OK|NO|BAD)/ and $code = $1; + if ($o->[DATA] =~ /^\*\s+BYE/) { + $self->State(Unconnected); + return undef ; + } + } + } + } + + $code =~ /^OK/ and $self->State(Authenticated) ; + return $code =~ /^OK/ ? $self : undef ; + +} + +sub _cram_md5_2 { + my ($code, $client) = @_; + my $hmac = Digest::HMAC_MD5::hmac_md5_hex(MIME::Base64::decode($code), + $client->Password()); + return MIME::Base64::encode($client->User() . " $hmac", ""); +}