[Mew-dist 2019] Re: Get Password from File patch for IM-65

AOSASA Shigeru aozasa at example.com
1997年 9月 15日 (月) 07:05:01 JST


Motonori Nakamura <motonori at example.com> writes:

> それから、ご推察通り、windows 方面ではうまく動かないような気がします。
> どうしましょ :-)

今のところは、パスワードをファイルにも書いておけるようにしておく
というのはどうでしょうか。

ということで、IM-66 + impwagent patch にあてるパッチです。
Config に UsePwFiles=yes 及び PwFiles=file1,file2,... と
書いておくとファイルからパスワードを探します。

パスワードを書いておくファイルの書式は以前流したパッチと同じです。
--
AOSASA Shigeru <aozasa at example.com>
1b 24 28 42 40 44 3a 7b 1b 28 42 20 1b 24 28 42 4c 50 1b 28 42 # c-text

diff -ur ../im-66-~orig/IM.in/Config.pm.in ./IM.in/Config.pm.in
--- ../im-66-~orig/IM.in/Config.pm.in	Sun Sep 14 21:03:54 1997
+++ ./IM.in/Config.pm.in	Mon Sep 15 06:29:11 1997
@@ -42,6 +42,7 @@
     mbox_style
     nntpservers nntphistoryfile
     popaccount pophistoryfile imapaccount httpproxy noproxy usepwagent
+    usepwfiles pwfiles
     unixp win95p wntp os2p
     im_msg im_info im_debug im_notice im_warn im_err im_die im_die2
     im_save_error im_saved_errors
@@ -157,6 +158,8 @@
     'httpproxy;s;;HTTPproxy'            => 'Proxy server for HTTP access',
     'noproxy;s;;Noproxy'                => 'URL regex not to use Proxy server',
     'usepwagent;b;;UsePwAgent'		=> 'Use password agent',
+    'usepwfiles;b;;UsePwFiles'		=> 'Use password files',
+    'pwfiles;s;;PwFiles'		=> 'Password files',
     );
 
 ##
@@ -757,6 +760,14 @@
 
 sub usepwagent () {
     return $UsePwAgent;
+}
+
+sub usepwfiles () {
+    return $UsePwFiles;
+}
+
+sub pwfiles () {
+    return split(',', $PwFiles);
 }
 
 ###
diff -ur ../im-66-~orig/IM.in/GetPass.pm.in ./IM.in/GetPass.pm.in
--- ../im-66-~orig/IM.in/GetPass.pm.in	Sun Sep 14 21:03:54 1997
+++ ./IM.in/GetPass.pm.in	Mon Sep 15 06:38:58 1997
@@ -23,7 +23,7 @@
 use IM::Stdio;
 
 @ISA = qw(Exporter);
- at example.com = qw(getpass loadpass savepass connect_agent);
+ at example.com = qw(getpass loadpass savepass connect_agent findpass);
 
 =head1 NAME
 
@@ -127,6 +127,41 @@
     shutdown (SOCK, 2);
     close(SOCK);
     return $res;
+}
+
+sub findpass($$$$) {
+    my ($proto, $auth, $host, $user) = @_;
+
+    my ($tmp_proto_auth);
+    my ($tmp_proto, $tmp_auth, $tmp_host, $tmp_user, $tmp_pass);
+
+    my ($passfile, @passfiles);
+    my ($pass) = '';
+
+    @passfiles = &pwfiles();
+
+    PASSFINDLOOP: foreach $passfile (@passfiles) {
+	unless (open (PASSFILE, "<$passfile")) {
+	    next;
+	}
+	while (<PASSFILE>) {
+	    s/\s*(\#.*)?$//;	# remove comments
+	    chomp;
+	    next unless defined;
+	    ($tmp_proto_auth, $tmp_host, $tmp_user, $tmp_pass) = split;
+	    ($tmp_proto, $tmp_auth) = split('/', $tmp_proto_auth);
+	    if (($tmp_proto eq $proto)
+		&& ($tmp_auth eq $auth)
+		&& ($tmp_host eq $host)
+		&& ($tmp_user eq $user)) {
+		$pass = $tmp_pass;
+		last PASSFINDLOOP;
+	    }
+	}
+	close (PASSFILE);
+    }
+
+    return $pass;
 }
 
 1;
diff -ur ../im-66-~orig/IM.in/Http.pm.in ./IM.in/Http.pm.in
--- ../im-66-~orig/IM.in/Http.pm.in	Sun Sep 14 21:03:54 1997
+++ ./IM.in/Http.pm.in	Mon Sep 15 06:15:01 1997
@@ -163,12 +163,21 @@
 	next if ($rcode == 302 && $new_spec);
 	if ($rcode == 401 && $auth =~ /Basic/i && $retry--) {
 	    require IM::GetPass && import IM::GetPass;
-	    if ($first && &usepwagent()) {
+	    if ($first) {
 		$first = 0;
-		$pass = &loadpass('http', $auth, $path, $user);
-		if ($pass ne '') {
-		    $found = 1;
-		    next;
+		if (&usepwagent()) {
+		    $pass = &loadpass('http', $auth, $path, $user);
+		    if ($pass ne '') {
+			$found = 1;
+			next;
+		    }
+		}
+		if (&usepwfiles()) {
+		    $pass = &findpass('http', $auth, $path, $user);
+		    if ($pass ne '') {
+			$found = 1;
+			next;
+		    }
 		}
 	    }
 #	    last if ($found && $NoPwQueryOnFail);
diff -ur ../im-66-~orig/IM.in/Imap.pm.in ./IM.in/Imap.pm.in
--- ../im-66-~orig/IM.in/Imap.pm.in	Sun Sep 14 21:03:54 1997
+++ ./IM.in/Imap.pm.in	Mon Sep 15 06:23:46 1997
@@ -535,7 +535,11 @@
     my $found = 0;
     if (&usepwagent()) {
 	$pass = &loadpass('imap', $auth, $host, $user);
-	found = 1 if ($pass ne '');
+	$found = 1 if ($pass ne '');
+    }
+    if ($pass eq '' && &usepwfiles()) {
+	$pass = &findpass('imap', $auth, $host, $user);
+	$found = 1 if ($pass ne '');
     }
     $pass = &getpass('Password: ') if ($pass eq '');
 
diff -ur ../im-66-~orig/IM.in/Pop.pm.in ./IM.in/Pop.pm.in
--- ../im-66-~orig/IM.in/Pop.pm.in	Sun Sep 14 21:03:55 1997
+++ ./IM.in/Pop.pm.in	Mon Sep 15 06:22:06 1997
@@ -482,6 +482,10 @@
 	    $pass = &loadpass('pop', $auth, $host, $user);
 	    $found = 1 if ($pass ne '');
 	}
+	if ($pass eq '' && &usepwfiles()) {
+	    $pass = &findpass('pop', $auth, $host, $user);
+	    $found = 1 if ($pass ne '');
+	}
 	$pass = &getpass('Password: ') if ($pass eq '');
     }
 
diff -ur ../im-66-~orig/imcat.in ./imcat.in
--- ../im-66-~orig/imcat.in	Sun Sep 14 21:03:55 1997
+++ ./imcat.in	Mon Sep 15 06:12:48 1997
@@ -159,6 +159,10 @@
 	$pass = &loadpass('imap', $auth, $host, $user);
 	$found = 1 if ($pass ne '');
     }
+    if ($pass eq '' && &usepwfiles()) {
+	$pass = &findpass('imap', $auth, $host, $user);
+	$found = 1 if ($pass ne '');
+    }
     $pass = &getpass('Password: ') if ($pass eq '');
 
     im_warn("accessing IMAP/$auth:$user\@$host\n") if (&verbose);
diff -ur ../im-66-~orig/imls.in ./imls.in
--- ../im-66-~orig/imls.in	Sun Sep 14 21:03:56 1997
+++ ./imls.in	Mon Sep 15 06:13:02 1997
@@ -443,6 +443,10 @@
 	$pass = &loadpass('imap', $auth, $host, $user);
 	$found = 1 if ($pass ne '');
     }
+    if ($pass eq '' && &usepwfiles()) {
+	$pass = &findpass('imap', $auth, $host, $user);
+	$found = 1 if ($pass ne '');
+    }
     $pass = &getpass('Password: ') if ($pass eq '');
 
 #   im_warn("accessing IMAP/$auth:$user\@$host\n") if (&verbose);



Mew-dist メーリングリストの案内