[Mew-dist 10088] patch for IMAP (Re: Re: Mew 1.94b48 + IM 119)
SAKAI Kiyotaka
ksakai at example.com
1999年 8月 16日 (月) 15:25:03 JST
im-119 で
・Imap の password の処理が複数の箇所に分散していたのを 1つにまとめる。
・imap_folder_regname() が folder/AUTH:user at example.com の形式ではなく、古い
folder:user/AUTH at example.com の形式を生成していたため、imap に関する immv,
imrm が正しく動作していなかった問題の修正。
を行いました。
>> In article <19990816112714J.kazu at example.com>, Kazu Yamamoto (山本和彦) <kazu at example.com> writes:
> imcat や imclean などにもパスワードの処理が必要のようですね。これを
> Mew で対応するのは、今のところ難しいので、今後の課題とさせて下さい。
> 結論
> IMAP ユーザは impwagent を使って下さい
最初、IM 側の問題かと思ってチェックしていたのですが、Mew の方で IM へ
パスワードを渡すのが難しいということなのですね。
--
酒井 清隆 (E-mail: ksakai at example.com)
-------------- next part --------------
Index: imcat.in
===================================================================
RCS file: /home/ksakai/cvsroot/im-119/imcat.in,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 imcat.in
--- imcat.in 1999/08/16 02:33:28 1.1.1.1
+++ imcat.in 1999/08/16 04:59:27
@@ -151,33 +151,14 @@
($folder, $auth, $user, $host) = imap_spec($folder);
}
- my $pass = '';
- my $agtfound = 0;
- my $interact = 0;
- if (&usepwagent()) {
- $pass = &loadpass('imap', $auth, $host, $user);
- $agtfound = 1 if ($pass ne '');
- }
- if ($pass eq '' && &usepwfiles()) {
- $pass = &findpass('imap', $auth, $host, $user);
- }
- if ($pass eq '') {
- $pass = &getpass('Password: ');
- $interact = 1;
- }
-
im_warn("accessing IMAP/$auth:$user\@$host\n") if (&verbose);
- my ($rc, $HANDLE) = &imap_open($auth, $host, $user, $pass);
+ my ($rc, $HANDLE) = imap_open($auth, $host, $user);
if ($rc < 0) {
im_warn("IMAP connection was not established.\n")
if (&debug('imap') || &verbose);
- &savepass('imap', $auth, $host, $user, '')
- if ($agtfound && &usepwagent());
exit $EXIT_ERROR;
}
- &savepass('imap', $auth, $host, $user, $pass)
- if ($interact && $pass ne '' && &usepwagent());
my $msgs = &imap_select($HANDLE, $folder, 1);
if ($msgs < 0) {
&imap_close($HANDLE);
Index: imclean.in
===================================================================
RCS file: /home/ksakai/cvsroot/im-119/imclean.in,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 imclean.in
--- imclean.in 1999/08/16 02:33:28 1.1.1.1
+++ imclean.in 1999/08/16 05:01:59
@@ -99,33 +99,14 @@
($ifld, $auth, $user, $host) = imap_spec($ifld);
}
- my $pass = '';
- my $agtfound = 0;
- my $interact = 0;
- if (&usepwagent()) {
- $pass = &loadpass('imap', $auth, $host, $user);
- $agtfound = 1 if ($pass ne '');
- }
- if ($pass eq '' && &usepwfiles()) {
- $pass = &findpass('imap', $auth, $host, $user);
- }
- if ($pass eq '') {
- $pass = &getpass('Password: ');
- $interact = 1;
- }
-
im_warn("accessing IMAP/$auth:$user\@$host\n") if (&verbose);
- (my $rc, $HANDLE) = imap_open($auth, $host, $user, $pass);
+ (my $rc, $HANDLE) = imap_open($auth, $host, $user);
if ($rc < 0) {
im_warn("IMAP connection was not established.\n")
if (&debug('imap') || &verbose);
- &savepass('imap', $auth, $host, $user, '')
- if ($agtfound && &usepwagent());
exit $EXIT_ERROR;
}
- &savepass('imap', $auth, $host, $user, $pass)
- if ($interact && $pass ne '' && &usepwagent());
my $exists = imap_select($HANDLE, $ifld, 1);
if ($exists < 0) {
imap_close($HANDLE);
Index: imls.in
===================================================================
RCS file: /home/ksakai/cvsroot/im-119/imls.in,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 imls.in
--- imls.in 1999/08/16 02:33:28 1.1.1.1
+++ imls.in 1999/08/16 05:28:05
@@ -521,34 +521,13 @@
($folder, $auth, $user, $host) = imap_spec($folder);
}
- my $pass = '';
- my $agtfound = 0;
- my $interact = 0;
- if (&usepwagent()) {
- $pass = &loadpass('imap', $auth, $host, $user);
- $agtfound = 1 if ($pass ne '');
- }
- if ($pass eq '' && &usepwfiles()) {
- $pass = &findpass('imap', $auth, $host, $user);
- }
- if ($pass eq '') {
- $pass = &getpass('Password: ');
- $interact = 1;
- }
-
-# im_warn("accessing IMAP/$auth:$user\@$host\n") if (&verbose);
-
- my ($rc, $HANDLE) = &imap_open($auth, $host, $user, $pass);
+ my ($rc, $HANDLE) = imap_open($auth, $host, $user);
if ($rc < 0) {
# im_warn("IMAP connection was not established.\n")
# if (&debug("imap") || &verbose);
- &savepass('imap', $auth, $host, $user, '')
- if ($agtfound && &usepwagent());
$scan_count = -1;
return -1;
}
- &savepass('imap', $auth, $host, $user, $pass)
- if ($interact && $pass ne '' && &usepwagent());
my $exists = &imap_select($HANDLE, $folder, 1);
if ($exists < 0) {
&imap_close($HANDLE);
Index: IM/Imap.pm
===================================================================
RCS file: /home/ksakai/cvsroot/im-119/IM/Imap.pm,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 Imap.pm
--- Imap.pm 1999/08/16 02:33:29 1.1.1.1
+++ Imap.pm 1999/08/16 05:59:54
@@ -47,12 +47,49 @@
# IMAP access routines #
########################
-# imap_open(auth, host, user, pass)
+# imap_open(auth, host, user)
# return value:
# 0: success
# -1: failure
#
-sub imap_open ($$$$) {
+
+sub imap_open ($$$) {
+ my ($auth, $host, $user) = @_;
+ my ($pass, $agtfound, $interact) = ('', 0, 0);
+
+ if ($user eq '' || $host eq '') {
+ im_warn("Invalid imap account: user=$user, host=$host.\n");
+ return -1;
+ }
+
+ # get password
+ if (usepwagent()) {
+ $pass = loadpass('imap', $auth, $host, $user);
+ $agtfound = 1 if ($pass ne '');
+ }
+ if ($pass eq '' && usepwfiles()) {
+ $pass = findpass('imap', $auth, $host, $user);
+ }
+ if ($pass eq '') {
+ $pass = getpass('Password: ');
+ $interact = 1;
+ }
+
+ im_notice("accessing IMAP/$auth:$user\@$host\n");
+
+ # save password to impwagent to use later
+ my ($rc, $HANDLE) = imap_open_sub($auth, $host, $user, $pass);
+ if ($rc < 0) {
+ savepass('imap', $auth, $host, $user, '')
+ if ($agtfound && usepwagent());
+ } else {
+ savepass('imap', $auth, $host, $user, $pass)
+ if ($pass ne '' && $interact && usepwagent());
+ }
+ return ($rc, $HANDLE);
+}
+
+sub imap_open_sub ($$$$) {
my ($auth, $host, $user, $pass) = @_;
my ($data, $seq, $errmsg);
my (@host_list) = ($host);
@@ -125,7 +162,7 @@
if ($resp !~ /^im$seq OK/) {
$errmsg = $resp;
$errmsg =~ s/^im$seq\s+NO\s*//i;
- im_warn($errmsg);
+ im_warn("$errmsg\n");
return -1
}
return -1 if ($failed);
@@ -578,35 +615,15 @@
my ($folder, $auth, $user, $host) = &imap_spec($src);
return -1 if ($folder eq '');
-
- my $pass = '';
- my $agtfound = 0;
- my $interact = 0;
- if (&usepwagent()) {
- $pass = &loadpass('imap', $auth, $host, $user);
- $agtfound = 1 if ($pass ne '');
- }
- if ($pass eq '' && &usepwfiles()) {
- $pass = &findpass('imap', $auth, $host, $user);
- }
- if ($pass eq '') {
- $pass = &getpass('Password: ');
- $interact = 1;
- }
- im_notice("accessing IMAP/$auth:$user\@$host for $how\n");
- my ($rc, $HANDLE) = &imap_open($auth, $host, $user, $pass);
+ my ($rc, $HANDLE) = imap_open($auth, $host, $user);
if ($rc == 0) {
- &savepass('imap', $auth, $host, $user, $pass)
- if ($pass ne '' && $interact && &usepwagent());
my $msgs = imap_process($HANDLE, $how, $host, $folder, $dst, $limit, $noscan);
return -1 if ($msgs < 0);
- &imap_close($HANDLE);
+ imap_close($HANDLE);
return $msgs;
} else {
im_err("IMAP connection was not established.\n");
- &savepass('imap', $auth, $host, $user, '')
- if ($agtfound && &usepwagent());
return -1;
}
}
@@ -733,7 +750,7 @@
($folder, $auth, $user, $host) = imap_spec($folder);
$folder =~ s/^/%/;
- return "$folder:$user/$auth\@$host"; # may be appended '/port'
+ return "$folder/$auth:$user\@$host"; # may be appended '/port'
}
sub imap_folder_name ($) {
@@ -866,32 +883,15 @@
my ($rc, $HANDLE);
unless ($HANDLE = $ImapHandleCache{$acct}) {
- my ($pass, $agtfound, $interact) = ('', 0, 0);
my ($dummy, $auth, $user, $host)
= imap_spec(imap_folder_regname($_));
-
- if (usepwagent()) {
- $pass = loadpass('imap', $auth, $host, $user);
- $agtfound = 1 if ($pass ne '');
- }
- if ($pass eq '' && usepwfiles()) {
- $pass = findpass('imap', $auth, $host, $user);
- }
- if ($pass eq '') {
- $pass = getpass("Password for $acct: ");
- $interact = 1;
- }
- ($rc, $HANDLE) = imap_open($auth, $host, $user, $pass);
+ ($rc, $HANDLE) = imap_open($auth, $host, $user);
if ($rc < 0) {
im_warn("can't open IMAP connection to $host.\n");
- savepass('imap', $auth, $host, $user, '')
- if ($agtfound && usepwagent());
imap_close_folders();
return -1;
}
- savepass('imap', $auth, $host, $user, $pass)
- if ($interact && $pass ne '' && usepwagent());
$ImapHandleCache{$acct} = $HANDLE;
}
Mew-dist メーリングリストの案内