diff --git a/ChangeLog b/ChangeLog index 3c1a5f8..1489748 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,17 +1,21 @@ RCS file: RCS/imapsync,v Working file: imapsync -head: 1.76 +head: 1.77 branch: locks: strict - gilles: 1.76 access list: symbolic names: keyword substitution: kv -total revisions: 76; selected revisions: 76 +total revisions: 77; selected revisions: 77 description: ---------------------------- -revision 1.76 locked by: gilles; +revision 1.77 +date: 2004/03/11 05:33:22; author: gilles; state: Exp; lines: +26 -8 +Better authmd5 stuff +Added option --noauthmd5 +---------------------------- +revision 1.76 date: 2004/02/18 21:34:46; author: gilles; state: Exp; lines: +9 -6 Added mailutil ref ---------------------------- diff --git a/README b/README index 8a24ca3..5b47b5f 100644 --- a/README +++ b/README @@ -2,7 +2,7 @@ NAME imapsync - IMAP sync or copy tool. Synchronize mailboxes between two imap servers. - $Revision: 1.76 $ + $Revision: 1.77 $ INSTALL imapsync works fine under any Unix OS. @@ -204,5 +204,5 @@ SIMILAR SOFTWARES Feedback (good or bad) will be always welcome. - $Id: imapsync,v 1.76 2004/02/18 21:34:46 gilles Exp gilles $ + $Id: imapsync,v 1.77 2004/03/11 05:33:22 gilles Exp $ diff --git a/VERSION b/VERSION index 9242d8e..3245dca 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.76 +1.77 diff --git a/imapsync b/imapsync index c6abcba..224d15b 100755 --- a/imapsync +++ b/imapsync @@ -4,7 +4,7 @@ imapsync - IMAP sync or copy tool. Synchronize mailboxes between two imap servers. -$Revision: 1.76 $ +$Revision: 1.77 $ =head1 INSTALL @@ -241,7 +241,7 @@ Entries for imapsync: Feedback (good or bad) will be always welcome. -$Id: imapsync,v 1.76 2004/02/18 21:34:46 gilles Exp gilles $ +$Id: imapsync,v 1.77 2004/03/11 05:33:22 gilles Exp $ =cut @@ -265,6 +265,7 @@ my( $syncinternaldates, $maxsize, $maxage, $delete, $expunge, $dry, + $authmd5, $subscribed, $subscribe, $version, $VERSION, $help, $justconnect, @@ -276,7 +277,7 @@ my( use vars qw ($opt_G); # missing code for this will be option. -$rcs = ' $Id: imapsync,v 1.76 2004/02/18 21:34:46 gilles Exp gilles $ '; +$rcs = ' $Id: imapsync,v 1.77 2004/03/11 05:33:22 gilles Exp $ '; $rcs =~ m/,v (\d+\.\d+)/; $VERSION = ($1) ? $1 : "UNKNOWN"; @@ -291,6 +292,7 @@ $mess_size_total_error = 0; sub md5_supported { + # before 2.2.6 no md5 native # I know this is ugly, I should write a sort function if ($VERSION_IMAPClient =~ m/(\d+)\.(\d+)\.(\d+)/) { @@ -311,8 +313,8 @@ $error=0; my $banner = join("", '$RCSfile: imapsync,v $ ', - '$Revision: 1.76 $ ', - '$Date: 2004/02/18 21:34:46 $ ', + '$Revision: 1.77 $ ', + '$Date: 2004/03/11 05:33:22 $ ', "\n", "Mail::IMAPClient version used here is ", $VERSION_IMAPClient, " auth md5 : $md5_supported", @@ -344,6 +346,8 @@ $user2 || missing_option("--user2"); $password2 || $passfile2 || missing_option("--passfile2 or --password2"); $password2 = (defined($passfile2)) ? firstline ($passfile2) : $password2; +$authmd5 = (defined($authmd5)) ? $authmd5 : 1; + print "From imap server [$host1] port [$port1] user [$user1]\n"; print "To imap server [$host2] port [$port2] user [$user2]\n"; @@ -376,11 +380,12 @@ sub login_imap { $imap->Peek(1); $imap->Debug($debugimap); $imap->connect() - or die "can't open imap connection on [$host] with user [$user] : $@\n"; + or die "Can not open imap connection on [$host] with user [$user] : $@\n"; + $imap->User($user); $imap->Password($password); md5auth($imap); - $imap->login(); + $imap->login() or die "Error login : [$host] with user [$user] : $@"; return($imap); } @@ -390,7 +395,10 @@ sub md5auth() { unless ($md5_supported) { return; } - + 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, @@ -400,10 +408,15 @@ sub md5auth() { "] has NOT capability $authmech\n"; return; } + #print "EE", $imap->Authmechanism(), "\n"; if ($imap->Authmechanism($authmech)) { print "Using $authmech authentification\n"; + #$imap->Authmechanism(undef); + #print "EE", $imap->Authmechanism(), "\n"; }else{ + $imap->Authmechanism(undef); print "Can NOT use $authmech authentification, using plain\n"; + } return; } @@ -415,6 +428,9 @@ print "To software : ", ($to->Report())[0]; print "From capability : ", join(" ", $from->capability()), "\n"; print "To capability : ", join(" ", $to->capability()), "\n"; +die unless $from->IsAuthenticated(); +die unless $to->IsAuthenticated(); + my (@f_folders, @t_folders, %fs_folders); # Make a hash of subscribed folders in source server. @@ -700,6 +716,7 @@ sub get_options "password2=s" => \$password2, "passfile1=s" => \$passfile1, "passfile2=s" => \$passfile2, + "authmd5!" => \$authmd5, "sep1=s" => \$sep1, "sep2=s" => \$sep2, "folder=s" => \@folder, @@ -789,6 +806,7 @@ Several options are mandatory. --user2 : user to login. Mandatory. --password2 : password for the user2. Dangerous, use --passfile2 --passfile2 : password file for the user2. Contains the password. +--noauthmd5 : don't use MD5 authentification --folder : sync only this folder. --folder : and this one. --folder : and this one, etc. diff --git a/tests.sh b/tests.sh index fe8c6a2..fe98e5d 100644 --- a/tests.sh +++ b/tests.sh @@ -1,8 +1,13 @@ #!/bin/sh -# $Id: tests.sh,v 1.14 2004/02/07 03:34:35 gilles Exp $ +# $Id: tests.sh,v 1.15 2004/03/11 05:32:08 gilles Exp $ # $Log: tests.sh,v $ +# Revision 1.15 2004/03/11 05:32:08 gilles +# Added bad_login() +# Added bad_host() +# Added lp_noauthmd5() +# # Revision 1.14 2004/02/07 03:34:35 gilles # Added lp_include() # @@ -252,7 +257,7 @@ lp_justconnect() fi } -lp_md5auth() +lp_authmd5() { if test X`hostname` = X"plume"; then echo3 Here is plume @@ -268,6 +273,22 @@ lp_md5auth() fi } +lp_noauthmd5() +{ + if test X`hostname` = X"plume"; then + echo3 Here is plume + perl -I ~gilles/build/Mail-IMAPClient-2.2.8/blib/lib/ \ + ./imapsync \ + --host2 plume --user2 tata@est.belle \ + --passfile2 /var/tmp/secret.tata \ + --host1 loul --user1 tata \ + --passfile1 /var/tmp/secret.tata \ + --justconnect --noauthmd5 + else + : + fi +} + lp_maxage() { @@ -317,6 +338,26 @@ lp_include() fi } +bad_login() +{ + ! ./imapsync \ + --host1 localhost --user1 toto@est.belle \ + --passfile1 /var/tmp/secret1 \ + --host2 localhost --user2 notiti@est.belle \ + --passfile2 /var/tmp/secret2 + +} + +bad_host() +{ + ! ./imapsync \ + --host1 localhost --user1 toto@est.belle \ + --passfile1 /var/tmp/secret1 \ + --host2 badhost --user2 titi@est.belle \ + --passfile2 /var/tmp/secret2 + +} + # mandatory tests @@ -337,10 +378,13 @@ test $# -eq 0 && run_tests \ lp_subscribed \ lp_subscribe \ lp_justconnect \ - lp_md5auth \ + lp_authmd5 \ lp_maxage \ lp_maxsize \ - lp_include + lp_include \ + bad_login \ + bad_host \ + lp_noauthmd5 # selective tests