1
0
mirror of https://github.com/imapsync/imapsync.git synced 2024-11-17 00:02:29 +01:00
This commit is contained in:
Nick Bebout 2011-03-12 02:44:22 +00:00
parent 79f17648bd
commit 7371bedc83
10 changed files with 110 additions and 117 deletions

View File

@ -11,6 +11,7 @@ See FAQ.
Vincent Deffontaines
Made me talk about --exclude 'fold1|fold2|f3'
Gave a patch for multiple --exclude
Jim Rosenberg
Had problems with dbmail 2.0.7.

View File

@ -1,15 +1,27 @@
RCS file: RCS/imapsync,v
Working file: imapsync
head: 1.159
head: 1.161
branch:
locks: strict
access list:
symbolic names:
keyword substitution: kv
total revisions: 159; selected revisions: 159
total revisions: 161; selected revisions: 161
description:
----------------------------
revision 1.161
date: 2006/03/20 00:09:41; author: gilles; state: Exp; lines: +12 -42
Fixed default auth to CRAM-MD5
unless not told to.
----------------------------
revision 1.160
date: 2006/03/19 23:54:48; author: gilles; state: Exp; lines: +82 -23
Added SSL support.
Added options --ssl1 --ssl2
Added PLAIN auth support
Added options --authmech1 --authmech2
----------------------------
revision 1.159
date: 2006/03/11 13:00:52; author: gilles; state: Exp; lines: +11 -8
Added failure story dkimap

View File

@ -1,5 +1,5 @@
# $Id: Makefile,v 1.8 2006/02/28 03:55:01 gilles Exp gilles $
# $Id: Makefile,v 1.10 2006/03/20 00:35:47 gilles Exp gilles $
TARGET=imapsync
@ -19,11 +19,11 @@ all: ChangeLog README VERSION
.PHONY: test testp testf
.test: $(TARGET) tests.sh
sh tests.sh 1>/dev/null
nice -40 sh tests.sh 1>/dev/null
touch .test
testv:
sh -x tests.sh
nice -40 sh -x tests.sh
test: .test

6
README
View File

@ -2,7 +2,7 @@ NAME
imapsync - IMAP synchronization, copy or migration tool. Synchronize
mailboxes between two imap servers. Good at IMAP migration.
$Revision: 1.159 $
$Revision: 1.161 $
INSTALL
imapsync works fine under any Unix OS.
@ -32,6 +32,8 @@ SYNOPSIS
[--user1 <string>] [--passfile1 <string>]
[--host2 server2] [--port2 <num>]
[--user2 <string>] [--passfile2 <string>]
[--ssl1] [--ssl2]
[--authmech1 <string>] [--authmech2 <string>]
[--noauthmd5]
[--folder <string> --folder <string> ...]
[--include <regex>] [--exclude <regex>]
@ -275,5 +277,5 @@ AUTHOR
teaching free open and gratis softwares. Don't hesitate to pay him for
that services.
$Id: imapsync,v 1.159 2006/03/11 13:00:52 gilles Exp $
$Id: imapsync,v 1.161 2006/03/20 00:09:41 gilles Exp $

View File

@ -1 +1 @@
1.159
1.161

View File

@ -1,20 +1,8 @@
Project: imapsync
Version: 1.155
Release-Focus: Major feature enhancements
Hide: N
Version: 1.159
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/
From imapsync version 1.121 to 1.153, the following options have been added:
--buffersize
--expunge1 --expunge2
--fastio1 --fastio2
--minage
--useheader
--prefix1
--foldersizes
The documentation has been updated.
Also, imapsync is now "IMAP4 Namespace" RFC 2342 compliant.
More than 20 different IMAP server softwares have
successfully migrate or been synchronised with imapsync.
Code cleanup.

View File

@ -1,8 +0,0 @@
Project: imapsync
Version: 1.158
Release-Focus: Code cleanup
Hide: Y
Home-Page-URL: http://www.linux-france.org/prj/imapsync/
Gzipped-Tar-URL: http://www.linux-france.org/prj/imapsync/dist/
Code cleanup.

133
imapsync
View File

@ -6,7 +6,7 @@ imapsync - IMAP synchronization, copy or migration
tool. Synchronize mailboxes between two imap servers. Good
at IMAP migration.
$Revision: 1.159 $
$Revision: 1.161 $
=head1 INSTALL
@ -38,6 +38,8 @@ $Revision: 1.159 $
[--user1 <string>] [--passfile1 <string>]
[--host2 server2] [--port2 <num>]
[--user2 <string>] [--passfile2 <string>]
[--ssl1] [--ssl2]
[--authmech1 <string>] [--authmech2 <string>]
[--noauthmd5]
[--folder <string> --folder <string> ...]
[--include <regex>] [--exclude <regex>]
@ -323,7 +325,7 @@ Gilles LAMIRAL earn his living writing, installing,
configuring and teaching free open and gratis
softwares. Don't hesitate to pay him for that services.
$Id: imapsync,v 1.159 2006/03/11 13:00:52 gilles Exp $
$Id: imapsync,v 1.161 2006/03/20 00:09:41 gilles Exp $
=cut
@ -335,6 +337,9 @@ use Mail::IMAPClient;
use Digest::MD5 qw(md5_base64);
use Term::ReadKey;
#use Digest::HMAC_MD5;
use IO::Socket::SSL;
use MIME::Base64;
eval { require 'usr/include/sysexits.ph' };
@ -366,12 +371,15 @@ my(
$timeout, # whr (ESS/PRW)
$timestart, $timeend, $timediff,
$timesize, $timebefore,
$ssl1, $ssl2,
$authusing1, $authusing2,
$authmech1, $authmech2,
);
use vars qw ($opt_G); # missing code for this will be option.
$rcs = ' $Id: imapsync,v 1.159 2006/03/11 13:00:52 gilles Exp $ ';
$rcs = ' $Id: imapsync,v 1.161 2006/03/20 00:09:41 gilles Exp $ ';
$rcs =~ m/,v (\d+\.\d+)/;
$VERSION = ($1) ? $1 : "UNKNOWN";
@ -408,8 +416,8 @@ $error=0;
my $banner = join("",
'$RCSfile: imapsync,v $ ',
'$Revision: 1.159 $ ',
'$Date: 2006/03/11 13:00:52 $ ',
'$Revision: 1.161 $ ',
'$Date: 2006/03/20 00:09:41 $ ',
"\n",
"Mail::IMAPClient version used here is ",
$VERSION_IMAPClient,"\n"
@ -429,10 +437,12 @@ sub missing_option {
}
$host1 || missing_option("--host1") ;
$port1 = (defined($port1)) ? $port1 : 143;
# $port1 = (defined($port1)) ? $port1 : 143;
$port1 ||= defined $ssl1 ? 993 : 143;
$host2 || missing_option("--host2") ;
$port2 = (defined($port2)) ? $port2 : 143;
# $port2 = (defined($port2)) ? $port2 : 143;
$port2 ||= defined $ssl2 ? 993 : 143;
sub connect_imap {
my($host, $port, $debugimap) = @_;
@ -458,12 +468,20 @@ if ($justconnect) {
$to->logout();
exit(0);
}
$user1 || missing_option("--user1");
$user2 || missing_option("--user2");
$authmd5 = (defined($authmd5)) ? $authmd5 : 1;
if(defined($authmd5) and not($authmd5)) {
$authmech1 ||= 'PLAIN';
$authmech2 ||= 'PLAIN';
}else{
$authmech1 ||= 'CRAM-MD5';
$authmech2 ||= 'CRAM-MD5';
}
print "will try to use $authmech1 authentication on host1\n";
print "will try to use $authmech2 authentication on host2\n";
$syncacls = (defined($syncacls)) ? $syncacls : 0;
$foldersizes = (defined($foldersizes)) ? $foldersizes : 1;
@ -497,9 +515,6 @@ $password2 = (defined($passfile2)) ? firstline ($passfile2) : $password2;
my $from = ();
my $to = ();
my $authmech = "CRAM-MD5";
$timestart = time();
$timebefore = $timestart;
@ -507,10 +522,12 @@ $fastio1 = 1;
$fastio2 = 1;
$debugimap and print "From connection\n";
$from = login_imap($host1, $port1, $user1, $password1, $debugimap, $timeout, $fastio1);
$from = login_imap($host1, $port1, $user1, $password1,
$debugimap, $timeout, $fastio1, $ssl1, $authmech1);
$debugimap and print "To connection\n";
$to = login_imap($host2, $port2, $user2, $password2, $debugimap, $timeout, $fastio2);
$to = login_imap($host2, $port2, $user2, $password2,
$debugimap, $timeout, $fastio2, $ssl2, $authmech2);
# No history
$from->Clear(2);
@ -523,8 +540,20 @@ $debug and print "To Buffer I/O : ", $to->Buffer(), "\n";
sub login_imap {
my($host, $port, $user, $password,
$debugimap, $timeout, $fastio) = @_;
my $imap = Mail::IMAPClient->new();
$debugimap, $timeout, $fastio, $ssl, $authmech) = @_;
my ($imap);
if ($ssl) {
my $socssl = new IO::Socket::SSL("$host:$port");
die "Error connecting to $host:$port: $@\n" unless $socssl;
$socssl->autoflush(1);
$imap = Mail::IMAPClient->new(
Socket => $socssl,
Server => $host,
);
} else {
$imap = Mail::IMAPClient->new();
}
$imap->Server($host);
$imap->Port($port);
$imap->Fast_io($fastio);
@ -532,51 +561,42 @@ sub login_imap {
$imap->Uid(1);
$imap->Peek(1);
$imap->Debug($debugimap);
$imap->connect()
if ($ssl) {
$imap->State(Mail::IMAPClient::Connected);
} else {
$imap->connect()
or die "Can not open imap connection on [$host] with user [$user] : $@\n";
if ($timeout) # whr (ESS/PRW)
{
$imap->Timeout($timeout);
print "Setting imap timeout to $timeout\n";
}
}
$timeout and $imap->Timeout($timeout);
if ($authmech eq "LOGIN") {
# Default mode for Mail::IMAPClient, so don't do anything.
} elsif ($imap->has_capability("AUTH=$authmech")
or $imap->has_capability($authmech)) {
$imap->Authmechanism($authmech);
$imap->Authcallback(\&plainauth) if $authmech eq "PLAIN";
} else {
printf("%s: no support for AUTHENTICATE %s, using LOGIN\n",
$imap->Server, $authmech);
}
$imap->User($user);
$imap->Password($password);
md5auth($imap);
#md5auth($imap);
$imap->login() or die "Error login : [$host] with user [$user] : $@";
return($imap);
}
sub plainauth() {
my $code = shift;
my $imap = shift;
sub md5auth() {
my ($imap) = @_;
unless ($authmd5) {
print "$authmech not wanted by you\n";
return;
}
if ($imap->has_capability($authmech)
or $imap->has_capability("AUTH=$authmech")) {
print "Server [", $imap->Server,
"] has capability $authmech\n";
}else{
print "Server [", $imap->Server,
"] has NOT capability $authmech\n";
return;
}
#print "EE", $imap->Authmechanism(), "\n";
if ($imap->Authmechanism($authmech)) {
print "Using $authmech authentification\n";
}else{
$imap->Authmechanism(undef);
print "Can NOT use $authmech authentification, using plain\n";
}
return;
my $string = sprintf("%s\x00%s\x00%s", $imap->User,
$imap->User, $imap->Password);
return encode_base64("$string");
}
print "From software : ", ($from->Report())[0];
print "To software : ", ($to->Report())[0];
@ -1174,6 +1194,10 @@ sub get_options
"skipsize!" => \$skipsize,
"fastio1!" => \$fastio1,
"fastio2!" => \$fastio2,
"ssl1!" => \$ssl1,
"ssl2!" => \$ssl2,
"authmech1=s" => \$authmech1,
"authmech2=s" => \$authmech2,
);
$debug and print "get options: [$opt_ret]\n";
@ -1258,17 +1282,22 @@ usage: $0 [options]
Several options are mandatory.
--host1 <string> : "from" imap server. Mandatory.
--port1 <int> : port to connect. Default is 143.
--user1 <string> : user to login. Mandatory.
--port1 <int> : port to connect on host1. Default is 143.
--user1 <string> : user to login on host1. Mandatory.
--password1 <string> : password for the user1. Dangerous, use --passfile1
--passfile1 <string> : password file for the user1. Contains the password.
--host2 <string> : "destination" imap server. Mandatory.
--port2 <int> : port to connect. Default is 143.
--user2 <string> : user to login. Mandatory.
--port2 <int> : port to connect on host2. Default is 143.
--user2 <string> : user to login on host2. Mandatory.
--password2 <string> : password for the user2. Dangerous, use --passfile2
--passfile2 <string> : password file for the user2. Contains the password.
--noauthmd5 : don't use MD5 authentification.
--authmd5 : use MD5 authentification.
--authmech1 <string> : auth mechanism to use with host1:
PLAIN, LOGIN, CRAM-MD5 etc.
--authmech2 <string> : auth mechanism to use with host2. See --authmech1
--ssl1 : use an SSL connection on host1.
--ssl2 : use an SSL connection on host2.
--folder <string> : sync only this folder.
--folder <string> : and this one.
--folder <string> : and this one, etc.

4
memo
View File

@ -37,14 +37,14 @@ niouzes_compil
fm_announce() {
software_version
NEWS_FILE_FM="/home/gilles/public_html/imapsync/freshmeat_submition2"
NEWS_FILE_FM="/home/gilles/public_html/imapsync/freshmeat_submition"
if ! newer VERSION $NEWS_FILE_FM; then
echo "$VERSION already announced"
else
cat > $NEWS_FILE_FM << EOF
Project: imapsync
Version: $VERSION
Release-Focus: Major bugfixe
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/

31
zzz
View File

@ -1,31 +0,0 @@
$RCSfile: imapsync,v $ $Revision: 1.158 $ $Date: 2006/03/02 06:28:30 $
Mail::IMAPClient version used here is 2.2.9
From imap server [loul] port [143] user [tata]
To imap server [plume] port [143] user [tata]
Server [loul] has NOT capability CRAM-MD5
Server [plume] has NOT capability CRAM-MD5
From software : 2 CAPABILITY
To software : 2 CAPABILITY
From capability : QUOTA X-NETSCAPE NAMESPACE X-NON-HIERARCHICAL-RENAME ACL UNSELECT LITERAL+ NO_ATOMIC_RENAME UIDPLUS IMAP4 IMAP4REV1
To capability : ACL AUTH=LOGIN NAMESPACE IMAP4REV1 IMAP4
From separator and prefix : [.][INBOX.]
To separator and prefix : [/][]
++++ Calculating sizes ++++
From Folder [INBOX] Size: 5703203 Messages: 1432
Total size: 5703203
Total messages: 1432
Time : 0 s
++++ Calculating sizes ++++
To Folder [INBOX] Size: 17108791 Messages: 4294
Total size: 17108791
Total messages: 4294
Time : 0 s
From folders : [INBOX]
To folders : [INBOX]
From subscribed folders : [INBOX.yop.yap]
From Folder [INBOX]
To Folder [INBOX]
++++ From [INBOX] Parse 1 ++++
++++ To [INBOX] Parse 1 ++++
++++ Verifying [INBOX] -> [INBOX] ++++
Time : 11 s