[Mew-dist 10838] Re: im-131

Ryota HIROSE hirose at example.com
1999年 10月 8日 (金) 11:51:09 JST


ヤマハの広瀬です。

>From: Masatoshi Tsuchiya <tsuchiya at example.com>
>Date: Thu, 7 Oct 1999 20:41:59 +0900

> RSA鍵認証を使えるようにして、ssh-keygen と組合わせて利用するようにすれ
> ば、直接パスワードを入力しなくてもログインできるように出来ます。

なるほど。だけど、そのたびにパスワードを打つのが好きなんです。ちゃんと
認証しているみたいで気分が良い。とは言え、impwagentがパスワード覚える
のに抵抗はないので一貫性がありませんけど。

片手落ちではありますが、imgetの場合だけsshに関してもパスワード認証でき
るようにしてみました。im-132へのパッチです。パスワード認証するかどうか
はオプションSSHServerPasswordAuthに'yes'/'no'を設定することで決めます。
imputの場合は常に'no'と扱われるので、sshがパスワード認証なしで接続でき
ないとssh経由ではメールが送信できません。

-------------- next part --------------
diff -rc im-132.orig/IM/Ssh.pm im-132/IM/Ssh.pm
*** im-132.orig/IM/Ssh.pm	Fri Oct  8 08:14:21 1999
--- im-132/IM/Ssh.pm	Fri Oct  8 11:44:52 1999
***************
*** 15,20 ****
--- 15,21 ----
  require Exporter;
  use IM::Config qw( connect_timeout command_timeout );
  use IM::Util;
+ use IM::GetPass;
  use strict;
  use vars qw( @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS $SSH $FH @PID );
  @ISA       = qw( Exporter );
***************
*** 35,40 ****
--- 36,49 ----
  	im_err( "Missing relay host.\n" );
  	return 0;
      }
+ 
+     my( $ssh_pass, $agtfound, $interact, $login ) = ( '', 0, 0, '' );
+     if ( $main::SSH_server_password_auth eq 'yes' ) {
+ 	$login = getlogin || getpwuid($>);
+ 	( $ssh_pass, $agtfound, $interact ) =
+ 	    getpass( 'ssh', 'password auth', $host, $login );
+     }
+ 
      im_notice( "openning SSH-tunnel to $server/$remote\%$local via $host\n" )
  	if &verbose;
  
***************
*** 45,56 ****
  	$write = $FH++;
  	pipe( $read, $write );
  	if ( $pid = fork ) {
! 	    close $write;
  	    my( $buf, $sig, $i );
  	    for( $i=0; $i<3; $i++ ){
  		$sig = $SIG{ALRM};
  		$SIG{ALRM} = sub { die "SIGALRM is received\n"; };
  		eval {
  		    alarm &connect_timeout();
  		    $buf = <$read>;
  		    alarm 0;
--- 54,70 ----
  	$write = $FH++;
  	pipe( $read, $write );
  	if ( $pid = fork ) {
! 	    if ( $main::SSH_server_password_auth ne 'yes' ) {
! 		close $write;
! 	    }
  	    my( $buf, $sig, $i );
  	    for( $i=0; $i<3; $i++ ){
  		$sig = $SIG{ALRM};
  		$SIG{ALRM} = sub { die "SIGALRM is received\n"; };
  		eval {
+ 		    if ( $main::SSH_server_password_auth eq 'yes' ) {
+ 			print $write $ssh_pass . "\n";
+ 		    }
  		    alarm &connect_timeout();
  		    $buf = <$read>;
  		    alarm 0;
***************
*** 59,64 ****
--- 73,80 ----
  		if ( $@ !~ /SIGALRM is received/ ) {
  		    push( @PID, $pid );
  		    if ( $buf =~ /ssh_proxy_connect/ ) {
+ 			&savepass( 'ssh', 'password auth', $host, $login,
+ 				  $ssh_pass );
  			return $local;
  		    } elsif ( $buf =~ /Local: bind: Address already in use/ ) {
  			$local++;
***************
*** 75,83 ****
  	    close $read;
  	    open( STDOUT, ">&$write" );
  	    open( STDERR, ">&$write" );
! 	    exec( $SSH, '-n', '-x', '-o', 'BatchMode yes',
! 		  "-L$local:$server:$remote", $host,
! 		  sprintf( 'echo ssh_proxy_connect ; sleep %s', &command_timeout() ) );
  	    exit 0;			# Not reach.
  	} elsif ( $! =~ /No more process/ ) {
  	    sleep 5;
--- 91,105 ----
  	    close $read;
  	    open( STDOUT, ">&$write" );
  	    open( STDERR, ">&$write" );
! 	    if ( $main::SSH_server_password_auth eq 'yes' ) {
! 		exec( $SSH, '-n', '-x',
! 		      "-L$local:$server:$remote", $host,
! 		      sprintf( 'echo ssh_proxy_connect ; sleep %s', &command_timeout() ) );
! 	    } else {
! 		exec( $SSH, '-n', '-x', '-o', 'BatchMode yes',
! 		      "-L$local:$server:$remote", $host,
! 		      sprintf( 'echo ssh_proxy_connect ; sleep %s', &command_timeout() ) );
! 	    }
  	    exit 0;			# Not reach.
  	} elsif ( $! =~ /No more process/ ) {
  	    sleep 5;
diff -rc im-132.orig/imget.in im-132/imget.in
*** im-132.orig/imget.in	Fri Oct  8 08:14:22 1999
--- im-132/imget.in	Fri Oct  8 08:40:53 1999
***************
*** 91,96 ****
--- 91,100 ----
      'help;b;;'         => 'Display this help message.',
      'SSHServer;s;localhost;SSH_server'
  		       => 'SSH port relay server.',
+     'SSHServerPasswordAuth;s;no;SSH_server_password_auth'
+ 		       => "Password authentication of SSH.\n" .
+ 	"\t\t(yes : enable passwrod authenticaiton)\n" .
+ 	"\t\t(no : disable passwrod authenticaiton)",
      );
  
  ##


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