1--- imapsync-master/imapsync 2014-08-08 01:10:54.000000000 -0600 2+++ imapsync-gw/imapsync 2014-11-12 20:21:33.727746150 -0700 3@@ -601,6 +601,7 @@ 4 $host1, $host2, $port1, $port2, 5 $user1, $user2, $domain1, $domain2, 6 $password1, $password2, $passfile1, $passfile2, 7+ $gwtapp1, $gwtappkey1, $gwtapp2, $gwtappkey2, 8 @folder, @include, @exclude, @folderrec, 9 @folderfirst, @folderlast, 10 $prefix1, $prefix2, 11@@ -1038,13 +1039,13 @@ 12 13 $debugimap1 and print "Host1 connection\n"; 14 $imap1 = login_imap($host1, $port1, $user1, $domain1, $password1, 15- $debugimap1, $timeout, $fastio1, $ssl1, $tls1, 16+ $debugimap1, $timeout, $fastio1, $gwtapp1, $gwtappkey1, $ssl1, $tls1, 17 $authmech1, $authuser1, $reconnectretry1, 18 $proxyauth1, $uid1, $split1, 'Host1', $ssl1_SSL_version ); 19 20 $debugimap2 and print "Host2 connection\n"; 21 $imap2 = login_imap($host2, $port2, $user2, $domain2, $password2, 22- $debugimap2, $timeout, $fastio2, $ssl2, $tls2, 23+ $debugimap2, $timeout, $fastio2, $gwtapp2, $gwtappkey2, $ssl2, $tls2, 24 $authmech2, $authuser2, $reconnectretry2, 25 $proxyauth2, $uid2, $split2, 'Host2', $ssl2_SSL_version ); 26 27@@ -2062,7 +2063,7 @@ 28 $imap1 = relogin_imap( 29 $imap1, 30 $host1, $port1, $user1, $domain1, $password1, 31- $debugimap1, $timeout, $fastio1, $ssl1, $tls1, 32+ $debugimap1, $timeout, $fastio1, $gwtapp1, $gwtappkey1, $ssl1, $tls1, 33 $authmech1, $authuser1, $reconnectretry1, 34 $proxyauth1, $uid1, $split1) ; 35 36@@ -2074,7 +2075,7 @@ 37 $imap2 = relogin_imap( 38 $imap2, 39 $host2, $port2, $user2, $domain2, $password2, 40- $debugimap2, $timeout, $fastio2, $ssl2, $tls2, 41+ $debugimap2, $timeout, $fastio2, $gwtapp2, $gwtappkey2, $ssl2, $tls2, 42 $authmech2, $authuser2, $reconnectretry2, 43 $proxyauth2, $uid2, $split2) ; 44 45@@ -2085,7 +2086,7 @@ 46 sub relogin_imap { 47 my($imap, 48 $host, $port, $user, $domain, $password, 49- $mydebugimap, $mytimeout, $fastio, 50+ $mydebugimap, $mytimeout, $fastio, $gwtapp, $gwtappkey, 51 $ssl, $tls, $authmech, $authuser, $reconnectretry, 52 $proxyauth, $uid, $split) = @_; 53 54@@ -2093,7 +2094,7 @@ 55 $imap->logout( ) ; 56 $imap = login_imap( 57 $host, $port, $user, $domain, $password, 58- $mydebugimap, $mytimeout, $fastio, 59+ $mydebugimap, $mytimeout, $fastio, $gwtapp, $gwtappkey, 60 $ssl, $tls, $authmech, $authuser, $reconnectretry, 61 $proxyauth, $uid, $split 62 ) ; 63@@ -2101,17 +2102,17 @@ 64 return( $imap ) ; 65 } 66 67- 68 sub login_imap { 69 70 my @allargs = @_ ; 71 my($host, $port, $user, $domain, $password, 72- $mydebugimap, $mytimeout, $fastio, 73+ $mydebugimap, $mytimeout, $fastio, $gwtapp, $gwtappkey, 74 $ssl, $tls, $authmech, $authuser, $reconnectretry, 75 $proxyauth, $uid, $split, $Side, $SSL_version ) = @allargs ; 76 77 my $side = lc( $Side ) ; 78 my $imap = init_imap( @allargs ) ; 79+ my $gwtapp_encoded = ""; 80 81 $imap->connect() 82 or die_clean("Failure: can not open imap connection on $side [$host] with user [$user]: $@\n"); 83@@ -2120,6 +2121,7 @@ 84 $imap->Banner( $banner ) ; 85 print "$Side: ", server_banner($imap); 86 87+ 88 if ( $authmech eq 'PREAUTH' ) { 89 if ( $imap->IsAuthenticated( ) ) { 90 $imap->Socket ; 91@@ -2135,6 +2137,13 @@ 92 or die_clean("Can not go to tls encryption on [$host]:", $imap->LastError, "\n" ) ; 93 } 94 95+ if ( defined($gwtapp) && !($gwtapp eq '') && defined($gwtappkey) && !($gwtappkey eq '')) { 96+ $gwtapp_encoded = encode_base64(qq/$gwtapp\x00$gwtappkey/,""); 97+ $imap->tag_and_run("AUTHENTICATE XGWTRUSTEDAPP\nXGWTRUSTEDAPP $gwtapp_encoded\n") 98+ or die_clean("Failed to log in with GroupWise Trust App."); 99+ @allargs[4] = ""; 100+ } 101+ 102 authenticate_imap( $imap, @allargs ) ; 103 104 print "$Side: success login on [$host] with user [$user] auth [$authmech]\n" ; 105@@ -2146,7 +2155,7 @@ 106 107 my($imap, 108 $host, $port, $user, $domain, $password, 109- $mydebugimap, $mytimeout, $fastio, 110+ $mydebugimap, $mytimeout, $fastio, $gwtapp, $gwtappkey, 111 $ssl, $tls, $authmech, $authuser, $reconnectretry, 112 $proxyauth, $uid, $split, $Side ) = @_ ; 113 114@@ -2247,7 +2256,7 @@ 115 116 sub init_imap { 117 my($host, $port, $user, $domain, $password, 118- $mydebugimap, $mytimeout, $fastio, 119+ $mydebugimap, $mytimeout, $fastio, $gwtapp, $gwtappkey, 120 $ssl, $tls, $authmech, $authuser, $reconnectretry, 121 $proxyauth, $uid, $split, $Side, $SSL_version ) = @_ ; 122 123@@ -5860,7 +5869,10 @@ 124 125 --dry : Makes imapsync doing nothing, just print what would 126 be done without --dry. 127- 128+--gwtapp1 <string> : GroupWise Trusted App Name for Source 129+--gwtappkey1 <string> : GroupWise Trusted App Key for Source 130+--gwtapp2 <string> : GroupWise Trusted App Key for Destination 131+--gwtappkey2 <string> : GroupWise Trusted App Key for Destination 132 --host1 <string> : Source or "from" imap server. Mandatory. 133 --port1 <int> : Port to connect on host1. Default is 143. 134 --user1 <string> : User to login on host1. Mandatory. 135@@ -6251,6 +6263,10 @@ 136 "debugcrossduplicates!" => \$debugcrossduplicates, 137 "log!" => \$log, 138 "logfile=s" => \$logfile, 139+ "gwtapp1=s" => \$gwtapp1, 140+ "gwtappkey1=s" => \$gwtappkey1, 141+ "gwtapp2=s" => \$gwtapp2, 142+ "gwtappkey2=s" => \$gwtappkey2, 143 ); 144 145 $debug and print "get options: [$opt_ret]\n"; 146